summaryrefslogtreecommitdiffstats
path: root/nat/nat2vpp/src/test/java/io/fd
diff options
context:
space:
mode:
Diffstat (limited to 'nat/nat2vpp/src/test/java/io/fd')
-rw-r--r--nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/read/MappingEntryCustomizerTest.java188
-rw-r--r--nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/read/NatInstanceCustomizerTest.java55
-rw-r--r--nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/util/MappingEntryContextTest.java6
3 files changed, 196 insertions, 53 deletions
diff --git a/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/read/MappingEntryCustomizerTest.java b/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/read/MappingEntryCustomizerTest.java
index 678d67bc2..05513b6e9 100644
--- a/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/read/MappingEntryCustomizerTest.java
+++ b/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/read/MappingEntryCustomizerTest.java
@@ -27,10 +27,13 @@ import io.fd.hc2vpp.nat.util.MappingEntryContext;
import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
import io.fd.honeycomb.translate.util.read.cache.DumpCacheManager;
import io.fd.honeycomb.translate.util.read.cache.EntityDumpExecutor;
+import io.fd.vpp.jvpp.snat.dto.Nat64BibDetails;
+import io.fd.vpp.jvpp.snat.dto.Nat64BibDetailsReplyDump;
import io.fd.vpp.jvpp.snat.dto.SnatStaticMappingDetails;
import io.fd.vpp.jvpp.snat.dto.SnatStaticMappingDetailsReplyDump;
import java.util.Arrays;
import java.util.List;
+import java.util.Optional;
import org.junit.Test;
import org.mockito.Mock;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.nat.rev150908.nat.state.NatInstances;
@@ -45,18 +48,22 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.nat.rev1509
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
public class MappingEntryCustomizerTest
- extends InitializingListReaderCustomizerTest<MappingEntry, MappingEntryKey, MappingEntryBuilder> {
+ extends InitializingListReaderCustomizerTest<MappingEntry, MappingEntryKey, MappingEntryBuilder> {
private static final long NAT_MAPPING_ID = 2L;
private InstanceIdentifier<MappingEntry> mappingEntryId;
private InstanceIdentifier<MappingEntry> mappingEntryWildcarded;
- private DumpCacheManager<SnatStaticMappingDetailsReplyDump, Void> dumpCacheManager;
+ private DumpCacheManager<SnatStaticMappingDetailsReplyDump, Void> nat44DumpManager;
+ private DumpCacheManager<Nat64BibDetailsReplyDump, Void> nat64DumpManager;
@Mock
private MappingEntryContext mappingContext;
@Mock
- private EntityDumpExecutor<SnatStaticMappingDetailsReplyDump, Void> dumpExecutor;
+ private EntityDumpExecutor<SnatStaticMappingDetailsReplyDump, Void> nat44DumpExecutor;
+
+ @Mock
+ private EntityDumpExecutor<Nat64BibDetailsReplyDump, Void> nat64DumpExecutor;
public MappingEntryCustomizerTest() {
super(MappingEntry.class, MappingTableBuilder.class);
@@ -65,90 +72,199 @@ public class MappingEntryCustomizerTest
@Override
protected void setUp() throws Exception {
mappingEntryId = InstanceIdentifier.create(NatInstances.class)
- .child(NatInstance.class, new NatInstanceKey(NatInstanceCustomizer.DEFAULT_VRF_ID))
- .child(MappingTable.class)
- .child(MappingEntry.class, new MappingEntryKey(NAT_MAPPING_ID));
+ .child(NatInstance.class, new NatInstanceKey(NatInstanceCustomizer.DEFAULT_VRF_ID))
+ .child(MappingTable.class)
+ .child(MappingEntry.class, new MappingEntryKey(NAT_MAPPING_ID));
mappingEntryWildcarded = InstanceIdentifier.create(NatInstances.class)
- .child(NatInstance.class, new NatInstanceKey(NatInstanceCustomizer.DEFAULT_VRF_ID))
- .child(MappingTable.class)
- .child(MappingEntry.class);
- dumpCacheManager = new DumpCacheManager.DumpCacheManagerBuilder<SnatStaticMappingDetailsReplyDump, Void>()
- .withExecutor(dumpExecutor)
- .acceptOnly(SnatStaticMappingDetailsReplyDump.class)
- .build();
+ .child(NatInstance.class, new NatInstanceKey(NatInstanceCustomizer.DEFAULT_VRF_ID))
+ .child(MappingTable.class)
+ .child(MappingEntry.class);
+ nat44DumpManager = new DumpCacheManager.DumpCacheManagerBuilder<SnatStaticMappingDetailsReplyDump, Void>()
+ .withExecutor(nat44DumpExecutor)
+ .acceptOnly(SnatStaticMappingDetailsReplyDump.class)
+ .build();
+ nat64DumpManager = new DumpCacheManager.DumpCacheManagerBuilder<Nat64BibDetailsReplyDump, Void>()
+ .withExecutor(nat64DumpExecutor)
+ .acceptOnly(Nat64BibDetailsReplyDump.class)
+ .build();
}
@Test
- public void testReadAttributes() throws Exception {
- final SnatStaticMappingDetailsReplyDump dump = dumpNonEmptyDefaultInstance();
- when(dumpExecutor.executeDump(mappingEntryId, null)).thenReturn(dump);
+ public void testReadNat44() throws Exception {
+ final SnatStaticMappingDetailsReplyDump dumpNat44 = dumpReplyNat44NonEmpty();
+ when(nat44DumpExecutor.executeDump(mappingEntryId, null)).thenReturn(dumpNat44);
final MappingEntryBuilder builder = new MappingEntryBuilder();
- when(mappingContext.findDetails(dump.snatStaticMappingDetails, NatInstanceCustomizer.DEFAULT_VRF_ID.getId(),
- NAT_MAPPING_ID, ctx.getMappingContext())).thenReturn(dump.snatStaticMappingDetails.get(2));
+ when(mappingContext
+ .findDetailsNat44(dumpNat44.snatStaticMappingDetails, NatInstanceCustomizer.DEFAULT_VRF_ID.getId(),
+ NAT_MAPPING_ID, ctx.getMappingContext()))
+ .thenReturn(Optional.of(dumpNat44.snatStaticMappingDetails.get(2)));
getCustomizer().readCurrentAttributes(mappingEntryId, builder, ctx);
assertEquals(NAT_MAPPING_ID, builder.getIndex().longValue());
assertEquals("192.168.3.8", builder.getExternalSrcAddress().getValue());
assertEquals(6874,
- ((SinglePortNumber) builder.getExternalSrcPort().getPortType()).getSinglePortNumber().getValue()
- .intValue());
+ ((SinglePortNumber) builder.getExternalSrcPort().getPortType()).getSinglePortNumber().getValue()
+ .intValue());
assertArrayEquals("192.168.2.2".toCharArray(), builder.getInternalSrcAddress().getValue());
assertEquals(1274,
- ((SinglePortNumber) builder.getInternalSrcPort().getPortType()).getSinglePortNumber().getValue()
- .intValue());
+ ((SinglePortNumber) builder.getInternalSrcPort().getPortType()).getSinglePortNumber().getValue()
+ .intValue());
+ }
+
+ @Test
+ public void testReadNat64() throws Exception {
+ when(nat44DumpExecutor.executeDump(mappingEntryId, null)).thenReturn(new SnatStaticMappingDetailsReplyDump());
+ final Nat64BibDetailsReplyDump dumpNat64 = dumpReplyNat64NonEmpty();
+ when(nat64DumpExecutor.executeDump(mappingEntryId, null)).thenReturn(dumpNat64);
+ final MappingEntryBuilder builder = new MappingEntryBuilder();
+ when(mappingContext
+ .findDetailsNat64(dumpNat64.nat64BibDetails, NatInstanceCustomizer.DEFAULT_VRF_ID.getId(),
+ NAT_MAPPING_ID, ctx.getMappingContext()))
+ .thenReturn(Optional.of(dumpNat64.nat64BibDetails.get(2)));
+ getCustomizer().readCurrentAttributes(mappingEntryId, builder, ctx);
+
+ assertEquals(NAT_MAPPING_ID, builder.getIndex().longValue());
+ assertEquals("192.168.64.3", builder.getExternalSrcAddress().getValue());
+ assertEquals(6874,
+ ((SinglePortNumber) builder.getExternalSrcPort().getPortType()).getSinglePortNumber().getValue()
+ .intValue());
+ assertArrayEquals("2001:db8:85a3::8a2e:370:7303".toCharArray(), builder.getInternalSrcAddress().getValue());
+ assertEquals(1274,
+ ((SinglePortNumber) builder.getInternalSrcPort().getPortType()).getSinglePortNumber().getValue()
+ .intValue());
}
@Test
- public void testGetAll() throws Exception {
- final SnatStaticMappingDetailsReplyDump dump = dumpNonEmptyDefaultInstance();
- when(dumpExecutor.executeDump(mappingEntryWildcarded, null)).thenReturn(dump);
+ public void testReadAllNat44() throws Exception {
+ final SnatStaticMappingDetailsReplyDump dumpNat44 = dumpReplyNat44NonEmpty();
+ when(nat44DumpExecutor.executeDump(mappingEntryWildcarded, null)).thenReturn(dumpNat44);
+ when(nat64DumpExecutor.executeDump(mappingEntryWildcarded, null)).thenReturn(new Nat64BibDetailsReplyDump());
when(mappingContext.getStoredOrArtificialIndex(NatInstanceCustomizer.DEFAULT_VRF_ID.getId(),
- dump.snatStaticMappingDetails.get(0), ctx.getMappingContext())).thenReturn(0L);
+ dumpNat44.snatStaticMappingDetails.get(0), ctx.getMappingContext())).thenReturn(0L);
when(mappingContext.getStoredOrArtificialIndex(NatInstanceCustomizer.DEFAULT_VRF_ID.getId(),
- dump.snatStaticMappingDetails.get(1), ctx.getMappingContext())).thenReturn(1L);
+ dumpNat44.snatStaticMappingDetails.get(1), ctx.getMappingContext())).thenReturn(1L);
when(mappingContext.getStoredOrArtificialIndex(NatInstanceCustomizer.DEFAULT_VRF_ID.getId(),
- dump.snatStaticMappingDetails.get(2), ctx.getMappingContext())).thenReturn(2L);
+ dumpNat44.snatStaticMappingDetails.get(2), ctx.getMappingContext())).thenReturn(2L);
final List<MappingEntryKey> allIds = getCustomizer().getAllIds(mappingEntryWildcarded, ctx);
assertThat(allIds, hasItems(new MappingEntryKey(0L), new MappingEntryKey(2L)));
}
+ @Test
+ public void testReadAllNat64() throws Exception {
+ final Nat64BibDetailsReplyDump dumpNat64 = dumpReplyNat64NonEmpty();
+ when(nat44DumpExecutor.executeDump(mappingEntryWildcarded, null))
+ .thenReturn(new SnatStaticMappingDetailsReplyDump());
+ when(nat64DumpExecutor.executeDump(mappingEntryWildcarded, null)).thenReturn(dumpNat64);
+ when(mappingContext.getStoredOrArtificialIndex(NatInstanceCustomizer.DEFAULT_VRF_ID.getId(),
+ dumpNat64.nat64BibDetails.get(0), ctx.getMappingContext())).thenReturn(0L);
+ when(mappingContext.getStoredOrArtificialIndex(NatInstanceCustomizer.DEFAULT_VRF_ID.getId(),
+ dumpNat64.nat64BibDetails.get(1), ctx.getMappingContext())).thenReturn(1L);
+ when(mappingContext.getStoredOrArtificialIndex(NatInstanceCustomizer.DEFAULT_VRF_ID.getId(),
+ dumpNat64.nat64BibDetails.get(2), ctx.getMappingContext())).thenReturn(2L);
+
+ final List<MappingEntryKey> allIds = getCustomizer().getAllIds(mappingEntryWildcarded, ctx);
+ assertThat(allIds, hasItems(new MappingEntryKey(0L), new MappingEntryKey(2L)));
+ }
+
+ @Test
+ public void testReadAll() throws Exception {
+ final SnatStaticMappingDetailsReplyDump dumpNat44 = dumpReplyNat44NonEmpty();
+ final Nat64BibDetailsReplyDump dumpNat64 = dumpReplyNat64NonEmpty();
+ when(nat44DumpExecutor.executeDump(mappingEntryWildcarded, null))
+ .thenReturn(dumpNat44);
+ when(nat64DumpExecutor.executeDump(mappingEntryWildcarded, null)).thenReturn(dumpNat64);
+ when(mappingContext.getStoredOrArtificialIndex(NatInstanceCustomizer.DEFAULT_VRF_ID.getId(),
+ dumpNat44.snatStaticMappingDetails.get(0), ctx.getMappingContext())).thenReturn(0L);
+ when(mappingContext.getStoredOrArtificialIndex(NatInstanceCustomizer.DEFAULT_VRF_ID.getId(),
+ dumpNat44.snatStaticMappingDetails.get(1), ctx.getMappingContext())).thenReturn(1L);
+ when(mappingContext.getStoredOrArtificialIndex(NatInstanceCustomizer.DEFAULT_VRF_ID.getId(),
+ dumpNat44.snatStaticMappingDetails.get(2), ctx.getMappingContext())).thenReturn(2L);
+ when(mappingContext.getStoredOrArtificialIndex(NatInstanceCustomizer.DEFAULT_VRF_ID.getId(),
+ dumpNat64.nat64BibDetails.get(0), ctx.getMappingContext())).thenReturn(3L);
+ when(mappingContext.getStoredOrArtificialIndex(NatInstanceCustomizer.DEFAULT_VRF_ID.getId(),
+ dumpNat64.nat64BibDetails.get(1), ctx.getMappingContext())).thenReturn(4L);
+ when(mappingContext.getStoredOrArtificialIndex(NatInstanceCustomizer.DEFAULT_VRF_ID.getId(),
+ dumpNat64.nat64BibDetails.get(2), ctx.getMappingContext())).thenReturn(5L);
+
+ final List<MappingEntryKey> allIds = getCustomizer().getAllIds(mappingEntryWildcarded, ctx);
+ assertThat(allIds, hasItems(new MappingEntryKey(0L), new MappingEntryKey(2L), new MappingEntryKey(3L),
+ new MappingEntryKey(5L)));
+ }
+
@Override
protected ReaderCustomizer<MappingEntry, MappingEntryBuilder> initCustomizer() {
- return new MappingEntryCustomizer(dumpCacheManager, mappingContext);
+ return new MappingEntryCustomizer(nat44DumpManager, nat64DumpManager, mappingContext);
}
- private static SnatStaticMappingDetailsReplyDump dumpNonEmptyDefaultInstance() {
+ private static SnatStaticMappingDetailsReplyDump dumpReplyNat44NonEmpty() {
SnatStaticMappingDetailsReplyDump replyDump = new SnatStaticMappingDetailsReplyDump();
SnatStaticMappingDetails detailsOne = new SnatStaticMappingDetails();
detailsOne.isIp4 = 1;
detailsOne.addrOnly = 1;
- detailsOne.localIpAddress = new byte[] {-64, -88, 2, 1};
+ detailsOne.localIpAddress = new byte[]{-64, -88, 2, 1};
detailsOne.localPort = 1234;
- detailsOne.externalIpAddress = new byte[] {-64, -88, 2, 8};
+ detailsOne.externalIpAddress = new byte[]{-64, -88, 2, 8};
detailsOne.externalPort = 5874;
detailsOne.vrfId = NatInstanceCustomizer.DEFAULT_VRF_ID.getId().byteValue();
SnatStaticMappingDetails detailsTwo = new SnatStaticMappingDetails();
detailsTwo.isIp4 = 1;
detailsTwo.addrOnly = 1;
- detailsTwo.localIpAddress = new byte[] {-64, -88, 2, 3};
+ detailsTwo.localIpAddress = new byte[]{-64, -88, 2, 3};
detailsTwo.localPort = 1235;
- detailsTwo.externalIpAddress = new byte[] {-64, -88, 2, 5};
+ detailsTwo.externalIpAddress = new byte[]{-64, -88, 2, 5};
detailsTwo.externalPort = 5874;
detailsTwo.vrfId = 2;
SnatStaticMappingDetails detailsThree = new SnatStaticMappingDetails();
detailsThree.isIp4 = 1;
detailsThree.addrOnly = 0;
- detailsThree.localIpAddress = new byte[] {-64, -88, 2, 2};
+ detailsThree.localIpAddress = new byte[]{-64, -88, 2, 2};
detailsThree.localPort = 1274;
- detailsThree.externalIpAddress = new byte[] {-64, -88, 3, 8};
+ detailsThree.externalIpAddress = new byte[]{-64, -88, 3, 8};
detailsThree.externalPort = 6874;
detailsThree.vrfId = NatInstanceCustomizer.DEFAULT_VRF_ID.getId().byteValue();
replyDump.snatStaticMappingDetails = Arrays.asList(detailsOne, detailsTwo, detailsThree);
return replyDump;
}
+
+ private static Nat64BibDetailsReplyDump dumpReplyNat64NonEmpty() {
+ Nat64BibDetailsReplyDump replyDump = new Nat64BibDetailsReplyDump();
+
+ Nat64BibDetails detailsOne = new Nat64BibDetails();
+ detailsOne.isStatic = 1;
+ detailsOne.iAddr =
+ new byte[]{0x20, 0x01, 0x0d, (byte) 0xb8, (byte) 0x85, (byte) 0xa3, 0, 0, 0, 0, (byte) 0x8a, 0x2e, 0x03,
+ 0x70, 0x73, 0x01};
+ detailsOne.iPort = 1234;
+ detailsOne.oAddr = new byte[]{-64, -88, 64, 1};
+ detailsOne.oPort = 5874;
+ detailsOne.vrfId = NatInstanceCustomizer.DEFAULT_VRF_ID.getId().byteValue();
+
+ Nat64BibDetails detailsTwo = new Nat64BibDetails();
+ detailsTwo.isStatic = 0;
+ detailsTwo.iAddr =
+ new byte[]{0x20, 0x01, 0x0d, (byte) 0xb8, (byte) 0x85, (byte) 0xa3, 0, 0, 0, 0, (byte) 0x8a, 0x2e, 0x03,
+ 0x70, 0x73, 0x02};
+ detailsTwo.iPort = 1235;
+ detailsTwo.oAddr = new byte[]{-64, -88, 64, 2};
+ detailsTwo.oPort = 5874;
+ detailsTwo.vrfId = 2;
+
+ Nat64BibDetails detailsThree = new Nat64BibDetails();
+ detailsThree.isStatic = 1;
+ detailsThree.iAddr =
+ new byte[]{0x20, 0x01, 0x0d, (byte) 0xb8, (byte) 0x85, (byte) 0xa3, 0, 0, 0, 0, (byte) 0x8a, 0x2e, 0x03,
+ 0x70, 0x73, 0x03};
+ detailsThree.iPort = 1274;
+ detailsThree.oAddr = new byte[]{-64, -88, 64, 3};
+ detailsThree.oPort = 6874;
+ detailsThree.vrfId = NatInstanceCustomizer.DEFAULT_VRF_ID.getId().byteValue();
+
+ replyDump.nat64BibDetails = Arrays.asList(detailsOne, detailsTwo, detailsThree);
+ return replyDump;
+ }
} \ No newline at end of file
diff --git a/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/read/NatInstanceCustomizerTest.java b/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/read/NatInstanceCustomizerTest.java
index 821a59235..0fad2abee 100644
--- a/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/read/NatInstanceCustomizerTest.java
+++ b/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/read/NatInstanceCustomizerTest.java
@@ -17,6 +17,7 @@
package io.fd.hc2vpp.nat.read;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.core.IsCollectionContaining.hasItems;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
@@ -26,6 +27,8 @@ import io.fd.hc2vpp.common.test.read.InitializingListReaderCustomizerTest;
import io.fd.honeycomb.translate.read.ReadFailedException;
import io.fd.honeycomb.translate.util.read.cache.DumpCacheManager;
import io.fd.honeycomb.translate.util.read.cache.EntityDumpExecutor;
+import io.fd.vpp.jvpp.snat.dto.Nat64BibDetails;
+import io.fd.vpp.jvpp.snat.dto.Nat64BibDetailsReplyDump;
import io.fd.vpp.jvpp.snat.dto.SnatStaticMappingDetails;
import io.fd.vpp.jvpp.snat.dto.SnatStaticMappingDetailsReplyDump;
import java.util.Arrays;
@@ -41,13 +44,16 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
public class NatInstanceCustomizerTest
- extends InitializingListReaderCustomizerTest<NatInstance, NatInstanceKey, NatInstanceBuilder> {
+ extends InitializingListReaderCustomizerTest<NatInstance, NatInstanceKey, NatInstanceBuilder> {
@Mock
- private EntityDumpExecutor<SnatStaticMappingDetailsReplyDump, Void> dumpExecutor;
+ private EntityDumpExecutor<SnatStaticMappingDetailsReplyDump, Void> nat44DumpExecutor;
+ @Mock
+ private EntityDumpExecutor<Nat64BibDetailsReplyDump, Void> nat64DumpExecutor;
private KeyedInstanceIdentifier<NatInstance, NatInstanceKey> natInstanceId;
private InstanceIdentifier<NatInstance> natInstanceWildcarded;
- private DumpCacheManager<SnatStaticMappingDetailsReplyDump, Void> dumpCacheManager;
+ private DumpCacheManager<SnatStaticMappingDetailsReplyDump, Void> mapEntryNat44DumpMgr;
+ private DumpCacheManager<Nat64BibDetailsReplyDump, Void> mapEntryNat64DumpMgr;
public NatInstanceCustomizerTest() {
super(NatInstance.class, NatInstancesBuilder.class);
@@ -55,19 +61,23 @@ public class NatInstanceCustomizerTest
@Override
protected NatInstanceCustomizer initCustomizer() {
- return new NatInstanceCustomizer(dumpCacheManager);
+ return new NatInstanceCustomizer(mapEntryNat44DumpMgr, mapEntryNat64DumpMgr);
}
@Override
protected void setUp() throws Exception {
natInstanceId = InstanceIdentifier.create(NatInstances.class)
- .child(NatInstance.class, new NatInstanceKey(NatInstanceCustomizer.DEFAULT_VRF_ID));
+ .child(NatInstance.class, new NatInstanceKey(NatInstanceCustomizer.DEFAULT_VRF_ID));
natInstanceWildcarded = InstanceIdentifier.create(NatInstances.class)
- .child(NatInstance.class);
- dumpCacheManager = new DumpCacheManager.DumpCacheManagerBuilder<SnatStaticMappingDetailsReplyDump, Void>()
- .withExecutor(dumpExecutor)
- .acceptOnly(SnatStaticMappingDetailsReplyDump.class)
- .build();
+ .child(NatInstance.class);
+ mapEntryNat44DumpMgr = new DumpCacheManager.DumpCacheManagerBuilder<SnatStaticMappingDetailsReplyDump, Void>()
+ .withExecutor(nat44DumpExecutor)
+ .acceptOnly(SnatStaticMappingDetailsReplyDump.class)
+ .build();
+ mapEntryNat64DumpMgr = new DumpCacheManager.DumpCacheManagerBuilder<Nat64BibDetailsReplyDump, Void>()
+ .withExecutor(nat64DumpExecutor)
+ .acceptOnly(Nat64BibDetailsReplyDump.class)
+ .build();
}
@Test
@@ -79,14 +89,16 @@ public class NatInstanceCustomizerTest
@Test
public void testReadAll() throws ReadFailedException {
- final SnatStaticMappingDetailsReplyDump dump = dumpNonEmptyDefaultInstance();
- when(dumpExecutor.executeDump(natInstanceWildcarded, null)).thenReturn(dump);
+ when(nat44DumpExecutor.executeDump(natInstanceWildcarded, null)).thenReturn(nat44NonEmptyDump());
+ when(nat64DumpExecutor.executeDump(natInstanceWildcarded, null)).thenReturn(nat64NonEmptyDump());
final List<NatInstanceKey> allIds = getCustomizer().getAllIds(natInstanceWildcarded, ctx);
+ assertThat(allIds, hasSize(6));
assertThat(allIds, hasItems(
- new NatInstanceKey(0L), new NatInstanceKey(1L), new NatInstanceKey(2L), new NatInstanceKey(3L)));
+ new NatInstanceKey(0L), new NatInstanceKey(1L), new NatInstanceKey(2L), new NatInstanceKey(3L),
+ new NatInstanceKey(5L), new NatInstanceKey(6L)));
}
- private static SnatStaticMappingDetailsReplyDump dumpNonEmptyDefaultInstance() {
+ private static SnatStaticMappingDetailsReplyDump nat44NonEmptyDump() {
SnatStaticMappingDetailsReplyDump replyDump = new SnatStaticMappingDetailsReplyDump();
SnatStaticMappingDetails detailsOne = new SnatStaticMappingDetails();
detailsOne.vrfId = 1;
@@ -100,4 +112,19 @@ public class NatInstanceCustomizerTest
replyDump.snatStaticMappingDetails = Arrays.asList(detailsOne, detailsTwo, detailsThree);
return replyDump;
}
+
+ private static Nat64BibDetailsReplyDump nat64NonEmptyDump() {
+ Nat64BibDetailsReplyDump replyDump = new Nat64BibDetailsReplyDump();
+ Nat64BibDetails detailsOne = new Nat64BibDetails();
+ detailsOne.vrfId = 2;
+
+ Nat64BibDetails detailsTwo = new Nat64BibDetails();
+ detailsTwo.vrfId = 5;
+
+ Nat64BibDetails detailsThree = new Nat64BibDetails();
+ detailsThree.vrfId = 6;
+
+ replyDump.nat64BibDetails = Arrays.asList(detailsOne, detailsTwo, detailsThree);
+ return replyDump;
+ }
} \ No newline at end of file
diff --git a/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/util/MappingEntryContextTest.java b/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/util/MappingEntryContextTest.java
index 4d8f8074d..a6643601e 100644
--- a/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/util/MappingEntryContextTest.java
+++ b/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/util/MappingEntryContextTest.java
@@ -107,7 +107,7 @@ public class MappingEntryContextTest implements Ipv4Translator {
MappingEntryContext.toCtxMapEntry(entry2, 1)))
.build()));
- assertSame(details, ctx.findDetails(someDetails, natId, 0, mappingCtx));
+ assertSame(details, ctx.findDetailsNat44(someDetails, natId, 0, mappingCtx).get());
}
@Test(expected = IllegalStateException.class)
@@ -118,7 +118,7 @@ public class MappingEntryContextTest implements Ipv4Translator {
final List<SnatStaticMappingDetails> someDetails = Lists.newArrayList(details);
when(mappingCtx.read(MappingEntryContext.getTableId(natId))).thenReturn(Optional.absent());
- ctx.findDetails(someDetails, natId, entryId, mappingCtx);
+ ctx.findDetailsNat44(someDetails, natId, entryId, mappingCtx);
}
@Test(expected = IllegalStateException.class)
@@ -131,7 +131,7 @@ public class MappingEntryContextTest implements Ipv4Translator {
when(mappingCtx.read(MappingEntryContext.getTableId(natId)))
.thenReturn(Optional.of(new MappingTableBuilder().setMappingEntry(Collections.emptyList()).build()));
- ctx.findDetails(someDetails, natId, entryId, mappingCtx);
+ ctx.findDetailsNat44(someDetails, natId, entryId, mappingCtx);
}
@Test