summaryrefslogtreecommitdiffstats
path: root/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces
diff options
context:
space:
mode:
Diffstat (limited to 'v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces')
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/RewriteCustomizerTest.java59
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/SubInterfaceCustomizerTest.java48
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/TapCustomizerTest.java3
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VhostUserCustomizerTest.java104
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VxlanCustomizerTest.java63
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VxlanGpeCustomizerTest.java38
6 files changed, 182 insertions, 133 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 068f9147e..655bda525 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,23 +16,14 @@
package io.fd.honeycomb.v3po.translate.v3po.interfaces;
-import static io.fd.honeycomb.v3po.translate.v3po.test.ContextTestUtils.getMapping;
-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;
import io.fd.honeycomb.v3po.translate.v3po.util.NamingContext;
import io.fd.honeycomb.v3po.translate.v3po.util.TagRewriteOperation;
-import io.fd.honeycomb.v3po.translate.v3po.util.VppApiInvocationException;
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;
import org.mockito.ArgumentCaptor;
@@ -41,6 +32,7 @@ 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;
@@ -50,10 +42,24 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.sub._interface.base.attributes.l2.RewriteBuilder;
import org.opendaylight.yangtools.yang.binding.ChildOf;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.jvpp.VppBaseCallException;
+import org.openvpp.jvpp.VppInvocationException;
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
@@ -106,23 +112,32 @@ public class RewriteCustomizerTest {
return request;
}
- private void whenL2InterfaceVlanTagRewriteThen(final int retval) throws ExecutionException, InterruptedException {
+ /**
+ * Positive response
+ */
+ private void whenL2InterfaceVlanTagRewriteThen() throws ExecutionException, InterruptedException, VppInvocationException {
final CompletableFuture<L2InterfaceVlanTagRewriteReply> replyFuture = new CompletableFuture<>();
final L2InterfaceVlanTagRewriteReply reply = new L2InterfaceVlanTagRewriteReply();
- reply.retval = retval;
replyFuture.complete(reply);
doReturn(replyFuture).when(api).l2InterfaceVlanTagRewrite(any(L2InterfaceVlanTagRewrite.class));
}
- private void whenL2InterfaceVlanTagRewriteThenSuccess() throws ExecutionException, InterruptedException {
- whenL2InterfaceVlanTagRewriteThen(0);
+ /**
+ * 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 {
- whenL2InterfaceVlanTagRewriteThen(-1);
+ private void whenL2InterfaceVlanTagRewriteThenFailure() throws ExecutionException, InterruptedException, VppInvocationException {
+ whenL2InterfaceVlanTagRewriteFailedThen(-1);
}
- private void verifyL2InterfaceVlanTagRewriteWasInvoked(final L2InterfaceVlanTagRewrite expected) {
+ 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();
@@ -133,7 +148,7 @@ public class RewriteCustomizerTest {
assertEquals(expected.tag2, actual.tag2);
}
- private void verifyL2InterfaceVlanTagRewriteDeleteWasInvoked() {
+ private void verifyL2InterfaceVlanTagRewriteDeleteWasInvoked() throws VppInvocationException {
final L2InterfaceVlanTagRewrite request = new L2InterfaceVlanTagRewrite();
request.swIfIndex = VLAN_IF_INDEX;
verifyL2InterfaceVlanTagRewriteWasInvoked(request);
@@ -165,7 +180,7 @@ public class RewriteCustomizerTest {
try {
customizer.writeCurrentAttributes(id, vlanTagRewrite, writeContext);
} catch (WriteFailedException.CreateFailedException e) {
- assertEquals(VppApiInvocationException.class, e.getCause().getClass());
+ assertTrue(e.getCause() instanceof VppBaseCallException);
verifyL2InterfaceVlanTagRewriteWasInvoked(generateL2InterfaceVlanTagRewrite(VLAN_IF_INDEX, op));
return;
}
@@ -196,7 +211,7 @@ public class RewriteCustomizerTest {
try {
customizer.updateCurrentAttributes(id, before, after, writeContext);
} catch (WriteFailedException.UpdateFailedException e) {
- assertEquals(VppApiInvocationException.class, e.getCause().getClass());
+ assertTrue(e.getCause() instanceof VppBaseCallException);
verifyL2InterfaceVlanTagRewriteWasInvoked(generateL2InterfaceVlanTagRewrite(VLAN_IF_INDEX, TagRewriteOperation.pop_1));
return;
}
@@ -223,7 +238,7 @@ public class RewriteCustomizerTest {
try {
customizer.deleteCurrentAttributes(id, null, writeContext);
} catch (WriteFailedException.DeleteFailedException e) {
- assertEquals(VppApiInvocationException.class, e.getCause().getClass());
+ Assert.assertTrue(e.getCause() instanceof VppBaseCallException);
verifyL2InterfaceVlanTagRewriteDeleteWasInvoked();
return;
}
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/SubInterfaceCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/SubInterfaceCustomizerTest.java
index a97e43697..5ed37aa40 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/SubInterfaceCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/SubInterfaceCustomizerTest.java
@@ -30,8 +30,8 @@ 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;
import io.fd.honeycomb.v3po.translate.v3po.util.NamingContext;
-import io.fd.honeycomb.v3po.translate.v3po.util.VppApiInvocationException;
import io.fd.honeycomb.v3po.translate.write.WriteContext;
import io.fd.honeycomb.v3po.translate.write.WriteFailedException;
import java.util.ArrayList;
@@ -66,12 +66,25 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.sub._interface.base.attributes.tags.TagBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.sub._interface.base.attributes.tags.TagKey;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.jvpp.VppBaseCallException;
+import org.openvpp.jvpp.VppInvocationException;
import org.openvpp.jvpp.dto.CreateSubif;
import org.openvpp.jvpp.dto.CreateSubifReply;
import org.openvpp.jvpp.dto.SwInterfaceSetFlags;
import org.openvpp.jvpp.dto.SwInterfaceSetFlagsReply;
import org.openvpp.jvpp.future.FutureJVpp;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ExecutionException;
+
+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.*;
+import static org.mockito.MockitoAnnotations.initMocks;
+
public class SubInterfaceCustomizerTest {
@Mock
@@ -116,7 +129,7 @@ public class SubInterfaceCustomizerTest {
}
private static Tag generateTag(final short index, final Class<? extends Dot1qTagVlanType> tagType,
- final Dot1qTag.VlanId vlanId) {
+ final Dot1qTag.VlanId vlanId) {
TagBuilder tag = new TagBuilder();
tag.setIndex(index);
tag.setKey(new TagKey(index));
@@ -160,35 +173,40 @@ public class SubInterfaceCustomizerTest {
SubinterfaceAugmentation.class).child(SubInterfaces.class).child(SubInterface.class, new SubInterfaceKey(index));
}
- private void whenCreateSubifThen(final int retval) throws ExecutionException, InterruptedException {
+ private void whenCreateSubifThen() throws ExecutionException, InterruptedException, VppBaseCallException {
final CompletableFuture<CreateSubifReply> replyFuture = new CompletableFuture<>();
final CreateSubifReply reply = new CreateSubifReply();
- reply.retval = retval;
replyFuture.complete(reply);
doReturn(replyFuture).when(api).createSubif(any(CreateSubif.class));
}
- private void whenSwInterfaceSetFlagsThen(final int retval) throws ExecutionException, InterruptedException {
+ /**
+ * Failure response send
+ */
+ private void whenCreateSubifFailedThen(final int retval) throws ExecutionException, InterruptedException, VppBaseCallException {
+ doReturn(TestHelperUtils.<CreateSubifReply>createFutureException(retval)).when(api).createSubif(any(CreateSubif.class));
+ }
+
+ private void whenSwInterfaceSetFlagsThen(final int retval) throws ExecutionException, InterruptedException, VppBaseCallException {
final CompletableFuture<SwInterfaceSetFlagsReply> replyFuture = new CompletableFuture<>();
final SwInterfaceSetFlagsReply reply = new SwInterfaceSetFlagsReply();
- reply.retval = retval;
replyFuture.complete(reply);
doReturn(replyFuture).when(api).swInterfaceSetFlags(any(SwInterfaceSetFlags.class));
}
- private void whenCreateSubifThenSuccess() throws ExecutionException, InterruptedException {
- whenCreateSubifThen(0);
+ private void whenCreateSubifThenSuccess() throws ExecutionException, InterruptedException, VppBaseCallException {
+ whenCreateSubifThen();
}
- private void whenCreateSubifThenFailure() throws ExecutionException, InterruptedException {
- whenCreateSubifThen(-1);
+ private void whenCreateSubifThenFailure() throws ExecutionException, InterruptedException, VppBaseCallException {
+ whenCreateSubifFailedThen(-1);
}
-
- private void whenSwInterfaceSetFlagsThenSuccess() throws ExecutionException, InterruptedException {
+
+ private void whenSwInterfaceSetFlagsThenSuccess() throws ExecutionException, InterruptedException, VppBaseCallException {
whenSwInterfaceSetFlagsThen(0);
}
- private CreateSubif verifyCreateSubifWasInvoked(final CreateSubif expected) {
+ private CreateSubif verifyCreateSubifWasInvoked(final CreateSubif expected) throws VppBaseCallException {
ArgumentCaptor<CreateSubif> argumentCaptor = ArgumentCaptor.forClass(CreateSubif.class);
verify(api).createSubif(argumentCaptor.capture());
final CreateSubif actual = argumentCaptor.getValue();
@@ -208,7 +226,7 @@ public class SubInterfaceCustomizerTest {
return actual;
}
- private SwInterfaceSetFlags verifySwInterfaceSetFlagsWasInvoked(final SwInterfaceSetFlags expected) {
+ private SwInterfaceSetFlags verifySwInterfaceSetFlagsWasInvoked(final SwInterfaceSetFlags expected) throws VppBaseCallException{
ArgumentCaptor<SwInterfaceSetFlags> argumentCaptor = ArgumentCaptor.forClass(SwInterfaceSetFlags.class);
verify(api).swInterfaceSetFlags(argumentCaptor.capture());
final SwInterfaceSetFlags actual = argumentCaptor.getValue();
@@ -249,7 +267,7 @@ public class SubInterfaceCustomizerTest {
try {
customizer.writeCurrentAttributes(id, subInterface, writeContext);
} catch (WriteFailedException.CreateFailedException e) {
- assertEquals(VppApiInvocationException.class, e.getCause().getClass());
+ assertTrue(e.getCause() instanceof VppBaseCallException );
verifyCreateSubifWasInvoked(generateSubInterfaceRequest(SUPER_IF_ID));
verify(mappingContext, times(0)).put(
eq(getMappingIid(subIfaceName, "test-instance")),
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/TapCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/TapCustomizerTest.java
index 61a94f8d2..ea6990f60 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/TapCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/TapCustomizerTest.java
@@ -87,7 +87,6 @@ public class TapCustomizerTest {
final CompletableFuture<Object> reply = new CompletableFuture<>();
final TapConnectReply t = new TapConnectReply();
t.swIfIndex = idx++;
- t.retval = 0;
reply.complete(t);
return reply;
}
@@ -112,7 +111,6 @@ public class TapCustomizerTest {
final CompletableFuture<TapModifyReply> replyModif = new CompletableFuture<>();
final TapModifyReply tmodif = new TapModifyReply();
tmodif.swIfIndex = 0;
- tmodif.retval = 0;
replyModif.complete(tmodif);
doReturn(replyModif).when(vppApi).tapModify(any(TapModify.class));
@@ -136,7 +134,6 @@ public class TapCustomizerTest {
final CompletableFuture<TapDeleteReply> replyDelete = new CompletableFuture<>();
final TapDeleteReply tmodif = new TapDeleteReply();
- tmodif.retval = 0;
replyDelete.complete(tmodif);
doReturn(replyDelete).when(vppApi).tapDelete(any(TapDelete.class));
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VhostUserCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VhostUserCustomizerTest.java
index 660430690..714466ec8 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VhostUserCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VhostUserCustomizerTest.java
@@ -18,30 +18,13 @@ 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 org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-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.verifyZeroInteractions;
-import static org.mockito.Mockito.when;
-import static org.mockito.MockitoAnnotations.initMocks;
-
import io.fd.honeycomb.v3po.translate.MappingContext;
import io.fd.honeycomb.v3po.translate.ModificationCache;
+import io.fd.honeycomb.v3po.translate.v3po.test.TestHelperUtils;
import io.fd.honeycomb.v3po.translate.v3po.util.NamingContext;
-import io.fd.honeycomb.v3po.translate.v3po.util.VppApiInvocationException;
import io.fd.honeycomb.v3po.translate.v3po.util.TranslateUtils;
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;
@@ -54,14 +37,21 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces._interface.VhostUser;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces._interface.VhostUserBuilder;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.openvpp.jvpp.dto.CreateVhostUserIf;
-import org.openvpp.jvpp.dto.CreateVhostUserIfReply;
-import org.openvpp.jvpp.dto.DeleteVhostUserIf;
-import org.openvpp.jvpp.dto.DeleteVhostUserIfReply;
-import org.openvpp.jvpp.dto.ModifyVhostUserIf;
-import org.openvpp.jvpp.dto.ModifyVhostUserIfReply;
+import org.openvpp.jvpp.VppBaseCallException;
+import org.openvpp.jvpp.VppInvocationException;
+import org.openvpp.jvpp.dto.*;
import org.openvpp.jvpp.future.FutureJVpp;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.CompletionStage;
+import java.util.concurrent.ExecutionException;
+
+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 VhostUserCustomizerTest {
@Mock
@@ -92,61 +82,79 @@ public class VhostUserCustomizerTest {
customizer = new VhostUserCustomizer(api, namingContext);
}
- private void whenCreateVhostUserIfThen(final int retval) throws ExecutionException, InterruptedException {
+ private void whenCreateVhostUserIfThen() throws ExecutionException, InterruptedException, VppInvocationException {
final CompletionStage<CreateVhostUserIfReply> replyCS = mock(CompletionStage.class);
final CompletableFuture<CreateVhostUserIfReply> replyFuture = mock(CompletableFuture.class);
when(replyCS.toCompletableFuture()).thenReturn(replyFuture);
final CreateVhostUserIfReply reply = new CreateVhostUserIfReply();
- reply.retval = retval;
when(replyFuture.get()).thenReturn(reply);
when(api.createVhostUserIf(any(CreateVhostUserIf.class))).thenReturn(replyCS);
}
- private void whenCreateVhostUserIfThenSuccess() throws ExecutionException, InterruptedException {
- whenCreateVhostUserIfThen(0);
+ /**
+ * Failure response send
+ */
+ private void whenCreateVhostUserIfFailedThen(final int retval) throws ExecutionException, InterruptedException, VppInvocationException {
+ doReturn(TestHelperUtils.<CreateVhostUserIfReply>createFutureException(retval)).when(api).createVhostUserIf(any(CreateVhostUserIf.class));
+ }
+
+ private void whenCreateVhostUserIfThenSuccess() throws ExecutionException, InterruptedException, VppInvocationException {
+ whenCreateVhostUserIfThen();
}
- private void whenVxlanAddDelTunnelThenFailure() throws ExecutionException, InterruptedException {
- whenCreateVhostUserIfThen(-1);
+ private void whenVxlanAddDelTunnelThenFailure() throws ExecutionException, InterruptedException, VppInvocationException {
+ whenCreateVhostUserIfFailedThen(-1);
}
- private void whenModifyVhostUserIfThen(final int retval) throws ExecutionException, InterruptedException {
+ private void whenModifyVhostUserIfThen() throws ExecutionException, InterruptedException, VppInvocationException {
final CompletionStage<ModifyVhostUserIfReply> replyCS = mock(CompletionStage.class);
final CompletableFuture<ModifyVhostUserIfReply> replyFuture = mock(CompletableFuture.class);
when(replyCS.toCompletableFuture()).thenReturn(replyFuture);
final ModifyVhostUserIfReply reply = new ModifyVhostUserIfReply();
- reply.retval = retval;
when(replyFuture.get()).thenReturn(reply);
when(api.modifyVhostUserIf(any(ModifyVhostUserIf.class))).thenReturn(replyCS);
}
- private void whenModifyVhostUserIfThenSuccess() throws ExecutionException, InterruptedException {
- whenModifyVhostUserIfThen(0);
+ /**
+ * Failure response send
+ */
+ private void whenModifyVhostUserIfFailedThen(final int retval) throws ExecutionException, InterruptedException, VppInvocationException {
+ doReturn(TestHelperUtils.<ModifyVhostUserIfReply>createFutureException(retval)).when(api).modifyVhostUserIf(any(ModifyVhostUserIf.class));
+ }
+
+ private void whenModifyVhostUserIfThenSuccess() throws ExecutionException, InterruptedException, VppInvocationException {
+ whenModifyVhostUserIfThen();
}
- private void whenModifyVhostUserIfThenFailure() throws ExecutionException, InterruptedException {
- whenModifyVhostUserIfThen(-1);
+ private void whenModifyVhostUserIfThenFailure() throws ExecutionException, InterruptedException, VppInvocationException {
+ whenModifyVhostUserIfFailedThen(-1);
}
- private void whenDeleteVhostUserIfThen(final int retval) throws ExecutionException, InterruptedException {
+ private void whenDeleteVhostUserIfThen() throws ExecutionException, InterruptedException, VppInvocationException {
final CompletionStage<DeleteVhostUserIfReply> replyCS = mock(CompletionStage.class);
final CompletableFuture<DeleteVhostUserIfReply> replyFuture = mock(CompletableFuture.class);
when(replyCS.toCompletableFuture()).thenReturn(replyFuture);
final DeleteVhostUserIfReply reply = new DeleteVhostUserIfReply();
- reply.retval = retval;
when(replyFuture.get()).thenReturn(reply);
when(api.deleteVhostUserIf(any(DeleteVhostUserIf.class))).thenReturn(replyCS);
}
- private void whenDeleteVhostUserIfThenSuccess() throws ExecutionException, InterruptedException {
- whenDeleteVhostUserIfThen(0);
+ /**
+ * Failure response send
+ */
+ private void whenDeleteVhostUserIfFailedThen(final int retval) throws ExecutionException, InterruptedException, VppInvocationException {
+ doReturn(TestHelperUtils.<DeleteVhostUserIfReply>createFutureException(retval)).when(api).deleteVhostUserIf(any(DeleteVhostUserIf.class));
+ }
+
+ private void whenDeleteVhostUserIfThenSuccess() throws ExecutionException, InterruptedException, VppInvocationException {
+ whenDeleteVhostUserIfThen();
}
- private void whenDeleteVhostUserIfThenFailure() throws ExecutionException, InterruptedException {
- whenDeleteVhostUserIfThen(-1);
+ private void whenDeleteVhostUserIfThenFailure() throws ExecutionException, InterruptedException, VppInvocationException {
+ whenDeleteVhostUserIfFailedThen(-1);
}
- private CreateVhostUserIf verifyCreateVhostUserIfWasInvoked(final VhostUser vhostUser) {
+ private CreateVhostUserIf verifyCreateVhostUserIfWasInvoked(final VhostUser vhostUser) throws VppInvocationException {
ArgumentCaptor<CreateVhostUserIf> argumentCaptor = ArgumentCaptor.forClass(CreateVhostUserIf.class);
verify(api).createVhostUserIf(argumentCaptor.capture());
final CreateVhostUserIf actual = argumentCaptor.getValue();
@@ -160,7 +168,7 @@ public class VhostUserCustomizerTest {
return actual;
}
- private ModifyVhostUserIf verifyModifyVhostUserIfWasInvoked(final VhostUser vhostUser, final int swIfIndex) {
+ private ModifyVhostUserIf verifyModifyVhostUserIfWasInvoked(final VhostUser vhostUser, final int swIfIndex) throws VppInvocationException {
ArgumentCaptor<ModifyVhostUserIf> argumentCaptor = ArgumentCaptor.forClass(ModifyVhostUserIf.class);
verify(api).modifyVhostUserIf(argumentCaptor.capture());
final ModifyVhostUserIf actual = argumentCaptor.getValue();
@@ -173,7 +181,7 @@ public class VhostUserCustomizerTest {
return actual;
}
- private DeleteVhostUserIf verifyDeleteVhostUserIfWasInvoked(final int swIfIndex) {
+ private DeleteVhostUserIf verifyDeleteVhostUserIfWasInvoked(final int swIfIndex) throws VppInvocationException {
ArgumentCaptor<DeleteVhostUserIf> argumentCaptor = ArgumentCaptor.forClass(DeleteVhostUserIf.class);
verify(api).deleteVhostUserIf(argumentCaptor.capture());
final DeleteVhostUserIf actual = argumentCaptor.getValue();
@@ -208,7 +216,7 @@ public class VhostUserCustomizerTest {
try {
customizer.writeCurrentAttributes(ID, vhostUser, writeContext);
} catch (WriteFailedException.CreateFailedException e) {
- assertEquals(VppApiInvocationException.class, e.getCause().getClass());
+ assertTrue(e.getCause() instanceof VppBaseCallException);
verifyCreateVhostUserIfWasInvoked(vhostUser);
verifyZeroInteractions(mappingContext);
return;
@@ -239,7 +247,7 @@ public class VhostUserCustomizerTest {
try {
customizer.updateCurrentAttributes(ID, vhostUserBefore, vhostUserAfter, writeContext);
} catch (WriteFailedException.UpdateFailedException e) {
- assertEquals(VppApiInvocationException.class, e.getCause().getClass());
+ assertTrue(e.getCause() instanceof VppBaseCallException);
verifyModifyVhostUserIfWasInvoked(vhostUserAfter, IFACE_ID);
return;
}
@@ -268,7 +276,7 @@ public class VhostUserCustomizerTest {
try {
customizer.deleteCurrentAttributes(ID, vhostUser, writeContext);
} catch (WriteFailedException.DeleteFailedException e) {
- assertEquals(VppApiInvocationException.class, e.getCause().getClass());
+ assertTrue(e.getCause() instanceof VppBaseCallException);
verifyDeleteVhostUserIfWasInvoked(IFACE_ID);
// Delete from context not invoked if delete from VPP failed
verify(mappingContext, times(0)).delete(eq(getMappingIid(IFACE_NAME, "test-instance")));
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 312ec9c01..e716dc6dc 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,32 +16,14 @@
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.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;
import io.fd.honeycomb.v3po.translate.ModificationCache;
+import io.fd.honeycomb.v3po.translate.v3po.test.TestHelperUtils;
import io.fd.honeycomb.v3po.translate.v3po.util.NamingContext;
-import io.fd.honeycomb.v3po.translate.v3po.util.VppApiInvocationException;
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;
@@ -59,10 +41,25 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces._interface.Vxlan;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces._interface.VxlanBuilder;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.jvpp.VppBaseCallException;
+import org.openvpp.jvpp.VppInvocationException;
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;
@@ -97,25 +94,31 @@ public class VxlanCustomizerTest {
.augmentation(VppInterfaceAugmentation.class).child(Vxlan.class);
}
- private void whenVxlanAddDelTunnelThen(final int retval) throws ExecutionException, InterruptedException {
+ private void whenVxlanAddDelTunnelThen() throws ExecutionException, InterruptedException, VppInvocationException {
final CompletionStage<VxlanAddDelTunnelReply> replyCS = mock(CompletionStage.class);
final CompletableFuture<VxlanAddDelTunnelReply> replyFuture = mock(CompletableFuture.class);
when(replyCS.toCompletableFuture()).thenReturn(replyFuture);
final VxlanAddDelTunnelReply reply = new VxlanAddDelTunnelReply();
- reply.retval = retval;
when(replyFuture.get()).thenReturn(reply);
when(api.vxlanAddDelTunnel(any(VxlanAddDelTunnel.class))).thenReturn(replyCS);
}
- private void whenVxlanAddDelTunnelThenSuccess() throws ExecutionException, InterruptedException {
- whenVxlanAddDelTunnelThen(0);
+ /**
+ * 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 {
- whenVxlanAddDelTunnelThen(-1);
+ private void whenVxlanAddDelTunnelThenFailure() throws ExecutionException, InterruptedException, VppInvocationException {
+ whenVxlanAddDelTunnelFailedThen(-1);
}
- private VxlanAddDelTunnel verifyVxlanAddDelTunnelWasInvoked(final Vxlan vxlan) {
+ private VxlanAddDelTunnel verifyVxlanAddDelTunnelWasInvoked(final Vxlan vxlan) throws VppInvocationException {
ArgumentCaptor<VxlanAddDelTunnel> argumentCaptor = ArgumentCaptor.forClass(VxlanAddDelTunnel.class);
verify(api).vxlanAddDelTunnel(argumentCaptor.capture());
final VxlanAddDelTunnel actual = argumentCaptor.getValue();
@@ -127,12 +130,12 @@ public class VxlanCustomizerTest {
assertEquals(vxlan.getVni().getValue().intValue(), actual.vni);
return actual;
}
- private void verifyVxlanAddWasInvoked(final Vxlan vxlan) {
+ private void verifyVxlanAddWasInvoked(final Vxlan vxlan) throws VppInvocationException {
final VxlanAddDelTunnel actual = verifyVxlanAddDelTunnelWasInvoked(vxlan);
assertEquals(ADD_VXLAN, actual.isAdd);
}
- private void verifyVxlanDeleteWasInvoked(final Vxlan vxlan) {
+ private void verifyVxlanDeleteWasInvoked(final Vxlan vxlan) throws VppInvocationException {
final VxlanAddDelTunnel actual = verifyVxlanAddDelTunnelWasInvoked(vxlan);
assertEquals(DEL_VXLAN, actual.isAdd);
}
@@ -191,7 +194,7 @@ public class VxlanCustomizerTest {
try {
customizer.writeCurrentAttributes(id, vxlan, writeContext);
} catch (WriteFailedException.CreateFailedException e) {
- assertEquals(VppApiInvocationException.class, e.getCause().getClass());
+ assertTrue(e.getCause() instanceof VppBaseCallException);
verifyVxlanAddWasInvoked(vxlan);
// Mapping not stored due to failure
verify(mappingContext, times(0)).put(eq(getMappingIid(ifaceName, "test-instance")), eq(getMapping(ifaceName, 0).get()));
@@ -233,7 +236,7 @@ public class VxlanCustomizerTest {
try {
customizer.deleteCurrentAttributes(id, vxlan, writeContext);
} catch (WriteFailedException.DeleteFailedException e) {
- assertEquals(VppApiInvocationException.class, e.getCause().getClass());
+ assertTrue(e.getCause() instanceof VppBaseCallException);
verifyVxlanDeleteWasInvoked(vxlan);
verify(mappingContext, times(0)).delete(eq(getMappingIid(ifaceName, "test-instance")));
return;
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VxlanGpeCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VxlanGpeCustomizerTest.java
index 44e8559b4..77404aa45 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VxlanGpeCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VxlanGpeCustomizerTest.java
@@ -19,9 +19,7 @@ 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.fail;
+import static org.junit.Assert.*;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.doReturn;
@@ -35,8 +33,8 @@ import com.google.common.base.Optional;
import com.google.common.net.InetAddresses;
import io.fd.honeycomb.v3po.translate.MappingContext;
import io.fd.honeycomb.v3po.translate.ModificationCache;
+import io.fd.honeycomb.v3po.translate.v3po.test.TestHelperUtils;
import io.fd.honeycomb.v3po.translate.v3po.util.NamingContext;
-import io.fd.honeycomb.v3po.translate.v3po.util.VppApiInvocationException;
import io.fd.honeycomb.v3po.translate.write.WriteContext;
import io.fd.honeycomb.v3po.translate.write.WriteFailedException;
import java.util.concurrent.CompletableFuture;
@@ -60,6 +58,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces._interface.VxlanGpe;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces._interface.VxlanGpeBuilder;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.jvpp.VppBaseCallException;
+import org.openvpp.jvpp.VppInvocationException;
+import org.openvpp.jvpp.dto.VxlanAddDelTunnel;
+import org.openvpp.jvpp.dto.VxlanAddDelTunnelReply;
import org.openvpp.jvpp.dto.VxlanGpeAddDelTunnel;
import org.openvpp.jvpp.dto.VxlanGpeAddDelTunnelReply;
import org.openvpp.jvpp.future.FutureJVpp;
@@ -98,25 +100,31 @@ public class VxlanGpeCustomizerTest {
.augmentation(VppInterfaceAugmentation.class).child(VxlanGpe.class);
}
- private void whenVxlanGpeAddDelTunnelThen(final int retval) throws ExecutionException, InterruptedException {
+ private void whenVxlanGpeAddDelTunnelThen() throws ExecutionException, InterruptedException, VppBaseCallException {
final CompletionStage<VxlanGpeAddDelTunnelReply> replyCS = mock(CompletionStage.class);
final CompletableFuture<VxlanGpeAddDelTunnelReply> replyFuture = mock(CompletableFuture.class);
when(replyCS.toCompletableFuture()).thenReturn(replyFuture);
final VxlanGpeAddDelTunnelReply reply = new VxlanGpeAddDelTunnelReply();
- reply.retval = retval;
when(replyFuture.get()).thenReturn(reply);
when(api.vxlanGpeAddDelTunnel(any(VxlanGpeAddDelTunnel.class))).thenReturn(replyCS);
}
- private void whenVxlanGpeAddDelTunnelThenSuccess() throws ExecutionException, InterruptedException {
- whenVxlanGpeAddDelTunnelThen(0);
+ private void whenVxlanGpeAddDelTunnelThenSuccess() throws ExecutionException, InterruptedException, VppBaseCallException {
+ whenVxlanGpeAddDelTunnelThen();
}
- private void whenVxlanGpeAddDelTunnelThenFailure() throws ExecutionException, InterruptedException {
- whenVxlanGpeAddDelTunnelThen(-1);
+ private void whenVxlanGpeAddDelTunnelThenFailure() throws ExecutionException, InterruptedException, VppBaseCallException {
+ whenVxlanGpeAddDelTunnelFailedThen(-1);
}
- private VxlanGpeAddDelTunnel verifyVxlanGpeAddDelTunnelWasInvoked(final VxlanGpe vxlanGpe) {
+ /**
+ * Failure response send
+ */
+ private void whenVxlanGpeAddDelTunnelFailedThen(final int retval) throws ExecutionException, InterruptedException, VppBaseCallException {
+ doReturn(TestHelperUtils.<VxlanAddDelTunnelReply>createFutureException(retval)).when(api).vxlanGpeAddDelTunnel(any(VxlanGpeAddDelTunnel.class));
+ }
+
+ private VxlanGpeAddDelTunnel verifyVxlanGpeAddDelTunnelWasInvoked(final VxlanGpe vxlanGpe) throws VppBaseCallException{
ArgumentCaptor<VxlanGpeAddDelTunnel> argumentCaptor = ArgumentCaptor.forClass(VxlanGpeAddDelTunnel.class);
verify(api).vxlanGpeAddDelTunnel(argumentCaptor.capture());
final VxlanGpeAddDelTunnel actual = argumentCaptor.getValue();
@@ -129,12 +137,12 @@ public class VxlanGpeCustomizerTest {
assertEquals(vxlanGpe.getDecapVrfId().intValue(), actual.decapVrfId);
return actual;
}
- private void verifyVxlanGpeAddWasInvoked(final VxlanGpe vxlanGpe) {
+ private void verifyVxlanGpeAddWasInvoked(final VxlanGpe vxlanGpe) throws VppBaseCallException{
final VxlanGpeAddDelTunnel actual = verifyVxlanGpeAddDelTunnelWasInvoked(vxlanGpe);
assertEquals(ADD_VXLAN_GPE, actual.isAdd);
}
- private void verifyVxlanGpeDeleteWasInvoked(final VxlanGpe vxlanGpe) {
+ private void verifyVxlanGpeDeleteWasInvoked(final VxlanGpe vxlanGpe) throws VppBaseCallException{
final VxlanGpeAddDelTunnel actual = verifyVxlanGpeAddDelTunnelWasInvoked(vxlanGpe);
assertEquals(DEL_VXLAN_GPE, actual.isAdd);
}
@@ -195,7 +203,7 @@ public class VxlanGpeCustomizerTest {
try {
customizer.writeCurrentAttributes(id, vxlanGpe, writeContext);
} catch (WriteFailedException.CreateFailedException e) {
- assertEquals(VppApiInvocationException.class, e.getCause().getClass());
+ assertTrue(e.getCause() instanceof VppBaseCallException);
verifyVxlanGpeAddWasInvoked(vxlanGpe);
// Mapping not stored due to failure
verify(mappingContext, times(0)).put(eq(getMappingIid(ifaceName, "test-instance")), eq(getMapping(ifaceName, 0).get()));
@@ -237,7 +245,7 @@ public class VxlanGpeCustomizerTest {
try {
customizer.deleteCurrentAttributes(id, vxlanGpe, writeContext);
} catch (WriteFailedException.DeleteFailedException e) {
- assertEquals(VppApiInvocationException.class, e.getCause().getClass());
+ assertTrue(e.getCause() instanceof VppBaseCallException);
verifyVxlanGpeDeleteWasInvoked(vxlanGpe);
verify(mappingContext, times(0)).delete(eq(getMappingIid(ifaceName, "test-instance")));
return;