Fixed discard-changes for mdsal netconf, mapping code cleanup.
[controller.git] / opendaylight / md-sal / statistics-manager / src / test / java / test / mock / NodeRegistrationTest.java
1 package test.mock;
2
3 import org.junit.Test;
4 import org.opendaylight.controller.md.statistics.manager.StatisticsManager;
5 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
6 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
7 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
8 import test.mock.util.StatisticsManagerTest;
9
10 import java.util.concurrent.ExecutionException;
11
12 import static org.junit.Assert.assertFalse;
13 import static org.junit.Assert.assertTrue;
14
15 public class NodeRegistrationTest extends StatisticsManagerTest {
16
17     @Test
18     public void nodeRegistrationTest() throws ExecutionException, InterruptedException {
19         StatisticsManager statisticsManager = setupStatisticsManager();
20
21         addFlowCapableNode(s1Key);
22         Thread.sleep(2000);
23         final InstanceIdentifier<Node> nodeII = InstanceIdentifier.create(Nodes.class).child(Node.class, s1Key);
24
25         assertTrue(statisticsManager.isProvidedFlowNodeActive(nodeII));
26     }
27
28     @Test
29     public void nodeUnregistrationTest() throws ExecutionException, InterruptedException {
30         StatisticsManager statisticsManager = setupStatisticsManager();
31
32         addFlowCapableNode(s1Key);
33         Thread.sleep(2000);
34         final InstanceIdentifier<Node> nodeII = InstanceIdentifier.create(Nodes.class).child(Node.class, s1Key);
35
36         assertTrue(statisticsManager.isProvidedFlowNodeActive(nodeII));
37
38         removeNode(s1Key);
39         Thread.sleep(2000);
40         assertFalse(statisticsManager.isProvidedFlowNodeActive(nodeII));
41     }
42 }
43