diff options
Diffstat (limited to 'v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/RewriteCustomizerTest.java')
-rw-r--r-- | v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/RewriteCustomizerTest.java | 56 |
1 files changed, 27 insertions, 29 deletions
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/RewriteCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/RewriteCustomizerTest.java index 655bda525..45eaf9ec9 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/RewriteCustomizerTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/RewriteCustomizerTest.java @@ -16,6 +16,15 @@ package io.fd.honeycomb.v3po.translate.v3po.interfaces; +import static io.fd.honeycomb.v3po.translate.v3po.test.ContextTestUtils.getMapping; +import static junit.framework.TestCase.assertTrue; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.verify; +import static org.mockito.MockitoAnnotations.initMocks; + import com.google.common.base.Optional; import io.fd.honeycomb.v3po.translate.MappingContext; import io.fd.honeycomb.v3po.translate.v3po.test.TestHelperUtils; @@ -23,6 +32,8 @@ import io.fd.honeycomb.v3po.translate.v3po.util.NamingContext; import io.fd.honeycomb.v3po.translate.v3po.util.TagRewriteOperation; import io.fd.honeycomb.v3po.translate.write.WriteContext; import io.fd.honeycomb.v3po.translate.write.WriteFailedException; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -32,7 +43,6 @@ import org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.naming.cont import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.Interfaces; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.*; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.SubinterfaceAugmentation; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527._802dot1q; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.interfaces._interface.SubInterfaces; @@ -48,18 +58,6 @@ import org.openvpp.jvpp.dto.L2InterfaceVlanTagRewrite; import org.openvpp.jvpp.dto.L2InterfaceVlanTagRewriteReply; import org.openvpp.jvpp.future.FutureJVpp; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ExecutionException; - -import static io.fd.honeycomb.v3po.translate.v3po.test.ContextTestUtils.getMapping; -import static junit.framework.TestCase.assertTrue; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.verify; -import static org.mockito.MockitoAnnotations.initMocks; - public class RewriteCustomizerTest { @Mock @@ -104,7 +102,8 @@ public class RewriteCustomizerTest { return builder.build(); } - private L2InterfaceVlanTagRewrite generateL2InterfaceVlanTagRewrite(final int swIfIndex, final TagRewriteOperation op) { + private L2InterfaceVlanTagRewrite generateL2InterfaceVlanTagRewrite(final int swIfIndex, + final TagRewriteOperation op) { final L2InterfaceVlanTagRewrite request = new L2InterfaceVlanTagRewrite(); request.swIfIndex = swIfIndex; request.vtrOp = op.ordinal(); @@ -115,7 +114,8 @@ public class RewriteCustomizerTest { /** * Positive response */ - private void whenL2InterfaceVlanTagRewriteThen() throws ExecutionException, InterruptedException, VppInvocationException { + private void whenL2InterfaceVlanTagRewriteThenSuccess() + throws ExecutionException, InterruptedException, VppInvocationException { final CompletableFuture<L2InterfaceVlanTagRewriteReply> replyFuture = new CompletableFuture<>(); final L2InterfaceVlanTagRewriteReply reply = new L2InterfaceVlanTagRewriteReply(); replyFuture.complete(reply); @@ -125,20 +125,16 @@ public class RewriteCustomizerTest { /** * Failure response send */ - private void whenL2InterfaceVlanTagRewriteFailedThen(final int retval) throws ExecutionException, InterruptedException, VppInvocationException { - doReturn(TestHelperUtils.<L2InterfaceVlanTagRewriteReply>createFutureException(retval)).when(api).l2InterfaceVlanTagRewrite(any(L2InterfaceVlanTagRewrite.class)); - } - - private void whenL2InterfaceVlanTagRewriteThenSuccess() throws ExecutionException, InterruptedException, VppInvocationException { - whenL2InterfaceVlanTagRewriteThen(); - } - - private void whenL2InterfaceVlanTagRewriteThenFailure() throws ExecutionException, InterruptedException, VppInvocationException { - whenL2InterfaceVlanTagRewriteFailedThen(-1); + private void whenL2InterfaceVlanTagRewriteThenFailure() + throws ExecutionException, InterruptedException, VppInvocationException { + doReturn(TestHelperUtils.<L2InterfaceVlanTagRewriteReply>createFutureException()).when(api) + .l2InterfaceVlanTagRewrite(any(L2InterfaceVlanTagRewrite.class)); } - private void verifyL2InterfaceVlanTagRewriteWasInvoked(final L2InterfaceVlanTagRewrite expected) throws VppInvocationException { - ArgumentCaptor<L2InterfaceVlanTagRewrite> argumentCaptor = ArgumentCaptor.forClass(L2InterfaceVlanTagRewrite.class); + private void verifyL2InterfaceVlanTagRewriteWasInvoked(final L2InterfaceVlanTagRewrite expected) + throws VppInvocationException { + ArgumentCaptor<L2InterfaceVlanTagRewrite> argumentCaptor = + ArgumentCaptor.forClass(L2InterfaceVlanTagRewrite.class); verify(api).l2InterfaceVlanTagRewrite(argumentCaptor.capture()); final L2InterfaceVlanTagRewrite actual = argumentCaptor.getValue(); assertEquals(expected.swIfIndex, actual.swIfIndex); @@ -197,7 +193,8 @@ public class RewriteCustomizerTest { customizer.updateCurrentAttributes(id, before, after, writeContext); - verifyL2InterfaceVlanTagRewriteWasInvoked(generateL2InterfaceVlanTagRewrite(VLAN_IF_INDEX, TagRewriteOperation.pop_1)); + verifyL2InterfaceVlanTagRewriteWasInvoked( + generateL2InterfaceVlanTagRewrite(VLAN_IF_INDEX, TagRewriteOperation.pop_1)); } @Test @@ -212,7 +209,8 @@ public class RewriteCustomizerTest { customizer.updateCurrentAttributes(id, before, after, writeContext); } catch (WriteFailedException.UpdateFailedException e) { assertTrue(e.getCause() instanceof VppBaseCallException); - verifyL2InterfaceVlanTagRewriteWasInvoked(generateL2InterfaceVlanTagRewrite(VLAN_IF_INDEX, TagRewriteOperation.pop_1)); + verifyL2InterfaceVlanTagRewriteWasInvoked(generateL2InterfaceVlanTagRewrite(VLAN_IF_INDEX, + TagRewriteOperation.pop_1)); return; } fail("WriteFailedException.UpdateFailedException was expected"); |