From 7ad1eb51710b65fdad35fab04122de4eb887e541 Mon Sep 17 00:00:00 2001 From: Marek Gradzki Date: Fri, 23 Sep 2016 09:06:19 +0200 Subject: 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 --- .../v3po/interfaces/GreCustomizerTest.java | 26 +++++++++------------- 1 file changed, 11 insertions(+), 15 deletions(-) (limited to 'v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/GreCustomizerTest.java') 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"); -- cgit 1.2.3-korg