summaryrefslogtreecommitdiffstats
path: root/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VxlanCustomizerTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VxlanCustomizerTest.java')
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VxlanCustomizerTest.java55
1 files changed, 29 insertions, 26 deletions
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VxlanCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VxlanCustomizerTest.java
index e716dc6dc..afe26beff 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VxlanCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VxlanCustomizerTest.java
@@ -16,6 +16,22 @@
package io.fd.honeycomb.v3po.translate.v3po.interfaces;
+import static io.fd.honeycomb.v3po.translate.v3po.test.ContextTestUtils.getMapping;
+import static io.fd.honeycomb.v3po.translate.v3po.test.ContextTestUtils.getMappingIid;
+import static java.util.Collections.singletonList;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import static org.mockito.MockitoAnnotations.initMocks;
+
import com.google.common.base.Optional;
import com.google.common.net.InetAddresses;
import io.fd.honeycomb.v3po.translate.MappingContext;
@@ -24,6 +40,9 @@ import io.fd.honeycomb.v3po.translate.v3po.test.TestHelperUtils;
import io.fd.honeycomb.v3po.translate.v3po.util.NamingContext;
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.CompletionStage;
+import java.util.concurrent.ExecutionException;
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
@@ -47,19 +66,6 @@ import org.openvpp.jvpp.dto.VxlanAddDelTunnel;
import org.openvpp.jvpp.dto.VxlanAddDelTunnelReply;
import org.openvpp.jvpp.future.FutureJVpp;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.CompletionStage;
-import java.util.concurrent.ExecutionException;
-
-import static io.fd.honeycomb.v3po.translate.v3po.test.ContextTestUtils.getMapping;
-import static io.fd.honeycomb.v3po.translate.v3po.test.ContextTestUtils.getMappingIid;
-import static java.util.Collections.singletonList;
-import static org.junit.Assert.*;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.*;
-import static org.mockito.MockitoAnnotations.initMocks;
-
public class VxlanCustomizerTest {
private static final byte ADD_VXLAN = 1;
@@ -94,7 +100,7 @@ public class VxlanCustomizerTest {
.augmentation(VppInterfaceAugmentation.class).child(Vxlan.class);
}
- private void whenVxlanAddDelTunnelThen() throws ExecutionException, InterruptedException, VppInvocationException {
+ private void whenVxlanAddDelTunnelThenSuccess() throws ExecutionException, InterruptedException, VppInvocationException {
final CompletionStage<VxlanAddDelTunnelReply> replyCS = mock(CompletionStage.class);
final CompletableFuture<VxlanAddDelTunnelReply> replyFuture = mock(CompletableFuture.class);
when(replyCS.toCompletableFuture()).thenReturn(replyFuture);
@@ -106,16 +112,10 @@ public class VxlanCustomizerTest {
/**
* Failure response send
*/
- private void whenVxlanAddDelTunnelFailedThen(final int retval) throws ExecutionException, InterruptedException, VppInvocationException {
- doReturn(TestHelperUtils.<VxlanAddDelTunnelReply>createFutureException(retval)).when(api).vxlanAddDelTunnel(any(VxlanAddDelTunnel.class));
- }
-
- private void whenVxlanAddDelTunnelThenSuccess() throws ExecutionException, InterruptedException, VppInvocationException {
- whenVxlanAddDelTunnelThen();
- }
-
- private void whenVxlanAddDelTunnelThenFailure() throws ExecutionException, InterruptedException, VppInvocationException {
- whenVxlanAddDelTunnelFailedThen(-1);
+ private void whenVxlanAddDelTunnelThenFailure()
+ throws ExecutionException, InterruptedException, VppInvocationException {
+ doReturn(TestHelperUtils.<VxlanAddDelTunnelReply>createFutureException()).when(api)
+ .vxlanAddDelTunnel(any(VxlanAddDelTunnel.class));
}
private VxlanAddDelTunnel verifyVxlanAddDelTunnelWasInvoked(final Vxlan vxlan) throws VppInvocationException {
@@ -124,12 +124,15 @@ public class VxlanCustomizerTest {
final VxlanAddDelTunnel actual = argumentCaptor.getValue();
assertEquals(0, actual.isIpv6);
assertEquals(-1, actual.decapNextIndex);
- assertArrayEquals(InetAddresses.forString(vxlan.getSrc().getIpv4Address().getValue()).getAddress(), actual.srcAddress);
- assertArrayEquals(InetAddresses.forString(vxlan.getDst().getIpv4Address().getValue()).getAddress(), actual.dstAddress);
+ assertArrayEquals(InetAddresses.forString(vxlan.getSrc().getIpv4Address().getValue()).getAddress(),
+ actual.srcAddress);
+ assertArrayEquals(InetAddresses.forString(vxlan.getDst().getIpv4Address().getValue()).getAddress(),
+ actual.dstAddress);
assertEquals(vxlan.getEncapVrfId().intValue(), actual.encapVrfId);
assertEquals(vxlan.getVni().getValue().intValue(), actual.vni);
return actual;
}
+
private void verifyVxlanAddWasInvoked(final Vxlan vxlan) throws VppInvocationException {
final VxlanAddDelTunnel actual = verifyVxlanAddDelTunnelWasInvoked(vxlan);
assertEquals(ADD_VXLAN, actual.isAdd);