--- /dev/null
+package org.opendaylight.groupbasedpolicy.renderer.iovisor.endpoint;\r
+\r
+import static org.mockito.Mockito.mock;\r
+import static org.mockito.Mockito.spy;\r
+import static org.mockito.Mockito.when;\r
+\r
+import java.util.Set;\r
+\r
+import com.google.common.collect.ImmutableSet;\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;\r
+import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;\r
+import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;\r
+import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;\r
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;\r
+import org.opendaylight.groupbasedpolicy.util.IidFactory;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.EndpointL3;\r
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;\r
+\r
+public class EndpointListenerCovrgTest {\r
+\r
+ private EndpointListener listener;\r
+ private DataObjectModification<EndpointL3> rootNode;\r
+ private Set<DataTreeModification<EndpointL3>> changes;\r
+\r
+ private InstanceIdentifier<EndpointL3> rootIdentifier;\r
+\r
+ @SuppressWarnings("unchecked")\r
+ @Before\r
+ public void init() {\r
+ DataBroker dataProvider = mock(DataBroker.class);\r
+\r
+ EndpointManager endpointManager = mock(EndpointManager.class);\r
+ listener = spy(new EndpointListener(dataProvider, endpointManager));\r
+\r
+ EndpointL3 endpointL3 = mock(EndpointL3.class);\r
+\r
+ rootNode = mock(DataObjectModification.class);\r
+ rootIdentifier = IidFactory.l3EndpointsIidWildcard();\r
+ DataTreeIdentifier<EndpointL3> rootPath =\r
+ new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL, rootIdentifier);\r
+\r
+ DataTreeModification<EndpointL3> change = mock(DataTreeModification.class);\r
+\r
+ when(change.getRootNode()).thenReturn(rootNode);\r
+ when(change.getRootPath()).thenReturn(rootPath);\r
+\r
+ changes = ImmutableSet.of(change);\r
+\r
+ when(rootNode.getDataBefore()).thenReturn(endpointL3);\r
+ when(rootNode.getDataAfter()).thenReturn(endpointL3);\r
+ }\r
+\r
+ @Test\r
+ public void testOnWrite() {\r
+ when(rootNode.getModificationType()).thenReturn(DataObjectModification.ModificationType.WRITE);\r
+\r
+ listener.onDataTreeChanged(changes);\r
+ }\r
+\r
+ @Test(expected = UnsupportedOperationException.class)\r
+ public void testOnDelete() {\r
+ when(rootNode.getModificationType()).thenReturn(DataObjectModification.ModificationType.DELETE);\r
+\r
+ listener.onDataTreeChanged(changes);\r
+ }\r
+\r
+ @Test\r
+ public void testOnSubtreeModified() {\r
+ when(rootNode.getModificationType()).thenReturn(DataObjectModification.ModificationType.SUBTREE_MODIFIED);\r
+\r
+ listener.onDataTreeChanged(changes);\r
+ }\r
+\r
+}\r
--- /dev/null
+package org.opendaylight.groupbasedpolicy.renderer.iovisor.endpoint;\r
+\r
+import static org.junit.Assert.assertNotNull;\r
+import static org.junit.Assert.assertNull;\r
+import static org.mockito.Matchers.any;\r
+import static org.mockito.Mockito.mock;\r
+import static org.mockito.Mockito.verify;\r
+import static org.mockito.Mockito.when;\r
+\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+import org.opendaylight.groupbasedpolicy.api.EpRendererAugmentationRegistry;\r
+import org.opendaylight.groupbasedpolicy.renderer.iovisor.test.GbpIovisorDataBrokerTest;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.RegisterEndpointInput;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.iovisor.rev151030.IovisorModuleAugmentationInput;\r
+\r
+public class IovisorEndpointAugCovrgTest extends GbpIovisorDataBrokerTest {\r
+\r
+ private EpRendererAugmentationRegistry epRAR;\r
+ private IovisorEndpointAug aug;\r
+\r
+ @Before\r
+ public void init() {\r
+ epRAR = mock(EpRendererAugmentationRegistry.class);\r
+\r
+ aug = new IovisorEndpointAug(epRAR);\r
+ }\r
+\r
+ @Test\r
+ public void testClose() throws Exception {\r
+ IovisorEndpointAug other = new IovisorEndpointAug(epRAR);\r
+ other.close();\r
+\r
+ verify(epRAR).unregister(any(IovisorEndpointAug.class));\r
+ }\r
+\r
+ @Test\r
+ public void testBuildEndpointAugmentation() {\r
+ assertNull(aug.buildEndpointAugmentation(null));\r
+ }\r
+\r
+ @Test\r
+ public void testBuildEndpointL3Augmentation() {\r
+ RegisterEndpointInput input = mock(RegisterEndpointInput.class);\r
+ IovisorModuleAugmentationInput iomAugInput = mock(IovisorModuleAugmentationInput.class);\r
+ when(input.getAugmentation(IovisorModuleAugmentationInput.class)).thenReturn(iomAugInput);\r
+ assertNotNull(aug.buildEndpointL3Augmentation(input));\r
+ }\r
+\r
+ @Test\r
+ public void testBuildEndpointL3Augmentation_Null() {\r
+ RegisterEndpointInput input = mock(RegisterEndpointInput.class);\r
+ when(input.getAugmentation(IovisorModuleAugmentationInput.class)).thenReturn(null);\r
+ assertNull(aug.buildEndpointL3Augmentation(input));\r
+ }\r
+\r
+ @Test\r
+ public void testBuildL3PrefixEndpointAugmentation() {\r
+ assertNull(aug.buildL3PrefixEndpointAugmentation(null));\r
+ }\r
+\r
+}\r