summaryrefslogtreecommitdiffstats
path: root/v3po
diff options
context:
space:
mode:
authorMarek Gradzki <mgradzki@cisco.com>2016-09-23 09:06:19 +0200
committerMarek Gradzki <mgradzki@cisco.com>2016-09-26 08:15:38 +0200
commit0cfdff5e57bd6357acc64debf0ee49c9455a24d7 (patch)
tree54f14153077acb811212c0ba7293d894ffca7596 /v3po
parent60d69218642cc976fa606fd8a38623d8c035dd86 (diff)
HONEYCOMB-116: utility for stubbing MappingContext methods
- introduces MappingContextHelper (refactored ContextTestUtils) - updates all v3po and lisp unit tests to use MCH - updates lisp tests to mock EidMappingContext Change-Id: I73b1adda767db71388ca1c4d7206cfd7ee9c70e1 Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
Diffstat (limited to 'v3po')
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/AclCustomizerTest.java3
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/GreCustomizerTest.java26
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/RewriteCustomizerTest.java3
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/SubInterfaceCustomizerTest.java17
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/TapCustomizerTest.java19
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/VhostUserCustomizerTest.java19
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/VxlanCustomizerTest.java27
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/VxlanGpeCustomizerTest.java29
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv4AddressCustomizerTest.java15
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv4NeighbourCustomizerTest.java3
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/AclCustomizerTest.java3
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/GreCustomizerTest.java3
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/InterfaceCustomizerTest.java7
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/L2CustomizerTest.java5
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/RewriteCustomizerTest.java3
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/SubInterfaceCustomizerTest.java9
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/VxlanCustomizerTest.java3
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/VxlanGpeCustomizerTest.java3
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/Ipv4AddressCustomizerTest.java5
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/notification/InterfaceChangeNotificationProducerTest.java6
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/test/ContextTestUtils.java86
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vpp/ArpTerminationTableEntryCustomizerTest.java5
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vpp/BridgeDomainCustomizerTest.java25
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vpp/L2FibEntryCustomizerTest.java5
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppstate/L2FibEntryCustomizerTest.java5
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppstate/VppStateTest.java10
26 files changed, 113 insertions, 231 deletions
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/AclCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/AclCustomizerTest.java
index b55a5ce2b..5de6e5e73 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/AclCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/AclCustomizerTest.java
@@ -22,7 +22,6 @@ import static org.mockito.Matchers.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.verify;
-import io.fd.honeycomb.translate.v3po.test.ContextTestUtils;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
import io.fd.honeycomb.translate.v3po.vppclassifier.VppClassifierContextManager;
import io.fd.honeycomb.translate.write.WriteFailedException;
@@ -58,7 +57,7 @@ public class AclCustomizerTest extends WriterCustomizerTest {
@Override
public void setUp() {
- ContextTestUtils.mockMapping(mappingContext, IF_NAME, IF_INDEX, IFC_TEST_INSTANCE);
+ defineMapping(mappingContext, IF_NAME, IF_INDEX, IFC_TEST_INSTANCE);
customizer = new AclCustomizer(api, new NamingContext("generatedInterfaceName", IFC_TEST_INSTANCE),
classifyTableContext);
}
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/GreCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/GreCustomizerTest.java
index 6918e1f01..1a8aec645 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/GreCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/GreCustomizerTest.java
@@ -16,10 +16,6 @@
package io.fd.honeycomb.translate.v3po.interfaces;
-import static io.fd.honeycomb.translate.v3po.test.ContextTestUtils.getMapping;
-import static io.fd.honeycomb.translate.v3po.test.ContextTestUtils.getMappingIid;
-import static io.fd.honeycomb.translate.v3po.test.ContextTestUtils.mockEmptyMapping;
-import static io.fd.honeycomb.translate.v3po.test.ContextTestUtils.mockMapping;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@@ -116,12 +112,12 @@ public class GreCustomizerTest extends WriterCustomizerTest {
whenGreAddDelTunnelThenSuccess();
- mockEmptyMapping(mappingContext, IFACE_NAME, IFC_TEST_INSTANCE);
+ noMappingDefined(mappingContext, IFACE_NAME, IFC_TEST_INSTANCE);
customizer.writeCurrentAttributes(id, gre, writeContext);
verifyGreAddWasInvoked(gre);
- verify(mappingContext).put(eq(getMappingIid(IFACE_NAME, IFC_TEST_INSTANCE)),
- eq(getMapping(IFACE_NAME, IFACE_ID).get()));
+ verify(mappingContext).put(eq(mappingIid(IFACE_NAME, IFC_TEST_INSTANCE)),
+ eq(mapping(IFACE_NAME, IFACE_ID).get()));
}
@Test
@@ -129,14 +125,14 @@ public class GreCustomizerTest extends WriterCustomizerTest {
final Gre gre = generateGre();
whenGreAddDelTunnelThenSuccess();
- mockMapping(mappingContext, IFACE_NAME, IFACE_ID, IFC_TEST_INSTANCE);
+ defineMapping(mappingContext, IFACE_NAME, IFACE_ID, IFC_TEST_INSTANCE);
customizer.writeCurrentAttributes(id, gre, writeContext);
verifyGreAddWasInvoked(gre);
// Remove the first mapping before putting in the new one
- verify(mappingContext).delete(eq(getMappingIid(IFACE_NAME, IFC_TEST_INSTANCE)));
- verify(mappingContext).put(eq(getMappingIid(IFACE_NAME, IFC_TEST_INSTANCE)), eq(getMapping(IFACE_NAME, IFACE_ID).get()));
+ verify(mappingContext).delete(eq(mappingIid(IFACE_NAME, IFC_TEST_INSTANCE)));
+ verify(mappingContext).put(eq(mappingIid(IFACE_NAME, IFC_TEST_INSTANCE)), eq(mapping(IFACE_NAME, IFACE_ID).get()));
}
@Test
@@ -151,7 +147,7 @@ public class GreCustomizerTest extends WriterCustomizerTest {
assertTrue(e.getCause() instanceof VppBaseCallException);
verifyGreAddWasInvoked(gre);
// Mapping not stored due to failure
- verify(mappingContext, times(0)).put(eq(getMappingIid(IFACE_NAME, IFC_TEST_INSTANCE)), eq(getMapping(
+ verify(mappingContext, times(0)).put(eq(mappingIid(IFACE_NAME, IFC_TEST_INSTANCE)), eq(mapping(
IFACE_NAME, 0).get()));
return;
}
@@ -174,11 +170,11 @@ public class GreCustomizerTest extends WriterCustomizerTest {
final Gre gre = generateGre();
whenGreAddDelTunnelThenSuccess();
- mockMapping(mappingContext, IFACE_NAME, IFACE_ID, IFC_TEST_INSTANCE);
+ defineMapping(mappingContext, IFACE_NAME, IFACE_ID, IFC_TEST_INSTANCE);
customizer.deleteCurrentAttributes(id, gre, writeContext);
verifyGreDeleteWasInvoked(gre);
- verify(mappingContext).delete(eq(getMappingIid(IFACE_NAME, IFC_TEST_INSTANCE)));
+ verify(mappingContext).delete(eq(mappingIid(IFACE_NAME, IFC_TEST_INSTANCE)));
}
@Test
@@ -186,14 +182,14 @@ public class GreCustomizerTest extends WriterCustomizerTest {
final Gre gre = generateGre();
whenGreAddDelTunnelThenFailure();
- mockMapping(mappingContext, IFACE_NAME, IFACE_ID, IFC_TEST_INSTANCE);
+ defineMapping(mappingContext, IFACE_NAME, IFACE_ID, IFC_TEST_INSTANCE);
try {
customizer.deleteCurrentAttributes(id, gre, writeContext);
} catch (WriteFailedException.DeleteFailedException e) {
assertTrue(e.getCause() instanceof VppBaseCallException);
verifyGreDeleteWasInvoked(gre);
- verify(mappingContext, times(0)).delete(eq(getMappingIid(IFACE_NAME, IFC_TEST_INSTANCE)));
+ verify(mappingContext, times(0)).delete(eq(mappingIid(IFACE_NAME, IFC_TEST_INSTANCE)));
return;
}
fail("WriteFailedException.DeleteFailedException was expected");
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/RewriteCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/RewriteCustomizerTest.java
index e28a0f6c6..d6d1631bb 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/RewriteCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/RewriteCustomizerTest.java
@@ -22,7 +22,6 @@ import static org.mockito.Matchers.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.verify;
-import io.fd.honeycomb.translate.v3po.test.ContextTestUtils;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
import io.fd.honeycomb.translate.v3po.util.TagRewriteOperation;
import io.fd.honeycomb.translate.write.WriteFailedException;
@@ -63,7 +62,7 @@ public class RewriteCustomizerTest extends WriterCustomizerTest {
namingContext = new NamingContext("generatedSubInterfaceName", IFC_TEST_INSTANCE);
customizer = new RewriteCustomizer(api, namingContext);
VLAN_IID = getVlanTagRewriteId(IF_NAME, VLAN_IF_ID);
- ContextTestUtils.mockMapping(mappingContext, VLAN_IF_NAME, VLAN_IF_INDEX, IFC_TEST_INSTANCE);
+ defineMapping(mappingContext, VLAN_IF_NAME, VLAN_IF_INDEX, IFC_TEST_INSTANCE);
}
private static InstanceIdentifier<Rewrite> getVlanTagRewriteId(final String name, final long index) {
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/SubInterfaceCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/SubInterfaceCustomizerTest.java
index 1fee0b3cf..86af0f094 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/SubInterfaceCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/SubInterfaceCustomizerTest.java
@@ -25,7 +25,6 @@ import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-import io.fd.honeycomb.translate.v3po.test.ContextTestUtils;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest;
@@ -91,8 +90,8 @@ public class SubInterfaceCustomizerTest extends WriterCustomizerTest {
public void setUp() throws Exception {
namingContext = new NamingContext("generatedSubInterfaceName", IFC_TEST_INSTANCE);
customizer = new SubInterfaceCustomizer(api, namingContext);
- ContextTestUtils.mockMapping(mappingContext, SUB_IFACE_NAME, SUBIF_INDEX, IFC_TEST_INSTANCE);
- ContextTestUtils.mockMapping(mappingContext, SUPER_IF_NAME, SUPER_IF_ID, IFC_TEST_INSTANCE);
+ defineMapping(mappingContext, SUB_IFACE_NAME, SUBIF_INDEX, IFC_TEST_INSTANCE);
+ defineMapping(mappingContext, SUPER_IF_NAME, SUPER_IF_ID, IFC_TEST_INSTANCE);
}
private SubInterface generateSubInterface(final boolean enabled, final List<Tag> tagList) {
@@ -198,8 +197,8 @@ public class SubInterfaceCustomizerTest extends WriterCustomizerTest {
verify(api).createSubif(generateSubInterfaceRequest(SUPER_IF_ID, CTAG_ID, false));
verify(mappingContext)
- .put(eq(ContextTestUtils.getMappingIid(SUB_IFACE_NAME, IFC_TEST_INSTANCE)), eq(
- ContextTestUtils.getMapping(SUB_IFACE_NAME, 0).get()));
+ .put(eq(mappingIid(SUB_IFACE_NAME, IFC_TEST_INSTANCE)), eq(
+ mapping(SUB_IFACE_NAME, 0).get()));
}
@Test
@@ -214,8 +213,8 @@ public class SubInterfaceCustomizerTest extends WriterCustomizerTest {
verify(api).createSubif(generateSubInterfaceRequest(SUPER_IF_ID, CTAG_ANY_ID, true));
verify(mappingContext)
- .put(eq(ContextTestUtils.getMappingIid(SUB_IFACE_NAME, IFC_TEST_INSTANCE)), eq(
- ContextTestUtils.getMapping(SUB_IFACE_NAME, 0).get()));
+ .put(eq(mappingIid(SUB_IFACE_NAME, IFC_TEST_INSTANCE)), eq(
+ mapping(SUB_IFACE_NAME, 0).get()));
}
@Test
@@ -231,8 +230,8 @@ public class SubInterfaceCustomizerTest extends WriterCustomizerTest {
assertTrue(e.getCause() instanceof VppBaseCallException);
verify(api).createSubif(generateSubInterfaceRequest(SUPER_IF_ID, CTAG_ID, false));
verify(mappingContext, times(0)).put(
- eq(ContextTestUtils.getMappingIid(SUPER_IF_NAME, IFC_TEST_INSTANCE)),
- eq(ContextTestUtils.getMapping(SUPER_IF_NAME, 0).get()));
+ eq(mappingIid(SUPER_IF_NAME, IFC_TEST_INSTANCE)),
+ eq(mapping(SUPER_IF_NAME, 0).get()));
return;
}
fail("WriteFailedException.CreateFailedException was expected");
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/TapCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/TapCustomizerTest.java
index c2c687602..88232d55f 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/TapCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/TapCustomizerTest.java
@@ -23,7 +23,6 @@ import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-import io.fd.honeycomb.translate.v3po.test.ContextTestUtils;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest;
import org.junit.Test;
@@ -74,10 +73,10 @@ public class TapCustomizerTest extends WriterCustomizerTest {
tapCustomizer.writeCurrentAttributes(getTapId("tap2"), getTapData("tap2", "ff:ff:ff:ff:ff:ff"), writeContext);
verify(api, times(2)).tapConnect(any(TapConnect.class));
- verify(mappingContext).put(eq(ContextTestUtils.getMappingIid("tap", IFC_TEST_INSTANCE)), eq(
- ContextTestUtils.getMapping("tap", 0).get()));
- verify(mappingContext).put(eq(ContextTestUtils.getMappingIid("tap2", IFC_TEST_INSTANCE)), eq(
- ContextTestUtils.getMapping("tap2", 1).get()));
+ verify(mappingContext).put(eq(mappingIid("tap", IFC_TEST_INSTANCE)), eq(
+ mapping("tap", 0).get()));
+ verify(mappingContext).put(eq(mappingIid("tap2", IFC_TEST_INSTANCE)), eq(
+ mapping("tap2", 1).get()));
}
@Test
@@ -92,14 +91,14 @@ public class TapCustomizerTest extends WriterCustomizerTest {
tapCustomizer.writeCurrentAttributes(getTapId("tap"), getTapData("tap", "ff:ff:ff:ff:ff:ff"), writeContext);
- ContextTestUtils.mockMapping(mappingContext, "tap", 1, IFC_TEST_INSTANCE);
+ defineMapping(mappingContext, "tap", 1, IFC_TEST_INSTANCE);
tapCustomizer.updateCurrentAttributes(getTapId("tap"), getTapData("tap", "ff:ff:ff:ff:ff:ff"), getTapData("tap", "ff:ff:ff:ff:ff:f1"), writeContext);
verify(api).tapConnect(any(TapConnect.class));
verify(api).tapModify(any(TapModify.class));
- verify(mappingContext).put(eq(ContextTestUtils.getMappingIid("tap", IFC_TEST_INSTANCE)), eq(
- ContextTestUtils.getMapping("tap", 0).get()));
+ verify(mappingContext).put(eq(mappingIid("tap", IFC_TEST_INSTANCE)), eq(
+ mapping("tap", 0).get()));
}
@Test
@@ -111,12 +110,12 @@ public class TapCustomizerTest extends WriterCustomizerTest {
doReturn(future(new TapDeleteReply())).when(api).tapDelete(any(TapDelete.class));
tapCustomizer.writeCurrentAttributes(getTapId("tap"), getTapData("tap", "ff:ff:ff:ff:ff:ff"), writeContext);
- ContextTestUtils.mockMapping(mappingContext, "tap", 1, IFC_TEST_INSTANCE);
+ defineMapping(mappingContext, "tap", 1, IFC_TEST_INSTANCE);
tapCustomizer.deleteCurrentAttributes(getTapId("tap"), getTapData("tap", "ff:ff:ff:ff:ff:ff"), writeContext);
verify(api).tapConnect(any(TapConnect.class));
verify(api).tapDelete(any(TapDelete.class));
- verify(mappingContext).delete(eq(ContextTestUtils.getMappingIid("tap", IFC_TEST_INSTANCE)));
+ verify(mappingContext).delete(eq(mappingIid("tap", IFC_TEST_INSTANCE)));
}
private InstanceIdentifier<Tap> getTapId(final String tap) {
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/VhostUserCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/VhostUserCustomizerTest.java
index a47f5b641..176f3209c 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/VhostUserCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/VhostUserCustomizerTest.java
@@ -29,7 +29,6 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.when;
-import io.fd.honeycomb.translate.v3po.test.ContextTestUtils;
import io.fd.honeycomb.translate.v3po.util.Ipv4Translator;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
@@ -121,8 +120,8 @@ public class VhostUserCustomizerTest extends WriterCustomizerTest implements Ipv
customizer.writeCurrentAttributes(ID, vhostUser, writeContext);
verifyCreateVhostUserIfWasInvoked(vhostUser);
- verify(mappingContext).put(eq(ContextTestUtils.getMappingIid(IFACE_NAME, "test-instance")), eq(
- ContextTestUtils.getMapping(IFACE_NAME, 0).get()));
+ verify(mappingContext).put(eq(mappingIid(IFACE_NAME, "test-instance")), eq(
+ mapping(IFACE_NAME, 0).get()));
}
@Test
@@ -146,7 +145,7 @@ public class VhostUserCustomizerTest extends WriterCustomizerTest implements Ipv
public void testUpdateCurrentAttributes() throws Exception {
final VhostUser vhostUserBefore = generateVhostUser(VhostUserRole.Client, "socketName0");
final VhostUser vhostUserAfter = generateVhostUser(VhostUserRole.Server, "socketName1");
- ContextTestUtils.mockMapping(mappingContext, IFACE_NAME, IFACE_ID, "test-instance");
+ defineMapping(mappingContext, IFACE_NAME, IFACE_ID, "test-instance");
when(api.modifyVhostUserIf(any(ModifyVhostUserIf.class))).thenReturn(future(new ModifyVhostUserIfReply()));
@@ -158,7 +157,7 @@ public class VhostUserCustomizerTest extends WriterCustomizerTest implements Ipv
public void testUpdateCurrentAttributesFailed() throws Exception {
final VhostUser vhostUserBefore = generateVhostUser(VhostUserRole.Client, "socketName0");
final VhostUser vhostUserAfter = generateVhostUser(VhostUserRole.Server, "socketName1");
- ContextTestUtils.mockMapping(mappingContext, IFACE_NAME, IFACE_ID, "test-instance");
+ defineMapping(mappingContext, IFACE_NAME, IFACE_ID, "test-instance");
doReturn(failedFuture()).when(api).modifyVhostUserIf(any(ModifyVhostUserIf.class));
@@ -175,19 +174,19 @@ public class VhostUserCustomizerTest extends WriterCustomizerTest implements Ipv
@Test
public void testDeleteCurrentAttributes() throws Exception {
final VhostUser vhostUser = generateVhostUser(VhostUserRole.Client, "socketName");
- ContextTestUtils.mockMapping(mappingContext, IFACE_NAME, IFACE_ID, "test-instance");
+ defineMapping(mappingContext, IFACE_NAME, IFACE_ID, "test-instance");
when(api.deleteVhostUserIf(any(DeleteVhostUserIf.class))).thenReturn(future(new DeleteVhostUserIfReply()));
customizer.deleteCurrentAttributes(ID, vhostUser, writeContext);
verifyDeleteVhostUserIfWasInvoked(IFACE_ID);
- verify(mappingContext).delete(eq(ContextTestUtils.getMappingIid(IFACE_NAME, "test-instance")));
+ verify(mappingContext).delete(eq(mappingIid(IFACE_NAME, "test-instance")));
}
@Test
public void testDeleteCurrentAttributesFailed() throws Exception {
final VhostUser vhostUser = generateVhostUser(VhostUserRole.Client, "socketName");
- ContextTestUtils.mockMapping(mappingContext, IFACE_NAME, IFACE_ID, "test-instance");
+ defineMapping(mappingContext, IFACE_NAME, IFACE_ID, "test-instance");
doReturn(failedFuture()).when(api).deleteVhostUserIf(any(DeleteVhostUserIf.class));
@@ -197,8 +196,8 @@ public class VhostUserCustomizerTest extends WriterCustomizerTest implements Ipv
assertTrue(e.getCause() instanceof VppBaseCallException);
verifyDeleteVhostUserIfWasInvoked(IFACE_ID);
// Delete from context not invoked if delete from VPP failed
- verify(mappingContext, times(0)).delete(eq(ContextTestUtils.getMappingIid(IFACE_NAME, "test-instance")));
- verify(mappingContext).read(eq(ContextTestUtils.getMappingIid(IFACE_NAME, "test-instance")));
+ verify(mappingContext, times(0)).delete(eq(mappingIid(IFACE_NAME, "test-instance")));
+ verify(mappingContext).read(eq(mappingIid(IFACE_NAME, "test-instance")));
return;
}
fail("WriteFailedException.DeleteFailedException was expected");
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/VxlanCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/VxlanCustomizerTest.java
index ed099f740..6bb8bd279 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/VxlanCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/VxlanCustomizerTest.java
@@ -16,8 +16,6 @@
package io.fd.honeycomb.translate.v3po.interfaces;
-import static io.fd.honeycomb.translate.v3po.test.ContextTestUtils.getMapping;
-import static io.fd.honeycomb.translate.v3po.test.ContextTestUtils.getMappingIid;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@@ -31,7 +29,6 @@ import static org.mockito.Mockito.when;
import com.google.common.net.InetAddresses;
import io.fd.honeycomb.translate.v3po.DisabledInterfacesManager;
-import io.fd.honeycomb.translate.v3po.test.ContextTestUtils;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest;
@@ -129,11 +126,11 @@ public class VxlanCustomizerTest extends WriterCustomizerTest {
final Vxlan vxlan = generateVxlan();
whenVxlanAddDelTunnelThenSuccess();
- ContextTestUtils.mockEmptyMapping(mappingContext, ifaceName, "test-instance");
+ noMappingDefined(mappingContext, ifaceName, "test-instance");
customizer.writeCurrentAttributes(id, vxlan, writeContext);
verifyVxlanAddWasInvoked(vxlan);
- verify(mappingContext).put(eq(getMappingIid(ifaceName, "test-instance")), eq(getMapping(ifaceName, 0).get()));
+ verify(mappingContext).put(eq(mappingIid(ifaceName, "test-instance")), eq(mapping(ifaceName, 0).get()));
}
@Test
@@ -141,12 +138,12 @@ public class VxlanCustomizerTest extends WriterCustomizerTest {
final Vxlan vxlan = generateVxlan();
whenVxlanAddDelTunnelThenSuccess();
- ContextTestUtils.mockEmptyMapping(mappingContext, ifaceName, "test-instance");
+ noMappingDefined(mappingContext, ifaceName, "test-instance");
doReturn(true).when(disableContext).isInterfaceDisabled(0, mappingContext);
customizer.writeCurrentAttributes(id, vxlan, writeContext);
verifyVxlanAddWasInvoked(vxlan);
- verify(mappingContext).put(eq(getMappingIid(ifaceName, "test-instance")), eq(getMapping(ifaceName, 0).get()));
+ verify(mappingContext).put(eq(mappingIid(ifaceName, "test-instance")), eq(mapping(ifaceName, 0).get()));
verify(disableContext).removeDisabledInterface(0, mappingContext);
}
@@ -156,15 +153,15 @@ public class VxlanCustomizerTest extends WriterCustomizerTest {
final int ifaceId = 0;
whenVxlanAddDelTunnelThenSuccess();
- ContextTestUtils.mockMapping(mappingContext, ifaceName, ifaceId, "test-instance");
+ defineMapping(mappingContext, ifaceName, ifaceId, "test-instance");
customizer.writeCurrentAttributes(id, vxlan, writeContext);
verifyVxlanAddWasInvoked(vxlan);
// Remove the first mapping before putting in the new one
- verify(mappingContext).delete(eq(getMappingIid(ifaceName, "test-instance")));
+ verify(mappingContext).delete(eq(mappingIid(ifaceName, "test-instance")));
verify(mappingContext)
- .put(eq(getMappingIid(ifaceName, "test-instance")), eq(getMapping(ifaceName, ifaceId).get()));
+ .put(eq(mappingIid(ifaceName, "test-instance")), eq(mapping(ifaceName, ifaceId).get()));
}
@Test
@@ -180,7 +177,7 @@ public class VxlanCustomizerTest extends WriterCustomizerTest {
verifyVxlanAddWasInvoked(vxlan);
// Mapping not stored due to failure
verify(mappingContext, times(0))
- .put(eq(getMappingIid(ifaceName, "test-instance")), eq(getMapping(ifaceName, 0).get()));
+ .put(eq(mappingIid(ifaceName, "test-instance")), eq(mapping(ifaceName, 0).get()));
return;
}
fail("WriteFailedException.CreateFailedException was expected");
@@ -202,11 +199,11 @@ public class VxlanCustomizerTest extends WriterCustomizerTest {
final Vxlan vxlan = generateVxlan();
whenVxlanAddDelTunnelThenSuccess();
- ContextTestUtils.mockMapping(mappingContext, ifaceName, 1, "test-instance");
+ defineMapping(mappingContext, ifaceName, 1, "test-instance");
customizer.deleteCurrentAttributes(id, vxlan, writeContext);
verifyVxlanDeleteWasInvoked(vxlan);
- verify(mappingContext).delete(eq(getMappingIid(ifaceName, "test-instance")));
+ verify(mappingContext).delete(eq(mappingIid(ifaceName, "test-instance")));
verify(disableContext).disableInterface(1, mappingContext);
}
@@ -215,14 +212,14 @@ public class VxlanCustomizerTest extends WriterCustomizerTest {
final Vxlan vxlan = generateVxlan();
whenVxlanAddDelTunnelThenFailure();
- ContextTestUtils.mockMapping(mappingContext, ifaceName, 1, "test-instance");
+ defineMapping(mappingContext, ifaceName, 1, "test-instance");
try {
customizer.deleteCurrentAttributes(id, vxlan, writeContext);
} catch (WriteFailedException.DeleteFailedException e) {
assertTrue(e.getCause() instanceof VppBaseCallException);
verifyVxlanDeleteWasInvoked(vxlan);
- verify(mappingContext, times(0)).delete(eq(getMappingIid(ifaceName, "test-instance")));
+ verify(mappingContext, times(0)).delete(eq(mappingIid(ifaceName, "test-instance")));
return;
}
fail("WriteFailedException.DeleteFailedException was expected");
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/VxlanGpeCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/VxlanGpeCustomizerTest.java
index 75e0d3bb1..d90aeb14d 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/VxlanGpeCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/VxlanGpeCustomizerTest.java
@@ -16,8 +16,6 @@
package io.fd.honeycomb.translate.v3po.interfaces;
-import static io.fd.honeycomb.translate.v3po.test.ContextTestUtils.getMapping;
-import static io.fd.honeycomb.translate.v3po.test.ContextTestUtils.getMappingIid;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@@ -31,7 +29,6 @@ import static org.mockito.Mockito.when;
import com.google.common.net.InetAddresses;
import io.fd.honeycomb.translate.v3po.DisabledInterfacesManager;
-import io.fd.honeycomb.translate.v3po.test.ContextTestUtils;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest;
@@ -133,12 +130,12 @@ public class VxlanGpeCustomizerTest extends WriterCustomizerTest {
final VxlanGpe vxlanGpe = generateVxlanGpe();
whenVxlanGpeAddDelTunnelThenSuccess();
- ContextTestUtils.mockEmptyMapping(mappingContext, ifaceName, "test-instance");
+ noMappingDefined(mappingContext, ifaceName, "test-instance");
customizer.writeCurrentAttributes(id, vxlanGpe, writeContext);
verifyVxlanGpeAddWasInvoked(vxlanGpe);
- verify(mappingContext).put(eq(getMappingIid(ifaceName, "test-instance")), eq(
- getMapping(ifaceName, 0).get()));
+ verify(mappingContext).put(eq(mappingIid(ifaceName, "test-instance")), eq(
+ mapping(ifaceName, 0).get()));
}
@Test
@@ -147,15 +144,15 @@ public class VxlanGpeCustomizerTest extends WriterCustomizerTest {
final int ifaceId = 0;
whenVxlanGpeAddDelTunnelThenSuccess();
- ContextTestUtils.mockMapping(mappingContext, ifaceName, ifaceId, "test-instance");
+ defineMapping(mappingContext, ifaceName, ifaceId, "test-instance");
customizer.writeCurrentAttributes(id, vxlanGpe, writeContext);
verifyVxlanGpeAddWasInvoked(vxlanGpe);
// Remove the first mapping before putting in the new one
- verify(mappingContext).delete(eq(getMappingIid(ifaceName, "test-instance")));
- verify(mappingContext).put(eq(getMappingIid(ifaceName, "test-instance")),
- eq(getMapping(ifaceName, ifaceId).get()));
+ verify(mappingContext).delete(eq(mappingIid(ifaceName, "test-instance")));
+ verify(mappingContext).put(eq(mappingIid(ifaceName, "test-instance")),
+ eq(mapping(ifaceName, ifaceId).get()));
}
@Test
@@ -171,8 +168,8 @@ public class VxlanGpeCustomizerTest extends WriterCustomizerTest {
verifyVxlanGpeAddWasInvoked(vxlanGpe);
// Mapping not stored due to failure
verify(mappingContext, times(0))
- .put(eq(getMappingIid(ifaceName, "test-instance")), eq(
- getMapping(ifaceName, 0).get()));
+ .put(eq(mappingIid(ifaceName, "test-instance")), eq(
+ mapping(ifaceName, 0).get()));
return;
}
fail("WriteFailedException.CreateFailedException was expected");
@@ -194,11 +191,11 @@ public class VxlanGpeCustomizerTest extends WriterCustomizerTest {
final VxlanGpe vxlanGpe = generateVxlanGpe();
whenVxlanGpeAddDelTunnelThenSuccess();
- ContextTestUtils.mockMapping(mappingContext, ifaceName, 1, "test-instance");
+ defineMapping(mappingContext, ifaceName, 1, "test-instance");
customizer.deleteCurrentAttributes(id, vxlanGpe, writeContext);
verifyVxlanGpeDeleteWasInvoked(vxlanGpe);
- verify(mappingContext).delete(eq(getMappingIid(ifaceName, "test-instance")));
+ verify(mappingContext).delete(eq(mappingIid(ifaceName, "test-instance")));
}
@Test
@@ -206,14 +203,14 @@ public class VxlanGpeCustomizerTest extends WriterCustomizerTest {
final VxlanGpe vxlanGpe = generateVxlanGpe();
whenVxlanGpeAddDelTunnelThenFailure();
- ContextTestUtils.mockMapping(mappingContext, ifaceName, 1, "test-instance");
+ defineMapping(mappingContext, ifaceName, 1, "test-instance");
try {
customizer.deleteCurrentAttributes(id, vxlanGpe, writeContext);
} catch (WriteFailedException.DeleteFailedException e) {
assertTrue(e.getCause() instanceof VppBaseCallException);
verifyVxlanGpeDeleteWasInvoked(vxlanGpe);
- verify(mappingContext, times(0)).delete(eq(getMappingIid(ifaceName, "test-instance")));
+ verify(mappingContext, times(0)).delete(eq(mappingIid(ifaceName, "test-instance")));
return;
}
fail("WriteFailedException.DeleteFailedException was expected");
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv4AddressCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv4AddressCustomizerTest.java
index 7b1fb53e0..56430cd46 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv4AddressCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv4AddressCustomizerTest.java
@@ -30,7 +30,6 @@ import static org.mockito.Mockito.when;
import com.google.common.base.Optional;
import io.fd.honeycomb.translate.v3po.interfaces.ip.subnet.validation.SubnetValidationException;
import io.fd.honeycomb.translate.v3po.interfaces.ip.subnet.validation.SubnetValidator;
-import io.fd.honeycomb.translate.v3po.test.ContextTestUtils;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest;
@@ -114,7 +113,7 @@ public class Ipv4AddressCustomizerTest extends WriterCustomizerTest {
PrefixLength length = new PrefixLengthBuilder().setPrefixLength(new Integer(24).shortValue()).build();
Address data = new AddressBuilder().setIp(noZoneIp).setSubnet(length).build();
- ContextTestUtils.mockMapping(mappingContext, IFACE_NAME, IFACE_ID, IFC_CTX_NAME);
+ defineMapping(mappingContext, IFACE_NAME, IFACE_ID, IFC_CTX_NAME);
whenSwInterfaceAddDelAddressThenSuccess();
customizer.writeCurrentAttributes(id, data, writeContext);
@@ -132,7 +131,7 @@ public class Ipv4AddressCustomizerTest extends WriterCustomizerTest {
PrefixLength length = new PrefixLengthBuilder().setPrefixLength(new Integer(24).shortValue()).build();
Address data = new AddressBuilder().setIp(noZoneIp).setSubnet(length).build();
- ContextTestUtils.mockMapping(mappingContext, IFACE_NAME, IFACE_ID, IFC_CTX_NAME);
+ defineMapping(mappingContext, IFACE_NAME, IFACE_ID, IFC_CTX_NAME);
whenSwInterfaceAddDelAddressThenFailure();
try {
@@ -166,7 +165,7 @@ public class Ipv4AddressCustomizerTest extends WriterCustomizerTest {
doReturn(Optional.of(new Ipv4Builder().setAddress(addressList).build())).when(writeContext)
.readAfter(argThat(matchInstanceIdentifier(Ipv4.class)));
- ContextTestUtils.mockMapping(mappingContext, IFACE_NAME, IFACE_ID, IFC_CTX_NAME);
+ defineMapping(mappingContext, IFACE_NAME, IFACE_ID, IFC_CTX_NAME);
try {
customizer.writeCurrentAttributes(id, data, writeContext);
@@ -210,7 +209,7 @@ public class Ipv4AddressCustomizerTest extends WriterCustomizerTest {
PrefixLength length = new PrefixLengthBuilder().setPrefixLength(new Integer(24).shortValue()).build();
Address data = new AddressBuilder().setIp(noZoneIp).setSubnet(length).build();
- ContextTestUtils.mockMapping(mappingContext, IFACE_NAME, IFACE_ID, IFC_CTX_NAME);
+ defineMapping(mappingContext, IFACE_NAME, IFACE_ID, IFC_CTX_NAME);
whenSwInterfaceAddDelAddressThenSuccess();
customizer.deleteCurrentAttributes(id, data, writeContext);
@@ -227,7 +226,7 @@ public class Ipv4AddressCustomizerTest extends WriterCustomizerTest {
PrefixLength length = new PrefixLengthBuilder().setPrefixLength(new Integer(24).shortValue()).build();
Address data = new AddressBuilder().setIp(noZoneIp).setSubnet(length).build();
- ContextTestUtils.mockMapping(mappingContext, IFACE_NAME, IFACE_ID, IFC_CTX_NAME);
+ defineMapping(mappingContext, IFACE_NAME, IFACE_ID, IFC_CTX_NAME);
whenSwInterfaceAddDelAddressThenFailure();
try {
@@ -250,7 +249,7 @@ public class Ipv4AddressCustomizerTest extends WriterCustomizerTest {
Netmask subnet = new NetmaskBuilder().setNetmask(new DottedQuad(stringMask)).build();
Address data = new AddressBuilder().setIp(noZoneIp).setSubnet(subnet).build();
- ContextTestUtils.mockMapping(mappingContext, IFACE_NAME, IFACE_ID, IFC_CTX_NAME);
+ defineMapping(mappingContext, IFACE_NAME, IFACE_ID, IFC_CTX_NAME);
whenSwInterfaceAddDelAddressThenSuccess();
customizer.writeCurrentAttributes(id, data, writeContext);
@@ -268,7 +267,7 @@ public class Ipv4AddressCustomizerTest extends WriterCustomizerTest {
Netmask subnet = new NetmaskBuilder().setNetmask(new DottedQuad(stringMask)).build();
Address data = new AddressBuilder().setIp(noZoneIp).setSubnet(subnet).build();
- ContextTestUtils.mockMapping(mappingContext, IFACE_NAME, IFACE_ID, IFC_CTX_NAME);
+ defineMapping(mappingContext, IFACE_NAME, IFACE_ID, IFC_CTX_NAME);
whenSwInterfaceAddDelAddressThenSuccess();
customizer.writeCurrentAttributes(id, data, writeContext);
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv4NeighbourCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv4NeighbourCustomizerTest.java
index 416468300..e9acdbe88 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv4NeighbourCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv4NeighbourCustomizerTest.java
@@ -23,7 +23,6 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import com.google.common.io.BaseEncoding;
-import io.fd.honeycomb.translate.v3po.test.ContextTestUtils;
import io.fd.honeycomb.translate.v3po.util.Ipv4Translator;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
@@ -56,7 +55,7 @@ public class Ipv4NeighbourCustomizerTest extends WriterCustomizerTest implements
@Before
public void init() {
- ContextTestUtils.mockMapping(mappingContext, IFACE_NAME, IFACE_ID, IFC_CTX_NAME);
+ defineMapping(mappingContext, IFACE_NAME, IFACE_ID, IFC_CTX_NAME);
customizer = new Ipv4NeighbourCustomizer(api, new NamingContext("prefix", IFC_CTX_NAME));
requestCaptor = ArgumentCaptor.forClass(IpNeighborAddDel.class);
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/AclCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/AclCustomizerTest.java
index b2a76c5c0..00dadddb1 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/AclCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/AclCustomizerTest.java
@@ -22,7 +22,6 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
-import io.fd.honeycomb.translate.v3po.test.ContextTestUtils;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
import io.fd.honeycomb.translate.v3po.vppclassifier.VppClassifierContextManager;
import io.fd.honeycomb.vpp.test.read.ReaderCustomizerTest;
@@ -61,7 +60,7 @@ public class AclCustomizerTest extends ReaderCustomizerTest<Acl, AclBuilder> {
@Override
public void setUp() {
interfaceContext = new NamingContext("generatedIfaceName", IFC_CTX_NAME);
- ContextTestUtils.mockMapping(mappingContext, IF_NAME, IF_INDEX, IFC_CTX_NAME);
+ defineMapping(mappingContext, IF_NAME, IF_INDEX, IFC_CTX_NAME);
}
@Override
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/GreCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/GreCustomizerTest.java
index 0728a5a2a..e62edadef 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/GreCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/GreCustomizerTest.java
@@ -26,7 +26,6 @@ import static org.mockito.Mockito.verifyZeroInteractions;
import com.google.common.collect.Lists;
import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
-import io.fd.honeycomb.translate.v3po.test.ContextTestUtils;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
import io.fd.honeycomb.vpp.test.read.ReaderCustomizerTest;
import java.net.InetAddress;
@@ -65,7 +64,7 @@ public class GreCustomizerTest extends ReaderCustomizerTest<Gre, GreBuilder> {
@Override
public void setUp() throws UnknownHostException, VppInvocationException {
interfacesContext = new NamingContext("gre-tunnel", IFC_CTX_NAME);
- ContextTestUtils.mockMapping(mappingContext, IFACE_NAME, IFACE_ID, IFC_CTX_NAME);
+ defineMapping(mappingContext, IFACE_NAME, IFACE_ID, IFC_CTX_NAME);
final SwInterfaceDetails v = new SwInterfaceDetails();
v.interfaceName = "gre-tunnel4".getBytes();
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/InterfaceCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/InterfaceCustomizerTest.java
index 5c6f88abd..94dfd077a 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/InterfaceCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/InterfaceCustomizerTest.java
@@ -28,7 +28,6 @@ import static org.mockito.Mockito.when;
import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
import io.fd.honeycomb.translate.v3po.DisabledInterfacesManager;
-import io.fd.honeycomb.translate.v3po.test.ContextTestUtils;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
import io.fd.honeycomb.vpp.test.read.ListReaderCustomizerTest;
import java.util.Arrays;
@@ -70,9 +69,9 @@ public class InterfaceCustomizerTest extends
@Override
public void setUp() {
interfacesContext = new NamingContext("generatedIfaceName", IFC_CTX_NAME);
- ContextTestUtils.mockMapping(mappingContext, IFACE0_NAME, IFACE0_ID, IFC_CTX_NAME);
- ContextTestUtils.mockMapping(mappingContext, IFACE1_NAME, IFACE1_ID, IFC_CTX_NAME);
- ContextTestUtils.mockMapping(mappingContext, SUB_IFACE_NAME, SUB_IFACE_ID, IFC_CTX_NAME);
+ defineMapping(mappingContext, IFACE0_NAME, IFACE0_ID, IFC_CTX_NAME);
+ defineMapping(mappingContext, IFACE1_NAME, IFACE1_ID, IFC_CTX_NAME);
+ defineMapping(mappingContext, SUB_IFACE_NAME, SUB_IFACE_ID, IFC_CTX_NAME);
}
@Override
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/L2CustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/L2CustomizerTest.java
index 29f0d0eb7..6be759bc5 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/L2CustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/L2CustomizerTest.java
@@ -22,7 +22,6 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
-import io.fd.honeycomb.translate.v3po.test.ContextTestUtils;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
import io.fd.honeycomb.vpp.test.read.ReaderCustomizerTest;
import java.util.Collections;
@@ -118,8 +117,8 @@ public class L2CustomizerTest extends ReaderCustomizerTest<L2, L2Builder> {
final int bdId = 1;
final String bdName = "bd001";
final String ifName = "eth0.sub0";
- ContextTestUtils.mockMapping(mappingContext, ifName, ifId, IFC_CTX_NAME);
- ContextTestUtils.mockMapping(mappingContext, bdName, bdId, BD_CTX_NAME);
+ defineMapping(mappingContext, ifName, ifId, IFC_CTX_NAME);
+ defineMapping(mappingContext, bdName, bdId, BD_CTX_NAME);
final SwInterfaceDetails ifaceDetails = new SwInterfaceDetails();
ifaceDetails.subId = ifId;
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/RewriteCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/RewriteCustomizerTest.java
index 432469ddc..ad2d4f6ce 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/RewriteCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/RewriteCustomizerTest.java
@@ -22,7 +22,6 @@ import static org.mockito.Mockito.verify;
import io.fd.honeycomb.translate.read.ReadFailedException;
import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
-import io.fd.honeycomb.translate.v3po.test.ContextTestUtils;
import io.fd.honeycomb.vpp.test.read.ReaderCustomizerTest;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
import io.fd.honeycomb.translate.v3po.util.TagRewriteOperation;
@@ -68,7 +67,7 @@ public class RewriteCustomizerTest extends ReaderCustomizerTest<Rewrite, Rewrite
@Override
public void setUp() {
interfacesContext = new NamingContext("generatedIfaceName", IFC_CTX_NAME);
- ContextTestUtils.mockMapping(mappingContext, VLAN_IF_NAME, VLAN_IF_INDEX, IFC_CTX_NAME);
+ defineMapping(mappingContext, VLAN_IF_NAME, VLAN_IF_INDEX, IFC_CTX_NAME);
}
@Override
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/SubInterfaceCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/SubInterfaceCustomizerTest.java
index 0d0a2cc83..74580bb73 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/SubInterfaceCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/SubInterfaceCustomizerTest.java
@@ -25,7 +25,6 @@ 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.translate.v3po.test.ContextTestUtils;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
import io.fd.honeycomb.vpp.test.read.ListReaderCustomizerTest;
import java.util.Collections;
@@ -70,8 +69,8 @@ public class SubInterfaceCustomizerTest extends
@Override
public void setUp() {
interfacesContext = new NamingContext("generatedIfaceName", IFC_CTX_NAME);
- ContextTestUtils.mockMapping(mappingContext, SUPER_IF_NAME, SUPER_IF_INDEX, IFC_CTX_NAME);
- ContextTestUtils.mockMapping(mappingContext, VLAN_IF_NAME, VLAN_IF_INDEX, IFC_CTX_NAME);
+ defineMapping(mappingContext, SUPER_IF_NAME, SUPER_IF_INDEX, IFC_CTX_NAME);
+ defineMapping(mappingContext, VLAN_IF_NAME, VLAN_IF_INDEX, IFC_CTX_NAME);
}
@Override
@@ -101,8 +100,8 @@ public class SubInterfaceCustomizerTest extends
ifaceDetails.subId = VLAN_IF_ID;
ifaceDetails.interfaceName = VLAN_IF_NAME.getBytes();
ifaceDetails.subDot1Ad = 1;
- ContextTestUtils.mockMapping(mappingContext, SUPER_IF_NAME, SUPER_IF_INDEX, IFC_CTX_NAME);
- ContextTestUtils.mockMapping(mappingContext, VLAN_IF_NAME, VLAN_IF_INDEX, IFC_CTX_NAME);
+ defineMapping(mappingContext, SUPER_IF_NAME, SUPER_IF_INDEX, IFC_CTX_NAME);
+ defineMapping(mappingContext, VLAN_IF_NAME, VLAN_IF_INDEX, IFC_CTX_NAME);
ifaceDetails.subNumberOfTags = 2;
ifaceDetails.subOuterVlanIdAny = 1;
ifaceDetails.subInnerVlanIdAny = 1;
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/VxlanCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/VxlanCustomizerTest.java
index e71441333..4bab8fcfa 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/VxlanCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/VxlanCustomizerTest.java
@@ -26,7 +26,6 @@ import static org.mockito.Mockito.verifyZeroInteractions;
import com.google.common.collect.Lists;
import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
-import io.fd.honeycomb.translate.v3po.test.ContextTestUtils;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
import io.fd.honeycomb.vpp.test.read.ReaderCustomizerTest;
import java.net.InetAddress;
@@ -65,7 +64,7 @@ public class VxlanCustomizerTest extends ReaderCustomizerTest<Vxlan, VxlanBuilde
@Override
public void setUp() throws UnknownHostException, VppInvocationException {
interfacesContext = new NamingContext("vxlan-tunnel", IFC_CTX_NAME);
- ContextTestUtils.mockMapping(mappingContext, IF_NAME, IF_INDEX, IFC_CTX_NAME);
+ defineMapping(mappingContext, IF_NAME, IF_INDEX, IFC_CTX_NAME);
final SwInterfaceDetails v = new SwInterfaceDetails();
v.interfaceName = "vxlan-tunnel4".getBytes();
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/VxlanGpeCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/VxlanGpeCustomizerTest.java
index e40962da3..19b3be862 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/VxlanGpeCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/VxlanGpeCustomizerTest.java
@@ -26,7 +26,6 @@ import static org.mockito.Mockito.verifyZeroInteractions;
import com.google.common.collect.Lists;
import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
-import io.fd.honeycomb.translate.v3po.test.ContextTestUtils;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
import io.fd.honeycomb.vpp.test.read.ReaderCustomizerTest;
import java.net.InetAddress;
@@ -65,7 +64,7 @@ public class VxlanGpeCustomizerTest extends ReaderCustomizerTest<VxlanGpe, Vxlan
@Override
public void setUp() throws UnknownHostException, VppBaseCallException {
interfacesContext = new NamingContext("vxlan_gpe_inf", IFC_CTX_NAME);
- ContextTestUtils.mockMapping(mappingContext, IF_NAME, IF_INDEX, IFC_CTX_NAME);
+ defineMapping(mappingContext, IF_NAME, IF_INDEX, IFC_CTX_NAME);
final SwInterfaceDetails v = new SwInterfaceDetails();
v.interfaceName = "vxlan_gpe_inf2".getBytes();
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/Ipv4AddressCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/Ipv4AddressCustomizerTest.java
index d351d2402..fc189d399 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/Ipv4AddressCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/Ipv4AddressCustomizerTest.java
@@ -27,7 +27,6 @@ import com.google.common.collect.ImmutableList;
import io.fd.honeycomb.translate.ModificationCache;
import io.fd.honeycomb.translate.read.ReadFailedException;
import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
-import io.fd.honeycomb.translate.v3po.test.ContextTestUtils;
import io.fd.honeycomb.translate.v3po.util.Ipv4Translator;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
import io.fd.honeycomb.vpp.test.read.ListReaderCustomizerTest;
@@ -73,8 +72,8 @@ public class Ipv4AddressCustomizerTest extends ListReaderCustomizerTest<Address,
@Override
public void setUp() {
interfacesContext = new NamingContext("generatedIfaceName", IFC_CTX_NAME);
- ContextTestUtils.mockMapping(mappingContext, IFACE_NAME, IFACE_ID, IFC_CTX_NAME);
- ContextTestUtils.mockMapping(mappingContext, IFACE_2_NAME, IFACE_2_ID, IFC_CTX_NAME);
+ defineMapping(mappingContext, IFACE_NAME, IFACE_ID, IFC_CTX_NAME);
+ defineMapping(mappingContext, IFACE_2_NAME, IFACE_2_ID, IFC_CTX_NAME);
}
@Override
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/notification/InterfaceChangeNotificationProducerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/notification/InterfaceChangeNotificationProducerTest.java
index a227602b4..96acb9979 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/notification/InterfaceChangeNotificationProducerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/notification/InterfaceChangeNotificationProducerTest.java
@@ -23,7 +23,7 @@ import static org.mockito.Mockito.verify;
import io.fd.honeycomb.notification.NotificationCollector;
import io.fd.honeycomb.translate.MappingContext;
-import io.fd.honeycomb.translate.v3po.test.ContextTestUtils;
+import io.fd.honeycomb.vpp.test.util.NamingContextHelper;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
import io.fd.honeycomb.vpp.test.util.FutureProducer;
import org.junit.Before;
@@ -40,7 +40,7 @@ import org.openvpp.jvpp.core.dto.WantInterfaceEventsReply;
import org.openvpp.jvpp.core.future.FutureJVppCore;
import org.openvpp.jvpp.core.notification.CoreNotificationRegistry;
-public class InterfaceChangeNotificationProducerTest implements FutureProducer {
+public class InterfaceChangeNotificationProducerTest implements FutureProducer, NamingContextHelper {
private static final String IFC_CTX_NAME = "ifc-test-instance";
private static final String IFACE_NAME = "eth0";
@@ -67,7 +67,7 @@ public class InterfaceChangeNotificationProducerTest implements FutureProducer {
callbackArgumentCaptor = ArgumentCaptor.forClass(SwInterfaceSetFlagsNotificationCallback.class);
doReturn(notificationListenerReg).when(notificationRegistry).registerSwInterfaceSetFlagsNotificationCallback(
callbackArgumentCaptor.capture());
- ContextTestUtils.mockMapping(mappingContext, IFACE_NAME, IFACE_ID, IFC_CTX_NAME);
+ defineMapping(mappingContext, IFACE_NAME, IFACE_ID, IFC_CTX_NAME);
doReturn(future(new WantInterfaceEventsReply())).when(jVpp).wantInterfaceEvents(any(WantInterfaceEvents.class));
}
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/test/ContextTestUtils.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/test/ContextTestUtils.java
deleted file mode 100644
index 9bfcd4d82..000000000
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/test/ContextTestUtils.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * 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.translate.v3po.test;
-
-import static org.mockito.Mockito.doReturn;
-
-import com.google.common.base.Optional;
-import com.google.common.collect.Lists;
-import io.fd.honeycomb.translate.MappingContext;
-import java.util.List;
-import org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.naming.context.rev160513.Contexts;
-import org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.naming.context.rev160513.contexts.NamingContextKey;
-import org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.naming.context.rev160513.contexts.naming.context.Mappings;
-import org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.naming.context.rev160513.contexts.naming.context.MappingsBuilder;
-import org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.naming.context.rev160513.contexts.naming.context.mappings.Mapping;
-import org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.naming.context.rev160513.contexts.naming.context.mappings.MappingBuilder;
-import org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.naming.context.rev160513.contexts.naming.context.mappings.MappingKey;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
-
-public class ContextTestUtils {
-
- public static Optional<Mapping> getMapping(final String name, final int index) {
- return Optional.of(new MappingBuilder().setName(name).setIndex(index).build());
- }
-
- public static KeyedInstanceIdentifier<Mapping, MappingKey> getMappingIid(final String name,
- final String namingContextName) {
- return InstanceIdentifier.create(Contexts.class).child(
- org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.naming.context.rev160513.contexts.NamingContext.class,
- new NamingContextKey(namingContextName)).child(Mappings.class).child(Mapping.class, new MappingKey(name));
- }
-
- private static List<Mapping> getMappingList(final MappingContext mappingContext, final InstanceIdentifier<Mappings> mappingsIid) {
- final Optional<Mappings> previousMappings = mappingContext.read(mappingsIid);
- final MappingsBuilder mappingsBuilder;
- if (previousMappings != null && previousMappings.isPresent()) {
- mappingsBuilder = new MappingsBuilder(previousMappings.get());
- } else {
- mappingsBuilder = new MappingsBuilder();
- mappingsBuilder.setMapping(Lists.newArrayList());
- }
-
- return mappingsBuilder.getMapping();
- }
-
- public static void mockMapping(final MappingContext mappingContext, final String name, final int id,
- final String namingContextName) {
- final InstanceIdentifier<Mappings> mappingsIid =
- getMappingIid(name, namingContextName).firstIdentifierOf(Mappings.class);
-
- final Optional<Mapping> singleMapping = getMapping(name, id);
- final List<Mapping> mappingList = getMappingList(mappingContext, mappingsIid);
- mappingList.add(singleMapping.get());
-
- doReturn(Optional.of(new MappingsBuilder().setMapping(mappingList).build()))
- .when(mappingContext).read(mappingsIid);
- doReturn(singleMapping).when(mappingContext).read(getMappingIid(name, namingContextName));
- }
-
- public static void mockEmptyMapping(final MappingContext mappingContext, final String name,
- final String namingContextName) {
- final InstanceIdentifier<Mappings> mappingsIid =
- getMappingIid(name, namingContextName).firstIdentifierOf(Mappings.class);
-
- final List<Mapping> mappingList = getMappingList(mappingContext, mappingsIid);
-
- doReturn(Optional.of(new MappingsBuilder().setMapping(mappingList).build()))
- .when(mappingContext).read(mappingsIid);
- doReturn(Optional.absent()).when(mappingContext).read(getMappingIid(name, namingContextName));
- }
-}
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vpp/ArpTerminationTableEntryCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vpp/ArpTerminationTableEntryCustomizerTest.java
index 4a38101af..8c2082210 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vpp/ArpTerminationTableEntryCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vpp/ArpTerminationTableEntryCustomizerTest.java
@@ -25,7 +25,6 @@ import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
-import io.fd.honeycomb.translate.v3po.test.ContextTestUtils;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest;
@@ -75,8 +74,8 @@ public class ArpTerminationTableEntryCustomizerTest extends WriterCustomizerTest
entry = generateArpEntry(ipAddress, physAddress);
id = getArpEntryId(ipAddress, physAddress);
- ContextTestUtils.mockMapping(mappingContext, BD_NAME, BD_ID, BD_CTX_NAME);
- ContextTestUtils.mockMapping(mappingContext, IFACE_NAME, IFACE_ID, IFC_CTX_NAME);
+ defineMapping(mappingContext, BD_NAME, BD_ID, BD_CTX_NAME);
+ defineMapping(mappingContext, IFACE_NAME, IFACE_ID, IFC_CTX_NAME);
}
private static InstanceIdentifier<ArpTerminationTableEntry> getArpEntryId(final IpAddress ipAddress,
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vpp/BridgeDomainCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vpp/BridgeDomainCustomizerTest.java
index f41448bf0..43b9c37fa 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vpp/BridgeDomainCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vpp/BridgeDomainCustomizerTest.java
@@ -23,7 +23,6 @@ import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import io.fd.honeycomb.translate.v3po.test.ContextTestUtils;
import io.fd.honeycomb.translate.v3po.util.ByteDataTranslator;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
@@ -120,15 +119,14 @@ public class BridgeDomainCustomizerTest extends WriterCustomizerTest implements
final int bdId = 1;
final String bdName = "bd1";
final BridgeDomain bd = generateBridgeDomain(bdName);
- ContextTestUtils.mockEmptyMapping(mappingContext, bdName, BD_CTX_NAME);
+ noMappingDefined(mappingContext, bdName, BD_CTX_NAME);
whenBridgeDomainAddDelThenSuccess();
customizer.writeCurrentAttributes(bdIdentifierForName(bdName), bd, writeContext);
verifyBridgeDomainAddOrUpdateWasInvoked(bd, bdId);
- verify(mappingContext).put(
- ContextTestUtils.getMappingIid(bdName, BD_CTX_NAME), ContextTestUtils.getMapping(bdName, bdId).get());
+ verify(mappingContext).put(mappingIid(bdName, BD_CTX_NAME), mapping(bdName, bdId).get());
}
@Test
@@ -136,15 +134,14 @@ public class BridgeDomainCustomizerTest extends WriterCustomizerTest implements
final int bdId = 1;
final String bdName = "bd1";
final BridgeDomain bd = generateBridgeDomain(bdName);
- ContextTestUtils.mockMapping(mappingContext, bdName, bdId, BD_CTX_NAME);
+ defineMapping(mappingContext, bdName, bdId, BD_CTX_NAME);
whenBridgeDomainAddDelThenSuccess();
customizer.writeCurrentAttributes(bdIdentifierForName(bdName), bd, writeContext);
verifyBridgeDomainAddOrUpdateWasInvoked(bd, bdId);
- verify(mappingContext).put(
- ContextTestUtils.getMappingIid(bdName, BD_CTX_NAME), ContextTestUtils.getMapping(bdName, bdId).get());
+ verify(mappingContext).put(mappingIid(bdName, BD_CTX_NAME), mapping(bdName, bdId).get());
}
@Test
@@ -152,7 +149,7 @@ public class BridgeDomainCustomizerTest extends WriterCustomizerTest implements
final int bdId = 1;
final String bdName = "bd1";
final BridgeDomain bd = generateBridgeDomain(bdName);
- ContextTestUtils.mockEmptyMapping(mappingContext, bdName, BD_CTX_NAME);
+ noMappingDefined(mappingContext, bdName, BD_CTX_NAME);
whenBridgeDomainAddDelThenFailure();
@@ -170,7 +167,7 @@ public class BridgeDomainCustomizerTest extends WriterCustomizerTest implements
final int bdId = 1;
final String bdName = "bd1";
final BridgeDomain bd = generateBridgeDomain(bdName);
- ContextTestUtils.mockMapping(mappingContext, bdName, bdId, BD_CTX_NAME);
+ defineMapping(mappingContext, bdName, bdId, BD_CTX_NAME);
whenBridgeDomainAddDelThenSuccess();
@@ -183,7 +180,7 @@ public class BridgeDomainCustomizerTest extends WriterCustomizerTest implements
public void testDeleteUnknownBridgeDomain() throws Exception {
final String bdName = "bd1";
final BridgeDomain bd = generateBridgeDomain("bd1");
- ContextTestUtils.mockEmptyMapping(mappingContext, bdName, BD_CTX_NAME);
+ noMappingDefined(mappingContext, bdName, BD_CTX_NAME);
try {
customizer.deleteCurrentAttributes(bdIdentifierForName(bdName), bd, writeContext);
@@ -199,7 +196,7 @@ public class BridgeDomainCustomizerTest extends WriterCustomizerTest implements
final int bdId = 1;
final String bdName = "bd1";
final BridgeDomain bd = generateBridgeDomain(bdName);
- ContextTestUtils.mockMapping(mappingContext, bdName, bdId, BD_CTX_NAME);
+ defineMapping(mappingContext, bdName, bdId, BD_CTX_NAME);
whenBridgeDomainAddDelThenFailure();
@@ -217,7 +214,7 @@ public class BridgeDomainCustomizerTest extends WriterCustomizerTest implements
public void testUpdateBridgeDomain() throws Exception {
final int bdId = 1;
final String bdName = "bd1";
- ContextTestUtils.mockMapping(mappingContext, bdName, bdId, BD_CTX_NAME);
+ defineMapping(mappingContext, bdName, bdId, BD_CTX_NAME);
final byte arpTermBefore = 1;
final byte floodBefore = 1;
@@ -244,7 +241,7 @@ public class BridgeDomainCustomizerTest extends WriterCustomizerTest implements
final String bdName = "bd1";
final BridgeDomain bdBefore = generateBridgeDomain(bdName, 0, 1, 0, 1, 0);
final BridgeDomain bdAfter = generateBridgeDomain(bdName, 1, 1, 0, 1, 0);
- ContextTestUtils.mockEmptyMapping(mappingContext, bdName, BD_CTX_NAME);
+ noMappingDefined(mappingContext, bdName, BD_CTX_NAME);
try {
customizer
@@ -263,7 +260,7 @@ public class BridgeDomainCustomizerTest extends WriterCustomizerTest implements
final String bdName = "bd1";
final BridgeDomain bdBefore = generateBridgeDomain(bdName, 0, 1, 0, 1, 0);
final BridgeDomain bdAfter = generateBridgeDomain(bdName, 1, 1, 0, 1, 0);
- ContextTestUtils.mockMapping(mappingContext, bdName, bdId, BD_CTX_NAME);
+ defineMapping(mappingContext, bdName, bdId, BD_CTX_NAME);
whenBridgeDomainAddDelThenFailure();
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vpp/L2FibEntryCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vpp/L2FibEntryCustomizerTest.java
index 174e27215..e52cc1783 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vpp/L2FibEntryCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vpp/L2FibEntryCustomizerTest.java
@@ -24,7 +24,6 @@ import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
-import io.fd.honeycomb.translate.v3po.test.ContextTestUtils;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest;
@@ -58,8 +57,8 @@ public class L2FibEntryCustomizerTest extends WriterCustomizerTest {
@Override
public void setUp() throws Exception {
- ContextTestUtils.mockMapping(mappingContext, BD_NAME, BD_ID, BD_CTX_NAME);
- ContextTestUtils.mockMapping(mappingContext, IFACE_NAME, IFACE_ID, IFC_CTX_NAME);
+ defineMapping(mappingContext, BD_NAME, BD_ID, BD_CTX_NAME);
+ defineMapping(mappingContext, IFACE_NAME, IFACE_ID, IFC_CTX_NAME);
customizer = new L2FibEntryCustomizer(
api,
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppstate/L2FibEntryCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppstate/L2FibEntryCustomizerTest.java
index 953332da7..f837717c7 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppstate/L2FibEntryCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppstate/L2FibEntryCustomizerTest.java
@@ -23,7 +23,6 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
-import io.fd.honeycomb.translate.v3po.test.ContextTestUtils;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
import io.fd.honeycomb.vpp.test.read.ListReaderCustomizerTest;
import java.util.Collections;
@@ -64,7 +63,7 @@ public class L2FibEntryCustomizerTest extends ListReaderCustomizerTest<L2FibEntr
@Override
public void setUp() {
bdContext = new NamingContext("generatedBdName", BD_CTX_NAME);
- ContextTestUtils.mockMapping(mappingContext, BD_NAME, BD_ID, BD_CTX_NAME);
+ defineMapping(mappingContext, BD_NAME, BD_ID, BD_CTX_NAME);
interfacesContext = new NamingContext("generatedIfaceName", IFC_CTX_NAME);
}
@@ -97,7 +96,7 @@ public class L2FibEntryCustomizerTest extends ListReaderCustomizerTest<L2FibEntr
public void testRead() throws Exception {
final long address_vpp = 0x0000010203040506L;
final PhysAddress address = new PhysAddress("01:02:03:04:05:06");
- ContextTestUtils.mockMapping(mappingContext, IFACE_NAME, IFACE_ID, IFC_CTX_NAME);
+ defineMapping(mappingContext, IFACE_NAME, IFACE_ID, IFC_CTX_NAME);
whenL2FibTableDumpThenReturn(Collections.singletonList(generateL2FibEntry(address_vpp)));
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppstate/VppStateTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppstate/VppStateTest.java
index b8013b59e..8cd8edad3 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppstate/VppStateTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppstate/VppStateTest.java
@@ -36,7 +36,7 @@ import io.fd.honeycomb.translate.read.ReadContext;
import io.fd.honeycomb.translate.read.ReadFailedException;
import io.fd.honeycomb.translate.read.registry.ReaderRegistry;
import io.fd.honeycomb.translate.util.read.registry.CompositeReaderRegistryBuilder;
-import io.fd.honeycomb.translate.v3po.test.ContextTestUtils;
+import io.fd.honeycomb.vpp.test.util.NamingContextHelper;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
import io.fd.honeycomb.vpp.test.util.FutureProducer;
import java.util.Arrays;
@@ -72,7 +72,7 @@ import org.openvpp.jvpp.core.dto.ShowVersion;
import org.openvpp.jvpp.core.dto.ShowVersionReply;
import org.openvpp.jvpp.core.future.FutureJVppCore;
-public class VppStateTest implements FutureProducer {
+public class VppStateTest implements FutureProducer, NamingContextHelper {
private static final String BD_CTX_NAME = "bd-test-instance";
@Mock
@@ -226,7 +226,7 @@ public class VppStateTest implements FutureProducer {
bd.bdId = 0;
final String bdName = "bdn1";
mockBdMapping(bd, bdName);
- ContextTestUtils.mockMapping(mappingContext, "eth1", 0, "ifc-test-instance");
+ defineMapping(mappingContext, "eth1", 0, "ifc-test-instance");
whenBridgeDomainDumpThenReturn(Collections.singletonList(bd));
final L2FibTableEntry l2FibEntry = new L2FibTableEntry();
@@ -253,7 +253,7 @@ public class VppStateTest implements FutureProducer {
}
private void mockBdMapping(final BridgeDomainDetails bd, final String bdName) {
- ContextTestUtils.mockMapping(mappingContext, bdName, bd.bdId, BD_CTX_NAME);
+ defineMapping(mappingContext, bdName, bd.bdId, BD_CTX_NAME);
}
@Test
@@ -301,7 +301,7 @@ public class VppStateTest implements FutureProducer {
@Test(expected = ReadFailedException.class)
public void testReadBridgeDomainNotExisting() throws Exception {
final String nonExistingBdName = "NOT EXISTING";
- ContextTestUtils.mockEmptyMapping(mappingContext, nonExistingBdName, BD_CTX_NAME);
+ noMappingDefined(mappingContext, nonExistingBdName, BD_CTX_NAME);
readerRegistry.read(InstanceIdentifier.create(VppState.class).child(BridgeDomains.class).child(
BridgeDomain.class, new BridgeDomainKey(nonExistingBdName)), ctx);