summaryrefslogtreecommitdiffstats
path: root/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate')
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/AdjacencyData.java59
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/AdjacencyCustomizerTest.java145
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/BridgeDomainSubtableCustomizerTest.java118
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/InterfaceCustomizerTest.java118
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/ItrRemoteLocatorSetCustomizerTest.java164
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/LispStateCustomizerTest.java68
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/LocalMappingCustomizerTest.java143
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/LocatorSetCustomizerTest.java96
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/MapResolverCustomizerTest.java102
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/PitrCfgCustomizerTest.java77
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/RemoteMappingCustomizerTest.java241
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/VniTableCustomizerTest.java121
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/VrfSubtableCustomizerTest.java121
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/trait/MappingProducerTest.java186
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/trait/MappingReaderTest.java95
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/trait/SubtableReaderTestCase.java97
-rwxr-xr-xlisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/util/EidTranslatorTest.java60
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/AdjacencyCustomizerTest.java243
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/BridgeDomainCustomizerTest.java108
-rwxr-xr-xlisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/InterfaceCustomizerTest.java160
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/ItrRemoteLocatorSetCustomizerTest.java146
-rwxr-xr-xlisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/LispCustomizerTest.java111
-rwxr-xr-xlisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/LocalMappingCustomizerTest.java163
-rwxr-xr-xlisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/LocatorSetCustomizerTest.java148
-rwxr-xr-xlisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/MapResolverCustomizerTest.java103
-rwxr-xr-xlisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/PitrCfgCustomizerTest.java117
-rwxr-xr-xlisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/RemoteMappingCustomizerTest.java155
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/VniTableCustomizerTest.java103
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/VrfSubtableCustomizerTest.java105
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/trait/SubtableWriterTestCase.java59
30 files changed, 3732 insertions, 0 deletions
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/AdjacencyData.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/AdjacencyData.java
new file mode 100644
index 000000000..cc3581ae4
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/AdjacencyData.java
@@ -0,0 +1,59 @@
+/*
+ * 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.hc2vpp.lisp.translate;
+
+import org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.eid.mapping.context.rev160801.contexts.eid.mapping.context.mappings.mapping.Eid;
+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.InstanceIdType;
+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.lisp.address.address.Ipv4Builder;
+
+public class AdjacencyData {
+
+ public static final Long VNI = 12L;
+
+ public static final Ipv4Address ADDRESS_ONE = new Ipv4Address("192.168.2.1");
+ public static final Ipv4Address ADDRESS_TWO = new Ipv4Address("192.168.2.2");
+ public static final Ipv4Address ADDRESS_THREE = new Ipv4Address("192.168.2.3");
+ public static final Ipv4Address ADDRESS_FOUR = new Ipv4Address("192.168.2.4");
+
+ public static final Eid LOCAL_EID_ONE = new EidBuilder()
+ .setAddressType(Ipv4Afi.class)
+ .setVirtualNetworkId(new InstanceIdType(VNI))
+ .setAddress(new Ipv4Builder().setIpv4(ADDRESS_ONE).build())
+ .build();
+
+ public static final Eid LOCAL_EID_TWO = new EidBuilder()
+ .setAddressType(Ipv4Afi.class)
+ .setVirtualNetworkId(new InstanceIdType(VNI))
+ .setAddress(new Ipv4Builder().setIpv4(ADDRESS_TWO).build())
+ .build();
+
+ public static final Eid REMOTE_EID_ONE = new EidBuilder()
+ .setAddressType(Ipv4Afi.class)
+ .setVirtualNetworkId(new InstanceIdType(VNI))
+ .setAddress(new Ipv4Builder().setIpv4(ADDRESS_THREE).build())
+ .build();
+ public static final Eid REMOTE_EID_TWO = new EidBuilder()
+ .setAddressType(Ipv4Afi.class)
+ .setVirtualNetworkId(new InstanceIdType(VNI))
+ .setAddress(new Ipv4Builder().setIpv4(ADDRESS_FOUR).build())
+ .build();
+
+
+}
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/AdjacencyCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/AdjacencyCustomizerTest.java
new file mode 100644
index 000000000..034d81857
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/AdjacencyCustomizerTest.java
@@ -0,0 +1,145 @@
+/*
+ * 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.hc2vpp.lisp.translate.read;
+
+import static io.fd.hc2vpp.lisp.translate.AdjacencyData.ADDRESS_ONE;
+import static io.fd.hc2vpp.lisp.translate.AdjacencyData.ADDRESS_THREE;
+import static io.fd.hc2vpp.lisp.translate.AdjacencyData.LOCAL_EID_ONE;
+import static io.fd.hc2vpp.lisp.translate.AdjacencyData.LOCAL_EID_TWO;
+import static io.fd.hc2vpp.lisp.translate.AdjacencyData.REMOTE_EID_ONE;
+import static io.fd.hc2vpp.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.hc2vpp.lisp.context.util.AdjacenciesMappingContext;
+import io.fd.hc2vpp.lisp.context.util.EidMappingContext;
+import io.fd.hc2vpp.lisp.translate.util.EidMetadataProvider;
+import io.fd.hc2vpp.lisp.util.AdjacencyMappingContextTestHelper;
+import io.fd.hc2vpp.lisp.util.EidMappingContextHelper;
+import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
+import io.fd.hc2vpp.common.translate.util.ByteDataTranslator;
+import io.fd.hc2vpp.common.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/hc2vpp/lisp/translate/read/BridgeDomainSubtableCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/BridgeDomainSubtableCustomizerTest.java
new file mode 100644
index 000000000..cd365286b
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/BridgeDomainSubtableCustomizerTest.java
@@ -0,0 +1,118 @@
+/*
+ * 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.hc2vpp.lisp.translate.read;
+
+
+import static io.fd.hc2vpp.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.hc2vpp.lisp.translate.read.trait.SubtableReaderTestCase;
+import io.fd.honeycomb.translate.read.ReadFailedException;
+import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
+import io.fd.hc2vpp.common.translate.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/hc2vpp/lisp/translate/read/InterfaceCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/InterfaceCustomizerTest.java
new file mode 100644
index 000000000..48f0d067c
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/InterfaceCustomizerTest.java
@@ -0,0 +1,118 @@
+/*
+ * 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.hc2vpp.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.hc2vpp.common.translate.util.NamingContext;
+import io.fd.hc2vpp.common.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/hc2vpp/lisp/translate/read/ItrRemoteLocatorSetCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/ItrRemoteLocatorSetCustomizerTest.java
new file mode 100644
index 000000000..acd72ce5b
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/ItrRemoteLocatorSetCustomizerTest.java
@@ -0,0 +1,164 @@
+/*
+ * 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.hc2vpp.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.hc2vpp.common.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/hc2vpp/lisp/translate/read/LispStateCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/LispStateCustomizerTest.java
new file mode 100644
index 000000000..e00d50977
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/LispStateCustomizerTest.java
@@ -0,0 +1,68 @@
+/*
+ * 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.hc2vpp.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.hc2vpp.common.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/hc2vpp/lisp/translate/read/LocalMappingCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/LocalMappingCustomizerTest.java
new file mode 100644
index 000000000..5be983716
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/LocalMappingCustomizerTest.java
@@ -0,0 +1,143 @@
+/*
+ * 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.hc2vpp.lisp.translate.read;
+
+import static io.fd.hc2vpp.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.hc2vpp.lisp.context.util.EidMappingContext;
+import io.fd.hc2vpp.lisp.translate.util.EidTranslator;
+import io.fd.honeycomb.translate.MappingContext;
+import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
+import io.fd.hc2vpp.common.translate.util.NamingContext;
+import io.fd.hc2vpp.common.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/hc2vpp/lisp/translate/read/LocatorSetCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/LocatorSetCustomizerTest.java
new file mode 100644
index 000000000..9c88b293c
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/LocatorSetCustomizerTest.java
@@ -0,0 +1,96 @@
+/*
+ * 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.hc2vpp.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.hc2vpp.common.translate.util.NamingContext;
+import io.fd.hc2vpp.common.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/hc2vpp/lisp/translate/read/MapResolverCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/MapResolverCustomizerTest.java
new file mode 100644
index 000000000..e533f88d8
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/MapResolverCustomizerTest.java
@@ -0,0 +1,102 @@
+/*
+ * 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.hc2vpp.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.hc2vpp.common.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/hc2vpp/lisp/translate/read/PitrCfgCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/PitrCfgCustomizerTest.java
new file mode 100644
index 000000000..77410f1fd
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/PitrCfgCustomizerTest.java
@@ -0,0 +1,77 @@
+/*
+ * 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.hc2vpp.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.hc2vpp.common.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/hc2vpp/lisp/translate/read/RemoteMappingCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/RemoteMappingCustomizerTest.java
new file mode 100644
index 000000000..5ffc77005
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/RemoteMappingCustomizerTest.java
@@ -0,0 +1,241 @@
+/*
+ * 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.hc2vpp.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.hc2vpp.lisp.context.util.EidMappingContext;
+import io.fd.hc2vpp.lisp.translate.util.EidTranslator;
+import io.fd.honeycomb.translate.MappingContext;
+import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
+import io.fd.hc2vpp.common.translate.util.NamingContext;
+import io.fd.hc2vpp.common.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/hc2vpp/lisp/translate/read/VniTableCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/VniTableCustomizerTest.java
new file mode 100644
index 000000000..7da43579c
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/VniTableCustomizerTest.java
@@ -0,0 +1,121 @@
+/*
+ * 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.hc2vpp.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.hc2vpp.common.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/hc2vpp/lisp/translate/read/VrfSubtableCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/VrfSubtableCustomizerTest.java
new file mode 100644
index 000000000..5757f02eb
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/VrfSubtableCustomizerTest.java
@@ -0,0 +1,121 @@
+/*
+ * 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.hc2vpp.lisp.translate.read;
+
+
+import static io.fd.hc2vpp.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.hc2vpp.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/hc2vpp/lisp/translate/read/trait/MappingProducerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/trait/MappingProducerTest.java
new file mode 100644
index 000000000..a09f7b874
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/trait/MappingProducerTest.java
@@ -0,0 +1,186 @@
+/*
+ * 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.hc2vpp.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/hc2vpp/lisp/translate/read/trait/MappingReaderTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/trait/MappingReaderTest.java
new file mode 100644
index 000000000..7945a5b8c
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/trait/MappingReaderTest.java
@@ -0,0 +1,95 @@
+/*
+ * 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.hc2vpp.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/hc2vpp/lisp/translate/read/trait/SubtableReaderTestCase.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/trait/SubtableReaderTestCase.java
new file mode 100644
index 000000000..21ac52257
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/trait/SubtableReaderTestCase.java
@@ -0,0 +1,97 @@
+/*
+ * 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.hc2vpp.lisp.translate.read.trait;
+
+
+import static io.fd.hc2vpp.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.hc2vpp.common.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());
+ }
+}
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/util/EidTranslatorTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/util/EidTranslatorTest.java
new file mode 100755
index 000000000..c2fc51b5a
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/util/EidTranslatorTest.java
@@ -0,0 +1,60 @@
+/*
+ * 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.hc2vpp.lisp.translate.util;
+
+import static io.fd.hc2vpp.lisp.translate.read.dump.executor.params.MappingsDumpParams.EidType.IPV4;
+import static io.fd.hc2vpp.lisp.translate.read.dump.executor.params.MappingsDumpParams.EidType.IPV6;
+import static io.fd.hc2vpp.lisp.translate.read.dump.executor.params.MappingsDumpParams.EidType.MAC;
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+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.inet.types.rev130715.Ipv6Address;
+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.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv6Builder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.MacBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
+
+public class EidTranslatorTest implements EidTranslator {
+
+ @Test
+ public void testGetEidType() {
+ assertEquals(IPV4, getEidType(
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.dp.subtable.grouping.remote.mappings.remote.mapping.EidBuilder()
+ .setAddress(
+ new Ipv4Builder().setIpv4(
+ new Ipv4Address("192.168.2.1"))
+ .build())
+ .build()));
+
+ assertEquals(IPV6, getEidType(
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.dp.subtable.grouping.remote.mappings.remote.mapping.EidBuilder()
+ .setAddress(
+ new Ipv6Builder().setIpv6(
+ new Ipv6Address("2001:0db8:0a0b:12f0:0000:0000:0000:0001"))
+ .build())
+ .build()));
+
+ assertEquals(MAC, getEidType(
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.dp.subtable.grouping.remote.mappings.remote.mapping.EidBuilder()
+ .setAddress(
+ new MacBuilder().setMac(
+ new MacAddress("aa:bb:cc:dd:ee:ff"))
+ .build())
+ .build()));
+ }
+}
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/AdjacencyCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/AdjacencyCustomizerTest.java
new file mode 100644
index 000000000..f263e78c9
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/AdjacencyCustomizerTest.java
@@ -0,0 +1,243 @@
+/*
+ * 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.hc2vpp.lisp.translate.write;
+
+import static io.fd.hc2vpp.lisp.translate.AdjacencyData.ADDRESS_ONE;
+import static io.fd.hc2vpp.lisp.translate.AdjacencyData.ADDRESS_THREE;
+import static io.fd.hc2vpp.lisp.translate.AdjacencyData.LOCAL_EID_ONE;
+import static io.fd.hc2vpp.lisp.translate.AdjacencyData.REMOTE_EID_ONE;
+import static io.fd.hc2vpp.lisp.translate.read.dump.executor.params.MappingsDumpParams.EidType.IPV4;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+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.hc2vpp.lisp.context.util.AdjacenciesMappingContext;
+import io.fd.hc2vpp.lisp.context.util.EidMappingContext;
+import io.fd.hc2vpp.lisp.util.EidMappingContextHelper;
+import io.fd.hc2vpp.common.test.write.WriterCustomizerTest;
+import io.fd.vpp.jvpp.core.dto.LispAddDelAdjacency;
+import io.fd.vpp.jvpp.core.dto.LispAddDelAdjacencyReply;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Captor;
+import org.mockito.Mock;
+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.InstanceIdType;
+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.MacAfi;
+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.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.MacBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
+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.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.adjacencies.grouping.adjacencies.adjacency.LocalEidBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.adjacencies.grouping.adjacencies.adjacency.RemoteEidBuilder;
+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 WriterCustomizerTest implements EidMappingContextHelper {
+
+ @Captor
+ private ArgumentCaptor<LispAddDelAdjacency> requestCaptor;
+
+ private EidMappingContext localMappingContext;
+
+ private EidMappingContext remoteMappingContext;
+
+ @Mock
+ private AdjacenciesMappingContext adjacenciesMappingContext;
+
+ private AdjacencyCustomizer customizer;
+
+ private InstanceIdentifier<Adjacency> emptyId;
+ private InstanceIdentifier<Adjacency> validId;
+
+ private Adjacency emptyData;
+ private Adjacency invalidData;
+ private Adjacency validData;
+
+ @Before
+ public void init() {
+ localMappingContext = new EidMappingContext("local-mapping-context");
+ remoteMappingContext = new EidMappingContext("remote-mapping-context");
+ customizer = new AdjacencyCustomizer(api, localMappingContext, remoteMappingContext, adjacenciesMappingContext);
+
+ emptyId = InstanceIdentifier.create(Adjacency.class);
+ validId = 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"));
+
+ emptyData = new AdjacencyBuilder().build();
+
+ invalidData = new AdjacencyBuilder().setId("ID").setLocalEid(
+ new LocalEidBuilder()
+ .setVirtualNetworkId(new InstanceIdType(12L))
+ .setAddressType(Ipv4Afi.class)
+ .setAddress(new Ipv4Builder().setIpv4(new Ipv4Address("192.168.2.1")).build())
+ .build()).setRemoteEid(
+ new RemoteEidBuilder()
+ .setVirtualNetworkId(new InstanceIdType(12L))
+ .setAddressType(MacAfi.class)
+ .setAddress(new MacBuilder().setMac(new MacAddress("aa:aa:aa:aa:aa:aa")).build())
+ .build())
+ .build();
+
+ validData = new AdjacencyBuilder().setId("ID").setLocalEid(
+ new LocalEidBuilder()
+ .setVirtualNetworkId(new InstanceIdType(12L))
+ .setAddressType(Ipv4Afi.class)
+ .setAddress(new Ipv4Builder().setIpv4(ADDRESS_ONE).build())
+ .build()).setRemoteEid(
+ new RemoteEidBuilder()
+ .setVirtualNetworkId(new InstanceIdType(12L))
+ .setAddressType(Ipv4Afi.class)
+ .setAddress(new Ipv4Builder().setIpv4(ADDRESS_THREE).build()).build()).build();
+
+ when(api.lispAddDelAdjacency(any())).thenReturn(future(new LispAddDelAdjacencyReply()));
+ }
+
+ @Test
+ public void writeCurrentAttributesNoKey() throws Exception {
+ try {
+ customizer.writeCurrentAttributes(emptyId, emptyData, writeContext);
+ } catch (NullPointerException e) {
+ verify(api, times(0)).lispAddDelAdjacency(any());
+ return;
+ }
+
+ fail("Test should have failed while reading parent vni table id");
+ }
+
+ @Test
+ public void writeCurrentAttributesInvalidCombination() throws Exception {
+ try {
+ customizer.writeCurrentAttributes(emptyId, invalidData, writeContext);
+ } catch (NullPointerException e) {
+ verify(api, times(0)).lispAddDelAdjacency(any());
+ return;
+ }
+
+ fail("Test should have failed while reading parent vni table id");
+ }
+
+
+ @Test
+ public void writeCurrentAttributes() throws Exception {
+ defineEidMapping(mappingContext, LOCAL_EID_ONE, new MappingId("local-eid-one"), "local-mapping-context");
+ defineEidMapping(mappingContext, REMOTE_EID_ONE, new MappingId("remote-eid-one"), "remote-mapping-context");
+ customizer.writeCurrentAttributes(validId, validData, writeContext);
+ verify(api, times(1)).lispAddDelAdjacency(requestCaptor.capture());
+ verifyRequest(requestCaptor.getValue(), 1, new byte[]{-64, -88, 2, 1}, 32, new byte[]{-64, -88, 2, 3},
+ 32, IPV4.getValue(), 2);
+ verify(adjacenciesMappingContext, times(1))
+ .addEidPair("adj-one", "local-eid-one", "remote-eid-one", mappingContext);
+ }
+
+ @Test
+ public void writeCurrentAttributesNonExistingLocalMapping() throws Exception {
+ noEidMappingDefined(mappingContext, "local-eid-one", "local-mapping-context");
+ defineEidMapping(mappingContext, REMOTE_EID_ONE, new MappingId("remote-eid-one"), "remote-mapping-context");
+ try {
+ customizer.writeCurrentAttributes(validId, validData, writeContext);
+ } catch (IllegalStateException e) {
+ verify(api, times(0)).lispAddDelAdjacency(any());
+ return;
+ }
+
+ fail("Test should have failed while verifying local eid");
+ }
+
+ @Test
+ public void writeCurrentAttributesNonExistingRemoteMapping() throws Exception {
+ noEidMappingDefined(mappingContext, "remote-eid-one", "remote-mapping-context");
+ defineEidMapping(mappingContext, LOCAL_EID_ONE, new MappingId("local-eid-one"), "local-mapping-context");
+
+ try {
+ customizer.writeCurrentAttributes(validId, validData, writeContext);
+ } catch (IllegalStateException e) {
+ verify(api, times(0)).lispAddDelAdjacency(any());
+ return;
+ }
+
+ fail("Test should have failed while verifying remote eid");
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void updateCurrentAttributes() throws Exception {
+ customizer.updateCurrentAttributes(emptyId, emptyData, emptyData, writeContext);
+ }
+
+ @Test
+ public void deleteCurrentAttributesNoKey() throws Exception {
+ try {
+ customizer.deleteCurrentAttributes(emptyId, emptyData, writeContext);
+ } catch (NullPointerException e) {
+ verify(api, times(0)).lispAddDelAdjacency(any());
+ return;
+ }
+
+ fail("Test should have failed while reading parent vni table id");
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void deleteCurrentAttributesInvalidCombination() throws Exception {
+ customizer.deleteCurrentAttributes(validId, invalidData, writeContext);
+ }
+
+ @Test
+ public void deleteCurrentAttributes() throws Exception {
+ customizer.deleteCurrentAttributes(validId, validData, writeContext);
+ verify(api, times(1)).lispAddDelAdjacency(requestCaptor.capture());
+ verifyRequest(requestCaptor.getValue(), 0, new byte[]{-64, -88, 2, 1}, 32, new byte[]{-64, -88, 2, 3},
+ 32, IPV4.getValue(), 2);
+ verify(adjacenciesMappingContext, times(1)).removeForIndex("adj-one", mappingContext);
+ }
+
+ private static void verifyRequest(final LispAddDelAdjacency request, final int isAdd, final byte[] leid,
+ final int leidLen, final byte[] reid, final int reidLen, final int eidType,
+ final int vni) {
+
+ assertNotNull(request);
+ assertEquals(isAdd, request.isAdd);
+ assertArrayEquals(leid, request.leid);
+ assertEquals(leidLen, request.leidLen);
+ assertArrayEquals(reid, request.reid);
+ assertEquals(reidLen, request.reidLen);
+ assertEquals(eidType, request.eidType);
+ assertEquals(vni, request.vni);
+
+ }
+} \ No newline at end of file
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/BridgeDomainCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/BridgeDomainCustomizerTest.java
new file mode 100644
index 000000000..982858132
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/BridgeDomainCustomizerTest.java
@@ -0,0 +1,108 @@
+/*
+ * 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.hc2vpp.lisp.translate.write;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import io.fd.hc2vpp.lisp.translate.write.trait.SubtableWriterTestCase;
+import io.fd.hc2vpp.common.translate.util.NamingContext;
+import io.fd.honeycomb.translate.write.WriteFailedException;
+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.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 BridgeDomainCustomizerTest extends SubtableWriterTestCase {
+
+ private BridgeDomainSubtableCustomizer customizer;
+ private InstanceIdentifier<BridgeDomainSubtable> validId;
+ private BridgeDomainSubtable validData;
+ private NamingContext bridgeDomainContext;
+
+ @Before
+ public void init() {
+ bridgeDomainContext = new NamingContext("br", "bridge-domain-context");
+ customizer = new BridgeDomainSubtableCustomizer(api, bridgeDomainContext);
+ validId = InstanceIdentifier.create(EidTable.class).child(VniTable.class, new VniTableKey(12L))
+ .child(BridgeDomainSubtable.class);
+ validData = new BridgeDomainSubtableBuilder().setBridgeDomainRef("br-domain").build();
+ defineMapping(mappingContext, "br-domain", 10, "bridge-domain-context");
+ }
+
+ @Test
+ public void testWriteSuccessfull() throws WriteFailedException {
+ whenAddDelEidTableAddDelMapSuccess();
+ customizer.writeCurrentAttributes(validId, validData, writeContext);
+ verifyAddDelEidTableAddDelMapInvokedCorrectly(1, 12, 10, 1);
+ }
+
+ @Test
+ public void testWriteFailed() throws WriteFailedException {
+ whenAddDelEidTableAddDelMapFail();
+
+ try {
+ customizer.writeCurrentAttributes(validId, validData, writeContext);
+ } catch (Exception e) {
+ assertTrue(e instanceof WriteFailedException);
+
+ final WriteFailedException realException = ((WriteFailedException) e);
+ assertEquals(validId, realException.getFailedId());
+ assertTrue(e.getCause() instanceof VppCallbackException);
+ return;
+ }
+
+ fail("Test should throw exception");
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void testUpdate() throws WriteFailedException {
+ customizer.updateCurrentAttributes(validId, validData, validData, writeContext);
+ }
+
+ @Test
+ public void testDeleteSuccessfull() throws WriteFailedException {
+ whenAddDelEidTableAddDelMapSuccess();
+ customizer.deleteCurrentAttributes(validId, validData, writeContext);
+ verifyAddDelEidTableAddDelMapInvokedCorrectly(0, 12, 10, 1);
+ }
+
+ @Test
+ public void testDeleteFailed() {
+ whenAddDelEidTableAddDelMapFail();
+
+ try {
+ customizer.deleteCurrentAttributes(validId, validData, writeContext);
+ } catch (Exception e) {
+ assertTrue(e instanceof WriteFailedException);
+
+ final WriteFailedException realException = ((WriteFailedException) e);
+ assertEquals(validId, realException.getFailedId());
+ assertTrue(e.getCause() instanceof VppCallbackException);
+ return;
+ }
+
+ fail("Test should throw exception");
+ }
+
+}
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/InterfaceCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/InterfaceCustomizerTest.java
new file mode 100755
index 000000000..61326ffab
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/InterfaceCustomizerTest.java
@@ -0,0 +1,160 @@
+/*
+ * 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.hc2vpp.lisp.translate.write;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import io.fd.hc2vpp.common.translate.util.ByteDataTranslator;
+import io.fd.hc2vpp.common.translate.util.NamingContext;
+import io.fd.honeycomb.translate.write.WriteFailedException;
+import io.fd.hc2vpp.common.test.write.WriterCustomizerTest;
+import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Captor;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.Lisp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.lisp.feature.data.grouping.LispFeatureData;
+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.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.LispAddDelLocator;
+import io.fd.vpp.jvpp.core.dto.LispAddDelLocatorReply;
+
+public class InterfaceCustomizerTest extends WriterCustomizerTest implements ByteDataTranslator {
+
+ @Captor
+ private ArgumentCaptor<LispAddDelLocator> intfCaptor;
+
+ private InstanceIdentifier<Interface> id;
+ private Interface intf;
+ private InterfaceCustomizer customizer;
+
+ @Override
+ public void setUp() {
+ final String ifcCtxName = "INInterruptedException, ExecutionException, STANCE";
+ final String interfaceName = "Interface";
+ defineMapping(mappingContext, interfaceName, 5, ifcCtxName);
+
+ id = InstanceIdentifier.builder(Lisp.class)
+ .child(LispFeatureData.class)
+ .child(LocatorSets.class)
+ .child(LocatorSet.class, new LocatorSetKey("Locator"))
+ .child(Interface.class, new InterfaceKey(interfaceName))
+ .build();
+
+ intf = new InterfaceBuilder()
+ .setPriority((short) 1)
+ .setWeight((short) 2)
+ .build();
+
+ customizer = new InterfaceCustomizer(api, new NamingContext("PREFIX", ifcCtxName));
+
+ when(api.lispAddDelLocator(any(LispAddDelLocator.class))).thenReturn(future(new LispAddDelLocatorReply()));
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testWriteCurrentAttributesNullData() throws WriteFailedException {
+ customizer.writeCurrentAttributes(null, null, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testWriteCurrentAttributesNullPriority() throws WriteFailedException {
+ Interface intf = mock(Interface.class);
+ when(intf.getWeight()).thenReturn((short) 1);
+ when(intf.getPriority()).thenReturn(null);
+
+ customizer.writeCurrentAttributes(null, intf, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testWriteCurrentAttributesNullWeight() throws WriteFailedException {
+ Interface intf = mock(Interface.class);
+ when(intf.getWeight()).thenReturn(null);
+ when(intf.getPriority()).thenReturn((short) 1);
+
+ customizer.writeCurrentAttributes(null, intf, null);
+ }
+
+ @Test
+ public void testWriteCurrentAttributes() throws WriteFailedException {
+ customizer.writeCurrentAttributes(id, intf, writeContext);
+
+ verify(api, times(1)).lispAddDelLocator(intfCaptor.capture());
+
+ LispAddDelLocator request = intfCaptor.getValue();
+
+ assertNotNull(request);
+ assertEquals(1, request.isAdd);
+ assertEquals(2, request.weight);
+ assertEquals(1, request.priority);
+ assertEquals(5, request.swIfIndex);
+ assertEquals("Locator", toString(request.locatorSetName));
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void testUpdateCurrentAttributes() throws WriteFailedException {
+ customizer.updateCurrentAttributes(null, null, null, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testDeleteCurrentAttributesNullData() throws WriteFailedException {
+ customizer.deleteCurrentAttributes(null, null, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testDeleteCurrentAttributesNullPriority() throws WriteFailedException {
+ Interface interf = mock(Interface.class);
+ when(interf.getWeight()).thenReturn((short) 1);
+ when(interf.getPriority()).thenReturn(null);
+
+ customizer.deleteCurrentAttributes(null, interf, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testDeleteCurrentAttributesNullWeight() throws WriteFailedException {
+ Interface interf = mock(Interface.class);
+ when(interf.getWeight()).thenReturn(null);
+ when(interf.getPriority()).thenReturn((short) 1);
+
+ customizer.deleteCurrentAttributes(null, interf, null);
+ }
+
+ @Test
+ public void testDeleteCurrentAttributes() throws WriteFailedException {
+ customizer.deleteCurrentAttributes(id, intf, writeContext);
+
+ verify(api, times(1)).lispAddDelLocator(intfCaptor.capture());
+
+ LispAddDelLocator request = intfCaptor.getValue();
+
+ assertNotNull(request);
+ assertEquals(0, request.isAdd);
+ assertEquals(2, request.weight);
+ assertEquals(1, request.priority);
+ assertEquals(5, request.swIfIndex);
+ assertEquals("Locator", toString(request.locatorSetName));
+ }
+}
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/ItrRemoteLocatorSetCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/ItrRemoteLocatorSetCustomizerTest.java
new file mode 100644
index 000000000..e86b946be
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/ItrRemoteLocatorSetCustomizerTest.java
@@ -0,0 +1,146 @@
+/*
+ * 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.hc2vpp.lisp.translate.write;
+
+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.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 io.fd.hc2vpp.common.translate.util.ByteDataTranslator;
+import io.fd.honeycomb.translate.write.WriteFailedException;
+import io.fd.hc2vpp.common.test.write.WriterCustomizerTest;
+import io.fd.vpp.jvpp.VppCallbackException;
+import io.fd.vpp.jvpp.core.dto.LispAddDelMapRequestItrRlocs;
+import io.fd.vpp.jvpp.core.dto.LispAddDelMapRequestItrRlocsReply;
+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.mockito.ArgumentCaptor;
+import org.mockito.Captor;
+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.yangtools.yang.binding.InstanceIdentifier;
+
+public class ItrRemoteLocatorSetCustomizerTest extends WriterCustomizerTest implements ByteDataTranslator {
+
+ private static final String VALID_NAME = "loc-set";
+
+ @Captor
+ private ArgumentCaptor<LispAddDelMapRequestItrRlocs> requestCaptor;
+
+ private ItrRemoteLocatorSetCustomizer customizer;
+ private InstanceIdentifier<ItrRemoteLocatorSet> validId;
+ private ItrRemoteLocatorSet validData;
+
+ @Before
+ public void setUp() throws Exception {
+ initMocks(this);
+ customizer = new ItrRemoteLocatorSetCustomizer(api);
+ validId = InstanceIdentifier.create(ItrRemoteLocatorSet.class);
+ validData = new ItrRemoteLocatorSetBuilder().setRemoteLocatorSetName(VALID_NAME).build();
+ }
+
+ @Test
+ public void writeCurrentAttributesSuccess() throws Exception {
+ onWriteSuccess();
+ customizer.writeCurrentAttributes(validId, validData, writeContext);
+ verifyWriteInvoked(true, VALID_NAME);
+ }
+
+ @Test
+ public void writeCurrentAttributesFailed() {
+ onWriteThrow();
+
+ try {
+ customizer.writeCurrentAttributes(validId, validData, writeContext);
+ } catch (WriteFailedException e) {
+ assertTrue(e.getCause() instanceof VppCallbackException);
+ verifyWriteInvoked(true, VALID_NAME);
+ return;
+ }
+
+ fail("Test should have thrown exception");
+ }
+
+ @Test
+ public void updateCurrentAttributes() {
+ try {
+ customizer.updateCurrentAttributes(validId, validData, validData, writeContext);
+ } catch (WriteFailedException e) {
+ assertTrue(e.getCause() instanceof UnsupportedOperationException);
+ return;
+ }
+
+ fail("Test should have thrown exception");
+ }
+
+ @Test
+ public void deleteCurrentAttributesSuccess() throws Exception {
+ onWriteSuccess();
+ customizer.deleteCurrentAttributes(validId, validData, writeContext);
+ verifyWriteInvoked(false, VALID_NAME);
+ }
+
+ @Test
+ public void deleteCurrentAttributesFailed() throws Exception {
+ onWriteThrow();
+
+ try {
+ customizer.writeCurrentAttributes(validId, validData, writeContext);
+ } catch (WriteFailedException e) {
+ assertTrue(e.getCause() instanceof VppCallbackException);
+ verifyWriteInvoked(true, VALID_NAME);
+ return;
+ }
+
+ fail("Test should have thrown exception");
+ }
+
+ private void onWriteSuccess() {
+ when(api.lispAddDelMapRequestItrRlocs(any(LispAddDelMapRequestItrRlocs.class)))
+ .thenReturn(CompletableFuture.completedFuture(new LispAddDelMapRequestItrRlocsReply()));
+ }
+
+ private void onWriteThrow() {
+ when(api.lispAddDelMapRequestItrRlocs(any(LispAddDelMapRequestItrRlocs.class)))
+ .thenReturn(new CompletableFuture<LispAddDelMapRequestItrRlocsReply>() {
+ @Override
+ public LispAddDelMapRequestItrRlocsReply get(final long l, final TimeUnit timeUnit)
+ throws InterruptedException, ExecutionException, TimeoutException {
+ throw new ExecutionException(new VppCallbackException("lispAddDelMapRequestItrRlocs", 1, -2));
+ }
+ });
+ }
+
+ private void verifyWriteInvoked(final boolean add, final String name) {
+ verify(api, times(1)).lispAddDelMapRequestItrRlocs(requestCaptor.capture());
+
+ final LispAddDelMapRequestItrRlocs request = requestCaptor.getValue();
+ assertNotNull(request);
+ assertEquals(booleanToByte(add), request.isAdd);
+ assertEquals(name, toString(request.locatorSetName));
+ }
+} \ No newline at end of file
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/LispCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/LispCustomizerTest.java
new file mode 100755
index 000000000..45e3e005b
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/LispCustomizerTest.java
@@ -0,0 +1,111 @@
+/*
+ * 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.hc2vpp.lisp.translate.write;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+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.write.WriteFailedException;
+import io.fd.hc2vpp.common.test.write.WriterCustomizerTest;
+import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.Lisp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.LispBuilder;
+import io.fd.vpp.jvpp.core.dto.LispEnableDisable;
+import io.fd.vpp.jvpp.core.dto.LispEnableDisableReply;
+
+
+public class LispCustomizerTest extends WriterCustomizerTest {
+
+ private LispCustomizer customizer;
+
+ @Override
+ public void setUp() {
+ customizer = new LispCustomizer(api);
+ }
+
+ private void whenlispEnableDisableThenSuccess() {
+ when(api.lispEnableDisable(any(LispEnableDisable.class))).thenReturn(future(new LispEnableDisableReply()));
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testWriteCurrentAttributesNullData() throws WriteFailedException {
+ customizer.writeCurrentAttributes(null, null, null);
+ }
+
+ @Test
+ public void testWriteCurrentAttributes() throws WriteFailedException {
+ Lisp intf = new LispBuilder().setEnable(true).build();
+
+ whenlispEnableDisableThenSuccess();
+ customizer.writeCurrentAttributes(null, intf, null);
+
+ ArgumentCaptor<LispEnableDisable> mappingCaptor = ArgumentCaptor.forClass(LispEnableDisable.class);
+ verify(api, times(1)).lispEnableDisable(mappingCaptor.capture());
+
+ LispEnableDisable request = mappingCaptor.getValue();
+
+ assertNotNull(request);
+ assertEquals(1, request.isEn);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testUpdateCurrentAttributesNullData() throws WriteFailedException {
+ customizer.updateCurrentAttributes(null, null, null, null);
+ }
+
+ @Test
+ public void testUpdateCurrentAttributes() throws WriteFailedException {
+ Lisp lisp = new LispBuilder().setEnable(true).build();
+
+ whenlispEnableDisableThenSuccess();
+ customizer.updateCurrentAttributes(null, null, lisp, null);
+
+ ArgumentCaptor<LispEnableDisable> lispCaptor = ArgumentCaptor.forClass(LispEnableDisable.class);
+ verify(api, times(1)).lispEnableDisable(lispCaptor.capture());
+
+ LispEnableDisable request = lispCaptor.getValue();
+
+ assertNotNull(request);
+ assertEquals(1, request.isEn);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testDeleteCurrentAttributesNullData() throws WriteFailedException {
+ customizer.deleteCurrentAttributes(null, null, null);
+ }
+
+ @Test
+ public void testDeleteCurrentAttributes() throws WriteFailedException {
+ Lisp lisp = new LispBuilder().setEnable(true).build();
+
+ whenlispEnableDisableThenSuccess();
+ customizer.deleteCurrentAttributes(null, lisp, null);
+
+ ArgumentCaptor<LispEnableDisable> lispCaptor = ArgumentCaptor.forClass(LispEnableDisable.class);
+ verify(api, times(1)).lispEnableDisable(lispCaptor.capture());
+
+ LispEnableDisable request = lispCaptor.getValue();
+
+ assertNotNull(request);
+ assertEquals(0, request.isEn);
+ }
+}
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/LocalMappingCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/LocalMappingCustomizerTest.java
new file mode 100755
index 000000000..e5663ee96
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/LocalMappingCustomizerTest.java
@@ -0,0 +1,163 @@
+/*
+ * 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.hc2vpp.lisp.translate.write;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import io.fd.hc2vpp.lisp.context.util.EidMappingContext;
+import io.fd.hc2vpp.common.translate.util.ByteDataTranslator;
+import io.fd.hc2vpp.common.translate.util.Ipv4Translator;
+import io.fd.honeycomb.translate.write.WriteFailedException;
+import io.fd.hc2vpp.common.test.write.WriterCustomizerTest;
+import java.util.concurrent.ExecutionException;
+import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Captor;
+import org.mockito.Mock;
+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.Ipv4Afi;
+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.Lisp;
+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.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.dp.subtable.grouping.local.mappings.local.mapping.EidBuilder;
+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.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.lisp.feature.data.grouping.LispFeatureData;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import io.fd.vpp.jvpp.core.dto.LispAddDelLocalEid;
+import io.fd.vpp.jvpp.core.dto.LispAddDelLocalEidReply;
+
+public class LocalMappingCustomizerTest extends WriterCustomizerTest implements ByteDataTranslator, Ipv4Translator {
+
+ @Mock
+ private EidMappingContext eidMappingContext;
+ @Captor
+ private ArgumentCaptor<LispAddDelLocalEid> mappingCaptor;
+
+ private InstanceIdentifier<LocalMapping> id;
+ private LocalMapping mapping;
+ private LocalMappingCustomizer customizer;
+
+ @Override
+ public void setUp() {
+ final Eid
+ eid = new EidBuilder()
+ .setAddressType(Ipv4Afi.class)
+ .setAddress(
+ new Ipv4Builder().setIpv4(
+ new Ipv4Address("192.168.2.1"))
+ .build())
+ .build();
+
+ mapping = new LocalMappingBuilder()
+ .setEid(eid)
+ .setLocatorSet("Locator")
+ .build();
+
+ id = InstanceIdentifier.builder(Lisp.class)
+ .child(LispFeatureData.class)
+ .child(EidTable.class)
+ .child(VniTable.class, new VniTableKey(25L))
+ .child(VrfSubtable.class)
+ .child(LocalMappings.class)
+ .child(LocalMapping.class, new LocalMappingKey(new MappingId("local")))
+ .build();
+
+ customizer = new LocalMappingCustomizer(api, eidMappingContext);
+
+ when(api.lispAddDelLocalEid(any(LispAddDelLocalEid.class))).thenReturn(future(new LispAddDelLocalEidReply()));
+ }
+
+
+ @Test(expected = NullPointerException.class)
+ public void testWriteCurrentAttributesNullData() throws WriteFailedException {
+ customizer.writeCurrentAttributes(null, null, writeContext);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testWriteCurrentAttributesNullEid() throws WriteFailedException {
+ LocalMapping mapping = mock(LocalMapping.class);
+ when(mapping.getEid()).thenReturn(null);
+ when(mapping.getLocatorSet()).thenReturn("Locator");
+
+ customizer.writeCurrentAttributes(null, mapping, writeContext);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testWriteCurrentAttributesNullLocator() throws WriteFailedException {
+ LocalMapping mapping = mock(LocalMapping.class);
+ when(mapping.getEid()).thenReturn(mock(Eid.class));
+ when(mapping.getLocatorSet()).thenReturn(null);
+
+ customizer.writeCurrentAttributes(null, mapping, writeContext);
+ }
+
+
+ @Test
+ public void testWriteCurrentAttributes() throws WriteFailedException {
+ customizer.writeCurrentAttributes(id, mapping, writeContext);
+
+ verify(api, times(1)).lispAddDelLocalEid(mappingCaptor.capture());
+
+ LispAddDelLocalEid request = mappingCaptor.getValue();
+
+ assertNotNull(request);
+ assertEquals("Locator", new String(request.locatorSetName));
+ assertEquals("1.2.168.192", arrayToIpv4AddressNoZone(request.eid).getValue());
+ assertEquals(0, request.eidType);
+ assertEquals(1, request.isAdd);
+ assertEquals(25, request.vni);
+ assertEquals("Locator", toString(request.locatorSetName));
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void testUpdateCurrentAttributes() throws WriteFailedException {
+ customizer.updateCurrentAttributes(null, null, null, writeContext);
+ }
+
+ @Test
+ public void testDeleteCurrentAttributes() throws WriteFailedException, InterruptedException, ExecutionException {
+ when(eidMappingContext.containsEid(any(), eq(mappingContext))).thenReturn(true);
+ customizer.deleteCurrentAttributes(id, mapping, writeContext);
+
+ verify(api, times(1)).lispAddDelLocalEid(mappingCaptor.capture());
+
+ LispAddDelLocalEid request = mappingCaptor.getValue();
+
+ assertNotNull(request);
+ assertEquals("Locator", new String(request.locatorSetName));
+ assertEquals("1.2.168.192", arrayToIpv4AddressNoZone(request.eid).getValue());
+ assertEquals(0, request.eidType);
+ assertEquals(0, request.isAdd);
+ assertEquals(25, request.vni);
+ assertEquals("Locator", toString(request.locatorSetName));
+ }
+}
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/LocatorSetCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/LocatorSetCustomizerTest.java
new file mode 100755
index 000000000..58049d8be
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/LocatorSetCustomizerTest.java
@@ -0,0 +1,148 @@
+/*
+ * 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.hc2vpp.lisp.translate.write;
+
+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.Matchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import com.google.common.base.Optional;
+import com.google.common.collect.ImmutableList;
+import io.fd.hc2vpp.common.translate.util.NamingContext;
+import io.fd.honeycomb.translate.write.WriteFailedException;
+import io.fd.hc2vpp.common.test.write.WriterCustomizerTest;
+import io.fd.vpp.jvpp.core.dto.LispAddDelLocatorSet;
+import io.fd.vpp.jvpp.core.dto.LispAddDelLocatorSetReply;
+import io.fd.vpp.jvpp.core.dto.LispLocatorSetDetails;
+import io.fd.vpp.jvpp.core.dto.LispLocatorSetDetailsReplyDump;
+import java.nio.charset.StandardCharsets;
+import java.util.Arrays;
+import java.util.concurrent.ExecutionException;
+import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+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.InterfaceBuilder;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public class LocatorSetCustomizerTest extends WriterCustomizerTest {
+
+ private LocatorSetCustomizer customizer;
+
+ @Override
+ public void setUp() {
+ customizer = new LocatorSetCustomizer(api, new NamingContext("locator-set", "locator-set-context"));
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testWriteCurrentAttributesNullData() throws WriteFailedException {
+ customizer.writeCurrentAttributes(null, null, writeContext);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testWriteCurrentAttributesBadData() throws WriteFailedException {
+ customizer.writeCurrentAttributes(null, mock(LocatorSet.class), writeContext);
+ }
+
+ @Test
+ public void testWriteCurrentAttributes() throws WriteFailedException, InterruptedException, ExecutionException {
+ noMappingDefined(mappingContext, "Locator", "locator-set-context");
+ LocatorSet locatorSet = new LocatorSetBuilder()
+ .setName("Locator")
+ .setInterface(Arrays.asList(new InterfaceBuilder().build()))
+ .build();
+
+ InstanceIdentifier<LocatorSet> validId =
+ InstanceIdentifier.create(LocatorSets.class).child(LocatorSet.class, new LocatorSetKey("Locator"));
+
+
+ ArgumentCaptor<LispAddDelLocatorSet> locatorSetCaptor = ArgumentCaptor.forClass(LispAddDelLocatorSet.class);
+
+ when(api.lispAddDelLocatorSet(any(LispAddDelLocatorSet.class)))
+ .thenReturn(future(new LispAddDelLocatorSetReply()));
+ when(writeContext.readAfter(validId)).thenReturn(Optional.of(locatorSet));
+
+ final LispLocatorSetDetailsReplyDump reply = new LispLocatorSetDetailsReplyDump();
+ LispLocatorSetDetails details = new LispLocatorSetDetails();
+ details.lsName = "Locator".getBytes(StandardCharsets.UTF_8);
+ reply.lispLocatorSetDetails = ImmutableList.of(details);
+
+ customizer.writeCurrentAttributes(validId, locatorSet, writeContext);
+
+ verify(api, times(1)).lispAddDelLocatorSet(locatorSetCaptor.capture());
+
+ LispAddDelLocatorSet request = locatorSetCaptor.getValue();
+
+ assertNotNull(request);
+ assertEquals("Locator", new String(request.locatorSetName));
+ assertEquals(1, request.isAdd);
+ }
+
+ @Test
+ public void testUpdateCurrentAttributes() throws WriteFailedException {
+ final InstanceIdentifier<LocatorSet> identifier = InstanceIdentifier.create(LocatorSet.class);
+ try {
+ customizer
+ .updateCurrentAttributes(identifier, mock(LocatorSet.class), mock(LocatorSet.class), writeContext);
+ } catch (WriteFailedException e) {
+ assertTrue(e.getCause() instanceof UnsupportedOperationException);
+ assertEquals(identifier, e.getFailedId());
+ return;
+ }
+ fail("Test should have failed");
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testDeleteCurrentAttributesNullData() throws WriteFailedException {
+ customizer.deleteCurrentAttributes(null, null, writeContext);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testDeleteCurrentAttributesBadData() throws WriteFailedException {
+ customizer.deleteCurrentAttributes(null, mock(LocatorSet.class), writeContext);
+ }
+
+ @Test
+ public void testDeleteCurrentAttributes() throws InterruptedException, ExecutionException, WriteFailedException {
+ LocatorSet locatorSet = new LocatorSetBuilder()
+ .setName("Locator")
+ .build();
+
+ ArgumentCaptor<LispAddDelLocatorSet> locatorSetCaptor = ArgumentCaptor.forClass(LispAddDelLocatorSet.class);
+
+ when(api.lispAddDelLocatorSet(any(LispAddDelLocatorSet.class)))
+ .thenReturn(future(new LispAddDelLocatorSetReply()));
+
+ customizer.deleteCurrentAttributes(null, locatorSet, writeContext);
+
+ verify(api, times(1)).lispAddDelLocatorSet(locatorSetCaptor.capture());
+
+ LispAddDelLocatorSet request = locatorSetCaptor.getValue();
+
+ assertNotNull(request);
+ assertEquals("Locator", new String(request.locatorSetName));
+ assertEquals(0, request.isAdd);
+ }
+}
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/MapResolverCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/MapResolverCustomizerTest.java
new file mode 100755
index 000000000..0780c68b4
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/MapResolverCustomizerTest.java
@@ -0,0 +1,103 @@
+/*
+ * 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.hc2vpp.lisp.translate.write;
+
+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 io.fd.hc2vpp.common.translate.util.Ipv4Translator;
+import io.fd.honeycomb.translate.write.WriteFailedException;
+import io.fd.hc2vpp.common.test.write.WriterCustomizerTest;
+import java.util.concurrent.ExecutionException;
+import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+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.Ipv4Address;
+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 io.fd.vpp.jvpp.core.dto.LispAddDelMapResolver;
+import io.fd.vpp.jvpp.core.dto.LispAddDelMapResolverReply;
+
+
+public class MapResolverCustomizerTest extends WriterCustomizerTest implements Ipv4Translator {
+
+ private MapResolverCustomizer customizer;
+
+ @Override
+ public void setUp() {
+ customizer = new MapResolverCustomizer(api);
+ }
+
+ private void whenLispAddDelMapResolverThenSuccess() {
+ when(api.lispAddDelMapResolver(any(LispAddDelMapResolver.class)))
+ .thenReturn(future(new LispAddDelMapResolverReply()));
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testWriteCurrentAttributesNullData() throws WriteFailedException {
+ customizer.writeCurrentAttributes(null, null, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testWriteCurrentAttributesBadData() throws WriteFailedException {
+ customizer.writeCurrentAttributes(null, new MapResolverBuilder().build(), null);
+ }
+
+ @Test
+ public void testWriteCurrentAttributes() throws WriteFailedException {
+ Ipv4Address address = new Ipv4Address("192.168.2.1");
+ MapResolver resolver = new MapResolverBuilder().setIpAddress(new IpAddress(address)).build();
+
+ whenLispAddDelMapResolverThenSuccess();
+
+ customizer.writeCurrentAttributes(null, resolver, null);
+
+ ArgumentCaptor<LispAddDelMapResolver> resolverCaptor = ArgumentCaptor.forClass(LispAddDelMapResolver.class);
+ verify(api, times(1)).lispAddDelMapResolver(resolverCaptor.capture());
+
+ LispAddDelMapResolver request = resolverCaptor.getValue();
+ assertEquals(1, request.isAdd);
+ assertEquals("1.2.168.192", arrayToIpv4AddressNoZone(request.ipAddress).getValue());
+ }
+
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void testUpdateCurrentAttributes() throws WriteFailedException {
+ customizer.updateCurrentAttributes(null, null, null, null);
+ }
+
+ @Test
+ public void testDeleteCurrentAttributes() throws InterruptedException, ExecutionException, WriteFailedException {
+ Ipv4Address address = new Ipv4Address("192.168.2.1");
+ MapResolver resolver = new MapResolverBuilder().setIpAddress(new IpAddress(address)).build();
+
+ whenLispAddDelMapResolverThenSuccess();
+
+ customizer.deleteCurrentAttributes(null, resolver, null);
+
+ ArgumentCaptor<LispAddDelMapResolver> resolverCaptor = ArgumentCaptor.forClass(LispAddDelMapResolver.class);
+ verify(api, times(1)).lispAddDelMapResolver(resolverCaptor.capture());
+
+ LispAddDelMapResolver request = resolverCaptor.getValue();
+ assertEquals(0, request.isAdd);
+ assertEquals("1.2.168.192", arrayToIpv4AddressNoZone(request.ipAddress).getValue());
+ }
+
+}
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/PitrCfgCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/PitrCfgCustomizerTest.java
new file mode 100755
index 000000000..7a2a8fe4c
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/PitrCfgCustomizerTest.java
@@ -0,0 +1,117 @@
+/*
+ * 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.hc2vpp.lisp.translate.write;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import io.fd.honeycomb.translate.write.WriteFailedException;
+import io.fd.hc2vpp.common.test.write.WriterCustomizerTest;
+import java.util.concurrent.ExecutionException;
+import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+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 io.fd.vpp.jvpp.core.dto.LispPitrSetLocatorSet;
+import io.fd.vpp.jvpp.core.dto.LispPitrSetLocatorSetReply;
+
+
+public class PitrCfgCustomizerTest extends WriterCustomizerTest {
+
+ private PitrCfgCustomizer customizer;
+
+ @Override
+ public void setUp() {
+ customizer = new PitrCfgCustomizer(api);
+ }
+
+ private void whenLispPitrSetLocatorSetThenSuccess() {
+ when(api.lispPitrSetLocatorSet(any(LispPitrSetLocatorSet.class))).thenReturn(future(new LispPitrSetLocatorSetReply()));
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testWriteCurrentAttributesNullData() throws WriteFailedException {
+ customizer.writeCurrentAttributes(null, null, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testWriteCurrentAttributesBadData() throws WriteFailedException {
+ customizer.writeCurrentAttributes(null, mock(PitrCfg.class), null);
+ }
+
+ @Test
+ public void testWriteCurrentAttributes() throws WriteFailedException {
+ PitrCfg cfg = new PitrCfgBuilder().setLocatorSet("Locator").build();
+
+ whenLispPitrSetLocatorSetThenSuccess();
+ customizer.writeCurrentAttributes(null, cfg, null);
+
+ ArgumentCaptor<LispPitrSetLocatorSet> cfgCaptor = ArgumentCaptor.forClass(LispPitrSetLocatorSet.class);
+ verify(api, times(1)).lispPitrSetLocatorSet(cfgCaptor.capture());
+
+ LispPitrSetLocatorSet request = cfgCaptor.getValue();
+ assertEquals(1, request.isAdd);
+ assertEquals("Locator", new String(request.lsName));
+ }
+
+ @Test
+ public void testUpdateCurrentAttributes() throws WriteFailedException {
+ PitrCfg cfg = new PitrCfgBuilder().setLocatorSet("Locator").build();
+
+ whenLispPitrSetLocatorSetThenSuccess();
+
+ customizer.writeCurrentAttributes(null, cfg, null);
+
+ ArgumentCaptor<LispPitrSetLocatorSet> cfgCaptor = ArgumentCaptor.forClass(LispPitrSetLocatorSet.class);
+ verify(api, times(1)).lispPitrSetLocatorSet(cfgCaptor.capture());
+
+ LispPitrSetLocatorSet request = cfgCaptor.getValue();
+ assertEquals(1, request.isAdd);
+ assertEquals("Locator", new String(request.lsName));
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testDeleteCurrentAttributesNullData() throws WriteFailedException {
+ customizer.deleteCurrentAttributes(null, null, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testDeleteCurrentAttributesBadData() throws WriteFailedException {
+ customizer.deleteCurrentAttributes(null, mock(PitrCfg.class), null);
+ }
+
+ @Test
+ public void testDeleteCurrentAttributes() throws WriteFailedException, InterruptedException, ExecutionException {
+ PitrCfg cfg = new PitrCfgBuilder().setLocatorSet("Locator").build();
+
+ whenLispPitrSetLocatorSetThenSuccess();
+
+ customizer.deleteCurrentAttributes(null, cfg, null);
+
+ ArgumentCaptor<LispPitrSetLocatorSet> cfgCaptor = ArgumentCaptor.forClass(LispPitrSetLocatorSet.class);
+ verify(api, times(1)).lispPitrSetLocatorSet(cfgCaptor.capture());
+
+ LispPitrSetLocatorSet request = cfgCaptor.getValue();
+ assertEquals(0, request.isAdd);
+ assertEquals("Locator", new String(request.lsName));
+ }
+
+}
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/RemoteMappingCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/RemoteMappingCustomizerTest.java
new file mode 100755
index 000000000..1645a9c3e
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/RemoteMappingCustomizerTest.java
@@ -0,0 +1,155 @@
+/*
+ * 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.hc2vpp.lisp.translate.write;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import io.fd.hc2vpp.lisp.context.util.EidMappingContext;
+import io.fd.hc2vpp.common.translate.util.Ipv4Translator;
+import io.fd.honeycomb.translate.write.WriteFailedException;
+import io.fd.hc2vpp.common.test.write.WriterCustomizerTest;
+import io.fd.vpp.jvpp.core.dto.LispAddDelRemoteMapping;
+import io.fd.vpp.jvpp.core.dto.LispAddDelRemoteMappingReply;
+import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Captor;
+import org.mockito.Mock;
+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.Ipv4Afi;
+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.Lisp;
+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.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.EidBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.dp.subtable.grouping.remote.mappings.remote.mapping.locator.list.NegativeMappingBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.dp.subtable.grouping.remote.mappings.remote.mapping.locator.list.negative.mapping.MapReplyBuilder;
+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.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.lisp.feature.data.grouping.LispFeatureData;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public class RemoteMappingCustomizerTest extends WriterCustomizerTest implements Ipv4Translator {
+
+ @Captor
+ private ArgumentCaptor<LispAddDelRemoteMapping> mappingCaptor;
+
+ private MappingId mappingId;
+ private RemoteMappingCustomizer customizer;
+ private RemoteMapping intf;
+ private InstanceIdentifier<RemoteMapping> id;
+
+ @Mock
+ private EidMappingContext remoteMappingContext;
+
+ @Override
+ public void setUp() {
+ final Eid eid = new EidBuilder()
+ .setAddressType(Ipv4Afi.class)
+ .setAddress(
+ new Ipv4Builder().setIpv4(
+ new Ipv4Address("192.168.2.1"))
+ .build())
+ .build();
+
+ mappingId = new MappingId("REMOTE");
+ final RemoteMappingKey key = new RemoteMappingKey(mappingId);
+
+ intf = new RemoteMappingBuilder()
+ .setEid(
+ eid)
+ .setLocatorList(new NegativeMappingBuilder()
+ .setMapReply(new MapReplyBuilder().setMapReplyAction(MapReplyAction.Drop).build()).build())
+ .build();
+
+ id = InstanceIdentifier.builder(Lisp.class)
+ .child(LispFeatureData.class)
+ .child(EidTable.class)
+ .child(VniTable.class, new VniTableKey(25L))
+ .child(VrfSubtable.class)
+ .child(RemoteMappings.class)
+ .child(RemoteMapping.class, key).build();
+
+ customizer = new RemoteMappingCustomizer(api, remoteMappingContext);
+
+ when(api.lispAddDelRemoteMapping(any())).thenReturn(future(new LispAddDelRemoteMappingReply()));
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testWriteCurrentAttributesNullData() throws WriteFailedException {
+ customizer.writeCurrentAttributes(null, null, writeContext);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testWriteCurrentAttributesBadData() throws WriteFailedException {
+ customizer
+ .writeCurrentAttributes(null, mock(RemoteMapping.class), writeContext);
+ }
+
+ @Test
+ public void testWriteCurrentAttributes() throws WriteFailedException {
+ customizer.writeCurrentAttributes(id, intf, writeContext);
+
+ verify(api, times(1)).lispAddDelRemoteMapping(mappingCaptor.capture());
+
+ LispAddDelRemoteMapping request = mappingCaptor.getValue();
+
+ assertNotNull(request);
+ assertEquals(1, request.isAdd);
+ assertEquals("1.2.168.192", arrayToIpv4AddressNoZone(request.eid).getValue());
+ assertEquals(25, request.vni);
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void testUpdateCurrentAttributes() throws WriteFailedException {
+ customizer.updateCurrentAttributes(null, null, null, writeContext);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testDeleteCurrentAttributesNullData() throws WriteFailedException {
+ customizer.deleteCurrentAttributes(null, null, writeContext);
+ }
+
+ @Test
+ public void testDeleteCurrentAttributes() throws WriteFailedException {
+ when(remoteMappingContext.containsEid(any(), eq(mappingContext))).thenReturn(true);
+ customizer.deleteCurrentAttributes(id, intf, writeContext);
+
+ verify(api, times(1)).lispAddDelRemoteMapping(mappingCaptor.capture());
+
+ LispAddDelRemoteMapping request = mappingCaptor.getValue();
+
+ assertNotNull(request);
+ assertEquals(0, request.isAdd);
+ assertEquals("1.2.168.192", arrayToIpv4AddressNoZone(request.eid).getValue());
+ assertEquals(25, request.vni);
+ }
+
+}
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/VniTableCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/VniTableCustomizerTest.java
new file mode 100644
index 000000000..885a6ded7
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/VniTableCustomizerTest.java
@@ -0,0 +1,103 @@
+/*
+ * 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.hc2vpp.lisp.translate.write;
+
+
+import static org.junit.Assert.fail;
+import static org.mockito.Mockito.when;
+import static org.mockito.MockitoAnnotations.initMocks;
+
+import com.google.common.base.Optional;
+import io.fd.honeycomb.translate.write.WriteFailedException;
+import io.fd.hc2vpp.common.test.write.WriterCustomizerTest;
+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.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.vni.table.VrfSubtableBuilder;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public class VniTableCustomizerTest extends WriterCustomizerTest {
+
+ private VniTableCustomizer customizer;
+ private InstanceIdentifier<VniTable> validId;
+ private VniTable validData;
+
+ @Before
+ public void init() {
+ initMocks(this);
+ customizer = new VniTableCustomizer(api);
+
+ validId = InstanceIdentifier.create(VniTable.class);
+ validData = new VniTableBuilder()
+ .setVrfSubtable(new VrfSubtableBuilder()
+ .build()).build();
+ }
+
+ @Test
+ public void testWriteSuccessfull() {
+ whenReadAfterReturnValid();
+ try {
+ customizer.writeCurrentAttributes(validId, validData, writeContext);
+ } catch (Exception e) {
+ fail("Test should pass without exception");
+ }
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testWriteFailed() throws WriteFailedException {
+ whenReadAfterReturnInvalid();
+ customizer.writeCurrentAttributes(validId, validData, writeContext);
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void testUpdate() throws WriteFailedException {
+ customizer.updateCurrentAttributes(validId, validData, validData, writeContext);
+ }
+
+ @Test
+ public void testDeleteSuccessfull() {
+ whenReadBeforeReturnValid();
+ try {
+ customizer.deleteCurrentAttributes(validId, validData, writeContext);
+ } catch (Exception e) {
+ fail("Test should pass without exception");
+ }
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testDeleteFailed() throws WriteFailedException {
+ whenReadBeforeReturnInvalid();
+ customizer.deleteCurrentAttributes(validId, validData, writeContext);
+ }
+
+ private void whenReadBeforeReturnValid() {
+ when(writeContext.readBefore(validId)).thenReturn(Optional.of(validData));
+ }
+
+ private void whenReadBeforeReturnInvalid() {
+ when(writeContext.readBefore(validId)).thenReturn(Optional.absent());
+ }
+
+ private void whenReadAfterReturnValid() {
+ when(writeContext.readAfter(validId)).thenReturn(Optional.of(validData));
+ }
+
+ private void whenReadAfterReturnInvalid() {
+ when(writeContext.readAfter(validId)).thenReturn(Optional.absent());
+ }
+} \ No newline at end of file
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/VrfSubtableCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/VrfSubtableCustomizerTest.java
new file mode 100644
index 000000000..7991cd9a6
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/VrfSubtableCustomizerTest.java
@@ -0,0 +1,105 @@
+/*
+ * 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.hc2vpp.lisp.translate.write;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import io.fd.hc2vpp.lisp.translate.write.trait.SubtableWriterTestCase;
+import io.fd.honeycomb.translate.write.WriteFailedException;
+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.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 SubtableWriterTestCase {
+
+ private VrfSubtableCustomizer customizer;
+ private InstanceIdentifier<VrfSubtable> validId;
+ private VrfSubtable validData;
+
+ @Before
+ public void init() {
+ customizer = new VrfSubtableCustomizer(api);
+ validId = InstanceIdentifier.create(EidTable.class).child(VniTable.class, new VniTableKey(12L))
+ .child(VrfSubtable.class);
+ validData = new VrfSubtableBuilder().setTableId(10L).build();
+ }
+
+ @Test
+ public void testWriteSuccessfull() throws WriteFailedException {
+ whenAddDelEidTableAddDelMapSuccess();
+
+ customizer.writeCurrentAttributes(validId, validData, writeContext);
+ verifyAddDelEidTableAddDelMapInvokedCorrectly(1, 12, 10, 0);
+ }
+
+ @Test
+ public void testWriteFailed() {
+ whenAddDelEidTableAddDelMapFail();
+
+ try {
+ customizer.writeCurrentAttributes(validId, validData, writeContext);
+ } catch (Exception e) {
+ assertTrue(e instanceof WriteFailedException);
+
+ final WriteFailedException realException = ((WriteFailedException) e);
+ assertEquals(validId, realException.getFailedId());
+ assertTrue(e.getCause() instanceof VppCallbackException);
+ return;
+ }
+
+ fail("Test should throw exception");
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void testUpdate() throws WriteFailedException {
+ customizer.updateCurrentAttributes(validId, validData, validData, writeContext);
+ }
+
+ @Test
+ public void testDeleteSuccessfull() throws WriteFailedException {
+ whenAddDelEidTableAddDelMapSuccess();
+
+ customizer.deleteCurrentAttributes(validId, validData, writeContext);
+ verifyAddDelEidTableAddDelMapInvokedCorrectly(0, 12, 10, 0);
+ }
+
+ @Test
+ public void testDeleteFailed() {
+ whenAddDelEidTableAddDelMapFail();
+
+ try {
+ customizer.deleteCurrentAttributes(validId, validData, writeContext);
+ } catch (Exception e) {
+ assertTrue(e instanceof WriteFailedException);
+
+ final WriteFailedException realException = ((WriteFailedException) e);
+ assertEquals(validId, realException.getFailedId());
+ assertTrue(e.getCause() instanceof VppCallbackException);
+ return;
+ }
+
+ fail("Test should throw exception");
+ }
+}
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/trait/SubtableWriterTestCase.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/trait/SubtableWriterTestCase.java
new file mode 100644
index 000000000..50186cd2b
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/trait/SubtableWriterTestCase.java
@@ -0,0 +1,59 @@
+/*
+ * 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.hc2vpp.lisp.translate.write.trait;
+
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import io.fd.hc2vpp.common.test.write.WriterCustomizerTest;
+import io.fd.vpp.jvpp.core.dto.LispEidTableAddDelMap;
+import io.fd.vpp.jvpp.core.dto.LispEidTableAddDelMapReply;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Captor;
+import org.mockito.Mockito;
+
+public class SubtableWriterTestCase extends WriterCustomizerTest implements SubtableWriter {
+ @Captor
+ protected ArgumentCaptor<LispEidTableAddDelMap> requestCaptor;
+
+
+ protected void verifyAddDelEidTableAddDelMapInvokedCorrectly(final int addDel, final int vni, final int tableId,
+ final int isL2) {
+ verify(api, times(1)).lispEidTableAddDelMap(requestCaptor.capture());
+
+ final LispEidTableAddDelMap request = requestCaptor.getValue();
+ assertNotNull(request);
+ assertEquals(addDel, request.isAdd);
+ assertEquals(vni, request.vni);
+ assertEquals(tableId, request.dpTable);
+ assertEquals(isL2, request.isL2);
+ }
+
+ protected void whenAddDelEidTableAddDelMapSuccess() {
+ when(api.lispEidTableAddDelMap(Mockito.any(LispEidTableAddDelMap.class)))
+ .thenReturn(future(new LispEidTableAddDelMapReply()));
+ }
+
+ protected void whenAddDelEidTableAddDelMapFail() {
+ when(api.lispEidTableAddDelMap(Mockito.any(LispEidTableAddDelMap.class)))
+ .thenReturn(failedFuture());
+ }
+}