diff options
Diffstat (limited to 'lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read')
15 files changed, 0 insertions, 1893 deletions
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/AdjacencyCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/AdjacencyCustomizerTest.java deleted file mode 100644 index 09d4d27fb..000000000 --- a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/AdjacencyCustomizerTest.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright (c) 2016 Cisco and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.fd.honeycomb.lisp.translate.read; - -import static io.fd.honeycomb.lisp.translate.AdjacencyData.ADDRESS_ONE; -import static io.fd.honeycomb.lisp.translate.AdjacencyData.ADDRESS_THREE; -import static io.fd.honeycomb.lisp.translate.AdjacencyData.LOCAL_EID_ONE; -import static io.fd.honeycomb.lisp.translate.AdjacencyData.LOCAL_EID_TWO; -import static io.fd.honeycomb.lisp.translate.AdjacencyData.REMOTE_EID_ONE; -import static io.fd.honeycomb.lisp.translate.AdjacencyData.REMOTE_EID_TWO; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.contains; -import static org.hamcrest.Matchers.hasSize; -import static org.junit.Assert.assertEquals; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.when; - -import io.fd.honeycomb.lisp.context.util.AdjacenciesMappingContext; -import io.fd.honeycomb.lisp.context.util.EidMappingContext; -import io.fd.honeycomb.lisp.translate.util.EidMetadataProvider; -import io.fd.honeycomb.lisp.util.AdjacencyMappingContextTestHelper; -import io.fd.honeycomb.lisp.util.EidMappingContextHelper; -import io.fd.honeycomb.translate.spi.read.ReaderCustomizer; -import io.fd.honeycomb.translate.vpp.util.ByteDataTranslator; -import io.fd.honeycomb.vpp.test.read.ListReaderCustomizerTest; -import io.fd.vpp.jvpp.core.dto.LispAdjacenciesGetReply; -import io.fd.vpp.jvpp.core.types.LispAdjacency; -import java.util.List; -import org.junit.Before; -import org.junit.Test; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv4; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.MappingId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.adjacencies.grouping.Adjacencies; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.adjacencies.grouping.AdjacenciesBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.adjacencies.grouping.adjacencies.Adjacency; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.adjacencies.grouping.adjacencies.AdjacencyBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.adjacencies.grouping.adjacencies.AdjacencyKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.dp.subtable.grouping.RemoteMappings; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.dp.subtable.grouping.remote.mappings.RemoteMapping; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.dp.subtable.grouping.remote.mappings.RemoteMappingKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.eid.table.grouping.EidTable; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.eid.table.grouping.eid.table.VniTable; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.eid.table.grouping.eid.table.VniTableKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.eid.table.grouping.eid.table.vni.table.BridgeDomainSubtable; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - - -public class AdjacencyCustomizerTest - extends ListReaderCustomizerTest<Adjacency, AdjacencyKey, AdjacencyBuilder> - implements ByteDataTranslator, EidMetadataProvider, EidMappingContextHelper, AdjacencyMappingContextTestHelper { - - private InstanceIdentifier<Adjacency> identifier; - - public AdjacencyCustomizerTest() { - super(Adjacency.class, AdjacenciesBuilder.class); - } - - @Before - public void init() { - identifier = InstanceIdentifier.create(EidTable.class) - .child(VniTable.class, new VniTableKey(2L)) - .child(BridgeDomainSubtable.class) - .child(RemoteMappings.class) - .child(RemoteMapping.class, new RemoteMappingKey(new MappingId("remote-mapping"))) - .child(Adjacencies.class) - .child(Adjacency.class, new AdjacencyKey("adj-one")); - - - mockApi(); - defineEidMapping(mappingContext, LOCAL_EID_ONE, new MappingId("local-eid-one"), "local-mapping-context"); - defineEidMapping(mappingContext, LOCAL_EID_TWO, new MappingId("local-eid-two"), "local-mapping-context"); - defineEidMapping(mappingContext, REMOTE_EID_ONE, new MappingId("remote-eid-one"), "remote-mapping-context"); - defineEidMapping(mappingContext, REMOTE_EID_TWO, new MappingId("remote-eid-two"), "remote-mapping-context"); - - defineAdjacencyMapping(mappingContext, "local-eid-one", "remote-eid-one", "adj-one", - "adjacencies-mapping-context"); - defineAdjacencyMapping(mappingContext, "local-eid-two", "remote-eid-two", "adj-two", - "adjacencies-mapping-context"); - mockApi(); - } - - @Test - public void getAllIds() throws Exception { - final List<AdjacencyKey> keys = getCustomizer().getAllIds(identifier, ctx); - - assertThat(keys, hasSize(2)); - assertThat(keys, contains(new AdjacencyKey("adj-one"), new AdjacencyKey("adj-two"))); - } - - @Test - public void readCurrentAttributes() throws Exception { - final AdjacencyBuilder builder = new AdjacencyBuilder(); - getCustomizer().readCurrentAttributes(identifier, builder, ctx); - - assertEquals("adj-one", builder.getId()); - assertEquals(new AdjacencyKey("adj-one"), builder.getKey()); - assertEquals(ADDRESS_ONE.getValue(), Ipv4.class.cast(builder.getLocalEid().getAddress()).getIpv4().getValue()); - assertEquals(ADDRESS_THREE.getValue(), - Ipv4.class.cast(builder.getRemoteEid().getAddress()).getIpv4().getValue()); - } - - @Override - protected ReaderCustomizer<Adjacency, AdjacencyBuilder> initCustomizer() { - return new AdjacencyCustomizer(api, new EidMappingContext("local-mapping-context"), - new EidMappingContext("remote-mapping-context"), - new AdjacenciesMappingContext("adjacencies-mapping-context")); - } - - - private void mockApi() { - LispAdjacency adjacencyOne = new LispAdjacency(); - adjacencyOne.eidType = 0; - adjacencyOne.leid = new byte[]{-64, -88, 2, 1}; - adjacencyOne.leidPrefixLen = 32; - adjacencyOne.reid = new byte[]{-64, -88, 2, 3}; - adjacencyOne.reidPrefixLen = 32; - - - LispAdjacency adjacencyTwo = new LispAdjacency(); - adjacencyTwo.eidType = 0; - adjacencyTwo.leid = new byte[]{-64, -88, 2, 2}; - adjacencyTwo.leidPrefixLen = 32; - adjacencyTwo.reid = new byte[]{-64, -88, 2, 4}; - adjacencyTwo.reidPrefixLen = 32; - - LispAdjacenciesGetReply reply = new LispAdjacenciesGetReply(); - reply.adjacencies = new LispAdjacency[]{adjacencyOne, adjacencyTwo}; - - when(api.lispAdjacenciesGet(any())).thenReturn(future(reply)); - } -}
\ No newline at end of file diff --git a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/BridgeDomainSubtableCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/BridgeDomainSubtableCustomizerTest.java deleted file mode 100644 index b230b3435..000000000 --- a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/BridgeDomainSubtableCustomizerTest.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (c) 2016 Cisco and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.fd.honeycomb.lisp.translate.read; - - -import static io.fd.honeycomb.lisp.translate.read.dump.executor.params.SubtableDumpParams.MapLevel.L2; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import io.fd.honeycomb.lisp.translate.read.trait.SubtableReaderTestCase; -import io.fd.honeycomb.translate.read.ReadFailedException; -import io.fd.honeycomb.translate.spi.read.ReaderCustomizer; -import io.fd.honeycomb.translate.vpp.util.NamingContext; -import io.fd.vpp.jvpp.VppCallbackException; -import org.junit.Test; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.eid.table.grouping.EidTable; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.eid.table.grouping.eid.table.VniTable; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.eid.table.grouping.eid.table.VniTableBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.eid.table.grouping.eid.table.VniTableKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.eid.table.grouping.eid.table.vni.table.BridgeDomainSubtable; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.eid.table.grouping.eid.table.vni.table.BridgeDomainSubtableBuilder; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - -public class BridgeDomainSubtableCustomizerTest - extends SubtableReaderTestCase<BridgeDomainSubtable, BridgeDomainSubtableBuilder> { - - private InstanceIdentifier<BridgeDomainSubtable> validId; - private NamingContext bridgeDomainContext; - - public BridgeDomainSubtableCustomizerTest() { - super(BridgeDomainSubtable.class, VniTableBuilder.class); - } - - @Override - protected void setUp() throws Exception { - bridgeDomainContext = new NamingContext("br", "br-domain-context"); - validId = InstanceIdentifier.create(EidTable.class).child(VniTable.class, new VniTableKey(expectedVni)) - .child(BridgeDomainSubtable.class); - - defineMapping(mappingContext, "br-domain", expectedTableId, "br-domain-context"); - } - - @Test - public void testReadCurrentSuccessfull() throws ReadFailedException { - doReturnValidNonEmptyDataOnDump(); - BridgeDomainSubtableBuilder builder = new BridgeDomainSubtableBuilder(); - customizer.readCurrentAttributes(validId, builder, ctx); - - verifyLispEidTableMapDumpCalled(L2); - - final BridgeDomainSubtable subtable = builder.build(); - assertNotNull(subtable); - assertEquals("br-domain", subtable.getBridgeDomainRef()); - } - - - @Test - public void testReadCurrentEmptyDump() throws ReadFailedException { - doReturnEmptyDataOnDump(); - BridgeDomainSubtableBuilder builder = new BridgeDomainSubtableBuilder(); - customizer.readCurrentAttributes(validId, builder, ctx); - - verifyLispEidTableMapDumpCalled(L2); - - final BridgeDomainSubtable subtable = builder.build(); - assertNotNull(subtable); - assertNull(subtable.getBridgeDomainRef()); - } - - @Test - public void testReadCurrentFailed() { - doThrowOnDump(); - BridgeDomainSubtableBuilder builder = new BridgeDomainSubtableBuilder(); - try { - customizer.readCurrentAttributes(validId, builder, ctx); - } catch (ReadFailedException e) { - assertTrue(e.getCause() instanceof VppCallbackException); - assertNull(builder.getBridgeDomainRef()); - verifyLispEidTableMapDumpNotCalled(); - - return; - } - - fail("Test should throw ReadFailedException"); - } - - @Test - public void testGetBuilder() { - final BridgeDomainSubtableBuilder builder = customizer.getBuilder(validId); - - assertNotNull(builder); - assertNull(builder.getLocalMappings()); - assertNull(builder.getRemoteMappings()); - assertNull(builder.getBridgeDomainRef()); - } - - @Override - protected ReaderCustomizer<BridgeDomainSubtable, BridgeDomainSubtableBuilder> initCustomizer() { - return new BridgeDomainSubtableCustomizer(api, bridgeDomainContext); - } -} diff --git a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/InterfaceCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/InterfaceCustomizerTest.java deleted file mode 100644 index fb97dce5d..000000000 --- a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/InterfaceCustomizerTest.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (c) 2016 Cisco and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.fd.honeycomb.lisp.translate.read; - -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.when; - -import com.google.common.collect.ImmutableList; -import io.fd.honeycomb.translate.read.ReadFailedException; -import io.fd.honeycomb.translate.spi.read.ReaderCustomizer; -import io.fd.honeycomb.translate.vpp.util.NamingContext; -import io.fd.honeycomb.vpp.test.read.ListReaderCustomizerTest; -import java.util.List; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mockito; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.locator.sets.grouping.LocatorSets; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.locator.sets.grouping.locator.sets.LocatorSet; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.locator.sets.grouping.locator.sets.LocatorSetBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.locator.sets.grouping.locator.sets.LocatorSetKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.locator.sets.grouping.locator.sets.locator.set.Interface; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.locator.sets.grouping.locator.sets.locator.set.InterfaceBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.locator.sets.grouping.locator.sets.locator.set.InterfaceKey; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import io.fd.vpp.jvpp.core.dto.LispLocatorDetails; -import io.fd.vpp.jvpp.core.dto.LispLocatorDetailsReplyDump; - -public class InterfaceCustomizerTest - extends ListReaderCustomizerTest<Interface, InterfaceKey, InterfaceBuilder> { - - public InterfaceCustomizerTest() { - super(Interface.class, LocatorSetBuilder.class); - } - - private InstanceIdentifier<Interface> validId; - - @Before - public void init() { - validId = InstanceIdentifier.create(LocatorSets.class).child(LocatorSet.class, new LocatorSetKey("loc-set-1")) - .child(Interface.class, new InterfaceKey("interface-1")); - - //mappings - defineMappings(); - //dump data - defineDumpData(); - } - - private void defineDumpData() { - final LispLocatorDetailsReplyDump dump = new LispLocatorDetailsReplyDump(); - - final LispLocatorDetails detail1 = new LispLocatorDetails(); - detail1.swIfIndex = 1; - detail1.ipAddress = new byte[]{-64, -88, 2, 1}; - detail1.isIpv6 = 0; - detail1.local = 0; - detail1.priority = 1; - detail1.weight = 2; - - final LispLocatorDetails detail2 = new LispLocatorDetails(); - detail2.swIfIndex = 2; - detail2.ipAddress = new byte[]{-64, -88, 2, 2}; - detail2.isIpv6 = 0; - detail2.local = 0; - detail2.priority = 2; - detail2.weight = 3; - - dump.lispLocatorDetails = ImmutableList.of(detail1, detail2); - - when(api.lispLocatorDump(Mockito.any())).thenReturn(future(dump)); - } - - private void defineMappings() { - defineMapping(mappingContext, "interface-1", 1, "interface-context"); - defineMapping(mappingContext, "interface-2", 2, "interface-context"); - defineMapping(mappingContext, "loc-set-1", 3, "locator-set-context"); - } - - @Test - public void testGetAllIds() throws ReadFailedException { - - final List<InterfaceKey> keys = getCustomizer().getAllIds(validId, ctx); - - assertEquals(2, keys.size()); - assertEquals("interface-1", keys.get(0).getInterfaceRef()); - assertEquals("interface-2", keys.get(1).getInterfaceRef()); - } - - @Test - public void testReadCurrentAttributes() throws ReadFailedException { - InterfaceBuilder builder = new InterfaceBuilder(); - getCustomizer().readCurrentAttributes(validId, builder, ctx); - - final Interface iface = builder.build(); - assertEquals("interface-1", iface.getInterfaceRef()); - assertEquals("interface-1", iface.getKey().getInterfaceRef()); - - } - - @Override - protected ReaderCustomizer<Interface, InterfaceBuilder> initCustomizer() { - return new InterfaceCustomizer(api, new NamingContext("interface", "interface-context"), - new NamingContext("loc-set", "locator-set-context")); - } -} diff --git a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/ItrRemoteLocatorSetCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/ItrRemoteLocatorSetCustomizerTest.java deleted file mode 100644 index 9b810b94d..000000000 --- a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/ItrRemoteLocatorSetCustomizerTest.java +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Copyright (c) 2016 Cisco and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.fd.honeycomb.lisp.translate.read; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import io.fd.honeycomb.translate.read.ReadFailedException; -import io.fd.honeycomb.translate.spi.read.ReaderCustomizer; -import io.fd.honeycomb.vpp.test.read.ReaderCustomizerTest; -import io.fd.vpp.jvpp.VppCallbackException; -import io.fd.vpp.jvpp.core.dto.LispGetMapRequestItrRlocs; -import io.fd.vpp.jvpp.core.dto.LispGetMapRequestItrRlocsReply; -import java.nio.charset.StandardCharsets; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; -import org.junit.Before; -import org.junit.Test; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.itr.remote.locator.sets.grouping.ItrRemoteLocatorSet; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.itr.remote.locator.sets.grouping.ItrRemoteLocatorSetBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.lisp.feature.data.grouping.LispFeatureDataBuilder; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - - -public class ItrRemoteLocatorSetCustomizerTest - extends ReaderCustomizerTest<ItrRemoteLocatorSet, ItrRemoteLocatorSetBuilder> { - - private static final String EXPECTED_LOCATOR_SET_NAME = "loc-set"; - - private InstanceIdentifier<ItrRemoteLocatorSet> validId; - private ItrRemoteLocatorSetBuilder builder; - - public ItrRemoteLocatorSetCustomizerTest() { - super(ItrRemoteLocatorSet.class, LispFeatureDataBuilder.class); - } - - @Before - public void setUp() throws Exception { - validId = InstanceIdentifier.create(ItrRemoteLocatorSet.class); - builder = new ItrRemoteLocatorSetBuilder(); - } - - @Override - protected ReaderCustomizer<ItrRemoteLocatorSet, ItrRemoteLocatorSetBuilder> initCustomizer() { - return new ItrRemoteLocatorSetCustomizer(api); - } - - @Test - public void getBuilder() throws Exception { - final ItrRemoteLocatorSetBuilder itrRemoteLocatorSetBuilder = getCustomizer().getBuilder(validId); - - assertNotNull(itrRemoteLocatorSetBuilder); - assertNull(itrRemoteLocatorSetBuilder.getRemoteLocatorSetName()); - } - - @Test - public void readCurrentAttributesSuccess() throws Exception { - doReturnValidDataOnDump(); - - getCustomizer().readCurrentAttributes(validId, builder, ctx); - - assertNotNull(builder); - assertEquals(EXPECTED_LOCATOR_SET_NAME, builder.getRemoteLocatorSetName()); - verifyLispGetMapRequestItrRlocsInvokedOnce(); - } - - @Test - public void readCurrentAttributesEmptyData() throws Exception { - doReturnEmptyDataOnDump(); - getCustomizer().readCurrentAttributes(validId, builder, ctx); - verifyInvalidDataCase(builder); - } - - @Test - public void readCurrentAttributesFailedCallHalted() { - doThrowExceptionOnDump(); - try { - getCustomizer().readCurrentAttributes(validId, builder, ctx); - } catch (ReadFailedException e) { - assertTrue(e.getCause() instanceof VppCallbackException); - assertNotNull(builder); - assertNull(builder.getRemoteLocatorSetName()); - - verifyLispGetMapRequestItrRlocsInvokedOnce(); - return; - } - - fail("Test should have thrown exception"); - } - - @Test - public void merge() throws Exception { - LispFeatureDataBuilder builder = new LispFeatureDataBuilder(); - ItrRemoteLocatorSet set = new ItrRemoteLocatorSetBuilder().setRemoteLocatorSetName("loc-set").build(); - getCustomizer().merge(builder, set); - - assertNotNull(builder); - assertEquals(set, builder.getItrRemoteLocatorSet()); - } - - - private void doReturnValidDataOnDump() { - LispGetMapRequestItrRlocsReply reply = new LispGetMapRequestItrRlocsReply(); - reply.locatorSetName = EXPECTED_LOCATOR_SET_NAME.getBytes(StandardCharsets.UTF_8); - - when(api.lispGetMapRequestItrRlocs(any(LispGetMapRequestItrRlocs.class))) - .thenReturn(CompletableFuture.completedFuture(reply)); - } - - private void doReturnNullDataOnDump() { - when(api.lispGetMapRequestItrRlocs(any(LispGetMapRequestItrRlocs.class))) - .thenReturn(CompletableFuture.completedFuture(null)); - } - - private void doReturnEmptyDataOnDump() { - when(api.lispGetMapRequestItrRlocs(any(LispGetMapRequestItrRlocs.class))) - .thenReturn(CompletableFuture.completedFuture(new LispGetMapRequestItrRlocsReply())); - } - - private void doThrowExceptionOnDump() { - when(api.lispGetMapRequestItrRlocs(any(LispGetMapRequestItrRlocs.class))). - thenReturn(new CompletableFuture<LispGetMapRequestItrRlocsReply>() { - @Override - public LispGetMapRequestItrRlocsReply get(final long l, final TimeUnit timeUnit) - throws InterruptedException, ExecutionException, TimeoutException { - throw new ExecutionException(new VppCallbackException("lispGetMapRequestItrRlocs", 1, -2)); - } - }); - } - - private void verifyLispGetMapRequestItrRlocsInvokedOnce() { - verify(api, times(1)).lispGetMapRequestItrRlocs(any(LispGetMapRequestItrRlocs.class)); - } - - private void verifyInvalidDataCase(final ItrRemoteLocatorSetBuilder builder) { - assertNotNull(builder); - assertNull(builder.getRemoteLocatorSetName()); - - verifyLispGetMapRequestItrRlocsInvokedOnce(); - } -}
\ No newline at end of file diff --git a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/LispStateCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/LispStateCustomizerTest.java deleted file mode 100644 index 33d956f8e..000000000 --- a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/LispStateCustomizerTest.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2016 Cisco and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.fd.honeycomb.lisp.translate.read; - -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.when; - -import io.fd.honeycomb.translate.read.ReadFailedException; -import io.fd.honeycomb.translate.spi.read.ReaderCustomizer; -import io.fd.honeycomb.vpp.test.read.ReaderCustomizerTest; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mockito; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.LispState; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.LispStateBuilder; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import io.fd.vpp.jvpp.core.dto.ShowLispStatusReply; - -public class LispStateCustomizerTest extends ReaderCustomizerTest<LispState, LispStateBuilder> { - - private InstanceIdentifier<LispState> identifier; - - public LispStateCustomizerTest() { - super(LispState.class, null); - } - - @Before - public void init() { - identifier = InstanceIdentifier.create(LispState.class); - final ShowLispStatusReply reply = new ShowLispStatusReply(); - reply.featureStatus = 1; - - when(api.showLispStatus(Mockito.any())).thenReturn(future(reply)); - } - - @Test - public void testReadCurrentAttributes() throws ReadFailedException { - - LispStateBuilder builder = new LispStateBuilder(); - getCustomizer().readCurrentAttributes(identifier, builder, ctx); - - assertEquals(true, builder.build().isEnable()); - } - - @Override - protected ReaderCustomizer<LispState, LispStateBuilder> initCustomizer() { - return new LispStateCustomizer(api); - } - - @Override - public void testMerge() throws Exception { - //LispState is root node, so there is no way to implement merge(it is also not needed) - } -} diff --git a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/LocalMappingCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/LocalMappingCustomizerTest.java deleted file mode 100644 index 065adcc4e..000000000 --- a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/LocalMappingCustomizerTest.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Copyright (c) 2016 Cisco and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.fd.honeycomb.lisp.translate.read; - -import static io.fd.honeycomb.lisp.translate.read.dump.executor.params.MappingsDumpParams.EidType.IPV4; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.when; - -import com.google.common.collect.ImmutableList; -import io.fd.honeycomb.lisp.context.util.EidMappingContext; -import io.fd.honeycomb.lisp.translate.read.dump.executor.params.MappingsDumpParams; -import io.fd.honeycomb.lisp.translate.util.EidTranslator; -import io.fd.honeycomb.translate.MappingContext; -import io.fd.honeycomb.translate.spi.read.ReaderCustomizer; -import io.fd.honeycomb.translate.vpp.util.NamingContext; -import io.fd.honeycomb.vpp.test.read.ListReaderCustomizerTest; -import java.util.List; -import org.junit.Test; -import org.mockito.Mock; -import org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.eid.mapping.context.rev160801.contexts.eid.mapping.context.mappings.mapping.EidBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv4; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv4Builder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.MappingId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.dp.subtable.grouping.LocalMappings; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.dp.subtable.grouping.LocalMappingsBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.dp.subtable.grouping.local.mappings.LocalMapping; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.dp.subtable.grouping.local.mappings.LocalMappingBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.dp.subtable.grouping.local.mappings.LocalMappingKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.dp.subtable.grouping.local.mappings.local.mapping.Eid; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.eid.table.grouping.EidTable; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.eid.table.grouping.eid.table.VniTable; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.eid.table.grouping.eid.table.VniTableKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.eid.table.grouping.eid.table.vni.table.BridgeDomainSubtable; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.eid.table.grouping.eid.table.vni.table.VrfSubtable; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import io.fd.vpp.jvpp.core.dto.LispEidTableDetails; -import io.fd.vpp.jvpp.core.dto.LispEidTableDetailsReplyDump; - -public class LocalMappingCustomizerTest extends - ListReaderCustomizerTest<LocalMapping, LocalMappingKey, LocalMappingBuilder> implements EidTranslator { - - private static final Ipv4 - EID_ADDRESS = new Ipv4Builder().setIpv4(new Ipv4Address("192.168.2.1")).build(); - - @Mock - private EidMappingContext localMappingContext; - - private InstanceIdentifier<LocalMapping> emptyIdentifier; - private InstanceIdentifier<LocalMapping> validIdentifier; - - public LocalMappingCustomizerTest() { - super(LocalMapping.class, LocalMappingsBuilder.class); - } - - - public void setUp() { - emptyIdentifier = InstanceIdentifier.create(EidTable.class) - .child(VniTable.class, new VniTableKey(12L)) - .child(VrfSubtable.class) - .child(LocalMappings.class) - .child(LocalMapping.class); - - validIdentifier = InstanceIdentifier.create(EidTable.class) - .child(VniTable.class, new VniTableKey(12L)) - .child(VrfSubtable.class) - .child(LocalMappings.class) - .child(LocalMapping.class, new LocalMappingKey(new MappingId("local-mapping"))); - - defineDumpData(); - defineMappings(); - } - - private void defineDumpData() { - LispEidTableDetailsReplyDump replyDump = new LispEidTableDetailsReplyDump(); - LispEidTableDetails detail = new LispEidTableDetails(); - detail.action = 0; - detail.authoritative = 1; - detail.context = 4; - detail.eid = new byte[]{-64, -88, 2, 1}; - detail.eidPrefixLen = 32; - detail.eidType = (byte) IPV4.getValue(); - detail.isLocal = 1; - detail.locatorSetIndex = 1; - detail.ttl = 7; - detail.vni = 12; - - replyDump.lispEidTableDetails = ImmutableList.of(detail); - when(api.lispEidTableDump(any())).thenReturn(future(replyDump)); - } - - private void defineMappings() { - //eid mapping - - when(localMappingContext.getId(any(Eid.class), any(MappingContext.class))) - .thenReturn(new MappingId("local-mapping")); - when(localMappingContext.containsEid(new MappingId("local-mapping"), mappingContext)).thenReturn(true); - when(localMappingContext.getEid(new MappingId("local-mapping"), mappingContext)).thenReturn(new EidBuilder() - .setAddress(EID_ADDRESS).build()); - //naming context for locator - defineMapping(mappingContext, "loc-set", 1, "locator-set-context"); - } - - @Test - public void readCurrentAttributes() throws Exception { - LocalMappingBuilder builder = new LocalMappingBuilder(); - getCustomizer().readCurrentAttributes(validIdentifier, builder, ctx); - - final LocalMapping mapping = builder.build(); - - assertNotNull(mapping); - assertEquals(true, compareAddresses(EID_ADDRESS, mapping.getEid().getAddress())); - assertEquals("loc-set", mapping.getLocatorSet()); - } - - @Test - public void getAllIds() throws Exception { - final List<LocalMappingKey> keys = getCustomizer().getAllIds(emptyIdentifier, ctx); - - assertEquals(1, keys.size()); - assertEquals("local-mapping", keys.get(0).getId().getValue()); - } - - @Override - protected ReaderCustomizer<LocalMapping, LocalMappingBuilder> initCustomizer() { - return new LocalMappingCustomizer(api, new NamingContext("loc", "locator-set-context"), localMappingContext); - } -}
\ No newline at end of file diff --git a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/LocatorSetCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/LocatorSetCustomizerTest.java deleted file mode 100644 index e863ba2bb..000000000 --- a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/LocatorSetCustomizerTest.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (c) 2016 Cisco and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.fd.honeycomb.lisp.translate.read; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.when; - -import com.google.common.collect.ImmutableList; -import io.fd.honeycomb.translate.spi.read.ReaderCustomizer; -import io.fd.honeycomb.translate.vpp.util.NamingContext; -import io.fd.honeycomb.vpp.test.read.ListReaderCustomizerTest; -import java.nio.charset.StandardCharsets; -import java.util.List; -import org.junit.Before; -import org.junit.Test; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.locator.sets.grouping.LocatorSets; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.locator.sets.grouping.LocatorSetsBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.locator.sets.grouping.locator.sets.LocatorSet; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.locator.sets.grouping.locator.sets.LocatorSetBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.locator.sets.grouping.locator.sets.LocatorSetKey; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import io.fd.vpp.jvpp.core.dto.LispLocatorSetDetails; -import io.fd.vpp.jvpp.core.dto.LispLocatorSetDetailsReplyDump; - - -public class LocatorSetCustomizerTest - extends ListReaderCustomizerTest<LocatorSet, LocatorSetKey, LocatorSetBuilder> { - - private InstanceIdentifier<LocatorSet> emptyId; - private InstanceIdentifier<LocatorSet> validId; - - public LocatorSetCustomizerTest() { - super(LocatorSet.class, LocatorSetsBuilder.class); - } - - @Before - public void init() { - emptyId = InstanceIdentifier.create(LocatorSet.class); - validId = InstanceIdentifier.create(LocatorSets.class).child(LocatorSet.class, new LocatorSetKey("loc-set")); - - defineDumpData(); - defineMapping(mappingContext, "loc-set", 1, "locator-set-context"); - } - - private void defineDumpData() { - LispLocatorSetDetailsReplyDump dump = new LispLocatorSetDetailsReplyDump(); - LispLocatorSetDetails detail = new LispLocatorSetDetails(); - detail.context = 4; - detail.lsName = "loc-set".getBytes(StandardCharsets.UTF_8); - detail.lsIndex = 1; - - dump.lispLocatorSetDetails = ImmutableList.of(detail); - - when(api.lispLocatorSetDump(any())).thenReturn(future(dump)); - } - - - @Test - public void readCurrentAttributes() throws Exception { - LocatorSetBuilder builder = new LocatorSetBuilder(); - getCustomizer().readCurrentAttributes(validId, builder, ctx); - - assertNotNull(builder); - assertEquals("loc-set", builder.getName()); - assertEquals("loc-set", builder.getKey().getName()); - } - - @Test - public void getAllIds() throws Exception { - final List<LocatorSetKey> keys = getCustomizer().getAllIds(emptyId, ctx); - - assertEquals(1, keys.size()); - assertEquals("loc-set", keys.get(0).getName()); - } - - @Override - protected ReaderCustomizer<LocatorSet, LocatorSetBuilder> initCustomizer() { - return new LocatorSetCustomizer(api, new NamingContext("loc", "locator-set-context")); - } -}
\ No newline at end of file diff --git a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/MapResolverCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/MapResolverCustomizerTest.java deleted file mode 100644 index adcbdb643..000000000 --- a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/MapResolverCustomizerTest.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (c) 2016 Cisco and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.fd.honeycomb.lisp.translate.read; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.when; - -import com.google.common.collect.ImmutableList; -import io.fd.honeycomb.translate.spi.read.ReaderCustomizer; -import io.fd.honeycomb.vpp.test.read.ListReaderCustomizerTest; -import io.fd.vpp.jvpp.core.dto.LispMapResolverDetails; -import io.fd.vpp.jvpp.core.dto.LispMapResolverDetailsReplyDump; -import java.util.List; -import org.junit.Before; -import org.junit.Test; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.map.resolvers.grouping.MapResolvers; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.map.resolvers.grouping.MapResolversBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.map.resolvers.grouping.map.resolvers.MapResolver; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.map.resolvers.grouping.map.resolvers.MapResolverBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.map.resolvers.grouping.map.resolvers.MapResolverKey; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - - -public class MapResolverCustomizerTest - extends ListReaderCustomizerTest<MapResolver, MapResolverKey, MapResolverBuilder> { - - private static final IpAddress IP_ADDRESS_REVERTED = - new IpAddress(new Ipv4AddressNoZone("1.2.168.192")); - - private InstanceIdentifier<MapResolver> emptyId; - private InstanceIdentifier<MapResolver> validId; - - public MapResolverCustomizerTest() { - super(MapResolver.class, MapResolversBuilder.class); - } - - @Before - public void init() { - - emptyId = InstanceIdentifier.create(MapResolver.class); - validId = InstanceIdentifier.create(MapResolvers.class) - .child(MapResolver.class, new MapResolverKey(IP_ADDRESS_REVERTED)); - defineDumpData(); - } - - @Test - public void readCurrentAttributes() throws Exception { - MapResolverBuilder builder = new MapResolverBuilder(); - getCustomizer().readCurrentAttributes(validId, builder, ctx); - - MapResolver resolver = builder.build(); - assertNotNull(resolver); - assertEquals("1.2.168.192", resolver.getIpAddress().getIpv4Address().getValue()); - } - - @Test - public void getAllIds() throws Exception { - final List<MapResolverKey> keys = getCustomizer().getAllIds(emptyId, ctx); - - assertEquals(1, keys.size()); - - final MapResolverKey key = keys.get(0); - assertNotNull(key); - assertEquals("1.2.168.192", new String(key.getIpAddress().getValue())); - - } - - private void defineDumpData() { - final LispMapResolverDetailsReplyDump replyDump = new LispMapResolverDetailsReplyDump(); - final LispMapResolverDetails detail = new LispMapResolverDetails(); - detail.context = 5; - detail.ipAddress = new byte[]{1, 2, -88, -64}; - detail.isIpv6 = 0; - - replyDump.lispMapResolverDetails = ImmutableList.of(detail); - - when(api.lispMapResolverDump(any())).thenReturn(future(replyDump)); - } - - @Override - protected ReaderCustomizer<MapResolver, MapResolverBuilder> initCustomizer() { - return new MapResolverCustomizer(api); - } -}
\ No newline at end of file diff --git a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/PitrCfgCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/PitrCfgCustomizerTest.java deleted file mode 100644 index 52abdf818..000000000 --- a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/PitrCfgCustomizerTest.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2016 Cisco and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.fd.honeycomb.lisp.translate.read; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.when; - -import io.fd.honeycomb.translate.spi.read.ReaderCustomizer; -import io.fd.honeycomb.vpp.test.read.ReaderCustomizerTest; -import java.nio.charset.StandardCharsets; -import org.junit.Before; -import org.junit.Test; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.LispStateBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.lisp.feature.data.grouping.LispFeatureDataBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.pitr.cfg.grouping.PitrCfg; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.pitr.cfg.grouping.PitrCfgBuilder; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import io.fd.vpp.jvpp.core.dto.ShowLispPitrReply; - - -public class PitrCfgCustomizerTest extends ReaderCustomizerTest<PitrCfg, PitrCfgBuilder> { - - private static final byte[] LOC_SET_NAME_BYTES = "loc-set".getBytes(StandardCharsets.UTF_8); - - private InstanceIdentifier<PitrCfg> emptyId; - - public PitrCfgCustomizerTest() { - super(PitrCfg.class, LispFeatureDataBuilder.class); - } - - @Before - public void init() { - emptyId = InstanceIdentifier.create(PitrCfg.class); - - mockDumpData(); - } - - @Test - public void readCurrentAttributes() throws Exception { - PitrCfgBuilder builder = new PitrCfgBuilder(); - getCustomizer().readCurrentAttributes(emptyId, builder, ctx); - - final PitrCfg cfg = builder.build(); - - assertNotNull(cfg); - assertEquals("loc-set", cfg.getLocatorSet()); - } - - private void mockDumpData() { - ShowLispPitrReply replyDump = new ShowLispPitrReply(); - replyDump.locatorSetName = LOC_SET_NAME_BYTES; - replyDump.status = 1; - - when(api.showLispPitr(any())).thenReturn(future(replyDump)); - } - - @Override - protected ReaderCustomizer<PitrCfg, PitrCfgBuilder> initCustomizer() { - return new PitrCfgCustomizer(api); - } -}
\ No newline at end of file diff --git a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/RemoteMappingCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/RemoteMappingCustomizerTest.java deleted file mode 100644 index 27c243e8b..000000000 --- a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/RemoteMappingCustomizerTest.java +++ /dev/null @@ -1,241 +0,0 @@ -/* - * Copyright (c) 2016 Cisco and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.fd.honeycomb.lisp.translate.read; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.when; - -import com.google.common.collect.ImmutableList; -import io.fd.honeycomb.lisp.context.util.EidMappingContext; -import io.fd.honeycomb.lisp.translate.util.EidTranslator; -import io.fd.honeycomb.translate.MappingContext; -import io.fd.honeycomb.translate.spi.read.ReaderCustomizer; -import io.fd.honeycomb.translate.vpp.util.NamingContext; -import io.fd.honeycomb.vpp.test.read.ListReaderCustomizerTest; -import io.fd.vpp.jvpp.core.dto.LispEidTableDetails; -import io.fd.vpp.jvpp.core.dto.LispEidTableDetailsReplyDump; -import io.fd.vpp.jvpp.core.dto.LispLocatorDetails; -import io.fd.vpp.jvpp.core.dto.LispLocatorDetailsReplyDump; -import java.util.Collections; -import java.util.List; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mock; -import org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.eid.mapping.context.rev160801.contexts.eid.mapping.context.mappings.mapping.EidBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv4; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv4Builder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.MapReplyAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.MappingId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.dp.subtable.grouping.RemoteMappings; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.dp.subtable.grouping.RemoteMappingsBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.dp.subtable.grouping.remote.mappings.RemoteMapping; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.dp.subtable.grouping.remote.mappings.RemoteMappingBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.dp.subtable.grouping.remote.mappings.RemoteMappingKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.dp.subtable.grouping.remote.mappings.remote.mapping.Eid; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.dp.subtable.grouping.remote.mappings.remote.mapping.locator.list.NegativeMapping; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.dp.subtable.grouping.remote.mappings.remote.mapping.locator.list.PositiveMapping; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.dp.subtable.grouping.remote.mappings.remote.mapping.locator.list.positive.mapping.rlocs.Locator; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.eid.table.grouping.EidTable; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.eid.table.grouping.eid.table.VniTable; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.eid.table.grouping.eid.table.VniTableKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.eid.table.grouping.eid.table.vni.table.VrfSubtable; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - -public class RemoteMappingCustomizerTest - extends ListReaderCustomizerTest<RemoteMapping, RemoteMappingKey, RemoteMappingBuilder> - implements EidTranslator { - - private static final Ipv4 - EID_ADDRESS = new Ipv4Builder().setIpv4(new Ipv4Address("192.168.2.1")).build(); - - @Mock - private EidMappingContext eidMappingContext; - - private InstanceIdentifier<RemoteMapping> validId; - - public RemoteMappingCustomizerTest() { - super(RemoteMapping.class, RemoteMappingsBuilder.class); - } - - @Before - public void init() { - - validId = InstanceIdentifier.create(EidTable.class) - .child(VniTable.class, new VniTableKey(12L)) - .child(VrfSubtable.class) - .child(RemoteMappings.class) - .child(RemoteMapping.class, new RemoteMappingKey(new MappingId("remote-mapping"))); - mockMappings(); - defineMapping(mappingContext,"loc-set",1,"loc-set-context"); - } - - - private void mockDumpDataActionZero() { - LispEidTableDetailsReplyDump replyDump = new LispEidTableDetailsReplyDump(); - LispEidTableDetails detail = new LispEidTableDetails(); - detail.action = 0; - detail.authoritative = 1; - detail.context = 4; - detail.eid = new byte[]{-64, -88, 2, 1}; - detail.eidPrefixLen = 32; - detail.isLocal = 0; - detail.locatorSetIndex = 1; - detail.ttl = 7; - detail.vni = 12; - - replyDump.lispEidTableDetails = ImmutableList.of(detail); - - when(api.lispEidTableDump(any())).thenReturn(future(replyDump)); - - LispLocatorDetailsReplyDump rlocs = new LispLocatorDetailsReplyDump(); - rlocs.lispLocatorDetails = Collections.emptyList(); - when(api.lispLocatorDump(any())).thenReturn(future(rlocs)); - } - - private void mockDumpDataActionOne() { - LispEidTableDetailsReplyDump replyDump = new LispEidTableDetailsReplyDump(); - LispEidTableDetails detail = new LispEidTableDetails(); - detail.action = 1; - detail.authoritative = 1; - detail.context = 4; - detail.eid = new byte[]{-64, -88, 2, 1}; - detail.eidPrefixLen = 32; - detail.isLocal = 0; - detail.locatorSetIndex = 1; - detail.ttl = 7; - detail.vni = 12; - - replyDump.lispEidTableDetails = ImmutableList.of(detail); - - when(api.lispEidTableDump(any())).thenReturn(future(replyDump)); - } - - private void mockDumpDataActionZeroWithRemotes() { - LispEidTableDetailsReplyDump replyDump = new LispEidTableDetailsReplyDump(); - LispEidTableDetails detail = new LispEidTableDetails(); - detail.action = 0; - detail.authoritative = 1; - detail.context = 4; - detail.eid = new byte[]{-64, -88, 2, 1}; - detail.eidPrefixLen = 32; - detail.isLocal = 0; - detail.locatorSetIndex = 1; - detail.ttl = 7; - detail.vni = 12; - - replyDump.lispEidTableDetails = ImmutableList.of(detail); - - when(api.lispEidTableDump(any())).thenReturn(future(replyDump)); - - LispLocatorDetailsReplyDump rlocs = new LispLocatorDetailsReplyDump(); - LispLocatorDetails rloc = new LispLocatorDetails(); - rloc.ipAddress = new byte[]{-64, -88, 2, 1}; - rloc.isIpv6 = 0; - rloc.priority = 1; - rloc.weight = 2; - - rlocs.lispLocatorDetails = ImmutableList.of(rloc); - - when(api.lispLocatorDump(any())).thenReturn(future(rlocs)); - } - - - private void mockMappings() { - - when(eidMappingContext.getId(any(Eid.class), any(MappingContext.class))) - .thenReturn(new MappingId("remote-mapping")); - when(eidMappingContext.containsEid(new MappingId("remote-mapping"), mappingContext)).thenReturn(true); - when(eidMappingContext.getEid(new MappingId("remote-mapping"), mappingContext)) - .thenReturn(new EidBuilder().setAddress(EID_ADDRESS).build()); - - } - - @Test - public void readCurrentAttributesNegativeMappingOne() throws Exception { - mockDumpDataActionOne(); - RemoteMappingBuilder builder = new RemoteMappingBuilder(); - getCustomizer().readCurrentAttributes(validId, builder, ctx); - - RemoteMapping mapping = builder.build(); - - assertNotNull(mapping); - assertEquals(true, compareAddresses(EID_ADDRESS, mapping.getEid().getAddress())); - assertEquals(true, mapping.getAuthoritative().isA()); - assertEquals(7L, mapping.getTtl().longValue()); - assertTrue(mapping.getLocatorList() instanceof NegativeMapping); - assertEquals(MapReplyAction.NativelyForward, - ((NegativeMapping) mapping.getLocatorList()).getMapReply().getMapReplyAction()); - } - - @Test - public void readCurrentAttributesNegativeMappingZero() throws Exception { - mockDumpDataActionZero(); - RemoteMappingBuilder builder = new RemoteMappingBuilder(); - getCustomizer().readCurrentAttributes(validId, builder, ctx); - - RemoteMapping mapping = builder.build(); - - assertNotNull(mapping); - assertEquals(true, compareAddresses(EID_ADDRESS, mapping.getEid().getAddress())); - assertEquals(true, mapping.getAuthoritative().isA()); - assertEquals(7L, mapping.getTtl().longValue()); - assertEquals(MapReplyAction.NoAction, - ((NegativeMapping) mapping.getLocatorList()).getMapReply().getMapReplyAction()); - } - - @Test - public void readCurrentAttributesPositiveMapping() throws Exception { - mockDumpDataActionZeroWithRemotes(); - RemoteMappingBuilder builder = new RemoteMappingBuilder(); - getCustomizer().readCurrentAttributes(validId, builder, ctx); - - RemoteMapping mapping = builder.build(); - - assertNotNull(mapping); - assertEquals(true, compareAddresses(EID_ADDRESS, mapping.getEid().getAddress())); - assertEquals(true, mapping.getAuthoritative().isA()); - assertEquals(7L, mapping.getTtl().longValue()); - assertTrue(mapping.getLocatorList() instanceof PositiveMapping); - - final List<Locator> locators = ((PositiveMapping) mapping.getLocatorList()).getRlocs().getLocator(); - assertEquals(1, locators.size()); - final Locator locator = locators.get(0); - assertEquals("192.168.2.1", locator.getAddress().getIpv4Address().getValue()); - assertEquals(1, locator.getPriority().shortValue()); - assertEquals(2, locator.getWeight().shortValue()); - } - - - @Test - public void getAllIds() throws Exception { - mockDumpDataActionOne(); - final List<RemoteMappingKey> keys = getCustomizer().getAllIds(validId, ctx); - - assertNotNull(keys); - assertEquals(1, keys.size()); - assertEquals("remote-mapping", keys.get(0).getId().getValue()); - } - - @Override - protected ReaderCustomizer<RemoteMapping, RemoteMappingBuilder> initCustomizer() { - return new RemoteMappingCustomizer(api, new NamingContext("loc-set", "loc-set-context"), eidMappingContext); - } -}
\ No newline at end of file diff --git a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/VniTableCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/VniTableCustomizerTest.java deleted file mode 100644 index 1ff6cc631..000000000 --- a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/VniTableCustomizerTest.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (c) 2016 Cisco and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.fd.honeycomb.lisp.translate.read; - - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; -import static org.mockito.Mockito.when; - -import com.google.common.collect.ImmutableList; -import io.fd.honeycomb.translate.read.ReadFailedException; -import io.fd.honeycomb.translate.spi.read.ReaderCustomizer; -import io.fd.honeycomb.vpp.test.read.ListReaderCustomizerTest; -import io.fd.vpp.jvpp.VppCallbackException; -import io.fd.vpp.jvpp.core.dto.LispEidTableVniDetails; -import io.fd.vpp.jvpp.core.dto.LispEidTableVniDetailsReplyDump; -import java.util.List; -import java.util.concurrent.CompletableFuture; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mockito; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.eid.table.grouping.EidTable; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.eid.table.grouping.EidTableBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.eid.table.grouping.eid.table.VniTable; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.eid.table.grouping.eid.table.VniTableBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.eid.table.grouping.eid.table.VniTableKey; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - -public class VniTableCustomizerTest extends ListReaderCustomizerTest<VniTable, VniTableKey, VniTableBuilder> { - - private InstanceIdentifier<VniTable> validId; - - public VniTableCustomizerTest() { - super(VniTable.class, EidTableBuilder.class); - } - - @Before - public void init() { - validId = InstanceIdentifier.create(EidTable.class).child(VniTable.class, new VniTableKey(12L)); - } - - @Test - public void testReadAllSuccessfull() throws ReadFailedException { - whenLispEidTableVniDumpReturnValid(); - final List<VniTableKey> keys = getCustomizer().getAllIds(validId, ctx); - - assertNotNull(keys); - assertEquals(3, keys.size()); - assertTrue(keys.contains(new VniTableKey(12L))); - assertTrue(keys.contains(new VniTableKey(14L))); - assertTrue(keys.contains(new VniTableKey(16L))); - } - - @Test - public void testReadAllFailed() { - whenLispEidTableVniDumpThrowException(); - try { - getCustomizer().getAllIds(validId, ctx); - } catch (ReadFailedException e) { - assertTrue(e.getCause() instanceof VppCallbackException); - return; - } - - fail("Test should have thrown ReadFailedException"); - } - - @Test - public void testReadAttributes() throws ReadFailedException { - whenLispEidTableVniDumpReturnValid(); - VniTableBuilder builder = new VniTableBuilder(); - - customizer.readCurrentAttributes(validId, builder, ctx); - - final VniTable table = builder.build(); - assertNotNull(table); - assertEquals(12L, table.getVirtualNetworkIdentifier().longValue()); - } - - private void whenLispEidTableVniDumpReturnValid() { - - LispEidTableVniDetailsReplyDump dump = new LispEidTableVniDetailsReplyDump(); - LispEidTableVniDetails details1 = new LispEidTableVniDetails(); - details1.vni = 14; - - LispEidTableVniDetails details2 = new LispEidTableVniDetails(); - details2.vni = 12; - - LispEidTableVniDetails details3 = new LispEidTableVniDetails(); - details3.vni = 16; - - dump.lispEidTableVniDetails = ImmutableList.of(details1, details2, details3); - - when(api.lispEidTableVniDump(Mockito.any())).thenReturn(CompletableFuture.completedFuture(dump)); - } - - private void whenLispEidTableVniDumpThrowException() { - when(api.lispEidTableVniDump(Mockito.any())) - .thenReturn(failedFuture()); - } - - @Override - protected ReaderCustomizer<VniTable, VniTableBuilder> initCustomizer() { - return new VniTableCustomizer(api); - } -}
\ No newline at end of file diff --git a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/VrfSubtableCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/VrfSubtableCustomizerTest.java deleted file mode 100644 index 58965edc6..000000000 --- a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/VrfSubtableCustomizerTest.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (c) 2016 Cisco and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.fd.honeycomb.lisp.translate.read; - - -import static io.fd.honeycomb.lisp.translate.read.dump.executor.params.SubtableDumpParams.MapLevel.L3; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import io.fd.honeycomb.lisp.translate.read.trait.SubtableReaderTestCase; -import io.fd.honeycomb.translate.read.ReadFailedException; -import io.fd.honeycomb.translate.spi.read.ReaderCustomizer; -import io.fd.vpp.jvpp.VppCallbackException; -import org.junit.Before; -import org.junit.Test; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.eid.table.grouping.EidTable; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.eid.table.grouping.eid.table.VniTable; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.eid.table.grouping.eid.table.VniTableBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.eid.table.grouping.eid.table.VniTableKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.eid.table.grouping.eid.table.vni.table.VrfSubtable; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.eid.table.grouping.eid.table.vni.table.VrfSubtableBuilder; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - -public class VrfSubtableCustomizerTest extends SubtableReaderTestCase<VrfSubtable, VrfSubtableBuilder> { - - private InstanceIdentifier<VrfSubtable> validId; - - public VrfSubtableCustomizerTest() { - super(VrfSubtable.class, VrfSubtableBuilder.class); - } - - @Before - public void init() { - validId = InstanceIdentifier.create(EidTable.class).child(VniTable.class, new VniTableKey(expectedVni)) - .child(VrfSubtable.class); - } - - @Test - public void testReadCurrentSuccessfull() throws ReadFailedException { - doReturnValidNonEmptyDataOnDump(); - VrfSubtableBuilder builder = new VrfSubtableBuilder(); - customizer.readCurrentAttributes(validId, builder, ctx); - - verifyLispEidTableMapDumpCalled(L3); - - final VrfSubtable subtable = builder.build(); - assertNotNull(subtable); - assertEquals(expectedTableId, subtable.getTableId().longValue()); - } - - @Test - public void testReadCurrentEmptyDump() throws ReadFailedException { - doReturnEmptyDataOnDump(); - VrfSubtableBuilder builder = new VrfSubtableBuilder(); - customizer.readCurrentAttributes(validId, builder, ctx); - - verifyLispEidTableMapDumpCalled(L3); - - final VrfSubtable subtable = builder.build(); - assertNotNull(subtable); - assertNull(subtable.getTableId()); - } - - @Test - public void testReadCurrentFailed() { - doThrowOnDump(); - VrfSubtableBuilder builder = new VrfSubtableBuilder(); - try { - customizer.readCurrentAttributes(validId, builder, ctx); - } catch (ReadFailedException e) { - assertTrue(e.getCause() instanceof VppCallbackException); - assertTrue(builder.getTableId() == null); - verifyLispEidTableMapDumpNotCalled(); - - return; - } - - fail("Test should throw ReadFailedException"); - } - - @Override - protected ReaderCustomizer<VrfSubtable, VrfSubtableBuilder> initCustomizer() { - return new VrfSubtableCustomizer(api); - } - - @Test - public void testGetBuilder() { - final VrfSubtableBuilder builder = customizer.getBuilder(validId); - - assertNotNull(builder); - assertNull(builder.getLocalMappings()); - assertNull(builder.getRemoteMappings()); - assertNull(builder.getTableId()); - } - - @Test - public void testMerge() { - VniTableBuilder parentBuilder = new VniTableBuilder(); - VrfSubtable subtable = new VrfSubtableBuilder().build(); - - customizer.merge(parentBuilder, subtable); - assertEquals(subtable, parentBuilder.getVrfSubtable()); - } -} diff --git a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/trait/MappingProducerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/trait/MappingProducerTest.java deleted file mode 100644 index 313f27dad..000000000 --- a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/trait/MappingProducerTest.java +++ /dev/null @@ -1,186 +0,0 @@ -/* - * Copyright (c) 2016 Cisco and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.fd.honeycomb.lisp.translate.read.trait; - - -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import io.fd.honeycomb.translate.write.WriteFailedException; -import org.junit.Before; -import org.junit.Test; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.Ipv4Afi; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.Ipv6Afi; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.MacAfi; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.dp.subtable.grouping.LocalMappings; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.dp.subtable.grouping.RemoteMappings; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.dp.subtable.grouping.local.mappings.LocalMapping; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.dp.subtable.grouping.local.mappings.LocalMappingBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.dp.subtable.grouping.local.mappings.local.mapping.EidBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.dp.subtable.grouping.remote.mappings.RemoteMapping; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.dp.subtable.grouping.remote.mappings.RemoteMappingBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.eid.table.grouping.eid.table.vni.table.BridgeDomainSubtable; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.eid.table.grouping.eid.table.vni.table.VrfSubtable; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - -public class MappingProducerTest implements MappingProducer { - - private InstanceIdentifier<LocalMapping> validVrfLocalMappingId; - private InstanceIdentifier<LocalMapping> validBridgeDomainLocalMappingId; - private InstanceIdentifier<RemoteMapping> validVrfRemoteMappingId; - private InstanceIdentifier<RemoteMapping> validBridgeDomainRemoteMappingId; - - private LocalMapping ipv4LocalMapping; - private LocalMapping ipv6LocalMapping; - private LocalMapping macLocalMapping; - - private RemoteMapping ipv4RemoteMapping; - private RemoteMapping ipv6RemoteMapping; - private RemoteMapping macRemoteMapping; - - @Before - public void init() { - validVrfLocalMappingId = InstanceIdentifier.create(VrfSubtable.class) - .child(LocalMappings.class) - .child(LocalMapping.class); - - validBridgeDomainLocalMappingId = InstanceIdentifier.create(BridgeDomainSubtable.class) - .child(LocalMappings.class) - .child(LocalMapping.class); - - validVrfRemoteMappingId = InstanceIdentifier.create(VrfSubtable.class) - .child(RemoteMappings.class) - .child(RemoteMapping.class); - - validBridgeDomainRemoteMappingId = InstanceIdentifier.create(BridgeDomainSubtable.class) - .child(RemoteMappings.class) - .child(RemoteMapping.class); - - ipv4LocalMapping = new LocalMappingBuilder() - .setEid(new EidBuilder() - .setAddressType(Ipv4Afi.class) - .build()).build(); - - ipv6LocalMapping = new LocalMappingBuilder() - .setEid(new EidBuilder() - .setAddressType(Ipv6Afi.class) - .build()).build(); - macLocalMapping = new LocalMappingBuilder() - .setEid(new EidBuilder() - .setAddressType(MacAfi.class) - .build()).build(); - - ipv4RemoteMapping = new RemoteMappingBuilder() - .setEid(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.dp.subtable.grouping.remote.mappings.remote.mapping.EidBuilder() - .setAddressType(Ipv4Afi.class).build()).build(); - - ipv6RemoteMapping = new RemoteMappingBuilder() - .setEid(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.dp.subtable.grouping.remote.mappings.remote.mapping.EidBuilder() - .setAddressType(Ipv6Afi.class).build()).build(); - - macRemoteMapping = new RemoteMappingBuilder() - .setEid(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.dp.subtable.grouping.remote.mappings.remote.mapping.EidBuilder() - .setAddressType(MacAfi.class).build()).build(); - } - - @Test - public void testValidVrfLocal() { - testPositiveCase(validVrfLocalMappingId, ipv4LocalMapping); - testPositiveCase(validVrfLocalMappingId, ipv6LocalMapping); - } - - @Test - public void testValidBridgeDomainLocal() { - testPositiveCase(validBridgeDomainLocalMappingId, macLocalMapping); - } - - @Test - public void testInvalidVrfLocal() { - testNegativeCase(validVrfLocalMappingId, macLocalMapping); - } - - @Test - public void testInvalidBridgeDomainLocal() { - testNegativeCase(validBridgeDomainLocalMappingId, ipv4LocalMapping); - testNegativeCase(validBridgeDomainLocalMappingId, ipv6LocalMapping); - } - - - @Test - public void testValidVrfRemote() { - testPositiveCase(validVrfRemoteMappingId, ipv4RemoteMapping); - testPositiveCase(validVrfRemoteMappingId, ipv6RemoteMapping); - } - - @Test - public void testValidBridgeDomainRemote() { - testPositiveCase(validBridgeDomainRemoteMappingId, macRemoteMapping); - } - - @Test - public void testInvalidVrfRemote() { - testNegativeCase(validVrfRemoteMappingId, macRemoteMapping); - } - - @Test - public void testInvalidBridgeDomainRemote() { - testNegativeCase(validBridgeDomainRemoteMappingId, ipv4RemoteMapping); - testNegativeCase(validBridgeDomainRemoteMappingId, ipv6RemoteMapping); - } - - private void testNegativeCase(final InstanceIdentifier<LocalMapping> identifier, final LocalMapping data) { - try { - checkAllowedCombination(identifier, data); - } catch (WriteFailedException e) { - assertTrue(e instanceof WriteFailedException.CreateFailedException); - assertTrue(e.getCause() instanceof IllegalArgumentException); - return; - } - - fail("Test should have failed"); - } - - - private void testPositiveCase(final InstanceIdentifier<LocalMapping> identifier, final LocalMapping data) { - try { - checkAllowedCombination(identifier, data); - } catch (WriteFailedException e) { - fail("Test should have passed"); - } - } - - private void testNegativeCase(final InstanceIdentifier<RemoteMapping> identifier, final RemoteMapping data) { - try { - checkAllowedCombination(identifier, data); - } catch (WriteFailedException e) { - assertTrue(e instanceof WriteFailedException.CreateFailedException); - assertTrue(e.getCause() instanceof IllegalArgumentException); - return; - } - - fail("Test should have failed"); - } - - - private void testPositiveCase(final InstanceIdentifier<RemoteMapping> identifier, final RemoteMapping data) { - try { - checkAllowedCombination(identifier, data); - } catch (WriteFailedException e) { - fail("Test should have passed"); - } - } -} diff --git a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/trait/MappingReaderTest.java b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/trait/MappingReaderTest.java deleted file mode 100644 index 9366037a1..000000000 --- a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/trait/MappingReaderTest.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 2016 Cisco and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.fd.honeycomb.lisp.translate.read.trait; - - -import static org.junit.Assert.assertEquals; - -import org.junit.Before; -import org.junit.Test; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.dp.subtable.grouping.LocalMappings; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.dp.subtable.grouping.RemoteMappings; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.dp.subtable.grouping.local.mappings.LocalMapping; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.dp.subtable.grouping.remote.mappings.RemoteMapping; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.eid.table.grouping.eid.table.vni.table.BridgeDomainSubtable; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.eid.table.grouping.eid.table.vni.table.VrfSubtable; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - -public class MappingReaderTest implements MappingReader { - - private InstanceIdentifier<LocalMapping> validVrfLocal; - private InstanceIdentifier<LocalMapping> validBdLocal; - private InstanceIdentifier<LocalMapping> invalidLocal; - - private InstanceIdentifier<RemoteMapping> validVrfRemote; - private InstanceIdentifier<RemoteMapping> validBdRemote; - private InstanceIdentifier<RemoteMapping> invalidRemote; - - - @Before - public void init() { - validVrfLocal = InstanceIdentifier.create(VrfSubtable.class) - .child(LocalMappings.class) - .child(LocalMapping.class); - - validBdLocal = InstanceIdentifier.create(BridgeDomainSubtable.class) - .child(LocalMappings.class) - .child(LocalMapping.class); - - invalidLocal = InstanceIdentifier.create(LocalMapping.class); - - validVrfRemote = InstanceIdentifier.create(VrfSubtable.class) - .child(RemoteMappings.class) - .child(RemoteMapping.class); - - validBdRemote = InstanceIdentifier.create(BridgeDomainSubtable.class) - .child(RemoteMappings.class) - .child(RemoteMapping.class); - - invalidRemote = InstanceIdentifier.create(RemoteMapping.class); - } - - @Test - public void testVrfLocalValid() { - assertEquals(VRF_MAPPINGS_ONLY, subtableFilterForLocalMappings(validVrfLocal)); - } - - @Test - public void testBridgeDomainLocalValid() { - assertEquals(BRIDGE_DOMAIN_MAPPINGS_ONLY, subtableFilterForLocalMappings(validBdLocal)); - } - - @Test(expected = IllegalArgumentException.class) - public void testLocalInvalid() { - subtableFilterForLocalMappings(invalidLocal); - } - - @Test - public void testVrfRemoteValid() { - assertEquals(VRF_MAPPINGS_ONLY, subtableFilterForRemoteMappings(validVrfRemote)); - } - - @Test - public void testBridgeDomainRemoteValid() { - assertEquals(BRIDGE_DOMAIN_MAPPINGS_ONLY, subtableFilterForRemoteMappings(validBdRemote)); - } - - @Test(expected = IllegalArgumentException.class) - public void testRemoteInvalid() { - subtableFilterForRemoteMappings(invalidRemote); - } -}
\ No newline at end of file diff --git a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/trait/SubtableReaderTestCase.java b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/trait/SubtableReaderTestCase.java deleted file mode 100644 index 3313395df..000000000 --- a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/trait/SubtableReaderTestCase.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2016 Cisco and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.fd.honeycomb.lisp.translate.read.trait; - - -import static io.fd.honeycomb.lisp.translate.read.dump.executor.params.SubtableDumpParams.MapLevel; -import static org.junit.Assert.assertEquals; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; -import static org.mockito.MockitoAnnotations.initMocks; - -import com.google.common.collect.ImmutableList; -import io.fd.honeycomb.vpp.test.read.ReaderCustomizerTest; -import io.fd.vpp.jvpp.VppCallbackException; -import io.fd.vpp.jvpp.core.dto.LispEidTableMapDetails; -import io.fd.vpp.jvpp.core.dto.LispEidTableMapDetailsReplyDump; -import io.fd.vpp.jvpp.core.dto.LispEidTableMapDump; -import java.util.Collections; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; -import javax.annotation.Nonnull; -import org.junit.Before; -import org.mockito.ArgumentCaptor; -import org.mockito.Captor; -import org.opendaylight.yangtools.concepts.Builder; -import org.opendaylight.yangtools.yang.binding.DataObject; - -public abstract class SubtableReaderTestCase<D extends DataObject, B extends Builder<D>> - extends ReaderCustomizerTest<D, B> - implements SubtableReader { - - protected final long expectedVni = 12; - protected final int expectedTableId = 14; - - @Captor - protected ArgumentCaptor<LispEidTableMapDump> requestCaptor; - - public SubtableReaderTestCase(final Class<D> dataObjectClass, - final Class<? extends Builder<? extends DataObject>> parentBuilderClass) { - super(dataObjectClass, parentBuilderClass); - } - - protected void doReturnValidNonEmptyDataOnDump() { - LispEidTableMapDetailsReplyDump reply = new LispEidTableMapDetailsReplyDump(); - LispEidTableMapDetails detailFirst = new LispEidTableMapDetails(); - detailFirst.vni = Long.valueOf(expectedVni).intValue(); - detailFirst.dpTable = expectedTableId; - - LispEidTableMapDetails detailSecond = new LispEidTableMapDetails(); - detailSecond.vni = 13; - detailSecond.dpTable = 15; - - reply.lispEidTableMapDetails = ImmutableList.of(detailFirst, detailSecond); - - when(api.lispEidTableMapDump(any(LispEidTableMapDump.class))) - .thenReturn(future(reply)); - } - - protected void doReturnEmptyDataOnDump() { - LispEidTableMapDetailsReplyDump reply = new LispEidTableMapDetailsReplyDump(); - reply.lispEidTableMapDetails = Collections.emptyList(); - when(api.lispEidTableMapDump(any(LispEidTableMapDump.class))) - .thenReturn(future(reply)); - } - - protected void doThrowOnDump() { - when(api.lispEidTableMapDump(any(LispEidTableMapDump.class))) - .thenReturn(failedFuture()); - } - - protected void verifyLispEidTableMapDumpCalled(@Nonnull final MapLevel expectedLevel) { - verify(api, times(1)).lispEidTableMapDump(requestCaptor.capture()); - assertEquals(expectedLevel.getValue(), requestCaptor.getValue().isL2); - } - - protected void verifyLispEidTableMapDumpNotCalled() { - verify(api, times(1)).lispEidTableMapDump(any()); - } -} |