X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=neutron-ovsdb%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fgroupbasedpolicy%2Fneutron%2Fovsdb%2Futil%2FNeutronOvsdbIidFactoryTest.java;h=442bd6e44e4a39bbc6776eccac1a2c76a7b4539b;hb=50c5719cefc6e73fdbcbc0a27e9f4e20ed6a14ac;hp=da90f4ce56f10106e56272bd4f3070a63e4d767e;hpb=e985e7fd657b2b4fef7a20865ef709207d6fcb44;p=groupbasedpolicy.git diff --git a/neutron-ovsdb/src/test/java/org/opendaylight/groupbasedpolicy/neutron/ovsdb/util/NeutronOvsdbIidFactoryTest.java b/neutron-ovsdb/src/test/java/org/opendaylight/groupbasedpolicy/neutron/ovsdb/util/NeutronOvsdbIidFactoryTest.java index da90f4ce5..442bd6e44 100644 --- a/neutron-ovsdb/src/test/java/org/opendaylight/groupbasedpolicy/neutron/ovsdb/util/NeutronOvsdbIidFactoryTest.java +++ b/neutron-ovsdb/src/test/java/org/opendaylight/groupbasedpolicy/neutron/ovsdb/util/NeutronOvsdbIidFactoryTest.java @@ -24,8 +24,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.neutron.gb import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.neutron.gbp.mapper.rev150513.mappings.gbp.by.neutron.mappings.endpoints.by.ports.EndpointByPort; import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.neutron.gbp.mapper.rev150513.mappings.neutron.by.gbp.mappings.ExternalGatewaysAsL3Endpoints; import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.neutron.gbp.mapper.rev150513.mappings.neutron.by.gbp.mappings.external.gateways.as.l3.endpoints.ExternalGatewayAsL3Endpoint; +import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbNodeAugmentation; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node; @@ -34,50 +36,82 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument; public class NeutronOvsdbIidFactoryTest { + private static final String OVSDB_TOPOLOGY_ID = "topologyId"; + private static final String UUID = "e0bb2cf8-8855-434e-839b-d2e59e045218"; + @Test - public void ovsdbNodeAugmentationIidTest() { - final String ovsdbTopologyId = "topologyId"; - InstanceIdentifier id = NeutronOvsdbIidFactory.ovsdbNodeAugmentationIid(new TopologyId(ovsdbTopologyId)); - assertNotNull(id); + public void test_OvsdbNodeAugmentationIid() { + InstanceIdentifier iid = + NeutronOvsdbIidFactory.ovsdbNodeAugmentationIid(new TopologyId(OVSDB_TOPOLOGY_ID)); + assertNotNull(iid); + Class[] expectedTypes = {NetworkTopology.class, Topology.class, Node.class, OvsdbNodeAugmentation.class}; - assertPathArgumentTypes(id.getPathArguments(), expectedTypes); - assertEquals(OvsdbNodeAugmentation.class, id.getTargetType()); - assertTrue(id.isWildcarded()); - assertEquals(ovsdbTopologyId, id.firstKeyOf(Topology.class).getTopologyId().getValue()); + assertPathArgumentTypes(iid.getPathArguments(), expectedTypes); + assertEquals(OvsdbNodeAugmentation.class, iid.getTargetType()); + assertTrue(iid.isWildcarded()); + assertEquals(OVSDB_TOPOLOGY_ID, iid.firstKeyOf(Topology.class).getTopologyId().getValue()); } @Test - public void neutronGbpExternalGatewayIidWildcardTest() { - InstanceIdentifier id = NeutronOvsdbIidFactory.neutronGbpExternalGatewayIidWildcard(); - assertNotNull(id); - Class[] expectedTypes = {Mappings.class, NeutronByGbpMappings.class, - ExternalGatewaysAsL3Endpoints.class, ExternalGatewayAsL3Endpoint.class}; - assertPathArgumentTypes(id.getPathArguments(), expectedTypes); - assertEquals(ExternalGatewayAsL3Endpoint.class, id.getTargetType()); - assertTrue(id.isWildcarded()); + public void test_NeutronGbpExternalGatewayIidWildcard() { + InstanceIdentifier iid = + NeutronOvsdbIidFactory.neutronGbpExternalGatewayIidWildcard(); + assertNotNull(iid); + Class[] expectedTypes = {Mappings.class, NeutronByGbpMappings.class, ExternalGatewaysAsL3Endpoints.class, + ExternalGatewayAsL3Endpoint.class}; + assertPathArgumentTypes(iid.getPathArguments(), expectedTypes); + assertEquals(ExternalGatewayAsL3Endpoint.class, iid.getTargetType()); + assertTrue(iid.isWildcarded()); } @Test - public void endpointByPortIidTest() { - final String portId = "e0bb2cf8-8855-434e-839b-d2e59e045218"; - InstanceIdentifier id = NeutronOvsdbIidFactory.endpointByPortIid(new UniqueId(portId)); - assertNotNull(id); - Class[] expectedTypes = {Mappings.class, GbpByNeutronMappings.class, - EndpointsByPorts.class, EndpointByPort.class}; - assertPathArgumentTypes(id.getPathArguments(), expectedTypes); - assertEquals(EndpointByPort.class, id.getTargetType()); - assertFalse(id.isWildcarded()); - assertEquals(portId, id.firstKeyOf(EndpointByPort.class).getPortId().getValue()); + public void test_EndpointByPortIid() { + String portId = UUID; + InstanceIdentifier iid = NeutronOvsdbIidFactory.endpointByPortIid(new UniqueId(portId)); + assertNotNull(iid); + Class[] expectedTypes = + {Mappings.class, GbpByNeutronMappings.class, EndpointsByPorts.class, EndpointByPort.class}; + assertPathArgumentTypes(iid.getPathArguments(), expectedTypes); + assertEquals(EndpointByPort.class, iid.getTargetType()); + assertFalse(iid.isWildcarded()); + assertEquals(portId, iid.firstKeyOf(EndpointByPort.class).getPortId().getValue()); } @Test - public void neutronGbpMappingsIidWildcardTest() { - InstanceIdentifier id = NeutronOvsdbIidFactory.neutronGbpMappingsIidWildcard(); - assertNotNull(id); + public void test_NeutronGbpMappingsIidWildcard() { + InstanceIdentifier iid = NeutronOvsdbIidFactory.neutronGbpMappingsIidWildcard(); + assertNotNull(iid); + Class[] expectedTypes = {Mappings.class, NeutronByGbpMappings.class}; - assertPathArgumentTypes(id.getPathArguments(), expectedTypes); - assertEquals(NeutronByGbpMappings.class, id.getTargetType()); - assertFalse(id.isWildcarded()); + assertPathArgumentTypes(iid.getPathArguments(), expectedTypes); + assertEquals(NeutronByGbpMappings.class, iid.getTargetType()); + assertFalse(iid.isWildcarded()); + } + + @Test + public void test_NodeIid_topology() { + InstanceIdentifier iid = + NeutronOvsdbIidFactory.nodeIid(new TopologyId(OVSDB_TOPOLOGY_ID), new NodeId(UUID)); + assertNotNull(iid); + Class[] expectedTypes = {NetworkTopology.class, Topology.class, Node.class}; + assertPathArgumentTypes(iid.getPathArguments(), expectedTypes); + assertEquals(Node.class, iid.getTargetType()); + assertFalse(iid.isWildcarded()); + } + + @Test + public void test_NodeIid_inventory() { + org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId nodeId = + new org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId(UUID); + InstanceIdentifier iid = + NeutronOvsdbIidFactory.nodeIid(nodeId); + assertNotNull(iid); + Class[] expectedTypes = + {Nodes.class, org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node.class}; + assertPathArgumentTypes(iid.getPathArguments(), expectedTypes); + assertEquals(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node.class, + iid.getTargetType()); + assertFalse(iid.isWildcarded()); } private static void assertPathArgumentTypes(Iterable pathArguments, Class[] expectedTypes) { @@ -85,7 +119,7 @@ public class NeutronOvsdbIidFactoryTest { Iterator it = pathArguments.iterator(); for (int i = 0; i < expectedTypes.length; ++i) { assertTrue("Next path argument expected.", it.hasNext()); - assertEquals("Unexpected path argument type.", expectedTypes[i] , it.next().getType()); + assertEquals("Unexpected path argument type.", expectedTypes[i], it.next().getType()); } } }