diff options
Diffstat (limited to 'nat/nat2vpp/src/test/java')
12 files changed, 200 insertions, 210 deletions
diff --git a/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/NatModuleTest.java b/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/NatModuleTest.java index 041a1fc0d..f8d384bd5 100644 --- a/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/NatModuleTest.java +++ b/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/NatModuleTest.java @@ -39,7 +39,7 @@ import io.fd.honeycomb.translate.read.ReaderFactory; import io.fd.honeycomb.translate.spi.read.ListReaderCustomizer; import io.fd.honeycomb.translate.util.YangDAG; import io.fd.honeycomb.translate.write.WriterFactory; -import io.fd.vpp.jvpp.snat.future.FutureJVppSnatFacade; +import io.fd.vpp.jvpp.nat.future.FutureJVppNatFacade; import java.util.HashSet; import java.util.Set; import org.junit.Before; @@ -94,7 +94,7 @@ public class NatModuleTest { registry.add(new GenericListReader<>( InstanceIdentifier.create(InterfacesState.class).child(Interface.class), mock(ListReaderCustomizer.class))); - }), new NatModule(MockJVppSnatProvider.class), BoundFieldModule.of(this)).injectMembers(this); + }), new NatModule(MockJVppNatProvider.class), BoundFieldModule.of(this)).injectMembers(this); } @Test @@ -117,11 +117,11 @@ public class NatModuleTest { assertNotNull(registryBuilder.build()); } - private static final class MockJVppSnatProvider implements Provider<FutureJVppSnatFacade> { + private static final class MockJVppNatProvider implements Provider<FutureJVppNatFacade> { @Override - public FutureJVppSnatFacade get() { - return mock(FutureJVppSnatFacade.class); + public FutureJVppNatFacade get() { + return mock(FutureJVppNatFacade.class); } } }
\ No newline at end of file diff --git a/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/read/ExternalIpPoolCustomizerTest.java b/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/read/ExternalIpPoolCustomizerTest.java index e6dfeb86f..521320591 100644 --- a/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/read/ExternalIpPoolCustomizerTest.java +++ b/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/read/ExternalIpPoolCustomizerTest.java @@ -27,11 +27,11 @@ import static org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v import io.fd.hc2vpp.common.test.read.ListReaderCustomizerTest; import io.fd.honeycomb.translate.spi.read.ReaderCustomizer; -import io.fd.vpp.jvpp.snat.dto.Nat64PoolAddrDetails; -import io.fd.vpp.jvpp.snat.dto.Nat64PoolAddrDetailsReplyDump; -import io.fd.vpp.jvpp.snat.dto.SnatAddressDetails; -import io.fd.vpp.jvpp.snat.dto.SnatAddressDetailsReplyDump; -import io.fd.vpp.jvpp.snat.future.FutureJVppSnatFacade; +import io.fd.vpp.jvpp.nat.dto.Nat44AddressDetails; +import io.fd.vpp.jvpp.nat.dto.Nat44AddressDetailsReplyDump; +import io.fd.vpp.jvpp.nat.dto.Nat64PoolAddrDetails; +import io.fd.vpp.jvpp.nat.dto.Nat64PoolAddrDetailsReplyDump; +import io.fd.vpp.jvpp.nat.future.FutureJVppNatFacade; import java.util.Arrays; import java.util.List; import java.util.stream.LongStream; @@ -64,7 +64,7 @@ public class ExternalIpPoolCustomizerTest .child(NatCurrentConfig.class).child(ExternalIpAddressPool.class); @Mock - private FutureJVppSnatFacade jvppSnat; + private FutureJVppNatFacade jvppNat; public ExternalIpPoolCustomizerTest() { super(ExternalIpAddressPool.class, NatCurrentConfigBuilder.class); @@ -72,12 +72,12 @@ public class ExternalIpPoolCustomizerTest @Override protected ReaderCustomizer<ExternalIpAddressPool, ExternalIpAddressPoolBuilder> initCustomizer() { - return new ExternalIpPoolCustomizer(jvppSnat); + return new ExternalIpPoolCustomizer(jvppNat); } @Test public void testReadAttributesNat44() throws Exception { - when(jvppSnat.snatAddressDump(any())).thenReturn(future(dumpReplyNat44NonEmpty())); + when(jvppNat.nat44AddressDump(any())).thenReturn(future(dumpReplyNat44NonEmpty())); final long poolId = 2; final ExternalIpAddressPoolBuilder builder = new ExternalIpAddressPoolBuilder(); getCustomizer().readCurrentAttributes(getId(poolId), builder, ctx); @@ -89,8 +89,8 @@ public class ExternalIpPoolCustomizerTest @Test public void testReadAttributesNat64() throws Exception { - when(jvppSnat.snatAddressDump(any())).thenReturn(future(dumpReplyNat44Empty())); - when(jvppSnat.nat64PoolAddrDump(any())).thenReturn(future(dumpReplyNat64NonEmpty())); + when(jvppNat.nat44AddressDump(any())).thenReturn(future(dumpReplyNat44Empty())); + when(jvppNat.nat64PoolAddrDump(any())).thenReturn(future(dumpReplyNat64NonEmpty())); final long poolId = 2; final ExternalIpAddressPoolBuilder builder = new ExternalIpAddressPoolBuilder(); @@ -103,8 +103,8 @@ public class ExternalIpPoolCustomizerTest @Test public void testReadAttributes() throws Exception { - when(jvppSnat.snatAddressDump(any())).thenReturn(future(dumpReplyNat44NonEmpty())); - when(jvppSnat.nat64PoolAddrDump(any())).thenReturn(future(dumpReplyNat64NonEmpty())); + when(jvppNat.nat44AddressDump(any())).thenReturn(future(dumpReplyNat44NonEmpty())); + when(jvppNat.nat64PoolAddrDump(any())).thenReturn(future(dumpReplyNat64NonEmpty())); final long poolId = 5; final ExternalIpAddressPoolBuilder builder = new ExternalIpAddressPoolBuilder(); @@ -117,8 +117,8 @@ public class ExternalIpPoolCustomizerTest @Test public void testGetAllNat44() throws Exception { - when(jvppSnat.snatAddressDump(any())).thenReturn(future(dumpReplyNat44NonEmpty())); - when(jvppSnat.nat64PoolAddrDump(any())).thenReturn(future(dumpReplyNat64Empty())); + when(jvppNat.nat44AddressDump(any())).thenReturn(future(dumpReplyNat44NonEmpty())); + when(jvppNat.nat64PoolAddrDump(any())).thenReturn(future(dumpReplyNat64Empty())); final List<ExternalIpAddressPoolKey> allIds = getCustomizer().getAllIds(NAT_DEFAULT_POOL_WILDCARDED_ID, ctx); assertThat(allIds, hasItems( @@ -128,8 +128,8 @@ public class ExternalIpPoolCustomizerTest @Test public void testGetAllNat64() throws Exception { - when(jvppSnat.snatAddressDump(any())).thenReturn(future(dumpReplyNat44Empty())); - when(jvppSnat.nat64PoolAddrDump(any())).thenReturn(future(dumpReplyNat64NonEmpty())); + when(jvppNat.nat44AddressDump(any())).thenReturn(future(dumpReplyNat44Empty())); + when(jvppNat.nat64PoolAddrDump(any())).thenReturn(future(dumpReplyNat64NonEmpty())); final List<ExternalIpAddressPoolKey> allIds = getCustomizer().getAllIds(NAT_DEFAULT_POOL_WILDCARDED_ID, ctx); assertThat(allIds, hasItems( @@ -139,8 +139,8 @@ public class ExternalIpPoolCustomizerTest @Test public void testGetAll() throws Exception { - when(jvppSnat.snatAddressDump(any())).thenReturn(future(dumpReplyNat44NonEmpty())); - when(jvppSnat.nat64PoolAddrDump(any())).thenReturn(future(dumpReplyNat64NonEmpty())); + when(jvppNat.nat44AddressDump(any())).thenReturn(future(dumpReplyNat44NonEmpty())); + when(jvppNat.nat64PoolAddrDump(any())).thenReturn(future(dumpReplyNat64NonEmpty())); final List<ExternalIpAddressPoolKey> allIds = getCustomizer().getAllIds(NAT_DEFAULT_POOL_WILDCARDED_ID, ctx); assertThat(allIds, hasItems( @@ -155,8 +155,8 @@ public class ExternalIpPoolCustomizerTest @Test public void testGetAllNoDump() throws Exception { - when(jvppSnat.snatAddressDump(any())).thenReturn(future(dumpReplyNat44Empty())); - when(jvppSnat.nat64PoolAddrDump(any())).thenReturn(future(dumpReplyNat64Empty())); + when(jvppNat.nat44AddressDump(any())).thenReturn(future(dumpReplyNat44Empty())); + when(jvppNat.nat64PoolAddrDump(any())).thenReturn(future(dumpReplyNat64Empty())); assertThat(getCustomizer().getAllIds(NAT_DEFAULT_POOL_WILDCARDED_ID, ctx), empty()); } @@ -164,26 +164,23 @@ public class ExternalIpPoolCustomizerTest return NAT_CONFIG_ID.child(ExternalIpAddressPool.class, new ExternalIpAddressPoolKey(id)); } - private static SnatAddressDetailsReplyDump dumpReplyNat44Empty() { - return new SnatAddressDetailsReplyDump(); + private static Nat44AddressDetailsReplyDump dumpReplyNat44Empty() { + return new Nat44AddressDetailsReplyDump(); } - private static SnatAddressDetailsReplyDump dumpReplyNat44NonEmpty() { - SnatAddressDetailsReplyDump replyDump = dumpReplyNat44Empty(); + private static Nat44AddressDetailsReplyDump dumpReplyNat44NonEmpty() { + Nat44AddressDetailsReplyDump replyDump = dumpReplyNat44Empty(); - SnatAddressDetails detailsOne = new SnatAddressDetails(); + Nat44AddressDetails detailsOne = new Nat44AddressDetails(); detailsOne.ipAddress = new byte[]{-64, -88, 44, 1}; - detailsOne.isIp4 = 1; - SnatAddressDetails detailsTwo = new SnatAddressDetails(); + Nat44AddressDetails detailsTwo = new Nat44AddressDetails(); detailsTwo.ipAddress = new byte[]{-64, -88, 44, 2}; - detailsTwo.isIp4 = 1; - SnatAddressDetails detailsThree = new SnatAddressDetails(); + Nat44AddressDetails detailsThree = new Nat44AddressDetails(); detailsThree.ipAddress = new byte[]{-64, -88, 44, 3}; - detailsThree.isIp4 = 1; - replyDump.snatAddressDetails = Arrays.asList(detailsOne, detailsTwo, detailsThree); + replyDump.nat44AddressDetails = Arrays.asList(detailsOne, detailsTwo, detailsThree); return replyDump; } 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 05513b6e9..5402746ae 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,10 @@ 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 io.fd.vpp.jvpp.nat.dto.Nat44StaticMappingDetails; +import io.fd.vpp.jvpp.nat.dto.Nat44StaticMappingDetailsReplyDump; +import io.fd.vpp.jvpp.nat.dto.Nat64BibDetails; +import io.fd.vpp.jvpp.nat.dto.Nat64BibDetailsReplyDump; import java.util.Arrays; import java.util.List; import java.util.Optional; @@ -53,14 +53,14 @@ public class MappingEntryCustomizerTest private static final long NAT_MAPPING_ID = 2L; private InstanceIdentifier<MappingEntry> mappingEntryId; private InstanceIdentifier<MappingEntry> mappingEntryWildcarded; - private DumpCacheManager<SnatStaticMappingDetailsReplyDump, Void> nat44DumpManager; + private DumpCacheManager<Nat44StaticMappingDetailsReplyDump, Void> nat44DumpManager; private DumpCacheManager<Nat64BibDetailsReplyDump, Void> nat64DumpManager; @Mock private MappingEntryContext mappingContext; @Mock - private EntityDumpExecutor<SnatStaticMappingDetailsReplyDump, Void> nat44DumpExecutor; + private EntityDumpExecutor<Nat44StaticMappingDetailsReplyDump, Void> nat44DumpExecutor; @Mock private EntityDumpExecutor<Nat64BibDetailsReplyDump, Void> nat64DumpExecutor; @@ -79,9 +79,9 @@ public class MappingEntryCustomizerTest .child(NatInstance.class, new NatInstanceKey(NatInstanceCustomizer.DEFAULT_VRF_ID)) .child(MappingTable.class) .child(MappingEntry.class); - nat44DumpManager = new DumpCacheManager.DumpCacheManagerBuilder<SnatStaticMappingDetailsReplyDump, Void>() + nat44DumpManager = new DumpCacheManager.DumpCacheManagerBuilder<Nat44StaticMappingDetailsReplyDump, Void>() .withExecutor(nat44DumpExecutor) - .acceptOnly(SnatStaticMappingDetailsReplyDump.class) + .acceptOnly(Nat44StaticMappingDetailsReplyDump.class) .build(); nat64DumpManager = new DumpCacheManager.DumpCacheManagerBuilder<Nat64BibDetailsReplyDump, Void>() .withExecutor(nat64DumpExecutor) @@ -91,13 +91,13 @@ public class MappingEntryCustomizerTest @Test public void testReadNat44() throws Exception { - final SnatStaticMappingDetailsReplyDump dumpNat44 = dumpReplyNat44NonEmpty(); + final Nat44StaticMappingDetailsReplyDump dumpNat44 = dumpReplyNat44NonEmpty(); when(nat44DumpExecutor.executeDump(mappingEntryId, null)).thenReturn(dumpNat44); final MappingEntryBuilder builder = new MappingEntryBuilder(); when(mappingContext - .findDetailsNat44(dumpNat44.snatStaticMappingDetails, NatInstanceCustomizer.DEFAULT_VRF_ID.getId(), + .findDetailsNat44(dumpNat44.nat44StaticMappingDetails, NatInstanceCustomizer.DEFAULT_VRF_ID.getId(), NAT_MAPPING_ID, ctx.getMappingContext())) - .thenReturn(Optional.of(dumpNat44.snatStaticMappingDetails.get(2))); + .thenReturn(Optional.of(dumpNat44.nat44StaticMappingDetails.get(2))); getCustomizer().readCurrentAttributes(mappingEntryId, builder, ctx); assertEquals(NAT_MAPPING_ID, builder.getIndex().longValue()); @@ -113,7 +113,7 @@ public class MappingEntryCustomizerTest @Test public void testReadNat64() throws Exception { - when(nat44DumpExecutor.executeDump(mappingEntryId, null)).thenReturn(new SnatStaticMappingDetailsReplyDump()); + when(nat44DumpExecutor.executeDump(mappingEntryId, null)).thenReturn(new Nat44StaticMappingDetailsReplyDump()); final Nat64BibDetailsReplyDump dumpNat64 = dumpReplyNat64NonEmpty(); when(nat64DumpExecutor.executeDump(mappingEntryId, null)).thenReturn(dumpNat64); final MappingEntryBuilder builder = new MappingEntryBuilder(); @@ -136,15 +136,15 @@ public class MappingEntryCustomizerTest @Test public void testReadAllNat44() throws Exception { - final SnatStaticMappingDetailsReplyDump dumpNat44 = dumpReplyNat44NonEmpty(); + final Nat44StaticMappingDetailsReplyDump 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(), - dumpNat44.snatStaticMappingDetails.get(0), ctx.getMappingContext())).thenReturn(0L); + dumpNat44.nat44StaticMappingDetails.get(0), ctx.getMappingContext())).thenReturn(0L); when(mappingContext.getStoredOrArtificialIndex(NatInstanceCustomizer.DEFAULT_VRF_ID.getId(), - dumpNat44.snatStaticMappingDetails.get(1), ctx.getMappingContext())).thenReturn(1L); + dumpNat44.nat44StaticMappingDetails.get(1), ctx.getMappingContext())).thenReturn(1L); when(mappingContext.getStoredOrArtificialIndex(NatInstanceCustomizer.DEFAULT_VRF_ID.getId(), - dumpNat44.snatStaticMappingDetails.get(2), ctx.getMappingContext())).thenReturn(2L); + dumpNat44.nat44StaticMappingDetails.get(2), ctx.getMappingContext())).thenReturn(2L); final List<MappingEntryKey> allIds = getCustomizer().getAllIds(mappingEntryWildcarded, ctx); assertThat(allIds, hasItems(new MappingEntryKey(0L), new MappingEntryKey(2L))); @@ -154,7 +154,7 @@ public class MappingEntryCustomizerTest public void testReadAllNat64() throws Exception { final Nat64BibDetailsReplyDump dumpNat64 = dumpReplyNat64NonEmpty(); when(nat44DumpExecutor.executeDump(mappingEntryWildcarded, null)) - .thenReturn(new SnatStaticMappingDetailsReplyDump()); + .thenReturn(new Nat44StaticMappingDetailsReplyDump()); when(nat64DumpExecutor.executeDump(mappingEntryWildcarded, null)).thenReturn(dumpNat64); when(mappingContext.getStoredOrArtificialIndex(NatInstanceCustomizer.DEFAULT_VRF_ID.getId(), dumpNat64.nat64BibDetails.get(0), ctx.getMappingContext())).thenReturn(0L); @@ -169,17 +169,17 @@ public class MappingEntryCustomizerTest @Test public void testReadAll() throws Exception { - final SnatStaticMappingDetailsReplyDump dumpNat44 = dumpReplyNat44NonEmpty(); + final Nat44StaticMappingDetailsReplyDump 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); + dumpNat44.nat44StaticMappingDetails.get(0), ctx.getMappingContext())).thenReturn(0L); when(mappingContext.getStoredOrArtificialIndex(NatInstanceCustomizer.DEFAULT_VRF_ID.getId(), - dumpNat44.snatStaticMappingDetails.get(1), ctx.getMappingContext())).thenReturn(1L); + dumpNat44.nat44StaticMappingDetails.get(1), ctx.getMappingContext())).thenReturn(1L); when(mappingContext.getStoredOrArtificialIndex(NatInstanceCustomizer.DEFAULT_VRF_ID.getId(), - dumpNat44.snatStaticMappingDetails.get(2), ctx.getMappingContext())).thenReturn(2L); + dumpNat44.nat44StaticMappingDetails.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(), @@ -197,11 +197,10 @@ public class MappingEntryCustomizerTest return new MappingEntryCustomizer(nat44DumpManager, nat64DumpManager, mappingContext); } - private static SnatStaticMappingDetailsReplyDump dumpReplyNat44NonEmpty() { - SnatStaticMappingDetailsReplyDump replyDump = new SnatStaticMappingDetailsReplyDump(); + private static Nat44StaticMappingDetailsReplyDump dumpReplyNat44NonEmpty() { + Nat44StaticMappingDetailsReplyDump replyDump = new Nat44StaticMappingDetailsReplyDump(); - SnatStaticMappingDetails detailsOne = new SnatStaticMappingDetails(); - detailsOne.isIp4 = 1; + Nat44StaticMappingDetails detailsOne = new Nat44StaticMappingDetails(); detailsOne.addrOnly = 1; detailsOne.localIpAddress = new byte[]{-64, -88, 2, 1}; detailsOne.localPort = 1234; @@ -209,8 +208,7 @@ public class MappingEntryCustomizerTest detailsOne.externalPort = 5874; detailsOne.vrfId = NatInstanceCustomizer.DEFAULT_VRF_ID.getId().byteValue(); - SnatStaticMappingDetails detailsTwo = new SnatStaticMappingDetails(); - detailsTwo.isIp4 = 1; + Nat44StaticMappingDetails detailsTwo = new Nat44StaticMappingDetails(); detailsTwo.addrOnly = 1; detailsTwo.localIpAddress = new byte[]{-64, -88, 2, 3}; detailsTwo.localPort = 1235; @@ -218,8 +216,7 @@ public class MappingEntryCustomizerTest detailsTwo.externalPort = 5874; detailsTwo.vrfId = 2; - SnatStaticMappingDetails detailsThree = new SnatStaticMappingDetails(); - detailsThree.isIp4 = 1; + Nat44StaticMappingDetails detailsThree = new Nat44StaticMappingDetails(); detailsThree.addrOnly = 0; detailsThree.localIpAddress = new byte[]{-64, -88, 2, 2}; detailsThree.localPort = 1274; @@ -227,7 +224,7 @@ public class MappingEntryCustomizerTest detailsThree.externalPort = 6874; detailsThree.vrfId = NatInstanceCustomizer.DEFAULT_VRF_ID.getId().byteValue(); - replyDump.snatStaticMappingDetails = Arrays.asList(detailsOne, detailsTwo, detailsThree); + replyDump.nat44StaticMappingDetails = Arrays.asList(detailsOne, detailsTwo, detailsThree); return replyDump; } 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 0fad2abee..8978fe5ba 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 @@ -27,10 +27,10 @@ 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 io.fd.vpp.jvpp.nat.dto.Nat44StaticMappingDetails; +import io.fd.vpp.jvpp.nat.dto.Nat44StaticMappingDetailsReplyDump; +import io.fd.vpp.jvpp.nat.dto.Nat64BibDetails; +import io.fd.vpp.jvpp.nat.dto.Nat64BibDetailsReplyDump; import java.util.Arrays; import java.util.List; import org.junit.Test; @@ -46,13 +46,13 @@ import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; public class NatInstanceCustomizerTest extends InitializingListReaderCustomizerTest<NatInstance, NatInstanceKey, NatInstanceBuilder> { @Mock - private EntityDumpExecutor<SnatStaticMappingDetailsReplyDump, Void> nat44DumpExecutor; + private EntityDumpExecutor<Nat44StaticMappingDetailsReplyDump, Void> nat44DumpExecutor; @Mock private EntityDumpExecutor<Nat64BibDetailsReplyDump, Void> nat64DumpExecutor; private KeyedInstanceIdentifier<NatInstance, NatInstanceKey> natInstanceId; private InstanceIdentifier<NatInstance> natInstanceWildcarded; - private DumpCacheManager<SnatStaticMappingDetailsReplyDump, Void> mapEntryNat44DumpMgr; + private DumpCacheManager<Nat44StaticMappingDetailsReplyDump, Void> mapEntryNat44DumpMgr; private DumpCacheManager<Nat64BibDetailsReplyDump, Void> mapEntryNat64DumpMgr; public NatInstanceCustomizerTest() { @@ -70,9 +70,9 @@ public class NatInstanceCustomizerTest .child(NatInstance.class, new NatInstanceKey(NatInstanceCustomizer.DEFAULT_VRF_ID)); natInstanceWildcarded = InstanceIdentifier.create(NatInstances.class) .child(NatInstance.class); - mapEntryNat44DumpMgr = new DumpCacheManager.DumpCacheManagerBuilder<SnatStaticMappingDetailsReplyDump, Void>() + mapEntryNat44DumpMgr = new DumpCacheManager.DumpCacheManagerBuilder<Nat44StaticMappingDetailsReplyDump, Void>() .withExecutor(nat44DumpExecutor) - .acceptOnly(SnatStaticMappingDetailsReplyDump.class) + .acceptOnly(Nat44StaticMappingDetailsReplyDump.class) .build(); mapEntryNat64DumpMgr = new DumpCacheManager.DumpCacheManagerBuilder<Nat64BibDetailsReplyDump, Void>() .withExecutor(nat64DumpExecutor) @@ -98,18 +98,18 @@ public class NatInstanceCustomizerTest new NatInstanceKey(5L), new NatInstanceKey(6L))); } - private static SnatStaticMappingDetailsReplyDump nat44NonEmptyDump() { - SnatStaticMappingDetailsReplyDump replyDump = new SnatStaticMappingDetailsReplyDump(); - SnatStaticMappingDetails detailsOne = new SnatStaticMappingDetails(); + private static Nat44StaticMappingDetailsReplyDump nat44NonEmptyDump() { + Nat44StaticMappingDetailsReplyDump replyDump = new Nat44StaticMappingDetailsReplyDump(); + Nat44StaticMappingDetails detailsOne = new Nat44StaticMappingDetails(); detailsOne.vrfId = 1; - SnatStaticMappingDetails detailsTwo = new SnatStaticMappingDetails(); + Nat44StaticMappingDetails detailsTwo = new Nat44StaticMappingDetails(); detailsTwo.vrfId = 2; - SnatStaticMappingDetails detailsThree = new SnatStaticMappingDetails(); + Nat44StaticMappingDetails detailsThree = new Nat44StaticMappingDetails(); detailsThree.vrfId = 3; - replyDump.snatStaticMappingDetails = Arrays.asList(detailsOne, detailsTwo, detailsThree); + replyDump.nat44StaticMappingDetails = Arrays.asList(detailsOne, detailsTwo, detailsThree); return replyDump; } diff --git a/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/read/ifc/InterfaceInboundNatCustomizerTest.java b/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/read/ifc/InterfaceInboundNatCustomizerTest.java index a2d92b4d0..837056f55 100644 --- a/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/read/ifc/InterfaceInboundNatCustomizerTest.java +++ b/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/read/ifc/InterfaceInboundNatCustomizerTest.java @@ -28,12 +28,12 @@ import io.fd.hc2vpp.common.translate.util.NamingContext; import io.fd.honeycomb.translate.impl.read.GenericReader; import io.fd.honeycomb.translate.spi.read.ReaderCustomizer; import io.fd.honeycomb.translate.util.RWUtils; -import io.fd.vpp.jvpp.snat.dto.Nat64InterfaceDetailsReplyDump; -import io.fd.vpp.jvpp.snat.dto.SnatInterfaceDetails; -import io.fd.vpp.jvpp.snat.dto.SnatInterfaceDetailsReplyDump; -import io.fd.vpp.jvpp.snat.dto.SnatInterfaceOutputFeatureDetails; -import io.fd.vpp.jvpp.snat.dto.SnatInterfaceOutputFeatureDetailsReplyDump; -import io.fd.vpp.jvpp.snat.future.FutureJVppSnatFacade; +import io.fd.vpp.jvpp.nat.dto.Nat44InterfaceDetails; +import io.fd.vpp.jvpp.nat.dto.Nat44InterfaceDetailsReplyDump; +import io.fd.vpp.jvpp.nat.dto.Nat44InterfaceOutputFeatureDetails; +import io.fd.vpp.jvpp.nat.dto.Nat44InterfaceOutputFeatureDetailsReplyDump; +import io.fd.vpp.jvpp.nat.dto.Nat64InterfaceDetailsReplyDump; +import io.fd.vpp.jvpp.nat.future.FutureJVppNatFacade; import org.junit.Test; import org.mockito.Mock; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfacesState; @@ -55,7 +55,7 @@ public class InterfaceInboundNatCustomizerTest private static final String CTX_NAME = "ifc"; @Mock - private FutureJVppSnatFacade jvppSnat; + private FutureJVppNatFacade jvppNat; private NamingContext ifcContext = new NamingContext(CTX_NAME, CTX_NAME); private InstanceIdentifier<Inbound> id; @@ -76,10 +76,10 @@ public class InterfaceInboundNatCustomizerTest protected void setUp() throws Exception { id = getId(Inbound.class); defineMapping(mappingContext, IFC_NAME, IFC_IDX, CTX_NAME); - when(jvppSnat.snatInterfaceDump(any())).thenReturn(future(new SnatInterfaceDetailsReplyDump())); - when(jvppSnat.snatInterfaceOutputFeatureDump(any())) - .thenReturn(future(new SnatInterfaceOutputFeatureDetailsReplyDump())); - when(jvppSnat.nat64InterfaceDump(any())) + when(jvppNat.nat44InterfaceDump(any())).thenReturn(future(new Nat44InterfaceDetailsReplyDump())); + when(jvppNat.nat44InterfaceOutputFeatureDump(any())) + .thenReturn(future(new Nat44InterfaceOutputFeatureDetailsReplyDump())); + when(jvppNat.nat64InterfaceDump(any())) .thenReturn(future(new Nat64InterfaceDetailsReplyDump())); } @@ -88,22 +88,22 @@ public class InterfaceInboundNatCustomizerTest } private void mockPostRoutingDump() { - final SnatInterfaceOutputFeatureDetailsReplyDump details = new SnatInterfaceOutputFeatureDetailsReplyDump(); - final SnatInterfaceOutputFeatureDetails detail = new SnatInterfaceOutputFeatureDetails(); + final Nat44InterfaceOutputFeatureDetailsReplyDump details = new Nat44InterfaceOutputFeatureDetailsReplyDump(); + final Nat44InterfaceOutputFeatureDetails detail = new Nat44InterfaceOutputFeatureDetails(); detail.isInside = 1; detail.swIfIndex = IFC_IDX; - details.snatInterfaceOutputFeatureDetails = Lists.newArrayList(detail); - when(jvppSnat.snatInterfaceOutputFeatureDump(any())).thenReturn(future(details)); + details.nat44InterfaceOutputFeatureDetails = Lists.newArrayList(detail); + when(jvppNat.nat44InterfaceOutputFeatureDump(any())).thenReturn(future(details)); } @Test public void testPresencePreRouting() throws Exception { - final SnatInterfaceDetailsReplyDump details = new SnatInterfaceDetailsReplyDump(); - final SnatInterfaceDetails detail = new SnatInterfaceDetails(); + final Nat44InterfaceDetailsReplyDump details = new Nat44InterfaceDetailsReplyDump(); + final Nat44InterfaceDetails detail = new Nat44InterfaceDetails(); detail.isInside = 1; detail.swIfIndex = IFC_IDX; - details.snatInterfaceDetails = Lists.newArrayList(detail); - when(jvppSnat.snatInterfaceDump(any())).thenReturn(future(details)); + details.nat44InterfaceDetails = Lists.newArrayList(detail); + when(jvppNat.nat44InterfaceDump(any())).thenReturn(future(details)); assertTrue(getReader().read(id, ctx).isPresent()); } @@ -124,6 +124,6 @@ public class InterfaceInboundNatCustomizerTest @Override protected ReaderCustomizer<Inbound, InboundBuilder> initCustomizer() { - return new InterfaceInboundNatCustomizer(jvppSnat, ifcContext); + return new InterfaceInboundNatCustomizer(jvppNat, ifcContext); } }
\ No newline at end of file diff --git a/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/read/ifc/InterfaceOutboundNatCustomizerTest.java b/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/read/ifc/InterfaceOutboundNatCustomizerTest.java index 4640944a5..0e1bad3da 100644 --- a/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/read/ifc/InterfaceOutboundNatCustomizerTest.java +++ b/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/read/ifc/InterfaceOutboundNatCustomizerTest.java @@ -29,12 +29,12 @@ import io.fd.hc2vpp.common.translate.util.NamingContext; import io.fd.honeycomb.translate.impl.read.GenericReader; import io.fd.honeycomb.translate.spi.read.ReaderCustomizer; import io.fd.honeycomb.translate.util.RWUtils; -import io.fd.vpp.jvpp.snat.dto.Nat64InterfaceDetailsReplyDump; -import io.fd.vpp.jvpp.snat.dto.SnatInterfaceDetails; -import io.fd.vpp.jvpp.snat.dto.SnatInterfaceDetailsReplyDump; -import io.fd.vpp.jvpp.snat.dto.SnatInterfaceOutputFeatureDetails; -import io.fd.vpp.jvpp.snat.dto.SnatInterfaceOutputFeatureDetailsReplyDump; -import io.fd.vpp.jvpp.snat.future.FutureJVppSnatFacade; +import io.fd.vpp.jvpp.nat.dto.Nat44InterfaceDetails; +import io.fd.vpp.jvpp.nat.dto.Nat44InterfaceDetailsReplyDump; +import io.fd.vpp.jvpp.nat.dto.Nat44InterfaceOutputFeatureDetails; +import io.fd.vpp.jvpp.nat.dto.Nat44InterfaceOutputFeatureDetailsReplyDump; +import io.fd.vpp.jvpp.nat.dto.Nat64InterfaceDetailsReplyDump; +import io.fd.vpp.jvpp.nat.future.FutureJVppNatFacade; import org.junit.Test; import org.mockito.Mock; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.nat.rev170816._interface.nat.attributes.NatBuilder; @@ -50,7 +50,7 @@ public class InterfaceOutboundNatCustomizerTest private static final String CTX_NAME = "ifc"; @Mock - private FutureJVppSnatFacade jvppSnat; + private FutureJVppNatFacade jvppNat; private NamingContext ifcContext = new NamingContext(CTX_NAME, CTX_NAME); private InstanceIdentifier<Outbound> id; @@ -62,10 +62,10 @@ public class InterfaceOutboundNatCustomizerTest protected void setUp() throws Exception { id = getId(Outbound.class); defineMapping(mappingContext, IFC_NAME, IFC_IDX, CTX_NAME); - when(jvppSnat.snatInterfaceDump(any())).thenReturn(future(new SnatInterfaceDetailsReplyDump())); - when(jvppSnat.snatInterfaceOutputFeatureDump(any())) - .thenReturn(future(new SnatInterfaceOutputFeatureDetailsReplyDump())); - when(jvppSnat.nat64InterfaceDump(any())) + when(jvppNat.nat44InterfaceDump(any())).thenReturn(future(new Nat44InterfaceDetailsReplyDump())); + when(jvppNat.nat44InterfaceOutputFeatureDump(any())) + .thenReturn(future(new Nat44InterfaceOutputFeatureDetailsReplyDump())); + when(jvppNat.nat64InterfaceDump(any())) .thenReturn(future(new Nat64InterfaceDetailsReplyDump())); } @@ -74,22 +74,22 @@ public class InterfaceOutboundNatCustomizerTest } private void mockPostRoutingDump() { - final SnatInterfaceOutputFeatureDetailsReplyDump details = new SnatInterfaceOutputFeatureDetailsReplyDump(); - final SnatInterfaceOutputFeatureDetails detail = new SnatInterfaceOutputFeatureDetails(); + final Nat44InterfaceOutputFeatureDetailsReplyDump details = new Nat44InterfaceOutputFeatureDetailsReplyDump(); + final Nat44InterfaceOutputFeatureDetails detail = new Nat44InterfaceOutputFeatureDetails(); detail.isInside = 0; detail.swIfIndex = IFC_IDX; - details.snatInterfaceOutputFeatureDetails = Lists.newArrayList(detail); - when(jvppSnat.snatInterfaceOutputFeatureDump(any())).thenReturn(future(details)); + details.nat44InterfaceOutputFeatureDetails = Lists.newArrayList(detail); + when(jvppNat.nat44InterfaceOutputFeatureDump(any())).thenReturn(future(details)); } @Test public void testPresencePreRouting() throws Exception { - final SnatInterfaceDetailsReplyDump details = new SnatInterfaceDetailsReplyDump(); - final SnatInterfaceDetails detail = new SnatInterfaceDetails(); + final Nat44InterfaceDetailsReplyDump details = new Nat44InterfaceDetailsReplyDump(); + final Nat44InterfaceDetails detail = new Nat44InterfaceDetails(); detail.isInside = 0; detail.swIfIndex = IFC_IDX; - details.snatInterfaceDetails = Lists.newArrayList(detail); - when(jvppSnat.snatInterfaceDump(any())).thenReturn(future(details)); + details.nat44InterfaceDetails = Lists.newArrayList(detail); + when(jvppNat.nat44InterfaceDump(any())).thenReturn(future(details)); assertTrue(getReader().read(id, ctx).isPresent()); } @@ -110,6 +110,6 @@ public class InterfaceOutboundNatCustomizerTest @Override protected ReaderCustomizer<Outbound, OutboundBuilder> initCustomizer() { - return new InterfaceOutboundNatCustomizer(jvppSnat, ifcContext); + return new InterfaceOutboundNatCustomizer(jvppNat, ifcContext); } }
\ 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 a6643601e..cd173fddc 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 @@ -28,7 +28,7 @@ import com.google.common.base.Optional; import com.google.common.collect.Lists; import io.fd.honeycomb.translate.MappingContext; import io.fd.hc2vpp.common.translate.util.Ipv4Translator; -import io.fd.vpp.jvpp.snat.dto.SnatStaticMappingDetails; +import io.fd.vpp.jvpp.nat.dto.Nat44StaticMappingDetails; import java.util.Collections; import java.util.List; import org.junit.Before; @@ -81,7 +81,7 @@ public class MappingEntryContextTest implements Ipv4Translator { final long natId = 0; final long entryId = 12; final MappingEntry entry = getEntry(entryId, "192.168.1.5", "17.14.4.6"); - final SnatStaticMappingDetails details = getDetails(entryId, "192.168.1.5", "17.14.4.6"); + final Nat44StaticMappingDetails details = getDetails(entryId, "192.168.1.5", "17.14.4.6"); when(mappingCtx.read(MappingEntryContext.getId(natId, MappingEntryContext.entryToKey(entry)))) .thenReturn(Optional.of(MappingEntryContext.toCtxMapEntry(entry, entryId))); @@ -94,11 +94,11 @@ public class MappingEntryContextTest implements Ipv4Translator { public void testFindDetails() throws Exception { final long natId = 0; final MappingEntry entry = getEntry(0, "192.168.1.5", "17.14.4.6"); - final SnatStaticMappingDetails details = getDetails(0, "192.168.1.5", "17.14.4.6"); + final Nat44StaticMappingDetails details = getDetails(0, "192.168.1.5", "17.14.4.6"); final MappingEntry entry2 = getEntry(1, "192.168.1.8", "17.14.4.10"); - final SnatStaticMappingDetails details2 = getDetails(1, "192.168.1.8", "17.14.4.10"); + final Nat44StaticMappingDetails details2 = getDetails(1, "192.168.1.8", "17.14.4.10"); - final List<SnatStaticMappingDetails> someDetails = Lists.newArrayList(details, details2); + final List<Nat44StaticMappingDetails> someDetails = Lists.newArrayList(details, details2); when(mappingCtx.read(MappingEntryContext.getTableId(natId))) .thenReturn(Optional.of(new MappingTableBuilder() @@ -114,8 +114,8 @@ public class MappingEntryContextTest implements Ipv4Translator { public void testFindDetailsNoMappingStored() throws Exception { final long natId = 0; final long entryId = 12; - final SnatStaticMappingDetails details = getDetails(entryId, "192.168.1.5", "17.14.4.6"); - final List<SnatStaticMappingDetails> someDetails = Lists.newArrayList(details); + final Nat44StaticMappingDetails details = getDetails(entryId, "192.168.1.5", "17.14.4.6"); + final List<Nat44StaticMappingDetails> someDetails = Lists.newArrayList(details); when(mappingCtx.read(MappingEntryContext.getTableId(natId))).thenReturn(Optional.absent()); ctx.findDetailsNat44(someDetails, natId, entryId, mappingCtx); @@ -125,8 +125,8 @@ public class MappingEntryContextTest implements Ipv4Translator { public void testFindDetailsNoMappingStored2() throws Exception { final long natId = 0; final long entryId = 12; - final SnatStaticMappingDetails details = getDetails(entryId, "192.168.1.5", "17.14.4.6"); - final List<SnatStaticMappingDetails> someDetails = Lists.newArrayList(details); + final Nat44StaticMappingDetails details = getDetails(entryId, "192.168.1.5", "17.14.4.6"); + final List<Nat44StaticMappingDetails> someDetails = Lists.newArrayList(details); when(mappingCtx.read(MappingEntryContext.getTableId(natId))) .thenReturn(Optional.of(new MappingTableBuilder().setMappingEntry(Collections.emptyList()).build())); @@ -148,7 +148,7 @@ public class MappingEntryContextTest implements Ipv4Translator { final long newEntryId = 18956; final MappingEntry newEntry = getEntry(newEntryId, "192.168.1.99", "17.14.4.99"); - final SnatStaticMappingDetails newDetails = getDetails(newEntryId, "192.168.1.99", "17.14.4.99"); + final Nat44StaticMappingDetails newDetails = getDetails(newEntryId, "192.168.1.99", "17.14.4.99"); when(mappingCtx.read(MappingEntryContext.getId(natId, MappingEntryContext.entryToKey(newEntry)))) .thenReturn(Optional.absent()); @@ -165,14 +165,13 @@ public class MappingEntryContextTest implements Ipv4Translator { assertEquals(newEntryId, ctx.getStoredOrArtificialIndex(natId, newDetails, mappingCtx)); } - private SnatStaticMappingDetails getDetails(final long vrfId, final String localIp, final String externIp) { - final SnatStaticMappingDetails snatStaticMappingDetails = new SnatStaticMappingDetails(); - snatStaticMappingDetails.vrfId = (int) vrfId; - snatStaticMappingDetails.addrOnly = 1; - snatStaticMappingDetails.isIp4 = 1; - snatStaticMappingDetails.localIpAddress = ipv4AddressNoZoneToArray(localIp); - snatStaticMappingDetails.externalIpAddress = ipv4AddressNoZoneToArray(externIp); - return snatStaticMappingDetails; + private Nat44StaticMappingDetails getDetails(final long vrfId, final String localIp, final String externIp) { + final Nat44StaticMappingDetails nat44StaticMappingDetails = new Nat44StaticMappingDetails(); + nat44StaticMappingDetails.vrfId = (int) vrfId; + nat44StaticMappingDetails.addrOnly = 1; + nat44StaticMappingDetails.localIpAddress = ipv4AddressNoZoneToArray(localIp); + nat44StaticMappingDetails.externalIpAddress = ipv4AddressNoZoneToArray(externIp); + return nat44StaticMappingDetails; } @Test(expected = IllegalArgumentException.class) diff --git a/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/write/ExternalIpPoolCustomizerTest.java b/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/write/ExternalIpPoolCustomizerTest.java index 8f25bfa12..db68ecf6a 100644 --- a/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/write/ExternalIpPoolCustomizerTest.java +++ b/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/write/ExternalIpPoolCustomizerTest.java @@ -27,11 +27,11 @@ import io.fd.hc2vpp.nat.NatTestSchemaContext; import io.fd.honeycomb.test.tools.HoneycombTestRunner; import io.fd.honeycomb.test.tools.annotations.InjectTestData; import io.fd.honeycomb.translate.write.WriteFailedException; -import io.fd.vpp.jvpp.snat.dto.Nat64AddDelPoolAddrRange; -import io.fd.vpp.jvpp.snat.dto.Nat64AddDelPoolAddrRangeReply; -import io.fd.vpp.jvpp.snat.dto.SnatAddAddressRange; -import io.fd.vpp.jvpp.snat.dto.SnatAddAddressRangeReply; -import io.fd.vpp.jvpp.snat.future.FutureJVppSnatFacade; +import io.fd.vpp.jvpp.nat.dto.Nat44AddDelAddressRange; +import io.fd.vpp.jvpp.nat.dto.Nat44AddDelAddressRangeReply; +import io.fd.vpp.jvpp.nat.dto.Nat64AddDelPoolAddrRange; +import io.fd.vpp.jvpp.nat.dto.Nat64AddDelPoolAddrRangeReply; +import io.fd.vpp.jvpp.nat.future.FutureJVppNatFacade; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; @@ -56,14 +56,14 @@ public class ExternalIpPoolCustomizerTest extends WriterCustomizerTest implement private static final String NAT_INSTANCES_PATH = "/ietf-nat:nat-config/ietf-nat:nat-instances"; @Mock - private FutureJVppSnatFacade jvppSnat; + private FutureJVppNatFacade jvppNat; private ExternalIpPoolCustomizer customizer; @Override public void setUpTest() { - customizer = new ExternalIpPoolCustomizer(jvppSnat); - when(jvppSnat.snatAddAddressRange(any())).thenReturn(future(new SnatAddAddressRangeReply())); - when(jvppSnat.nat64AddDelPoolAddrRange(any())).thenReturn(future(new Nat64AddDelPoolAddrRangeReply())); + customizer = new ExternalIpPoolCustomizer(jvppNat); + when(jvppNat.nat44AddDelAddressRange(any())).thenReturn(future(new Nat44AddDelAddressRangeReply())); + when(jvppNat.nat64AddDelPoolAddrRange(any())).thenReturn(future(new Nat64AddDelPoolAddrRangeReply())); } @Test @@ -71,8 +71,8 @@ public class ExternalIpPoolCustomizerTest extends WriterCustomizerTest implement @InjectTestData(resourcePath = "/nat44/external-ip-pool.json", id = NAT_INSTANCES_PATH) NatInstances data) throws WriteFailedException { customizer.writeCurrentAttributes(IID, extractIpPool(data), writeContext); - final SnatAddAddressRange expectedRequest = getExpectedRequestNat44(true); - verify(jvppSnat).snatAddAddressRange(expectedRequest); + final Nat44AddDelAddressRange expectedRequest = getExpectedRequestNat44(true); + verify(jvppNat).nat44AddDelAddressRange(expectedRequest); } @Test @@ -81,7 +81,7 @@ public class ExternalIpPoolCustomizerTest extends WriterCustomizerTest implement throws WriteFailedException { customizer.writeCurrentAttributes(IID, extractIpPool(data), writeContext); final Nat64AddDelPoolAddrRange expectedRequest = getExpectedRequestNat64(true); - verify(jvppSnat).nat64AddDelPoolAddrRange(expectedRequest); + verify(jvppNat).nat64AddDelPoolAddrRange(expectedRequest); } @Test(expected = UnsupportedOperationException.class) @@ -95,8 +95,8 @@ public class ExternalIpPoolCustomizerTest extends WriterCustomizerTest implement @InjectTestData(resourcePath = "/nat44/external-ip-pool.json", id = NAT_INSTANCES_PATH) NatInstances data) throws WriteFailedException { customizer.deleteCurrentAttributes(IID, extractIpPool(data), writeContext); - final SnatAddAddressRange expectedRequest = getExpectedRequestNat44(false); - verify(jvppSnat).snatAddAddressRange(expectedRequest); + final Nat44AddDelAddressRange expectedRequest = getExpectedRequestNat44(false); + verify(jvppNat).nat44AddDelAddressRange(expectedRequest); } @Test @@ -105,7 +105,7 @@ public class ExternalIpPoolCustomizerTest extends WriterCustomizerTest implement throws WriteFailedException { customizer.deleteCurrentAttributes(IID, extractIpPool(data), writeContext); final Nat64AddDelPoolAddrRange expectedRequest = getExpectedRequestNat64(false); - verify(jvppSnat).nat64AddDelPoolAddrRange(expectedRequest); + verify(jvppNat).nat64AddDelPoolAddrRange(expectedRequest); } private static ExternalIpAddressPool extractIpPool(NatInstances data) { @@ -113,10 +113,9 @@ public class ExternalIpPoolCustomizerTest extends WriterCustomizerTest implement return data.getNatInstance().get(0).getExternalIpAddressPool().get(0); } - private SnatAddAddressRange getExpectedRequestNat44(final boolean isAdd) { - final SnatAddAddressRange expectedRequest = new SnatAddAddressRange(); + private Nat44AddDelAddressRange getExpectedRequestNat44(final boolean isAdd) { + final Nat44AddDelAddressRange expectedRequest = new Nat44AddDelAddressRange(); expectedRequest.isAdd = booleanToByte(isAdd); - expectedRequest.isIp4 = 1; expectedRequest.firstIpAddress = new byte[] {(byte) 192, (byte) 168, 1, 0}; expectedRequest.lastIpAddress = new byte[] {(byte) 192, (byte) 168, 1, (byte) 255}; return expectedRequest; diff --git a/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/write/MappingEntryCustomizerTest.java b/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/write/MappingEntryCustomizerTest.java index 96726cb11..29869381a 100644 --- a/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/write/MappingEntryCustomizerTest.java +++ b/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/write/MappingEntryCustomizerTest.java @@ -26,11 +26,11 @@ import io.fd.hc2vpp.nat.util.MappingEntryContext; import io.fd.honeycomb.test.tools.HoneycombTestRunner; import io.fd.honeycomb.test.tools.annotations.InjectTestData; import io.fd.honeycomb.translate.write.WriteFailedException; -import io.fd.vpp.jvpp.snat.dto.Nat64AddDelStaticBib; -import io.fd.vpp.jvpp.snat.dto.Nat64AddDelStaticBibReply; -import io.fd.vpp.jvpp.snat.dto.SnatAddStaticMapping; -import io.fd.vpp.jvpp.snat.dto.SnatAddStaticMappingReply; -import io.fd.vpp.jvpp.snat.future.FutureJVppSnatFacade; +import io.fd.vpp.jvpp.nat.dto.Nat44AddDelStaticMapping; +import io.fd.vpp.jvpp.nat.dto.Nat44AddDelStaticMappingReply; +import io.fd.vpp.jvpp.nat.dto.Nat64AddDelStaticBib; +import io.fd.vpp.jvpp.nat.dto.Nat64AddDelStaticBibReply; +import io.fd.vpp.jvpp.nat.future.FutureJVppNatFacade; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; @@ -56,16 +56,16 @@ public class MappingEntryCustomizerTest extends WriterCustomizerTest implements + "ietf-nat:nat-instance[ietf-nat:id='" + NAT_INSTANCE_ID + "']/ietf-nat:mapping-table"; @Mock - private FutureJVppSnatFacade jvppSnat; + private FutureJVppNatFacade jvppNat; @Mock private MappingEntryContext mappingContext; private MappingEntryCustomizer customizer; @Override public void setUpTest() { - customizer = new MappingEntryCustomizer(jvppSnat, mappingContext); - when(jvppSnat.snatAddStaticMapping(any())).thenReturn(future(new SnatAddStaticMappingReply())); - when(jvppSnat.nat64AddDelStaticBib(any())).thenReturn(future(new Nat64AddDelStaticBibReply())); + customizer = new MappingEntryCustomizer(jvppNat, mappingContext); + when(jvppNat.nat44AddDelStaticMapping(any())).thenReturn(future(new Nat44AddDelStaticMappingReply())); + when(jvppNat.nat64AddDelStaticBib(any())).thenReturn(future(new Nat64AddDelStaticBibReply())); } @Test @@ -73,9 +73,9 @@ public class MappingEntryCustomizerTest extends WriterCustomizerTest implements @InjectTestData(resourcePath = "/nat44/static-mapping.json", id = MAPPING_TABLE_PATH) MappingTable data) throws WriteFailedException { customizer.writeCurrentAttributes(IID, extractMappingEntry(data), writeContext); - final SnatAddStaticMapping expectedRequest = getExpectedNat44Request(); + final Nat44AddDelStaticMapping expectedRequest = getExpectedNat44Request(); expectedRequest.isAdd = 1; - verify(jvppSnat).snatAddStaticMapping(expectedRequest); + verify(jvppNat).nat44AddDelStaticMapping(expectedRequest); } @Test @@ -85,7 +85,7 @@ public class MappingEntryCustomizerTest extends WriterCustomizerTest implements customizer.writeCurrentAttributes(IID, extractMappingEntry(data), writeContext); final Nat64AddDelStaticBib expectedRequest = getExpectedNat64Request(); expectedRequest.isAdd = 1; - verify(jvppSnat).nat64AddDelStaticBib(expectedRequest); + verify(jvppNat).nat64AddDelStaticBib(expectedRequest); } @Test(expected = IllegalArgumentException.class) @@ -102,10 +102,10 @@ public class MappingEntryCustomizerTest extends WriterCustomizerTest implements throws WriteFailedException { customizer.updateCurrentAttributes(IID, extractMappingEntry(before), extractMappingEntry(after), writeContext); final Nat64AddDelStaticBib expectedDeleteRequest = getExpectedNat64Request(); - verify(jvppSnat).nat64AddDelStaticBib(expectedDeleteRequest); + verify(jvppNat).nat64AddDelStaticBib(expectedDeleteRequest); final Nat64AddDelStaticBib expectedUpdateRequest = getExpectedNat64UpdateRequest(); expectedUpdateRequest.isAdd = 1; - verify(jvppSnat).nat64AddDelStaticBib(expectedUpdateRequest); + verify(jvppNat).nat64AddDelStaticBib(expectedUpdateRequest); } @Test @@ -113,7 +113,7 @@ public class MappingEntryCustomizerTest extends WriterCustomizerTest implements @InjectTestData(resourcePath = "/nat44/static-mapping.json", id = MAPPING_TABLE_PATH) MappingTable data) throws WriteFailedException { customizer.deleteCurrentAttributes(IID, extractMappingEntry(data), writeContext); - verify(jvppSnat).snatAddStaticMapping(getExpectedNat44Request()); + verify(jvppNat).nat44AddDelStaticMapping(getExpectedNat44Request()); } @Test @@ -121,7 +121,7 @@ public class MappingEntryCustomizerTest extends WriterCustomizerTest implements @InjectTestData(resourcePath = "/nat64/static-mapping.json", id = MAPPING_TABLE_PATH) MappingTable data) throws WriteFailedException { customizer.deleteCurrentAttributes(IID, extractMappingEntry(data), writeContext); - verify(jvppSnat).nat64AddDelStaticBib(getExpectedNat64Request()); + verify(jvppNat).nat64AddDelStaticBib(getExpectedNat64Request()); } private static MappingEntry extractMappingEntry(MappingTable data) { @@ -129,9 +129,8 @@ public class MappingEntryCustomizerTest extends WriterCustomizerTest implements return data.getMappingEntry().get(0); } - private static SnatAddStaticMapping getExpectedNat44Request() { - final SnatAddStaticMapping expectedRequest = new SnatAddStaticMapping(); - expectedRequest.isIp4 = 1; + private static Nat44AddDelStaticMapping getExpectedNat44Request() { + final Nat44AddDelStaticMapping expectedRequest = new Nat44AddDelStaticMapping(); expectedRequest.addrOnly = 1; expectedRequest.protocol = 17; // udp expectedRequest.vrfId = (int) NAT_INSTANCE_ID; @@ -150,9 +149,8 @@ public class MappingEntryCustomizerTest extends WriterCustomizerTest implements return expectedRequest; } - private static SnatAddStaticMapping getExpectedNat44UpdateRequest() { - final SnatAddStaticMapping expectedRequest = new SnatAddStaticMapping(); - expectedRequest.isIp4 = 1; + private static Nat44AddDelStaticMapping getExpectedNat44UpdateRequest() { + final Nat44AddDelStaticMapping expectedRequest = new Nat44AddDelStaticMapping(); expectedRequest.addrOnly = 1; expectedRequest.protocol = 17; // udp expectedRequest.vrfId = (int) NAT_INSTANCE_ID; diff --git a/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/write/ifc/AbstractNatCustomizerTest.java b/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/write/ifc/AbstractNatCustomizerTest.java index c70999907..611103d40 100644 --- a/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/write/ifc/AbstractNatCustomizerTest.java +++ b/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/write/ifc/AbstractNatCustomizerTest.java @@ -24,13 +24,13 @@ import static org.mockito.Mockito.when; import io.fd.hc2vpp.common.test.write.WriterCustomizerTest; import io.fd.hc2vpp.common.translate.util.ByteDataTranslator; import io.fd.hc2vpp.common.translate.util.NamingContext; -import io.fd.vpp.jvpp.snat.dto.Nat64AddDelInterface; -import io.fd.vpp.jvpp.snat.dto.Nat64AddDelInterfaceReply; -import io.fd.vpp.jvpp.snat.dto.SnatInterfaceAddDelFeature; -import io.fd.vpp.jvpp.snat.dto.SnatInterfaceAddDelFeatureReply; -import io.fd.vpp.jvpp.snat.dto.SnatInterfaceAddDelOutputFeature; -import io.fd.vpp.jvpp.snat.dto.SnatInterfaceAddDelOutputFeatureReply; -import io.fd.vpp.jvpp.snat.future.FutureJVppSnatFacade; +import io.fd.vpp.jvpp.nat.dto.Nat44InterfaceAddDelFeature; +import io.fd.vpp.jvpp.nat.dto.Nat44InterfaceAddDelFeatureReply; +import io.fd.vpp.jvpp.nat.dto.Nat44InterfaceAddDelOutputFeature; +import io.fd.vpp.jvpp.nat.dto.Nat44InterfaceAddDelOutputFeatureReply; +import io.fd.vpp.jvpp.nat.dto.Nat64AddDelInterface; +import io.fd.vpp.jvpp.nat.dto.Nat64AddDelInterfaceReply; +import io.fd.vpp.jvpp.nat.future.FutureJVppNatFacade; import org.junit.Test; import org.mockito.Mock; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.nat.rev170816.InterfaceNatVppFeatureAttributes; @@ -47,17 +47,17 @@ abstract class AbstractNatCustomizerTest<D extends InterfaceNatVppFeatureAttribu private T customizer; @Mock - private FutureJVppSnatFacade snatApi; + private FutureJVppNatFacade natApi; private NamingContext ifcNamingCtx = new NamingContext("generatedIfaceName", IFC_CTX_NAME); @Override public void setUpTest() { - customizer = getCustomizer(snatApi, ifcNamingCtx); + customizer = getCustomizer(natApi, ifcNamingCtx); defineMapping(mappingContext, IFACE_NAME, IFACE_ID, IFC_CTX_NAME); - when(snatApi.snatInterfaceAddDelFeature(any())).thenReturn(future(new SnatInterfaceAddDelFeatureReply())); - when(snatApi.snatInterfaceAddDelOutputFeature(any())) - .thenReturn(future(new SnatInterfaceAddDelOutputFeatureReply())); - when(snatApi.nat64AddDelInterface(any())).thenReturn(future(new Nat64AddDelInterfaceReply())); + when(natApi.nat44InterfaceAddDelFeature(any())).thenReturn(future(new Nat44InterfaceAddDelFeatureReply())); + when(natApi.nat44InterfaceAddDelOutputFeature(any())) + .thenReturn(future(new Nat44InterfaceAddDelOutputFeatureReply())); + when(natApi.nat64AddDelInterface(any())).thenReturn(future(new Nat64AddDelInterfaceReply())); } @Test @@ -71,8 +71,8 @@ abstract class AbstractNatCustomizerTest<D extends InterfaceNatVppFeatureAttribu public void testWritePostRouting() throws Exception { final D data = getPostRoutingConfig(); customizer.writeCurrentAttributes(getIId(IFACE_NAME), data, writeContext); - verify(snatApi).snatInterfaceAddDelOutputFeature(expectedPostRoutingRequest(data, true)); - verify(snatApi, never()).nat64AddDelInterface(any()); // VPP does not support it currently + verify(natApi).nat44InterfaceAddDelOutputFeature(expectedPostRoutingRequest(data, true)); + verify(natApi, never()).nat64AddDelInterface(any()); // VPP does not support it currently } @Test(expected = UnsupportedOperationException.class) @@ -98,26 +98,26 @@ abstract class AbstractNatCustomizerTest<D extends InterfaceNatVppFeatureAttribu public void testDeletePostRouting() throws Exception { final D data = getPostRoutingConfig(); customizer.deleteCurrentAttributes(getIId(IFACE_NAME), data, writeContext); - verify(snatApi).snatInterfaceAddDelOutputFeature(expectedPostRoutingRequest(data, false)); - verify(snatApi, never()).nat64AddDelInterface(any()); // VPP does not support it currently + verify(natApi).nat44InterfaceAddDelOutputFeature(expectedPostRoutingRequest(data, false)); + verify(natApi, never()).nat64AddDelInterface(any()); // VPP does not support it currently } private void verifyPreRouting(final D data, final boolean isAdd) { if (data.isNat44Support()) { - verify(snatApi).snatInterfaceAddDelFeature(expectedPreRoutingNat44Request(data, isAdd)); + verify(natApi).nat44InterfaceAddDelFeature(expectedPreRoutingNat44Request(data, isAdd)); } else { - verify(snatApi, never()).snatInterfaceAddDelFeature(any()); + verify(natApi, never()).nat44InterfaceAddDelFeature(any()); } if (data.isNat64Support() != null && data.isNat64Support()) { - verify(snatApi).nat64AddDelInterface(expectedPreRoutingNat64Request(data, isAdd)); + verify(natApi).nat64AddDelInterface(expectedPreRoutingNat64Request(data, isAdd)); } else { - verify(snatApi, never()).nat64AddDelInterface(any()); + verify(natApi, never()).nat64AddDelInterface(any()); } } - private SnatInterfaceAddDelFeature expectedPreRoutingNat44Request(final D data, boolean isAdd) { - SnatInterfaceAddDelFeature request = new SnatInterfaceAddDelFeature(); + private Nat44InterfaceAddDelFeature expectedPreRoutingNat44Request(final D data, boolean isAdd) { + Nat44InterfaceAddDelFeature request = new Nat44InterfaceAddDelFeature(); request.isInside = booleanToByte(data instanceof Inbound); request.swIfIndex = IFACE_ID; request.isAdd = booleanToByte(isAdd); @@ -132,8 +132,8 @@ abstract class AbstractNatCustomizerTest<D extends InterfaceNatVppFeatureAttribu return request; } - private SnatInterfaceAddDelOutputFeature expectedPostRoutingRequest(final D data, boolean isAdd) { - SnatInterfaceAddDelOutputFeature request = new SnatInterfaceAddDelOutputFeature(); + private Nat44InterfaceAddDelOutputFeature expectedPostRoutingRequest(final D data, boolean isAdd) { + Nat44InterfaceAddDelOutputFeature request = new Nat44InterfaceAddDelOutputFeature(); request.isInside = booleanToByte(data instanceof Inbound); request.swIfIndex = IFACE_ID; request.isAdd = booleanToByte(isAdd); @@ -146,5 +146,5 @@ abstract class AbstractNatCustomizerTest<D extends InterfaceNatVppFeatureAttribu protected abstract InstanceIdentifier<D> getIId(final String ifaceName); - protected abstract T getCustomizer(final FutureJVppSnatFacade snatApi, final NamingContext ifcNamingCtx); + protected abstract T getCustomizer(final FutureJVppNatFacade natApi, final NamingContext ifcNamingCtx); }
\ No newline at end of file diff --git a/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/write/ifc/InterfaceInboundNatCustomizerTest.java b/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/write/ifc/InterfaceInboundNatCustomizerTest.java index 74dd59938..b05c83e1a 100644 --- a/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/write/ifc/InterfaceInboundNatCustomizerTest.java +++ b/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/write/ifc/InterfaceInboundNatCustomizerTest.java @@ -17,7 +17,7 @@ package io.fd.hc2vpp.nat.write.ifc; import io.fd.hc2vpp.common.translate.util.NamingContext; -import io.fd.vpp.jvpp.snat.future.FutureJVppSnatFacade; +import io.fd.vpp.jvpp.nat.future.FutureJVppNatFacade; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.Interfaces; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey; @@ -48,8 +48,8 @@ public class InterfaceInboundNatCustomizerTest } @Override - protected InterfaceInboundNatCustomizer getCustomizer(final FutureJVppSnatFacade snatApi, + protected InterfaceInboundNatCustomizer getCustomizer(final FutureJVppNatFacade natApi, final NamingContext ifcNamingCtx) { - return new InterfaceInboundNatCustomizer(snatApi, ifcNamingCtx); + return new InterfaceInboundNatCustomizer(natApi, ifcNamingCtx); } }
\ No newline at end of file diff --git a/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/write/ifc/InterfaceOutboundNatCustomizerTest.java b/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/write/ifc/InterfaceOutboundNatCustomizerTest.java index ddd589472..f15182659 100644 --- a/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/write/ifc/InterfaceOutboundNatCustomizerTest.java +++ b/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/write/ifc/InterfaceOutboundNatCustomizerTest.java @@ -17,7 +17,7 @@ package io.fd.hc2vpp.nat.write.ifc; import io.fd.hc2vpp.common.translate.util.NamingContext; -import io.fd.vpp.jvpp.snat.future.FutureJVppSnatFacade; +import io.fd.vpp.jvpp.nat.future.FutureJVppNatFacade; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.Interfaces; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey; @@ -48,8 +48,8 @@ public class InterfaceOutboundNatCustomizerTest } @Override - protected InterfaceOutboundNatCustomizer getCustomizer(final FutureJVppSnatFacade snatApi, + protected InterfaceOutboundNatCustomizer getCustomizer(final FutureJVppNatFacade natApi, final NamingContext ifcNamingCtx) { - return new InterfaceOutboundNatCustomizer(snatApi, ifcNamingCtx); + return new InterfaceOutboundNatCustomizer(natApi, ifcNamingCtx); } }
\ No newline at end of file |