summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Srnicek <jsrnicek@cisco.com>2016-09-28 09:33:32 +0200
committerMarek Gradzki <mgradzki@cisco.com>2016-09-28 07:51:13 +0000
commit4afdbd544d82c4ed89a5a17812e114e54b2c82a2 (patch)
treec2741a55d4443efd566b4cff8febc264ef49b0fd
parent083a0439b72e4803ad713232a48c71d3dc9fbd42 (diff)
Lisp test coverage increased to ~80%
Change-Id: Id4e9072ebb8d66e532e30c1dc3bb6036bfdc9012 Signed-off-by: Jan Srnicek <jsrnicek@cisco.com>
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/initializers/LispInitializerTest.java42
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/AdjacencyCustomizerTest.java44
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/InterfaceCustomizerTest.java102
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/LispStateCustomizerTest.java52
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/LocalMappingCustomizerTest.java120
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/LocatorSetCustomizerTest.java80
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/MapResolverCustomizerTest.java87
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/PitrCfgCustomizerTest.java62
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/RemoteMappingCustomizerTest.java125
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/VniTableCustomizerTest.java75
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/dump/check/LocatorDumpCheckTest.java25
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/dump/check/LocatorSetsDumpCheckTest.java26
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/dump/check/MapResolverDumpCheckTest.java26
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/dump/check/MappingsDumpCheckTest.java26
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/dump/check/VniTableDumpCheckTest.java26
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/dump/executor/LocatorDumpExecutorTest.java105
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/dump/executor/LocatorSetsDumpExecutorTest.java95
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/dump/executor/MapResolversDumpExecutorTest.java76
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/dump/executor/MappingsDumpExecutorTest.java121
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/dump/executor/VniTableDumpExecutorTest.java76
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/AdjacencyCustomizerTest.java129
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/VniTableCustomizerTest.java86
-rw-r--r--vpp-common/vpp-translate-test/pom.xml8
-rw-r--r--vpp-common/vpp-translate-test/src/main/java/io/fd/honeycomb/vpp/test/read/DumpCheckTest.java81
-rw-r--r--vpp-common/vpp-translate-test/src/main/java/io/fd/honeycomb/vpp/test/read/JvppDumpExecutorTest.java93
25 files changed, 1787 insertions, 1 deletions
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/initializers/LispInitializerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/initializers/LispInitializerTest.java
new file mode 100644
index 000000000..087f2cdee
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/initializers/LispInitializerTest.java
@@ -0,0 +1,42 @@
+package io.fd.honeycomb.lisp.translate.initializers;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Mockito.mock;
+
+import org.junit.Test;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.Lisp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.LispState;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.LispStateBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.EidTableBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.locator.sets.grouping.LocatorSetsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.map.resolvers.grouping.MapResolversBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.pitr.cfg.grouping.PitrCfgBuilder;
+
+
+public class LispInitializerTest {
+ @Test
+ public void convert() throws Exception {
+
+ final LispInitializer initializer = new LispInitializer(mock(DataBroker.class));
+ final LispState state = new LispStateBuilder()
+ .setEnable(true)
+ .setEidTable(new EidTableBuilder().build())
+ .setLocatorSets(new LocatorSetsBuilder().build())
+ .setMapResolvers(new MapResolversBuilder().build())
+ .setPitrCfg(new PitrCfgBuilder().build())
+ .build();
+
+ final Lisp operational = initializer.convert(state);
+
+ assertNotNull(operational);
+ assertEquals(operational.getPitrCfg(), state.getPitrCfg());
+ assertEquals(operational.isEnable(), state.isEnable());
+ assertEquals(operational.getEidTable(), state.getEidTable());
+ assertEquals(operational.getLocatorSets(), state.getLocatorSets());
+ assertEquals(operational.getMapResolvers(), state.getMapResolvers());
+
+ }
+
+} \ No newline at end of file
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/AdjacencyCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/AdjacencyCustomizerTest.java
new file mode 100644
index 000000000..0a88f946c
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/AdjacencyCustomizerTest.java
@@ -0,0 +1,44 @@
+package io.fd.honeycomb.lisp.translate.read;
+
+import static org.junit.Assert.assertTrue;
+
+import io.fd.honeycomb.translate.read.ReadFailedException;
+import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
+import io.fd.honeycomb.vpp.test.read.ListReaderCustomizerTest;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.AdjacenciesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.adjacencies.Adjacency;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.adjacencies.AdjacencyBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.adjacencies.AdjacencyKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+
+public class AdjacencyCustomizerTest extends ListReaderCustomizerTest<Adjacency, AdjacencyKey, AdjacencyBuilder> {
+
+ private InstanceIdentifier<Adjacency> identifier;
+
+ public AdjacencyCustomizerTest() {
+ super(Adjacency.class, AdjacenciesBuilder.class);
+ }
+
+ @Before
+ public void init() {
+ identifier = InstanceIdentifier.create(Adjacency.class);
+ }
+
+ @Test
+ public void getAllIds() throws Exception {
+ assertTrue(getCustomizer().getAllIds(identifier, ctx).isEmpty());
+ }
+
+ @Test(expected = ReadFailedException.class)
+ public void readCurrentAttributes() throws Exception {
+ getCustomizer().readCurrentAttributes(identifier, new AdjacencyBuilder(), ctx);
+ }
+
+ @Override
+ protected ReaderCustomizer<Adjacency, AdjacencyBuilder> initCustomizer() {
+ return new AdjacencyCustomizer(api);
+ }
+} \ No newline at end of file
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/InterfaceCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/InterfaceCustomizerTest.java
new file mode 100644
index 000000000..3c87a7540
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/InterfaceCustomizerTest.java
@@ -0,0 +1,102 @@
+package io.fd.honeycomb.lisp.translate.read;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.when;
+
+import com.google.common.collect.ImmutableList;
+import io.fd.honeycomb.translate.read.ReadFailedException;
+import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
+import io.fd.honeycomb.translate.v3po.util.NamingContext;
+import io.fd.honeycomb.vpp.test.read.ListReaderCustomizerTest;
+import java.util.List;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.locator.sets.grouping.LocatorSets;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.locator.sets.grouping.locator.sets.LocatorSet;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.locator.sets.grouping.locator.sets.LocatorSetBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.locator.sets.grouping.locator.sets.LocatorSetKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.locator.sets.grouping.locator.sets.locator.set.Interface;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.locator.sets.grouping.locator.sets.locator.set.InterfaceBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.locator.sets.grouping.locator.sets.locator.set.InterfaceKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.jvpp.core.dto.LispLocatorDetails;
+import org.openvpp.jvpp.core.dto.LispLocatorDetailsReplyDump;
+
+public class InterfaceCustomizerTest
+ extends ListReaderCustomizerTest<Interface, InterfaceKey, InterfaceBuilder> {
+
+ public InterfaceCustomizerTest() {
+ super(Interface.class, LocatorSetBuilder.class);
+ }
+
+ private InstanceIdentifier<Interface> validId;
+
+ @Before
+ public void init() {
+ validId = InstanceIdentifier.create(LocatorSets.class).child(LocatorSet.class, new LocatorSetKey("loc-set-1"))
+ .child(Interface.class, new InterfaceKey("interface-1"));
+
+ //mappings
+ defineMappings();
+ //dump data
+ defineDumpData();
+ }
+
+ private void defineDumpData() {
+ final LispLocatorDetailsReplyDump dump = new LispLocatorDetailsReplyDump();
+
+ final LispLocatorDetails detail1 = new LispLocatorDetails();
+ detail1.swIfIndex = 1;
+ detail1.ipAddress = new byte[]{-64, -88, 2, 1};
+ detail1.isIpv6 = 0;
+ detail1.local = 0;
+ detail1.priority = 1;
+ detail1.weight = 2;
+
+ final LispLocatorDetails detail2 = new LispLocatorDetails();
+ detail2.swIfIndex = 2;
+ detail2.ipAddress = new byte[]{-64, -88, 2, 2};
+ detail2.isIpv6 = 0;
+ detail2.local = 0;
+ detail2.priority = 2;
+ detail2.weight = 3;
+
+ dump.lispLocatorDetails = ImmutableList.of(detail1, detail2);
+
+ when(api.lispLocatorDump(Mockito.any())).thenReturn(future(dump));
+ }
+
+ private void defineMappings() {
+ defineMapping(mappingContext, "interface-1", 1, "interface-context");
+ defineMapping(mappingContext, "interface-2", 2, "interface-context");
+ defineMapping(mappingContext, "loc-set-1", 3, "locator-set-context");
+ }
+
+ @Test
+ public void testGetAllIds() throws ReadFailedException {
+
+ final List<InterfaceKey> keys = getCustomizer().getAllIds(validId, ctx);
+
+ assertEquals(2, keys.size());
+ assertEquals("interface-1", keys.get(0).getInterfaceRef());
+ assertEquals("interface-2", keys.get(1).getInterfaceRef());
+ }
+
+ @Test
+ public void testReadCurrentAttributes() throws ReadFailedException {
+ InterfaceBuilder builder = new InterfaceBuilder();
+ getCustomizer().readCurrentAttributes(validId, builder, ctx);
+
+ final Interface iface = builder.build();
+ assertEquals("interface-1", iface.getInterfaceRef());
+ assertEquals("interface-1", iface.getKey().getInterfaceRef());
+
+ }
+
+ @Override
+ protected ReaderCustomizer<Interface, InterfaceBuilder> initCustomizer() {
+ return new InterfaceCustomizer(api, new NamingContext("interface", "interface-context"),
+ new NamingContext("loc-set", "locator-set-context"));
+ }
+}
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/LispStateCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/LispStateCustomizerTest.java
new file mode 100644
index 000000000..4a76debc7
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/LispStateCustomizerTest.java
@@ -0,0 +1,52 @@
+package io.fd.honeycomb.lisp.translate.read;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.when;
+
+import io.fd.honeycomb.translate.read.ReadFailedException;
+import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
+import io.fd.honeycomb.vpp.test.read.ReaderCustomizerTest;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.LispState;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.LispStateBuilder;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.jvpp.core.dto.ShowLispStatusReply;
+
+public class LispStateCustomizerTest extends ReaderCustomizerTest<LispState, LispStateBuilder> {
+
+ private InstanceIdentifier<LispState> identifier;
+
+ public LispStateCustomizerTest() {
+ super(LispState.class, null);
+ }
+
+ @Before
+ public void init() {
+ identifier = InstanceIdentifier.create(LispState.class);
+ final ShowLispStatusReply reply = new ShowLispStatusReply();
+ reply.featureStatus = 1;
+
+ when(api.showLispStatus(Mockito.any())).thenReturn(future(reply));
+ }
+
+ @Test
+ public void testReadCurrentAttributes() throws ReadFailedException {
+
+ LispStateBuilder builder = new LispStateBuilder();
+ getCustomizer().readCurrentAttributes(identifier, builder, ctx);
+
+ assertEquals(true, builder.build().isEnable());
+ }
+
+ @Override
+ protected ReaderCustomizer<LispState, LispStateBuilder> initCustomizer() {
+ return new LispStateCustomizer(api);
+ }
+
+ @Override
+ public void testMerge() throws Exception {
+ //LispState is root node, so there is no way to implement merge(it is also not needed)
+ }
+}
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/LocalMappingCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/LocalMappingCustomizerTest.java
new file mode 100644
index 000000000..b874bce48
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/LocalMappingCustomizerTest.java
@@ -0,0 +1,120 @@
+package io.fd.honeycomb.lisp.translate.read;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.when;
+
+import com.google.common.collect.ImmutableList;
+import io.fd.honeycomb.lisp.context.util.EidMappingContext;
+import io.fd.honeycomb.lisp.translate.util.EidTranslator;
+import io.fd.honeycomb.translate.MappingContext;
+import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
+import io.fd.honeycomb.translate.v3po.util.NamingContext;
+import io.fd.honeycomb.vpp.test.read.ListReaderCustomizerTest;
+import java.util.List;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.eid.mapping.context.rev160801.contexts.eid.mapping.context.mappings.mapping.EidBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv4;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv4Builder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.MappingId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.EidTable;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.VniTable;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.VniTableKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.LocalMappings;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.LocalMappingsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.local.mappings.LocalMapping;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.local.mappings.LocalMappingBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.local.mappings.LocalMappingKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.local.mappings.local.mapping.Eid;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.jvpp.core.dto.LispEidTableDetails;
+import org.openvpp.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(LocalMappings.class)
+ .child(LocalMapping.class);
+
+ validIdentifier = InstanceIdentifier.create(EidTable.class)
+ .child(VniTable.class, new VniTableKey(12L))
+ .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.isLocal = 1;
+ detail.locatorSetIndex = 1;
+ detail.ttl = 7;
+ detail.vni = 12;
+
+ replyDump.lispEidTableDetails = ImmutableList.of(detail);
+ when(api.lispEidTableDump(any())).thenReturn(future(replyDump));
+ }
+
+ private void defineMappings() {
+ //eid mapping
+
+ when(localMappingContext.getId(any(Eid.class), any(MappingContext.class))).thenReturn(new MappingId("local-mapping"));
+ when(localMappingContext.containsEid(new MappingId("local-mapping"), mappingContext)).thenReturn(true);
+ when(localMappingContext.getEid(new MappingId("local-mapping"), mappingContext)).thenReturn(new EidBuilder()
+ .setAddress(EID_ADDRESS).build());
+ //naming context for locator
+ defineMapping(mappingContext, "loc-set", 1, "locator-set-context");
+ }
+
+ @Test
+ public void readCurrentAttributes() throws Exception {
+ LocalMappingBuilder builder = new LocalMappingBuilder();
+ getCustomizer().readCurrentAttributes(validIdentifier, builder, ctx);
+
+ final LocalMapping mapping = builder.build();
+
+ assertNotNull(mapping);
+ assertEquals(true, compareAddresses(EID_ADDRESS, mapping.getEid().getAddress()));
+ assertEquals("loc-set", mapping.getLocatorSet());
+ }
+
+ @Test
+ public void getAllIds() throws Exception {
+ final List<LocalMappingKey> keys = getCustomizer().getAllIds(emptyIdentifier, ctx);
+
+ assertEquals(1, keys.size());
+ assertEquals("local-mapping", keys.get(0).getId().getValue());
+ }
+
+ @Override
+ protected ReaderCustomizer<LocalMapping, LocalMappingBuilder> initCustomizer() {
+ return new LocalMappingCustomizer(api, new NamingContext("loc", "locator-set-context"), localMappingContext);
+ }
+} \ No newline at end of file
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/LocatorSetCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/LocatorSetCustomizerTest.java
new file mode 100644
index 000000000..2c40c2fdf
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/LocatorSetCustomizerTest.java
@@ -0,0 +1,80 @@
+package io.fd.honeycomb.lisp.translate.read;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.when;
+
+import com.google.common.collect.ImmutableList;
+import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
+import io.fd.honeycomb.translate.v3po.util.NamingContext;
+import io.fd.honeycomb.vpp.test.read.ListReaderCustomizerTest;
+import java.nio.charset.StandardCharsets;
+import java.util.List;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.locator.sets.grouping.LocatorSets;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.locator.sets.grouping.LocatorSetsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.locator.sets.grouping.locator.sets.LocatorSet;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.locator.sets.grouping.locator.sets.LocatorSetBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.locator.sets.grouping.locator.sets.LocatorSetKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.jvpp.core.dto.LispLocatorSetDetails;
+import org.openvpp.jvpp.core.dto.LispLocatorSetDetailsReplyDump;
+
+
+public class LocatorSetCustomizerTest
+ extends ListReaderCustomizerTest<LocatorSet, LocatorSetKey, LocatorSetBuilder> {
+
+ private InstanceIdentifier<LocatorSet> emptyId;
+ private InstanceIdentifier<LocatorSet> validId;
+
+ public LocatorSetCustomizerTest() {
+ super(LocatorSet.class, LocatorSetsBuilder.class);
+ }
+
+ @Before
+ public void init() {
+ emptyId = InstanceIdentifier.create(LocatorSet.class);
+ validId = InstanceIdentifier.create(LocatorSets.class).child(LocatorSet.class, new LocatorSetKey("loc-set"));
+
+ defineDumpData();
+ defineMapping(mappingContext, "loc-set", 1, "locator-set-context");
+ }
+
+ private void defineDumpData() {
+ LispLocatorSetDetailsReplyDump dump = new LispLocatorSetDetailsReplyDump();
+ LispLocatorSetDetails detail = new LispLocatorSetDetails();
+ detail.context = 4;
+ detail.lsName = "loc-set".getBytes(StandardCharsets.UTF_8);
+ detail.lsIndex = 1;
+
+ dump.lispLocatorSetDetails = ImmutableList.of(detail);
+
+ when(api.lispLocatorSetDump(any())).thenReturn(future(dump));
+ }
+
+
+ @Test
+ public void readCurrentAttributes() throws Exception {
+ LocatorSetBuilder builder = new LocatorSetBuilder();
+ getCustomizer().readCurrentAttributes(validId, builder, ctx);
+
+ assertNotNull(builder);
+ assertEquals("loc-set", builder.getName());
+ assertEquals("loc-set", builder.getKey().getName());
+ }
+
+ @Test
+ public void getAllIds() throws Exception {
+ final List<LocatorSetKey> keys = getCustomizer().getAllIds(emptyId, ctx);
+
+ assertEquals(1, keys.size());
+ assertEquals("loc-set", keys.get(0).getName());
+ }
+
+ @Override
+ protected ReaderCustomizer<LocatorSet, LocatorSetBuilder> initCustomizer() {
+ return new LocatorSetCustomizer(api, new NamingContext("loc", "locator-set-context"));
+ }
+} \ No newline at end of file
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/MapResolverCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/MapResolverCustomizerTest.java
new file mode 100644
index 000000000..be5d1c7f0
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/MapResolverCustomizerTest.java
@@ -0,0 +1,87 @@
+package io.fd.honeycomb.lisp.translate.read;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.when;
+
+import com.google.common.collect.ImmutableList;
+import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
+import io.fd.honeycomb.vpp.test.read.ListReaderCustomizerTest;
+import 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.rev160520.map.resolvers.grouping.MapResolvers;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.map.resolvers.grouping.MapResolversBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.map.resolvers.grouping.map.resolvers.MapResolver;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.map.resolvers.grouping.map.resolvers.MapResolverBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.map.resolvers.grouping.map.resolvers.MapResolverKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.jvpp.core.dto.LispMapResolverDetails;
+import org.openvpp.jvpp.core.dto.LispMapResolverDetailsReplyDump;
+
+
+public class MapResolverCustomizerTest
+ extends ListReaderCustomizerTest<MapResolver, MapResolverKey, MapResolverBuilder> {
+
+ private static final IpAddress IP_ADDRESS = new IpAddress(new Ipv4AddressNoZone("192.168.2.1"));
+ 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("192.168.2.1", new String(key.getIpAddress().getValue()));
+
+ }
+
+ private void defineDumpData() {
+ final LispMapResolverDetailsReplyDump replyDump = new LispMapResolverDetailsReplyDump();
+ final LispMapResolverDetails detail = new LispMapResolverDetails();
+ detail.context = 5;
+ detail.ipAddress = new byte[]{1, 2, -88, -64};
+ detail.isIpv6 = 0;
+
+ replyDump.lispMapResolverDetails = ImmutableList.of(detail);
+
+ when(api.lispMapResolverDump(any())).thenReturn(future(replyDump));
+ }
+
+ @Override
+ protected ReaderCustomizer<MapResolver, MapResolverBuilder> initCustomizer() {
+ return new MapResolverCustomizer(api);
+ }
+} \ No newline at end of file
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/PitrCfgCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/PitrCfgCustomizerTest.java
new file mode 100644
index 000000000..a752b736e
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/PitrCfgCustomizerTest.java
@@ -0,0 +1,62 @@
+package io.fd.honeycomb.lisp.translate.read;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.when;
+
+import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
+import io.fd.honeycomb.vpp.test.read.ReaderCustomizerTest;
+import java.nio.charset.StandardCharsets;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.LispStateBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.pitr.cfg.grouping.PitrCfg;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.pitr.cfg.grouping.PitrCfgBuilder;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.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;
+ private PitrCfg validData;
+
+ public PitrCfgCustomizerTest() {
+ super(PitrCfg.class, LispStateBuilder.class);
+ }
+
+ @Before
+ public void init() {
+ emptyId = InstanceIdentifier.create(PitrCfg.class);
+ validData = new PitrCfgBuilder().setLocatorSet("loc-set").build();
+
+ mockDumpData();
+ }
+
+ @Test
+ public void readCurrentAttributes() throws Exception {
+ PitrCfgBuilder builder = new PitrCfgBuilder();
+ getCustomizer().readCurrentAttributes(emptyId, builder, ctx);
+
+ final PitrCfg cfg = builder.build();
+
+ assertNotNull(cfg);
+ assertEquals("loc-set", cfg.getLocatorSet());
+ }
+
+ private void mockDumpData() {
+ ShowLispPitrReply replyDump = new ShowLispPitrReply();
+ replyDump.locatorSetName = LOC_SET_NAME_BYTES;
+ replyDump.status = 1;
+
+ when(api.showLispPitr(any())).thenReturn(future(replyDump));
+ }
+
+ @Override
+ protected ReaderCustomizer<PitrCfg, PitrCfgBuilder> initCustomizer() {
+ return new PitrCfgCustomizer(api);
+ }
+} \ No newline at end of file
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/RemoteMappingCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/RemoteMappingCustomizerTest.java
new file mode 100644
index 000000000..ea3a1e002
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/RemoteMappingCustomizerTest.java
@@ -0,0 +1,125 @@
+package io.fd.honeycomb.lisp.translate.read;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.when;
+
+import com.google.common.collect.ImmutableList;
+import io.fd.honeycomb.lisp.context.util.EidMappingContext;
+import io.fd.honeycomb.lisp.translate.util.EidTranslator;
+import io.fd.honeycomb.translate.MappingContext;
+import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
+import io.fd.honeycomb.vpp.test.read.ListReaderCustomizerTest;
+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.rev160520.MappingId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.EidTable;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.VniTable;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.VniTableKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.RemoteMappings;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.RemoteMappingsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.RemoteMapping;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.RemoteMappingBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.RemoteMappingKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.remote.mapping.Eid;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.jvpp.core.dto.LispEidTableDetails;
+import org.openvpp.jvpp.core.dto.LispEidTableDetailsReplyDump;
+
+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> emptyId;
+ private InstanceIdentifier<RemoteMapping> validId;
+
+ public RemoteMappingCustomizerTest() {
+ super(RemoteMapping.class, RemoteMappingsBuilder.class);
+ }
+
+ @Before
+ public void init() {
+
+ emptyId = InstanceIdentifier.create(EidTable.class)
+ .child(VniTable.class, new VniTableKey(12L))
+ .child(RemoteMappings.class)
+ .child(RemoteMapping.class);
+
+ validId = InstanceIdentifier.create(EidTable.class)
+ .child(VniTable.class, new VniTableKey(12L))
+ .child(RemoteMappings.class)
+ .child(RemoteMapping.class, new RemoteMappingKey(new MappingId("remote-mapping")));
+
+ mockDumpData();
+ mockMappings();
+ }
+
+
+ private void mockDumpData() {
+ 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));
+ }
+
+ 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 readCurrentAttributes() throws Exception {
+ 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());
+ }
+
+
+ @Test
+ public void getAllIds() throws Exception {
+ 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, eidMappingContext);
+ }
+} \ No newline at end of file
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/VniTableCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/VniTableCustomizerTest.java
new file mode 100644
index 000000000..c83887a6e
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/VniTableCustomizerTest.java
@@ -0,0 +1,75 @@
+package io.fd.honeycomb.lisp.translate.read;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.when;
+
+import com.google.common.collect.ImmutableList;
+import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
+import io.fd.honeycomb.vpp.test.read.ListReaderCustomizerTest;
+import java.util.List;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.EidTable;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.EidTableBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.VniTable;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.VniTableBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.VniTableKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.jvpp.core.dto.LispEidTableMapDetails;
+import org.openvpp.jvpp.core.dto.LispEidTableMapDetailsReplyDump;
+
+
+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(2L));
+
+ final LispEidTableMapDetailsReplyDump replyDump = new LispEidTableMapDetailsReplyDump();
+ final LispEidTableMapDetails detail = new LispEidTableMapDetails();
+ detail.dpTable = 3;
+ detail.vni = 2;
+ detail.context = 4;
+ replyDump.lispEidTableMapDetails = ImmutableList.of(detail);
+
+ when(api.lispEidTableMapDump(any())).thenReturn(future(replyDump));
+ }
+
+ @Test
+ public void getAllIds() throws Exception {
+ final List<VniTableKey> keys = getCustomizer().getAllIds(validId, ctx);
+
+ assertEquals(1, keys.size());
+
+ final VniTableKey key = keys.get(0);
+ assertNotNull(key);
+ //due to ambigous call (long,long) vs (Object,Object)
+ assertEquals(2L, key.getVirtualNetworkIdentifier().longValue());
+
+ }
+
+ @Test
+ public void readCurrentAttributes() throws Exception {
+ VniTableBuilder builder = new VniTableBuilder();
+ getCustomizer().readCurrentAttributes(validId, builder, ctx);
+
+ final VniTable table = builder.build();
+
+ assertNotNull(table);
+ assertEquals(3L, table.getTableId().longValue());
+ assertEquals(2L, table.getVirtualNetworkIdentifier().longValue());
+ }
+
+ @Override
+ protected ReaderCustomizer<VniTable, VniTableBuilder> initCustomizer() {
+ return new VniTableCustomizer(api);
+ }
+} \ No newline at end of file
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/dump/check/LocatorDumpCheckTest.java b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/dump/check/LocatorDumpCheckTest.java
new file mode 100644
index 000000000..8c52eb930
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/dump/check/LocatorDumpCheckTest.java
@@ -0,0 +1,25 @@
+package io.fd.honeycomb.lisp.translate.read.dump.check;
+
+import io.fd.honeycomb.vpp.test.read.DumpCheckTest;
+import org.openvpp.jvpp.core.dto.LispLocatorDetailsReplyDump;
+
+public class LocatorDumpCheckTest extends DumpCheckTest<LocatorDumpCheck, LispLocatorDetailsReplyDump> {
+
+ @Override
+ protected LocatorDumpCheck initCheck() {
+ return new LocatorDumpCheck();
+ }
+
+ @Override
+ protected LispLocatorDetailsReplyDump initEmptyData() {
+ final LispLocatorDetailsReplyDump replyDump = new LispLocatorDetailsReplyDump();
+ replyDump.lispLocatorDetails = null;
+
+ return replyDump;
+ }
+
+ @Override
+ protected LispLocatorDetailsReplyDump initValidData() {
+ return new LispLocatorDetailsReplyDump();
+ }
+} \ No newline at end of file
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/dump/check/LocatorSetsDumpCheckTest.java b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/dump/check/LocatorSetsDumpCheckTest.java
new file mode 100644
index 000000000..f932c22e5
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/dump/check/LocatorSetsDumpCheckTest.java
@@ -0,0 +1,26 @@
+package io.fd.honeycomb.lisp.translate.read.dump.check;
+
+import io.fd.honeycomb.vpp.test.read.DumpCheckTest;
+import org.openvpp.jvpp.core.dto.LispLocatorSetDetailsReplyDump;
+
+
+public class LocatorSetsDumpCheckTest extends DumpCheckTest<LocatorSetsDumpCheck, LispLocatorSetDetailsReplyDump> {
+
+ @Override
+ protected LocatorSetsDumpCheck initCheck() {
+ return new LocatorSetsDumpCheck();
+ }
+
+ @Override
+ protected LispLocatorSetDetailsReplyDump initEmptyData() {
+ final LispLocatorSetDetailsReplyDump replyDump = new LispLocatorSetDetailsReplyDump();
+ replyDump.lispLocatorSetDetails = null;
+
+ return replyDump;
+ }
+
+ @Override
+ protected LispLocatorSetDetailsReplyDump initValidData() {
+ return new LispLocatorSetDetailsReplyDump();
+ }
+} \ No newline at end of file
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/dump/check/MapResolverDumpCheckTest.java b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/dump/check/MapResolverDumpCheckTest.java
new file mode 100644
index 000000000..236f3c494
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/dump/check/MapResolverDumpCheckTest.java
@@ -0,0 +1,26 @@
+package io.fd.honeycomb.lisp.translate.read.dump.check;
+
+import io.fd.honeycomb.vpp.test.read.DumpCheckTest;
+import org.openvpp.jvpp.core.dto.LispMapResolverDetailsReplyDump;
+
+
+public class MapResolverDumpCheckTest extends DumpCheckTest<MapResolverDumpCheck, LispMapResolverDetailsReplyDump> {
+
+ @Override
+ protected MapResolverDumpCheck initCheck() {
+ return new MapResolverDumpCheck();
+ }
+
+ @Override
+ protected LispMapResolverDetailsReplyDump initEmptyData() {
+ final LispMapResolverDetailsReplyDump replyDump = new LispMapResolverDetailsReplyDump();
+ replyDump.lispMapResolverDetails = null;
+
+ return replyDump;
+ }
+
+ @Override
+ protected LispMapResolverDetailsReplyDump initValidData() {
+ return new LispMapResolverDetailsReplyDump();
+ }
+} \ No newline at end of file
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/dump/check/MappingsDumpCheckTest.java b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/dump/check/MappingsDumpCheckTest.java
new file mode 100644
index 000000000..6378e5f6b
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/dump/check/MappingsDumpCheckTest.java
@@ -0,0 +1,26 @@
+package io.fd.honeycomb.lisp.translate.read.dump.check;
+
+import io.fd.honeycomb.vpp.test.read.DumpCheckTest;
+import org.openvpp.jvpp.core.dto.LispEidTableDetailsReplyDump;
+
+
+public class MappingsDumpCheckTest extends DumpCheckTest<MappingsDumpCheck, LispEidTableDetailsReplyDump> {
+
+ @Override
+ protected MappingsDumpCheck initCheck() {
+ return new MappingsDumpCheck();
+ }
+
+ @Override
+ protected LispEidTableDetailsReplyDump initEmptyData() {
+ final LispEidTableDetailsReplyDump replyDump = new LispEidTableDetailsReplyDump();
+ replyDump.lispEidTableDetails = null;
+
+ return replyDump;
+ }
+
+ @Override
+ protected LispEidTableDetailsReplyDump initValidData() {
+ return new LispEidTableDetailsReplyDump();
+ }
+} \ No newline at end of file
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/dump/check/VniTableDumpCheckTest.java b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/dump/check/VniTableDumpCheckTest.java
new file mode 100644
index 000000000..5f70e8a1e
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/dump/check/VniTableDumpCheckTest.java
@@ -0,0 +1,26 @@
+package io.fd.honeycomb.lisp.translate.read.dump.check;
+
+import io.fd.honeycomb.vpp.test.read.DumpCheckTest;
+import org.openvpp.jvpp.core.dto.LispEidTableMapDetailsReplyDump;
+
+
+public class VniTableDumpCheckTest extends DumpCheckTest<VniTableDumpCheck, LispEidTableMapDetailsReplyDump> {
+
+ @Override
+ protected VniTableDumpCheck initCheck() {
+ return new VniTableDumpCheck();
+ }
+
+ @Override
+ protected LispEidTableMapDetailsReplyDump initEmptyData() {
+ final LispEidTableMapDetailsReplyDump replyDump = new LispEidTableMapDetailsReplyDump();
+ replyDump.lispEidTableMapDetails = null;
+
+ return replyDump;
+ }
+
+ @Override
+ protected LispEidTableMapDetailsReplyDump initValidData() {
+ return new LispEidTableMapDetailsReplyDump();
+ }
+} \ No newline at end of file
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/dump/executor/LocatorDumpExecutorTest.java b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/dump/executor/LocatorDumpExecutorTest.java
new file mode 100644
index 000000000..efa655bf1
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/dump/executor/LocatorDumpExecutorTest.java
@@ -0,0 +1,105 @@
+package io.fd.honeycomb.lisp.translate.read.dump.executor;
+
+
+import static io.fd.honeycomb.lisp.translate.read.dump.executor.params.LocatorDumpParams.LocatorDumpParamsBuilder;
+import static org.junit.Assert.assertArrayEquals;
+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.times;
+import static org.mockito.Mockito.verify;
+
+import com.google.common.collect.ImmutableList;
+import io.fd.honeycomb.lisp.translate.read.dump.executor.params.LocatorDumpParams;
+import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.DumpExecutionFailedException;
+import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.i.DumpCallFailedException;
+import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.i.DumpTimeoutException;
+import io.fd.honeycomb.vpp.test.read.JvppDumpExecutorTest;
+import java.util.concurrent.TimeoutException;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Captor;
+import org.mockito.Mockito;
+import org.openvpp.jvpp.core.dto.LispLocatorDetails;
+import org.openvpp.jvpp.core.dto.LispLocatorDetailsReplyDump;
+import org.openvpp.jvpp.core.dto.LispLocatorDump;
+
+
+public class LocatorDumpExecutorTest extends JvppDumpExecutorTest<LocatorDumpExecutor> {
+
+ @Captor
+ private ArgumentCaptor<LispLocatorDump> requestCaptor;
+
+ private LispLocatorDetailsReplyDump validDump;
+
+ @Before
+ public void init() {
+ validDump = new LispLocatorDetailsReplyDump();
+ LispLocatorDetails detail = new LispLocatorDetails();
+
+ detail.swIfIndex = 1;
+ detail.priority = 2;
+ detail.local = 1;
+ detail.weight = 3;
+ detail.isIpv6 = 0;
+ detail.context = 8;
+ detail.ipAddress = new byte[]{-64, -88, 4, 2};
+
+ validDump.lispLocatorDetails = ImmutableList.of(detail);
+ }
+
+ @Test
+ public void testExecuteDumpTimeout() throws Exception {
+ doThrowTimeoutExceptionWhen().lispLocatorDump(Mockito.any());
+ try {
+ getExecutor().executeDump(new LocatorDumpParamsBuilder().build());
+ } catch (Exception e) {
+ assertTrue(e instanceof DumpTimeoutException);
+ assertTrue(e.getCause() instanceof TimeoutException);
+ return;
+ }
+ fail("Test should have thrown exception");
+ }
+
+ @Test(expected = DumpCallFailedException.class)
+ public void testExecuteDumpHalted() throws DumpExecutionFailedException {
+ doThrowFailExceptionWhen().lispLocatorDump(Mockito.any());
+ getExecutor().executeDump(new LocatorDumpParamsBuilder().build());
+ }
+
+ @Test
+ public void testExecuteDump() throws DumpExecutionFailedException {
+ doReturnResponseWhen(validDump).lispLocatorDump(Mockito.any());
+
+ final LocatorDumpParams params = new LocatorDumpParamsBuilder().setLocatorSetIndex(5).build();
+
+ final LispLocatorDetailsReplyDump reply = getExecutor().executeDump(params);
+ verify(api, times(1)).lispLocatorDump(requestCaptor.capture());
+
+ final LispLocatorDump request = requestCaptor.getValue();
+
+ //check passed params
+ assertNotNull(request);
+ assertEquals(5, request.lsIndex);
+
+ //check result
+ assertNotNull(reply);
+ assertEquals(1, reply.lispLocatorDetails.size());
+
+ final LispLocatorDetails details = reply.lispLocatorDetails.get(0);
+ assertEquals(1, details.swIfIndex);
+ assertEquals(2, details.priority);
+ assertEquals(1, details.local);
+ assertEquals(3, details.weight);
+ assertEquals(0, details.isIpv6);
+ assertEquals(8, details.context);
+ assertArrayEquals(new byte[]{-64, -88, 4, 2}, details.ipAddress);
+ }
+
+ @Override
+ protected LocatorDumpExecutor initExecutor() {
+ return new LocatorDumpExecutor(api);
+ }
+} \ No newline at end of file
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/dump/executor/LocatorSetsDumpExecutorTest.java b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/dump/executor/LocatorSetsDumpExecutorTest.java
new file mode 100644
index 000000000..5daf77a3d
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/dump/executor/LocatorSetsDumpExecutorTest.java
@@ -0,0 +1,95 @@
+package io.fd.honeycomb.lisp.translate.read.dump.executor;
+
+
+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.any;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
+import com.google.common.collect.ImmutableList;
+import io.fd.honeycomb.translate.util.read.cache.EntityDumpExecutor;
+import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.DumpExecutionFailedException;
+import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.i.DumpCallFailedException;
+import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.i.DumpTimeoutException;
+import io.fd.honeycomb.vpp.test.read.JvppDumpExecutorTest;
+import java.nio.charset.StandardCharsets;
+import java.util.concurrent.TimeoutException;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Captor;
+import org.openvpp.jvpp.core.dto.LispLocatorSetDetails;
+import org.openvpp.jvpp.core.dto.LispLocatorSetDetailsReplyDump;
+import org.openvpp.jvpp.core.dto.LispLocatorSetDump;
+
+
+public class LocatorSetsDumpExecutorTest extends JvppDumpExecutorTest<LocatorSetsDumpExecutor> {
+
+ public static final byte[] LOCATOR_SET_NAME_BYTES = "loc-set".getBytes(StandardCharsets.UTF_8);
+
+ private LispLocatorSetDetailsReplyDump validDump;
+
+ @Captor
+ private ArgumentCaptor<LispLocatorSetDump> requestCaptor;
+
+ @Before
+ public void init() {
+ validDump = new LispLocatorSetDetailsReplyDump();
+ LispLocatorSetDetails detail = new LispLocatorSetDetails();
+ detail.lsIndex = 2;
+ detail.lsName = LOCATOR_SET_NAME_BYTES;
+ detail.context = 4;
+
+ validDump.lispLocatorSetDetails = ImmutableList.of(detail);
+ }
+
+ @Test
+ public void testExecuteDumpTimeout() throws Exception {
+ doThrowTimeoutExceptionWhen().lispLocatorSetDump(any());
+ try {
+ getExecutor().executeDump(EntityDumpExecutor.NO_PARAMS);
+ } catch (Exception e) {
+ assertTrue(e instanceof DumpTimeoutException);
+ assertTrue(e.getCause() instanceof TimeoutException);
+ return;
+ }
+ fail("Test should have thrown exception");
+ }
+
+ @Test(expected = DumpCallFailedException.class)
+ public void testExecuteDumpHalted() throws DumpExecutionFailedException {
+ doThrowFailExceptionWhen().lispLocatorSetDump(any());
+ getExecutor().executeDump(EntityDumpExecutor.NO_PARAMS);
+ }
+
+ @Test
+ public void testExecuteDump() throws DumpExecutionFailedException {
+ doReturnResponseWhen(validDump).lispLocatorSetDump(any());
+
+ final LispLocatorSetDetailsReplyDump replyDump = getExecutor().executeDump(EntityDumpExecutor.NO_PARAMS);
+ verify(api, times(1)).lispLocatorSetDump(requestCaptor.capture());
+
+ final LispLocatorSetDump request = requestCaptor.getValue();
+
+ assertNotNull(request);
+ assertEquals(1, request.filter);
+
+ assertNotNull(replyDump);
+ assertNotNull(replyDump.lispLocatorSetDetails);
+ assertEquals(1, replyDump.lispLocatorSetDetails.size());
+ final LispLocatorSetDetails detail = replyDump.lispLocatorSetDetails.get(0);
+
+ assertNotNull(detail);
+ assertEquals(4, detail.context);
+ assertEquals(2, detail.lsIndex);
+ assertEquals(LOCATOR_SET_NAME_BYTES, detail.lsName);
+ }
+
+ @Override
+ protected LocatorSetsDumpExecutor initExecutor() {
+ return new LocatorSetsDumpExecutor(api);
+ }
+} \ No newline at end of file
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/dump/executor/MapResolversDumpExecutorTest.java b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/dump/executor/MapResolversDumpExecutorTest.java
new file mode 100644
index 000000000..446300365
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/dump/executor/MapResolversDumpExecutorTest.java
@@ -0,0 +1,76 @@
+package io.fd.honeycomb.lisp.translate.read.dump.executor;
+
+
+import static org.junit.Assert.assertArrayEquals;
+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 com.google.common.collect.ImmutableList;
+import io.fd.honeycomb.translate.util.read.cache.EntityDumpExecutor;
+import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.DumpExecutionFailedException;
+import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.i.DumpCallFailedException;
+import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.i.DumpTimeoutException;
+import io.fd.honeycomb.vpp.test.read.JvppDumpExecutorTest;
+import java.util.concurrent.TimeoutException;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.openvpp.jvpp.core.dto.LispMapResolverDetails;
+import org.openvpp.jvpp.core.dto.LispMapResolverDetailsReplyDump;
+
+
+public class MapResolversDumpExecutorTest extends JvppDumpExecutorTest<MapResolversDumpExecutor> {
+
+ private LispMapResolverDetailsReplyDump validDump;
+
+ @Before
+ public void init() {
+ validDump = new LispMapResolverDetailsReplyDump();
+ final LispMapResolverDetails details = new LispMapResolverDetails();
+ details.isIpv6 = 0;
+ details.ipAddress = new byte[]{-64, -88, 5, 4};
+ details.context = 7;
+
+ validDump.lispMapResolverDetails = ImmutableList.of(details);
+ }
+
+ @Test
+ public void testExecuteDumpTimeout() throws Exception {
+ doThrowTimeoutExceptionWhen().lispMapResolverDump(Mockito.any());
+ try {
+ getExecutor().executeDump(EntityDumpExecutor.NO_PARAMS);
+ } catch (Exception e) {
+ assertTrue(e instanceof DumpTimeoutException);
+ assertTrue(e.getCause() instanceof TimeoutException);
+ return;
+ }
+ fail("Test should have thrown exception");
+ }
+
+ @Test(expected = DumpCallFailedException.class)
+ public void testExecuteDumpHalted() throws DumpExecutionFailedException {
+ doThrowFailExceptionWhen().lispMapResolverDump(Mockito.any());
+ getExecutor().executeDump(EntityDumpExecutor.NO_PARAMS);
+ }
+
+ @Test
+ public void testExecuteDump() throws DumpExecutionFailedException {
+ doReturnResponseWhen(validDump).lispMapResolverDump(Mockito.any());
+ final LispMapResolverDetailsReplyDump reply = getExecutor().executeDump(EntityDumpExecutor.NO_PARAMS);
+
+ assertNotNull(reply);
+ assertEquals(1, reply.lispMapResolverDetails.size());
+
+ final LispMapResolverDetails detail = reply.lispMapResolverDetails.get(0);
+ assertEquals(7, detail.context);
+ assertEquals(0, detail.isIpv6);
+ assertArrayEquals(new byte[]{-64, -88, 5, 4}, detail.ipAddress);
+ }
+
+ @Override
+ protected MapResolversDumpExecutor initExecutor() {
+ return new MapResolversDumpExecutor(api);
+ }
+} \ No newline at end of file
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/dump/executor/MappingsDumpExecutorTest.java b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/dump/executor/MappingsDumpExecutorTest.java
new file mode 100644
index 000000000..85b22fa7e
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/dump/executor/MappingsDumpExecutorTest.java
@@ -0,0 +1,121 @@
+package io.fd.honeycomb.lisp.translate.read.dump.executor;
+
+import static io.fd.honeycomb.lisp.translate.read.dump.executor.params.MappingsDumpParams.EidType;
+import static io.fd.honeycomb.lisp.translate.read.dump.executor.params.MappingsDumpParams.FilterType;
+import static io.fd.honeycomb.lisp.translate.read.dump.executor.params.MappingsDumpParams.MappingsDumpParamsBuilder;
+import static io.fd.honeycomb.lisp.translate.read.dump.executor.params.MappingsDumpParams.QuantityType;
+import static org.junit.Assert.assertArrayEquals;
+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 com.google.common.collect.ImmutableList;
+import io.fd.honeycomb.lisp.translate.read.dump.executor.params.MappingsDumpParams;
+import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.DumpExecutionFailedException;
+import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.i.DumpCallFailedException;
+import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.i.DumpTimeoutException;
+import io.fd.honeycomb.vpp.test.read.JvppDumpExecutorTest;
+import java.util.concurrent.TimeoutException;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Captor;
+import org.openvpp.jvpp.core.dto.LispEidTableDetails;
+import org.openvpp.jvpp.core.dto.LispEidTableDetailsReplyDump;
+import org.openvpp.jvpp.core.dto.LispEidTableDump;
+
+public class MappingsDumpExecutorTest extends JvppDumpExecutorTest<MappingsDumpExecutor> {
+
+ private static final byte[] EID = {-64, -88, 2, 1};
+
+ @Captor
+ private ArgumentCaptor<LispEidTableDump> requestCaptor;
+
+ private LispEidTableDetailsReplyDump validDump;
+ private MappingsDumpParams emptyParams;
+ private MappingsDumpParams validParams;
+
+ @Before
+ public void init() {
+ validDump = 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 = 1;
+ detail.locatorSetIndex = 2;
+ detail.ttl = 7;
+ detail.vni = 2;
+
+ validDump.lispEidTableDetails = ImmutableList.of(detail);
+
+ emptyParams = MappingsDumpParamsBuilder.newInstance().build();
+ validParams =
+ MappingsDumpParamsBuilder.newInstance().setVni(2).setPrefixLength((byte) 32).setEidSet(QuantityType.ALL)
+ .setEid(EID)
+ .setEidType(EidType.IPV4).setFilter(FilterType.LOCAL).build();
+ }
+
+ @Test
+ public void testExecuteDumpTimeout() throws Exception {
+ doThrowTimeoutExceptionWhen().lispEidTableDump(any());
+ try {
+ getExecutor().executeDump(emptyParams);
+ } catch (Exception e) {
+ assertTrue(e instanceof DumpTimeoutException);
+ assertTrue(e.getCause() instanceof TimeoutException);
+ return;
+ }
+ fail("Test should have thrown exception");
+ }
+
+ @Test(expected = DumpCallFailedException.class)
+ public void testExecuteDumpHalted() throws DumpExecutionFailedException {
+ doThrowFailExceptionWhen().lispEidTableDump(any());
+ getExecutor().executeDump(emptyParams);
+ }
+
+ @Test
+ public void testExecuteDump() throws DumpExecutionFailedException {
+ doReturnResponseWhen(validDump).lispEidTableDump(any());
+ final LispEidTableDetailsReplyDump reply = getExecutor().executeDump(validParams);
+ verify(api, times(1)).lispEidTableDump(requestCaptor.capture());
+
+ final LispEidTableDump request = requestCaptor.getValue();
+ assertNotNull(request);
+ assertEquals(2, request.vni);
+ assertEquals(QuantityType.ALL.getValue(), request.eidSet);
+ assertArrayEquals(EID, request.eid);
+ assertEquals(EidType.IPV4.getValue(), request.eidType);
+ assertEquals(FilterType.LOCAL.getValue(), request.filter);
+ assertEquals(32, request.prefixLength);
+
+ assertNotNull(reply);
+ assertEquals(1, reply.lispEidTableDetails.size());
+
+ final LispEidTableDetails detail = reply.lispEidTableDetails.get(0);
+
+ assertNotNull(detail);
+ assertEquals(0, detail.action);
+ assertEquals(1, detail.authoritative);
+ assertEquals(4, detail.context);
+ assertArrayEquals(EID, detail.eid);
+ assertEquals(32, detail.eidPrefixLen);
+ assertEquals(1, detail.isLocal);
+ assertEquals(2, detail.locatorSetIndex);
+ assertEquals(7, detail.ttl);
+ assertEquals(2, detail.vni);
+ }
+
+ @Override
+ protected MappingsDumpExecutor initExecutor() {
+ return new MappingsDumpExecutor(api);
+ }
+} \ No newline at end of file
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/dump/executor/VniTableDumpExecutorTest.java b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/dump/executor/VniTableDumpExecutorTest.java
new file mode 100644
index 000000000..13033bf65
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/dump/executor/VniTableDumpExecutorTest.java
@@ -0,0 +1,76 @@
+package io.fd.honeycomb.lisp.translate.read.dump.executor;
+
+
+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 com.google.common.collect.ImmutableList;
+import io.fd.honeycomb.translate.util.read.cache.EntityDumpExecutor;
+import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.DumpExecutionFailedException;
+import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.i.DumpCallFailedException;
+import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.i.DumpTimeoutException;
+import io.fd.honeycomb.vpp.test.read.JvppDumpExecutorTest;
+import java.util.concurrent.TimeoutException;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.openvpp.jvpp.core.dto.LispEidTableMapDetails;
+import org.openvpp.jvpp.core.dto.LispEidTableMapDetailsReplyDump;
+
+
+public class VniTableDumpExecutorTest extends JvppDumpExecutorTest<VniTableDumpExecutor> {
+
+ private LispEidTableMapDetailsReplyDump validDump;
+
+ @Before
+ public void init() {
+ validDump = new LispEidTableMapDetailsReplyDump();
+ LispEidTableMapDetails detail = new LispEidTableMapDetails();
+ detail.dpTable = 1;
+ detail.vni = 2;
+ detail.context = 4;
+ validDump.lispEidTableMapDetails = ImmutableList.of(detail);
+ }
+
+ @Test(expected = DumpCallFailedException.class)
+ public void testExecuteDumpFail() throws DumpExecutionFailedException {
+ doThrowFailExceptionWhen().lispEidTableMapDump(Mockito.any());
+ getExecutor().executeDump(EntityDumpExecutor.NO_PARAMS);
+ }
+
+
+ @Test
+ public void testExecuteDumpTimeout() throws Exception {
+ doThrowTimeoutExceptionWhen().lispEidTableMapDump(Mockito.any());
+ try {
+ getExecutor().executeDump(EntityDumpExecutor.NO_PARAMS);
+ } catch (Exception e) {
+ assertTrue(e instanceof DumpTimeoutException);
+ assertTrue(e.getCause() instanceof TimeoutException);
+ return;
+ }
+ fail("Test should have thrown exception");
+ }
+
+ @Test
+ public void testExecuteDump() throws DumpExecutionFailedException {
+
+ doReturnResponseWhen(validDump).lispEidTableMapDump(Mockito.any());
+ final LispEidTableMapDetailsReplyDump reply = getExecutor().executeDump(EntityDumpExecutor.NO_PARAMS);
+
+ assertNotNull(reply);
+ assertEquals(1, reply.lispEidTableMapDetails.size());
+ final LispEidTableMapDetails detail = reply.lispEidTableMapDetails.get(0);
+
+ assertEquals(4, detail.context);
+ assertEquals(1, detail.dpTable);
+ assertEquals(2, detail.vni);
+ }
+
+ @Override
+ protected VniTableDumpExecutor initExecutor() {
+ return new VniTableDumpExecutor(api);
+ }
+} \ No newline at end of file
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/AdjacencyCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/AdjacencyCustomizerTest.java
new file mode 100644
index 000000000..d6c5816e1
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/AdjacencyCustomizerTest.java
@@ -0,0 +1,129 @@
+package io.fd.honeycomb.lisp.translate.write;
+
+import static io.fd.honeycomb.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.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.vpp.test.write.WriterCustomizerTest;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Captor;
+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.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.rev160520.eid.table.grouping.EidTable;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.VniTable;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.VniTableKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.Adjacencies;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.adjacencies.Adjacency;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.adjacencies.AdjacencyBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.adjacencies.adjacency.LocalEidBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.adjacencies.adjacency.RemoteEidBuilder;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.jvpp.core.dto.LispAddDelAdjacency;
+import org.openvpp.jvpp.core.dto.LispAddDelAdjacencyReply;
+
+public class AdjacencyCustomizerTest extends WriterCustomizerTest {
+
+ @Captor
+ private ArgumentCaptor<LispAddDelAdjacency> requestCaptor;
+
+ private AdjacencyCustomizer customizer;
+
+ private InstanceIdentifier<Adjacency> emptyId;
+ private InstanceIdentifier<Adjacency> validId;
+
+ private Adjacency emptyData;
+ private Adjacency invalidData;
+ private Adjacency validData;
+
+ @Before
+ public void init() {
+ customizer = new AdjacencyCustomizer(api);
+
+ emptyId = InstanceIdentifier.create(Adjacency.class);
+ validId = InstanceIdentifier.create(EidTable.class)
+ .child(VniTable.class, new VniTableKey(2L))
+ .child(Adjacencies.class)
+ .child(Adjacency.class);
+
+ emptyData = new AdjacencyBuilder().build();
+
+ invalidData = new AdjacencyBuilder().setId("ID").setLocalEid(
+ new LocalEidBuilder().setAddress(new Ipv4Builder().setIpv4(new Ipv4Address("192.168.2.1")).build())
+ .build()).setRemoteEid(
+ new RemoteEidBuilder().setAddress(new MacBuilder().setMac(new MacAddress("aa:aa:aa:aa:aa:aa")).build())
+ .build())
+ .build();
+
+ validData = new AdjacencyBuilder().setId("ID").setLocalEid(
+ new LocalEidBuilder().setAddress(new Ipv4Builder().setIpv4(new Ipv4Address("192.168.2.1")).build())
+ .build()).setRemoteEid(
+ new RemoteEidBuilder()
+ .setAddress(new Ipv4Builder().setIpv4(new Ipv4Address("192.168.5.2")).build()).build()).build();
+
+ when(api.lispAddDelAdjacency(any())).thenReturn(future(new LispAddDelAdjacencyReply()));
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void writeCurrentAttributesNoKey() throws Exception {
+ customizer.writeCurrentAttributes(emptyId, emptyData, writeContext);
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void writeCurrentAttributesInvalidCombination() throws Exception {
+ customizer.writeCurrentAttributes(emptyId, invalidData, writeContext);
+ }
+
+ @Test
+ public void writeCurrentAttributes() throws Exception {
+ 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, 5, 2},
+ 32, IPV4.getValue(), 2);
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void updateCurrentAttributes() throws Exception {
+ customizer.updateCurrentAttributes(emptyId, emptyData, emptyData, writeContext);
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void deleteCurrentAttributesNoKey() throws Exception {
+ customizer.deleteCurrentAttributes(emptyId, emptyData, writeContext);
+ }
+
+ @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, 5, 2},
+ 32, IPV4.getValue(), 2);
+ }
+
+ private static void verifyRequest(final LispAddDelAdjacency request, final int isAdd, final byte[] seid,
+ final int seidLen, final byte[] deid, final int deidLen, final int eidType,
+ final int vni) {
+
+ assertNotNull(request);
+ assertEquals(isAdd, request.isAdd);
+ assertArrayEquals(seid, request.seid);
+ assertEquals(seidLen, request.seidLen);
+ assertArrayEquals(deid, request.deid);
+ assertEquals(eidType, request.eidType);
+ assertEquals(vni, request.vni);
+
+ }
+} \ No newline at end of file
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/VniTableCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/VniTableCustomizerTest.java
new file mode 100644
index 000000000..a6bd5b967
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/VniTableCustomizerTest.java
@@ -0,0 +1,86 @@
+package io.fd.honeycomb.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.vpp.test.write.WriterCustomizerTest;
+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.rev160520.eid.table.grouping.eid.table.VniTable;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.VniTableBuilder;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.jvpp.core.dto.LispEidTableAddDelMap;
+import org.openvpp.jvpp.core.dto.LispEidTableAddDelMapReply;
+
+
+public class VniTableCustomizerTest extends WriterCustomizerTest {
+
+ @Captor
+ private ArgumentCaptor<LispEidTableAddDelMap> requestCaptor;
+
+ private VniTableCustomizer customizer;
+ private InstanceIdentifier<VniTable> emptyId;
+
+ private VniTable emptyData;
+ private VniTable validData;
+
+ @Before
+ public void init() {
+ customizer = new VniTableCustomizer(api);
+
+ emptyId = InstanceIdentifier.create(VniTable.class);
+
+ emptyData = new VniTableBuilder().build();
+ validData = new VniTableBuilder().setTableId(2L).setVirtualNetworkIdentifier(3L).build();
+
+ when(api.lispEidTableAddDelMap(any())).thenReturn(future(new LispEidTableAddDelMapReply()));
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testWriteCurrentAttributesEmptyData() throws Exception {
+ customizer.writeCurrentAttributes(emptyId, emptyData, writeContext);
+ }
+
+
+ @Test
+ public void testWriteCurrentAttributes() throws Exception {
+ customizer.writeCurrentAttributes(emptyId, validData, writeContext);
+ verify(api, times(1)).lispEidTableAddDelMap(requestCaptor.capture());
+ verifyRequest(requestCaptor.getValue(), (byte) 1, 2L, 3L);
+ }
+
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void testUpdateCurrentAttributes() throws Exception {
+ customizer.updateCurrentAttributes(emptyId, emptyData, emptyData, writeContext);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testDeleteCurrentAttributesEmptyData() throws Exception {
+ customizer.deleteCurrentAttributes(emptyId, emptyData, writeContext);
+ }
+
+ @Test
+ public void testDeleteCurrentAttributes() throws Exception {
+ customizer.deleteCurrentAttributes(emptyId, validData, writeContext);
+ verify(api, times(1)).lispEidTableAddDelMap(requestCaptor.capture());
+ verifyRequest(requestCaptor.getValue(), (byte) 0, 2L, 3L);
+ }
+
+ private static void verifyRequest(final LispEidTableAddDelMap request, final byte isAdd,
+ final long dpTable,
+ final long vni) {
+ assertNotNull(request);
+ assertEquals(isAdd, request.isAdd);
+ assertEquals(dpTable, request.dpTable);
+ assertEquals(vni, request.vni);
+
+ }
+
+} \ No newline at end of file
diff --git a/vpp-common/vpp-translate-test/pom.xml b/vpp-common/vpp-translate-test/pom.xml
index faa5b8b60..4dff6183d 100644
--- a/vpp-common/vpp-translate-test/pom.xml
+++ b/vpp-common/vpp-translate-test/pom.xml
@@ -14,7 +14,8 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>io.fd.honeycomb.vpp</groupId>
@@ -64,5 +65,10 @@
<version>4.12</version>
<scope>compile</scope>
</dependency>
+ <dependency>
+ <groupId>io.fd.honeycomb</groupId>
+ <artifactId>translate-utils</artifactId>
+ <version>${project.version}</version>
+ </dependency>
</dependencies>
</project>
diff --git a/vpp-common/vpp-translate-test/src/main/java/io/fd/honeycomb/vpp/test/read/DumpCheckTest.java b/vpp-common/vpp-translate-test/src/main/java/io/fd/honeycomb/vpp/test/read/DumpCheckTest.java
new file mode 100644
index 000000000..a21f49b6e
--- /dev/null
+++ b/vpp-common/vpp-translate-test/src/main/java/io/fd/honeycomb/vpp/test/read/DumpCheckTest.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.vpp.test.read;
+
+
+import io.fd.honeycomb.translate.util.read.cache.EntityDumpNonEmptyCheck;
+import io.fd.honeycomb.translate.util.read.cache.exceptions.check.DumpCheckFailedException;
+import io.fd.honeycomb.translate.util.read.cache.exceptions.check.i.DumpEmptyException;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Generic test for classes implementing {@link EntityDumpNonEmptyCheck}
+ *
+ * @param <T> implementations of {@link EntityDumpNonEmptyCheck}, that will be tested
+ * @param <U> data node handled by {@link EntityDumpNonEmptyCheck}
+ */
+public abstract class DumpCheckTest<T extends EntityDumpNonEmptyCheck<U>, U> {
+
+ private T check;
+ private U emptyData;
+ private U validData;
+
+ @Before
+ public void setupParent() {
+ this.check = initCheck();
+ this.emptyData = initEmptyData();
+ this.validData = initValidData();
+ }
+
+ @Test(expected = DumpEmptyException.class)
+ public void testWithNull() throws DumpCheckFailedException {
+ check.assertNotEmpty(null);
+ }
+
+ @Test(expected = DumpEmptyException.class)
+ public void testWithEmpty() throws DumpCheckFailedException {
+ check.assertNotEmpty(emptyData);
+ }
+
+ @Test
+ public void testWithValid() throws DumpCheckFailedException {
+ check.assertNotEmpty(validData);
+ }
+
+ /**
+ * Initialize new {@link EntityDumpNonEmptyCheck}.
+ */
+ protected abstract T initCheck();
+
+ /**
+ * Initialize data that should throw {@link DumpEmptyException} ,
+ * while beeing processed by {@link EntityDumpNonEmptyCheck}
+ */
+ protected abstract U initEmptyData();
+
+ /**
+ * Initialize data that should pass without exception ,
+ * while beeing processed by {@link EntityDumpNonEmptyCheck}
+ */
+ protected abstract U initValidData();
+
+
+ protected T getCheck() {
+ return this.check;
+ }
+}
diff --git a/vpp-common/vpp-translate-test/src/main/java/io/fd/honeycomb/vpp/test/read/JvppDumpExecutorTest.java b/vpp-common/vpp-translate-test/src/main/java/io/fd/honeycomb/vpp/test/read/JvppDumpExecutorTest.java
new file mode 100644
index 000000000..a3ab1fc3e
--- /dev/null
+++ b/vpp-common/vpp-translate-test/src/main/java/io/fd/honeycomb/vpp/test/read/JvppDumpExecutorTest.java
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.vpp.test.read;
+
+import static org.mockito.Matchers.anyLong;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import io.fd.honeycomb.translate.util.read.cache.EntityDumpExecutor;
+import io.fd.honeycomb.vpp.test.util.FutureProducer;
+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.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.openvpp.jvpp.VppInvocationException;
+import org.openvpp.jvpp.core.future.FutureJVppCore;
+
+/**
+ * Generic test for implementation of {@link EntityDumpExecutor}
+ *
+ * @param <T> implementation of {@link EntityDumpExecutor}
+ */
+public abstract class JvppDumpExecutorTest<T extends EntityDumpExecutor<?, ?>> implements FutureProducer {
+
+ @Mock
+ protected FutureJVppCore api;
+
+ private T executor;
+
+ @Before
+ public void setUpParent() {
+ MockitoAnnotations.initMocks(this);
+ this.executor = initExecutor();
+ }
+
+ protected abstract T initExecutor();
+
+ protected T getExecutor() {
+ return this.executor;
+ }
+
+ /**
+ * Return pre-stubed mock that will throw {@link TimeoutException},
+ * while performing desired method
+ */
+ protected FutureJVppCore doThrowTimeoutExceptionWhen()
+ throws InterruptedException, ExecutionException, TimeoutException {
+
+ CompletableFuture failedFuture = mock(CompletableFuture.class);
+ when(failedFuture.toCompletableFuture()).thenReturn(failedFuture);
+ when(failedFuture.get(anyLong(), eq(TimeUnit.SECONDS)))
+ .thenThrow(new TimeoutException("Exception invoked by " + JvppDumpExecutorTest.class.getName()));
+
+ return doReturn(failedFuture).when(api);
+ }
+
+ /**
+ * Return pre-stubed mock that will throw {@link VppInvocationException},
+ * while performing desired method
+ */
+ protected FutureJVppCore doThrowFailExceptionWhen() {
+ return doReturn(failedFuture(
+ new VppInvocationException("Exception invoked by " + JvppDumpExecutorTest.class.getName(), -1)))
+ .when(api);
+ }
+
+ /**
+ * Return pre-stubed mock that will return specified result
+ * while performing desired method
+ */
+ protected <U> FutureJVppCore doReturnResponseWhen(U replyDump) {
+ return doReturn(future(replyDump)).when(api);
+ }
+}