2 * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.openflowplugin.impl.registry.group;
11 import org.junit.Assert;
12 import org.junit.Before;
13 import org.junit.Test;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId;
17 * Test for {@link DeviceGroupRegistryImpl}.
19 public class DeviceGroupRegistryImplTest {
21 private GroupId groupId;
22 private GroupId groupId2;
23 private DeviceGroupRegistryImpl deviceGroupRegistry;
26 public void setUp() throws Exception {
27 deviceGroupRegistry = new DeviceGroupRegistryImpl();
28 groupId = new GroupId(42L);
29 groupId2 = new GroupId(84L);
30 Assert.assertEquals(0, deviceGroupRegistry.getAllGroupIds().size());
31 deviceGroupRegistry.store(groupId);
32 Assert.assertEquals(1, deviceGroupRegistry.getAllGroupIds().size());
36 public void testStore() throws Exception {
37 deviceGroupRegistry.store(groupId2);
38 Assert.assertEquals(2, deviceGroupRegistry.getAllGroupIds().size());
42 public void testRemoveMarked() throws Exception {
43 deviceGroupRegistry.addMark(groupId);
44 deviceGroupRegistry.processMarks();
45 Assert.assertEquals(0, deviceGroupRegistry.getAllGroupIds().size());
49 public void testRemoveMarkedNegative() throws Exception {
50 deviceGroupRegistry.addMark(groupId2);
51 deviceGroupRegistry.processMarks();
52 Assert.assertEquals(1, deviceGroupRegistry.getAllGroupIds().size());
57 public void testClose() throws Exception {
58 deviceGroupRegistry.addMark(groupId);
59 deviceGroupRegistry.close();
61 Assert.assertEquals(0, deviceGroupRegistry.getAllGroupIds().size());
62 deviceGroupRegistry.store(groupId);
63 Assert.assertEquals(1, deviceGroupRegistry.getAllGroupIds().size());
64 deviceGroupRegistry.processMarks();
65 Assert.assertEquals(1, deviceGroupRegistry.getAllGroupIds().size());