summaryrefslogtreecommitdiffstats
path: root/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/read/ifc/InterfaceOutboundNatCustomizerTest.java
diff options
context:
space:
mode:
authorMarek Gradzki <mgradzki@cisco.com>2017-08-01 13:43:14 +0200
committerJan Srnicek <jsrnicek@cisco.com>2017-08-02 11:19:25 +0000
commit33ecedc83c01e4d33e8304d9759100dcd95cb244 (patch)
tree739f0fdd39960f53e3b11d5926ed5fde69687c7c /nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/read/ifc/InterfaceOutboundNatCustomizerTest.java
parentc86637969d6fce3759b3ce8a693ec16eb14b04e6 (diff)
HC2VPP-197: translation layert for post routing NAT
Change-Id: Icef6682fbc7a18a1e52953270ad26f6b3b7676eb Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
Diffstat (limited to 'nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/read/ifc/InterfaceOutboundNatCustomizerTest.java')
-rw-r--r--nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/read/ifc/InterfaceOutboundNatCustomizerTest.java55
1 files changed, 39 insertions, 16 deletions
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 b19878be8..833a4fa74 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
@@ -19,6 +19,10 @@ package io.fd.hc2vpp.nat.read.ifc;
import static io.fd.hc2vpp.nat.read.ifc.InterfaceInboundNatCustomizerTest.getId;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
import com.google.common.collect.Lists;
import io.fd.hc2vpp.common.test.read.ReaderCustomizerTest;
@@ -26,13 +30,13 @@ 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.honeycomb.translate.util.read.cache.DumpCacheManager;
-import io.fd.honeycomb.translate.util.read.cache.EntityDumpExecutor;
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 org.junit.Test;
import org.mockito.Mock;
-import org.mockito.Mockito;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.nat.rev170801._interface.nat.attributes.NatBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.nat.rev170801._interface.nat.attributes.nat.Outbound;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.nat.rev170801._interface.nat.attributes.nat.OutboundBuilder;
@@ -46,8 +50,7 @@ public class InterfaceOutboundNatCustomizerTest
private static final String CTX_NAME = "ifc";
@Mock
- private EntityDumpExecutor<SnatInterfaceDetailsReplyDump, Void> abc;
- private DumpCacheManager<SnatInterfaceDetailsReplyDump, Void> dumpMgr;
+ private FutureJVppSnatFacade jvppSnat;
private NamingContext ifcContext = new NamingContext(CTX_NAME, CTX_NAME);
private InstanceIdentifier<Outbound> id;
@@ -59,12 +62,13 @@ public class InterfaceOutboundNatCustomizerTest
protected void setUp() throws Exception {
id = getId(Outbound.class);
defineMapping(mappingContext, IFC_NAME, IFC_IDX, CTX_NAME);
- // empty dump
- Mockito.doReturn(new SnatInterfaceDetailsReplyDump()).when(abc).executeDump(id, null);
- dumpMgr = new DumpCacheManager.DumpCacheManagerBuilder<SnatInterfaceDetailsReplyDump, Void>()
- .withExecutor(abc)
- .acceptOnly(SnatInterfaceDetailsReplyDump.class)
- .build();
+ when(jvppSnat.snatInterfaceDump(any())).thenReturn(future(new SnatInterfaceDetailsReplyDump()));
+ when(jvppSnat.snatInterfaceOutputFeatureDump(any()))
+ .thenReturn(future(new SnatInterfaceOutputFeatureDetailsReplyDump()));
+ }
+
+ private GenericReader<Outbound, OutboundBuilder> getReader() {
+ return new GenericReader<>(RWUtils.makeIidWildcarded(id), customizer);
}
@Test
@@ -72,24 +76,43 @@ public class InterfaceOutboundNatCustomizerTest
assertFalse(getReader().read(id, ctx).isPresent());
}
- private GenericReader<Outbound, OutboundBuilder> getReader() {
- return new GenericReader<>(RWUtils.makeIidWildcarded(id), customizer);
+ private void mockPostRoutingDump() {
+ final SnatInterfaceOutputFeatureDetailsReplyDump details = new SnatInterfaceOutputFeatureDetailsReplyDump();
+ final SnatInterfaceOutputFeatureDetails detail = new SnatInterfaceOutputFeatureDetails();
+ detail.isInside = 0;
+ detail.swIfIndex = IFC_IDX;
+ details.snatInterfaceOutputFeatureDetails = Lists.newArrayList(detail);
+ when(jvppSnat.snatInterfaceOutputFeatureDump(any())).thenReturn(future(details));
}
@Test
- public void testPresence() throws Exception {
+ public void testPresencePreRouting() throws Exception {
final SnatInterfaceDetailsReplyDump details = new SnatInterfaceDetailsReplyDump();
final SnatInterfaceDetails detail = new SnatInterfaceDetails();
detail.isInside = 0;
detail.swIfIndex = IFC_IDX;
details.snatInterfaceDetails = Lists.newArrayList(detail);
- Mockito.doReturn(details).when(abc).executeDump(id, null);
+ when(jvppSnat.snatInterfaceDump(any())).thenReturn(future(details));
assertTrue(getReader().read(id, ctx).isPresent());
}
+ @Test
+ public void testPresencePostRouting() throws Exception {
+ mockPostRoutingDump();
+ assertTrue(getReader().read(id, ctx).isPresent());
+ }
+
+ @Test
+ public void testReadPostRouting() throws Exception {
+ mockPostRoutingDump();
+ final OutboundBuilder builder = mock(OutboundBuilder.class);
+ customizer.readCurrentAttributes(id, builder, ctx);
+ verify(builder).setPostRouting(true);
+ }
+
@Override
protected ReaderCustomizer<Outbound, OutboundBuilder> initCustomizer() {
- return new InterfaceOutboundNatCustomizer(dumpMgr, ifcContext);
+ return new InterfaceOutboundNatCustomizer(jvppSnat, ifcContext);
}
} \ No newline at end of file