diff options
author | Marek Gradzki <mgradzki@cisco.com> | 2016-09-23 09:06:19 +0200 |
---|---|---|
committer | Marek Gradzki <mgradzki@cisco.com> | 2016-09-26 08:15:38 +0200 |
commit | 7ad1eb51710b65fdad35fab04122de4eb887e541 (patch) | |
tree | 512a725f33ca65bf211bc4c64ba2bd0d7c49a080 /v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces | |
parent | a7147d16c31d9028c6b5dc557264433de0f11c91 (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/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces')
10 files changed, 72 insertions, 89 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); |