summaryrefslogtreecommitdiffstats
path: root/v3po
diff options
context:
space:
mode:
authorMarek Gradzki <mgradzki@cisco.com>2016-09-23 07:21:11 +0200
committerMarek Gradzki <mgradzki@cisco.com>2016-09-23 07:21:14 +0200
commit08cd3ae5fd61d60ec07996179146c956459c084f (patch)
tree2596a04ee8854a595c8e1808e0b4504352b79150 /v3po
parent723170e52190110fd21b86177373f8f22223b760 (diff)
HONEYCOMB-116: utility for stubbing jvpp methods
- introduces FutureProducer (inspired by https://gerrit.fd.io/r/#/c/2650/) - updates unit tests for v3po and lisp Change-Id: I56488bb1dcd6fcaf6821a58f99b528677e095662 Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
Diffstat (limited to 'v3po')
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/AclCustomizerTest.java60
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/GreCustomizerTest.java37
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/RewriteCustomizerTest.java59
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/SubInterfaceCustomizerTest.java55
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/TapCustomizerTest.java24
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/VhostUserCustomizerTest.java79
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/VxlanCustomizerTest.java38
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/VxlanGpeCustomizerTest.java47
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv4AddressCustomizerTest.java73
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv4NeighbourCustomizerTest.java9
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/AclCustomizerTest.java7
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/GreCustomizerTest.java10
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/InterfaceCustomizerTest.java22
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/L2CustomizerTest.java13
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/SubInterfaceCustomizerTest.java12
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/VxlanCustomizerTest.java12
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/VxlanGpeCustomizerTest.java12
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/Ipv4AddressCustomizerTest.java23
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/notification/InterfaceChangeNotificationProducerTest.java11
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/test/InterfaceTestUtils.java52
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/test/TestHelperUtils.java37
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vpp/ArpTerminationTableEntryCustomizerTest.java12
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vpp/BridgeDomainCustomizerTest.java83
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vpp/BridgeDomainTestUtils.java51
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vpp/L2FibEntryCustomizerTest.java13
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifySessionReaderTest.java6
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifySessionWriterTest.java48
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifyTableReaderTest.java9
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifyTableWriterTest.java51
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppstate/L2FibEntryCustomizerTest.java6
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppstate/VersionCustomizerTest.java5
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppstate/VppStateTest.java85
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppstate/VppStateTestUtils.java68
33 files changed, 267 insertions, 862 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 75999e5a4..b55a5ce2b 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
@@ -17,23 +17,17 @@
package io.fd.honeycomb.translate.v3po.interfaces;
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 io.fd.honeycomb.translate.v3po.test.ContextTestUtils;
-import io.fd.honeycomb.translate.v3po.test.TestHelperUtils;
-import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
import io.fd.honeycomb.translate.v3po.vppclassifier.VppClassifierContextManager;
import io.fd.honeycomb.translate.write.WriteFailedException;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.ExecutionException;
+import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest;
import org.junit.Test;
-import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
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;
@@ -47,14 +41,12 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.openvpp.jvpp.VppBaseCallException;
import org.openvpp.jvpp.core.dto.InputAclSetInterface;
import org.openvpp.jvpp.core.dto.InputAclSetInterfaceReply;
-import org.openvpp.jvpp.core.dto.L2InterfaceVlanTagRewriteReply;
public class AclCustomizerTest extends WriterCustomizerTest {
@Mock
private VppClassifierContextManager classifyTableContext;
- private NamingContext interfaceContext;
private AclCustomizer customizer;
private static final String IFC_TEST_INSTANCE = "ifc-test-instance";
@@ -65,16 +57,12 @@ public class AclCustomizerTest extends WriterCustomizerTest {
private static final String ACL_TABLE_NAME = "table0";
@Override
- public void setUp() throws Exception {
- initMocks(this);
- interfaceContext = new NamingContext("generatedInterfaceName", IFC_TEST_INSTANCE);
+ public void setUp() {
ContextTestUtils.mockMapping(mappingContext, IF_NAME, IF_INDEX, IFC_TEST_INSTANCE);
-
- doReturn(mappingContext).when(writeContext).getMappingContext();
- customizer = new AclCustomizer(api, interfaceContext, classifyTableContext);
+ customizer = new AclCustomizer(api, new NamingContext("generatedInterfaceName", IFC_TEST_INSTANCE),
+ classifyTableContext);
}
-
private InstanceIdentifier<Acl> getAclId(final String name) {
return InstanceIdentifier.create(Interfaces.class).child(Interface.class, new InterfaceKey(name)).augmentation(
VppInterfaceAugmentation.class).child(Acl.class);
@@ -87,36 +75,13 @@ public class AclCustomizerTest extends WriterCustomizerTest {
return builder.build();
}
- private void whenInputAclSetInterfaceThenSuccess() throws ExecutionException, InterruptedException {
- final CompletableFuture<InputAclSetInterfaceReply> replyFuture = new CompletableFuture<>();
- final InputAclSetInterfaceReply reply = new InputAclSetInterfaceReply();
- replyFuture.complete(reply);
- doReturn(replyFuture).when(api).inputAclSetInterface(any(InputAclSetInterface.class));
- }
-
- private void whenInputAclSetInterfaceThenFailure() throws ExecutionException, InterruptedException {
- doReturn(TestHelperUtils.<L2InterfaceVlanTagRewriteReply>createFutureException()).when(api)
+ private void whenInputAclSetInterfaceThenSuccess() {
+ doReturn(future(new InputAclSetInterfaceReply())).when(api)
.inputAclSetInterface(any(InputAclSetInterface.class));
}
- private void verifyInputAclSetInterfaceWasInvoked(final InputAclSetInterface expected) {
- final ArgumentCaptor<InputAclSetInterface> argumentCaptor = ArgumentCaptor.forClass(InputAclSetInterface.class);
- verify(api).inputAclSetInterface(argumentCaptor.capture());
- final InputAclSetInterface actual = argumentCaptor.getValue();
- assertEquals(expected.swIfIndex, actual.swIfIndex);
- assertEquals(expected.l2TableIndex, actual.l2TableIndex);
- assertEquals(expected.ip4TableIndex, actual.ip4TableIndex);
- assertEquals(expected.ip6TableIndex, actual.ip6TableIndex);
- assertEquals(expected.isAdd, actual.isAdd);
- }
-
- private void verifyInputAclSetInterfaceDisableWasInvoked(final InputAclSetInterface expected) {
- final ArgumentCaptor<InputAclSetInterface> argumentCaptor = ArgumentCaptor.forClass(InputAclSetInterface.class);
- verify(api).inputAclSetInterface(argumentCaptor.capture());
- final InputAclSetInterface actual = argumentCaptor.getValue();
- assertEquals(expected.swIfIndex, actual.swIfIndex);
- assertEquals(expected.l2TableIndex, actual.l2TableIndex);
- assertEquals(0, actual.isAdd);
+ private void whenInputAclSetInterfaceThenFailure() {
+ doReturn(failedFuture()).when(api).inputAclSetInterface(any(InputAclSetInterface.class));
}
private static InputAclSetInterface generateInputAclSetInterface(final byte isAdd, final int ifIndex,
@@ -139,7 +104,7 @@ public class AclCustomizerTest extends WriterCustomizerTest {
customizer.writeCurrentAttributes(id, acl, writeContext);
- verifyInputAclSetInterfaceWasInvoked(generateInputAclSetInterface((byte) 1, IF_INDEX, ACL_TABLE_INDEX));
+ verify(api).inputAclSetInterface(generateInputAclSetInterface((byte) 1, IF_INDEX, ACL_TABLE_INDEX));
}
@Test
@@ -153,7 +118,7 @@ public class AclCustomizerTest extends WriterCustomizerTest {
customizer.writeCurrentAttributes(id, acl, writeContext);
} catch (WriteFailedException.CreateFailedException e) {
assertTrue(e.getCause() instanceof VppBaseCallException);
- verifyInputAclSetInterfaceWasInvoked(generateInputAclSetInterface((byte) 1, IF_INDEX, ACL_TABLE_INDEX));
+ verify(api).inputAclSetInterface(generateInputAclSetInterface((byte) 1, IF_INDEX, ACL_TABLE_INDEX));
return;
}
fail("WriteFailedException.CreateFailedException was expected");
@@ -168,7 +133,7 @@ public class AclCustomizerTest extends WriterCustomizerTest {
customizer.deleteCurrentAttributes(id, acl, writeContext);
- verifyInputAclSetInterfaceDisableWasInvoked(generateInputAclSetInterface((byte) 0, IF_INDEX, ACL_TABLE_INDEX));
+ verify(api).inputAclSetInterface(generateInputAclSetInterface((byte) 0, IF_INDEX, ACL_TABLE_INDEX));
}
@Test
@@ -182,8 +147,7 @@ public class AclCustomizerTest extends WriterCustomizerTest {
customizer.deleteCurrentAttributes(id, acl, writeContext);
} catch (WriteFailedException.DeleteFailedException e) {
assertTrue(e.getCause() instanceof VppBaseCallException);
- verifyInputAclSetInterfaceDisableWasInvoked(
- generateInputAclSetInterface((byte) 0, IF_INDEX, ACL_TABLE_INDEX));
+ verify(api).inputAclSetInterface(generateInputAclSetInterface((byte) 0, IF_INDEX, ACL_TABLE_INDEX));
return;
}
fail("WriteFailedException.DeleteFailedException was expected");
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 cf92ab91f..6918e1f01 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
@@ -25,24 +25,15 @@ 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.anyLong;
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 com.google.common.net.InetAddresses;
-import io.fd.honeycomb.translate.v3po.test.TestHelperUtils;
-import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.CompletionStage;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
+import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
@@ -78,24 +69,14 @@ public class GreCustomizerTest extends WriterCustomizerTest {
customizer = new GreCustomizer(api, new NamingContext("generateInterfaceNAme", IFC_TEST_INSTANCE));
}
- private void whenGreAddDelTunnelThenSuccess()
- throws ExecutionException, InterruptedException, VppInvocationException, TimeoutException {
- final CompletionStage<GreAddDelTunnelReply> replyCS = mock(CompletionStage.class);
- final CompletableFuture<GreAddDelTunnelReply> replyFuture = mock(CompletableFuture.class);
- when(replyCS.toCompletableFuture()).thenReturn(replyFuture);
+ private void whenGreAddDelTunnelThenSuccess() {
final GreAddDelTunnelReply reply = new GreAddDelTunnelReply();
reply.swIfIndex = IFACE_ID;
- when(replyFuture.get(anyLong(), eq(TimeUnit.SECONDS))).thenReturn(reply);
- when(api.greAddDelTunnel(any(GreAddDelTunnel.class))).thenReturn(replyCS);
+ doReturn(future(reply)).when(api).greAddDelTunnel(any(GreAddDelTunnel.class));
}
- /**
- * Failure response send
- */
- private void whenGreAddDelTunnelThenFailure()
- throws ExecutionException, InterruptedException, VppInvocationException {
- doReturn(TestHelperUtils.<GreAddDelTunnelReply>createFutureException()).when(api)
- .greAddDelTunnel(any(GreAddDelTunnel.class));
+ private void whenGreAddDelTunnelThenFailure() {
+ doReturn(failedFuture()).when(api).greAddDelTunnel(any(GreAddDelTunnel.class));
}
private GreAddDelTunnel verifyGreAddDelTunnelWasInvoked(final Gre gre) throws VppInvocationException {
@@ -121,7 +102,7 @@ public class GreCustomizerTest extends WriterCustomizerTest {
assertEquals(DEL_GRE, actual.isAdd);
}
- private static Gre generateGre(long vni) {
+ private static Gre generateGre() {
final GreBuilder builder = new GreBuilder();
builder.setSrc(new IpAddress(new Ipv4Address("192.168.20.10")));
builder.setDst(new IpAddress(new Ipv4Address("192.168.20.11")));
@@ -129,10 +110,6 @@ public class GreCustomizerTest extends WriterCustomizerTest {
return builder.build();
}
- private static Gre generateGre() {
- return generateGre(Long.valueOf(11));
- }
-
@Test
public void testWriteCurrentAttributes() throws Exception {
final Gre gre = generateGre();
@@ -184,7 +161,7 @@ public class GreCustomizerTest extends WriterCustomizerTest {
@Test
public void testUpdateCurrentAttributes() throws Exception {
try {
- customizer.updateCurrentAttributes(id, generateGre(10), generateGre(11), writeContext);
+ customizer.updateCurrentAttributes(id, generateGre(), generateGre(), writeContext);
} catch (WriteFailedException.UpdateFailedException e) {
assertEquals(UnsupportedOperationException.class, e.getCause().getClass());
return;
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 366d9429e..e28a0f6c6 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
@@ -17,23 +17,18 @@
package io.fd.honeycomb.translate.v3po.interfaces;
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 io.fd.honeycomb.translate.v3po.test.ContextTestUtils;
-import io.fd.honeycomb.translate.v3po.test.TestHelperUtils;
-import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
import io.fd.honeycomb.translate.v3po.util.TagRewriteOperation;
import io.fd.honeycomb.translate.write.WriteFailedException;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.ExecutionException;
+import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest;
import org.junit.Assert;
import org.junit.Test;
-import org.mockito.ArgumentCaptor;
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;
@@ -72,12 +67,12 @@ public class RewriteCustomizerTest extends WriterCustomizerTest {
}
private static InstanceIdentifier<Rewrite> getVlanTagRewriteId(final String name, final long index) {
- final Class<ChildOf<? super SubInterface>> child = (Class)Rewrite.class;
+ final Class<ChildOf<? super SubInterface>> child = (Class) Rewrite.class;
final InstanceIdentifier id =
- InstanceIdentifier.create(Interfaces.class).child(Interface.class, new InterfaceKey(name)).augmentation(
- SubinterfaceAugmentation.class).child(SubInterfaces.class)
- .child(SubInterface.class, new SubInterfaceKey(index))
- .child(child);
+ InstanceIdentifier.create(Interfaces.class).child(Interface.class, new InterfaceKey(name)).augmentation(
+ SubinterfaceAugmentation.class).child(SubInterfaces.class)
+ .child(SubInterface.class, new SubInterfaceKey(index))
+ .child(child);
return id;
}
@@ -100,40 +95,22 @@ public class RewriteCustomizerTest extends WriterCustomizerTest {
/**
* Positive response
*/
- private void whenL2InterfaceVlanTagRewriteThenSuccess()
- throws ExecutionException, InterruptedException, VppInvocationException {
- final CompletableFuture<L2InterfaceVlanTagRewriteReply> replyFuture = new CompletableFuture<>();
- final L2InterfaceVlanTagRewriteReply reply = new L2InterfaceVlanTagRewriteReply();
- replyFuture.complete(reply);
- doReturn(replyFuture).when(api).l2InterfaceVlanTagRewrite(any(L2InterfaceVlanTagRewrite.class));
+ private void whenL2InterfaceVlanTagRewriteThenSuccess() {
+ doReturn(future(new L2InterfaceVlanTagRewriteReply())).when(api)
+ .l2InterfaceVlanTagRewrite(any(L2InterfaceVlanTagRewrite.class));
}
/**
* Failure response send
*/
- 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);
- verify(api).l2InterfaceVlanTagRewrite(argumentCaptor.capture());
- final L2InterfaceVlanTagRewrite actual = argumentCaptor.getValue();
- assertEquals(expected.swIfIndex, actual.swIfIndex);
- assertEquals(expected.vtrOp, actual.vtrOp);
- assertEquals(expected.pushDot1Q, actual.pushDot1Q);
- assertEquals(expected.tag1, actual.tag1);
- assertEquals(expected.tag2, actual.tag2);
+ private void whenL2InterfaceVlanTagRewriteThenFailure() {
+ doReturn(failedFuture()).when(api).l2InterfaceVlanTagRewrite(any(L2InterfaceVlanTagRewrite.class));
}
private void verifyL2InterfaceVlanTagRewriteDeleteWasInvoked() throws VppInvocationException {
final L2InterfaceVlanTagRewrite request = new L2InterfaceVlanTagRewrite();
request.swIfIndex = VLAN_IF_INDEX;
- verifyL2InterfaceVlanTagRewriteWasInvoked(request);
+ verify(api).l2InterfaceVlanTagRewrite(request);
}
@Test
@@ -145,7 +122,7 @@ public class RewriteCustomizerTest extends WriterCustomizerTest {
customizer.writeCurrentAttributes(VLAN_IID, vlanTagRewrite, writeContext);
- verifyL2InterfaceVlanTagRewriteWasInvoked(generateL2InterfaceVlanTagRewrite(VLAN_IF_INDEX, op));
+ verify(api).l2InterfaceVlanTagRewrite(generateL2InterfaceVlanTagRewrite(VLAN_IF_INDEX, op));
}
@Test
@@ -159,7 +136,7 @@ public class RewriteCustomizerTest extends WriterCustomizerTest {
customizer.writeCurrentAttributes(VLAN_IID, vlanTagRewrite, writeContext);
} catch (WriteFailedException.CreateFailedException e) {
assertTrue(e.getCause() instanceof VppBaseCallException);
- verifyL2InterfaceVlanTagRewriteWasInvoked(generateL2InterfaceVlanTagRewrite(VLAN_IF_INDEX, op));
+ verify(api).l2InterfaceVlanTagRewrite(generateL2InterfaceVlanTagRewrite(VLAN_IF_INDEX, op));
return;
}
fail("WriteFailedException.CreateFailedException was expected");
@@ -174,8 +151,8 @@ public class RewriteCustomizerTest extends WriterCustomizerTest {
customizer.updateCurrentAttributes(VLAN_IID, before, after, writeContext);
- verifyL2InterfaceVlanTagRewriteWasInvoked(
- generateL2InterfaceVlanTagRewrite(VLAN_IF_INDEX, TagRewriteOperation.pop_1));
+ verify(api)
+ .l2InterfaceVlanTagRewrite(generateL2InterfaceVlanTagRewrite(VLAN_IF_INDEX, TagRewriteOperation.pop_1));
}
@Test
@@ -189,8 +166,8 @@ public class RewriteCustomizerTest extends WriterCustomizerTest {
customizer.updateCurrentAttributes(VLAN_IID, before, after, writeContext);
} catch (WriteFailedException.UpdateFailedException e) {
assertTrue(e.getCause() instanceof VppBaseCallException);
- verifyL2InterfaceVlanTagRewriteWasInvoked(generateL2InterfaceVlanTagRewrite(VLAN_IF_INDEX,
- TagRewriteOperation.pop_1));
+ verify(api)
+ .l2InterfaceVlanTagRewrite(generateL2InterfaceVlanTagRewrite(VLAN_IF_INDEX, TagRewriteOperation.pop_1));
return;
}
fail("WriteFailedException.UpdateFailedException was expected");
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 c370a97ea..1fee0b3cf 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
@@ -26,14 +26,11 @@ 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.test.TestHelperUtils;
-import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
+import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest;
import java.util.Arrays;
import java.util.List;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.ExecutionException;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.opendaylight.yang.gen.v1.urn.ieee.params.xml.ns.yang.dot1q.types.rev150626.CVlan;
@@ -163,47 +160,19 @@ public class SubInterfaceCustomizerTest extends WriterCustomizerTest {
.child(SubInterface.class, new SubInterfaceKey(index));
}
- private void whenCreateSubifThenSuccess() throws ExecutionException, InterruptedException, VppBaseCallException {
- final CompletableFuture<CreateSubifReply> replyFuture = new CompletableFuture<>();
- final CreateSubifReply reply = new CreateSubifReply();
- replyFuture.complete(reply);
- doReturn(replyFuture).when(api).createSubif(any(CreateSubif.class));
+ private void whenCreateSubifThenSuccess() {
+ doReturn(future(new CreateSubifReply())).when(api).createSubif(any(CreateSubif.class));
}
/**
* Failure response send
*/
- private void whenCreateSubifThenFailure() throws ExecutionException, InterruptedException, VppBaseCallException {
- doReturn(TestHelperUtils.<CreateSubifReply>createFutureException()).when(api)
- .createSubif(any(CreateSubif.class));
- }
-
- private void whenSwInterfaceSetFlagsThenSuccess()
- throws ExecutionException, InterruptedException, VppBaseCallException {
- final CompletableFuture<SwInterfaceSetFlagsReply> replyFuture = new CompletableFuture<>();
- final SwInterfaceSetFlagsReply reply = new SwInterfaceSetFlagsReply();
- replyFuture.complete(reply);
- doReturn(replyFuture).when(api).swInterfaceSetFlags(any(SwInterfaceSetFlags.class));
+ private void whenCreateSubifThenFailure() {
+ doReturn(failedFuture()).when(api).createSubif(any(CreateSubif.class));
}
- 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();
-
- assertEquals(expected.swIfIndex, actual.swIfIndex);
- assertEquals(expected.subId, actual.subId);
- assertEquals(expected.noTags, actual.noTags);
- assertEquals(expected.oneTag, actual.oneTag);
- assertEquals(expected.twoTags, actual.twoTags);
- assertEquals(expected.dot1Ad, actual.dot1Ad);
- assertEquals(expected.exactMatch, actual.exactMatch);
- assertEquals(expected.defaultSub, actual.defaultSub);
- assertEquals(expected.outerVlanIdAny, actual.outerVlanIdAny);
- assertEquals(expected.innerVlanIdAny, actual.innerVlanIdAny);
- assertEquals(expected.outerVlanId, actual.outerVlanId);
- assertEquals(expected.innerVlanId, actual.innerVlanId);
- return actual;
+ private void whenSwInterfaceSetFlagsThenSuccess() {
+ doReturn(future(new SwInterfaceSetFlagsReply())).when(api).swInterfaceSetFlags(any(SwInterfaceSetFlags.class));
}
private SwInterfaceSetFlags verifySwInterfaceSetFlagsWasInvoked(final SwInterfaceSetFlags expected)
@@ -227,10 +196,10 @@ public class SubInterfaceCustomizerTest extends WriterCustomizerTest {
customizer.writeCurrentAttributes(id, subInterface, writeContext);
- verifyCreateSubifWasInvoked(generateSubInterfaceRequest(SUPER_IF_ID, CTAG_ID, false));
+ 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()));
+ ContextTestUtils.getMapping(SUB_IFACE_NAME, 0).get()));
}
@Test
@@ -243,10 +212,10 @@ public class SubInterfaceCustomizerTest extends WriterCustomizerTest {
customizer.writeCurrentAttributes(id, subInterface, writeContext);
- verifyCreateSubifWasInvoked(generateSubInterfaceRequest(SUPER_IF_ID, CTAG_ANY_ID, true));
+ 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()));
+ ContextTestUtils.getMapping(SUB_IFACE_NAME, 0).get()));
}
@Test
@@ -260,7 +229,7 @@ public class SubInterfaceCustomizerTest extends WriterCustomizerTest {
customizer.writeCurrentAttributes(id, subInterface, writeContext);
} catch (WriteFailedException.CreateFailedException e) {
assertTrue(e.getCause() instanceof VppBaseCallException);
- verifyCreateSubifWasInvoked(generateSubInterfaceRequest(SUPER_IF_ID, CTAG_ID, false));
+ 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()));
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 fedc59e79..c2c687602 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
@@ -24,9 +24,8 @@ import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import io.fd.honeycomb.translate.v3po.test.ContextTestUtils;
-import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
-import java.util.concurrent.CompletableFuture;
+import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest;
import org.junit.Test;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
@@ -65,11 +64,9 @@ public class TapCustomizerTest extends WriterCustomizerTest {
@Override
public Object answer(final InvocationOnMock invocation) throws Throwable {
- final CompletableFuture<Object> reply = new CompletableFuture<>();
final TapConnectReply t = new TapConnectReply();
t.swIfIndex = idx++;
- reply.complete(t);
- return reply;
+ return future(t);
}
}).when(api).tapConnect(any(TapConnect.class));
@@ -85,17 +82,13 @@ public class TapCustomizerTest extends WriterCustomizerTest {
@Test
public void testModify() throws Exception {
- final CompletableFuture<TapConnectReply> reply = new CompletableFuture<>();
final TapConnectReply t = new TapConnectReply();
t.swIfIndex = 0;
- reply.complete(t);
- doReturn(reply).when(api).tapConnect(any(TapConnect.class));
+ doReturn(future(t)).when(api).tapConnect(any(TapConnect.class));
- final CompletableFuture<TapModifyReply> replyModif = new CompletableFuture<>();
final TapModifyReply tmodif = new TapModifyReply();
tmodif.swIfIndex = 0;
- replyModif.complete(tmodif);
- doReturn(replyModif).when(api).tapModify(any(TapModify.class));
+ doReturn(future(tmodif)).when(api).tapModify(any(TapModify.class));
tapCustomizer.writeCurrentAttributes(getTapId("tap"), getTapData("tap", "ff:ff:ff:ff:ff:ff"), writeContext);
@@ -111,16 +104,11 @@ public class TapCustomizerTest extends WriterCustomizerTest {
@Test
public void testDelete() throws Exception {
- final CompletableFuture<TapConnectReply> reply = new CompletableFuture<>();
final TapConnectReply t = new TapConnectReply();
t.swIfIndex = 0;
- reply.complete(t);
- doReturn(reply).when(api).tapConnect(any(TapConnect.class));
+ doReturn(future(t)).when(api).tapConnect(any(TapConnect.class));
- final CompletableFuture<TapDeleteReply> replyDelete = new CompletableFuture<>();
- final TapDeleteReply tmodif = new TapDeleteReply();
- replyDelete.complete(tmodif);
- doReturn(replyDelete).when(api).tapDelete(any(TapDelete.class));
+ 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);
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 1d2fb609d..0c1d2d72f 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
@@ -22,26 +22,18 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyLong;
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 io.fd.honeycomb.translate.v3po.test.ContextTestUtils;
-import io.fd.honeycomb.translate.v3po.test.TestHelperUtils;
-import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
import io.fd.honeycomb.translate.write.WriteFailedException;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.CompletionStage;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
+import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.Interfaces;
@@ -77,63 +69,6 @@ public class VhostUserCustomizerTest extends WriterCustomizerTest {
customizer = new VhostUserCustomizer(api, new NamingContext("generatedInterfaceName", "test-instance"));
}
- private void whenCreateVhostUserIfThenSuccess()
- throws ExecutionException, InterruptedException, VppInvocationException, TimeoutException {
- final CompletionStage<CreateVhostUserIfReply> replyCS = mock(CompletionStage.class);
- final CompletableFuture<CreateVhostUserIfReply> replyFuture = mock(CompletableFuture.class);
- when(replyCS.toCompletableFuture()).thenReturn(replyFuture);
- final CreateVhostUserIfReply reply = new CreateVhostUserIfReply();
- when(replyFuture.get(anyLong(), eq(TimeUnit.SECONDS))).thenReturn(reply);
- when(api.createVhostUserIf(any(CreateVhostUserIf.class))).thenReturn(replyCS);
- }
-
- /**
- * Failure response send
- */
- private void whenCreateVhostUserIfThenFailure()
- throws ExecutionException, InterruptedException, VppInvocationException {
- doReturn(TestHelperUtils.<CreateVhostUserIfReply>createFutureException()).when(api)
- .createVhostUserIf(any(CreateVhostUserIf.class));
- }
-
- private void whenModifyVhostUserIfThenSuccess()
- throws ExecutionException, InterruptedException, VppInvocationException, TimeoutException {
- final CompletionStage<ModifyVhostUserIfReply> replyCS = mock(CompletionStage.class);
- final CompletableFuture<ModifyVhostUserIfReply> replyFuture = mock(CompletableFuture.class);
- when(replyCS.toCompletableFuture()).thenReturn(replyFuture);
- final ModifyVhostUserIfReply reply = new ModifyVhostUserIfReply();
- when(replyFuture.get(anyLong(), eq(TimeUnit.SECONDS))).thenReturn(reply);
- when(api.modifyVhostUserIf(any(ModifyVhostUserIf.class))).thenReturn(replyCS);
- }
-
- /**
- * Failure response send
- */
- private void whenModifyVhostUserIfThenFailure()
- throws ExecutionException, InterruptedException, VppInvocationException {
- doReturn(TestHelperUtils.<ModifyVhostUserIfReply>createFutureException()).when(api)
- .modifyVhostUserIf(any(ModifyVhostUserIf.class));
- }
-
- private void whenDeleteVhostUserIfThenSuccess()
- throws ExecutionException, InterruptedException, VppInvocationException, TimeoutException {
- final CompletionStage<DeleteVhostUserIfReply> replyCS = mock(CompletionStage.class);
- final CompletableFuture<DeleteVhostUserIfReply> replyFuture = mock(CompletableFuture.class);
- when(replyCS.toCompletableFuture()).thenReturn(replyFuture);
- final DeleteVhostUserIfReply reply = new DeleteVhostUserIfReply();
- when(replyFuture.get(anyLong(), eq(TimeUnit.SECONDS))).thenReturn(reply);
- when(api.deleteVhostUserIf(any(DeleteVhostUserIf.class))).thenReturn(replyCS);
- }
-
- /**
- * Failure response send
- */
- private void whenDeleteVhostUserIfThenFailure()
- throws ExecutionException, InterruptedException, VppInvocationException {
- doReturn(TestHelperUtils.<DeleteVhostUserIfReply>createFutureException()).when(api)
- .deleteVhostUserIf(any(DeleteVhostUserIf.class));
- }
-
private CreateVhostUserIf verifyCreateVhostUserIfWasInvoked(final VhostUser vhostUser)
throws VppInvocationException {
ArgumentCaptor<CreateVhostUserIf> argumentCaptor = ArgumentCaptor.forClass(CreateVhostUserIf.class);
@@ -182,7 +117,7 @@ public class VhostUserCustomizerTest extends WriterCustomizerTest {
public void testWriteCurrentAttributes() throws Exception {
final VhostUser vhostUser = generateVhostUser(VhostUserRole.Server, "socketName");
- whenCreateVhostUserIfThenSuccess();
+ when(api.createVhostUserIf(any(CreateVhostUserIf.class))).thenReturn(future(new CreateVhostUserIfReply()));
customizer.writeCurrentAttributes(ID, vhostUser, writeContext);
verifyCreateVhostUserIfWasInvoked(vhostUser);
@@ -194,7 +129,7 @@ public class VhostUserCustomizerTest extends WriterCustomizerTest {
public void testWriteCurrentAttributesFailed() throws Exception {
final VhostUser vhostUser = generateVhostUser(VhostUserRole.Client, "socketName");
- whenCreateVhostUserIfThenFailure();
+ doReturn(failedFuture()).when(api).createVhostUserIf(any(CreateVhostUserIf.class));
try {
customizer.writeCurrentAttributes(ID, vhostUser, writeContext);
@@ -213,7 +148,7 @@ public class VhostUserCustomizerTest extends WriterCustomizerTest {
final VhostUser vhostUserAfter = generateVhostUser(VhostUserRole.Server, "socketName1");
ContextTestUtils.mockMapping(mappingContext, IFACE_NAME, IFACE_ID, "test-instance");
- whenModifyVhostUserIfThenSuccess();
+ when(api.modifyVhostUserIf(any(ModifyVhostUserIf.class))).thenReturn(future(new ModifyVhostUserIfReply()));
customizer.updateCurrentAttributes(ID, vhostUserBefore, vhostUserAfter, writeContext);
verifyModifyVhostUserIfWasInvoked(vhostUserAfter, IFACE_ID);
@@ -225,7 +160,7 @@ public class VhostUserCustomizerTest extends WriterCustomizerTest {
final VhostUser vhostUserAfter = generateVhostUser(VhostUserRole.Server, "socketName1");
ContextTestUtils.mockMapping(mappingContext, IFACE_NAME, IFACE_ID, "test-instance");
- whenModifyVhostUserIfThenFailure();
+ doReturn(failedFuture()).when(api).modifyVhostUserIf(any(ModifyVhostUserIf.class));
try {
customizer.updateCurrentAttributes(ID, vhostUserBefore, vhostUserAfter, writeContext);
@@ -242,7 +177,7 @@ public class VhostUserCustomizerTest extends WriterCustomizerTest {
final VhostUser vhostUser = generateVhostUser(VhostUserRole.Client, "socketName");
ContextTestUtils.mockMapping(mappingContext, IFACE_NAME, IFACE_ID, "test-instance");
- whenDeleteVhostUserIfThenSuccess();
+ when(api.deleteVhostUserIf(any(DeleteVhostUserIf.class))).thenReturn(future(new DeleteVhostUserIfReply()));
customizer.deleteCurrentAttributes(ID, vhostUser, writeContext);
verifyDeleteVhostUserIfWasInvoked(IFACE_ID);
@@ -254,7 +189,7 @@ public class VhostUserCustomizerTest extends WriterCustomizerTest {
final VhostUser vhostUser = generateVhostUser(VhostUserRole.Client, "socketName");
ContextTestUtils.mockMapping(mappingContext, IFACE_NAME, IFACE_ID, "test-instance");
- whenDeleteVhostUserIfThenFailure();
+ doReturn(failedFuture()).when(api).deleteVhostUserIf(any(DeleteVhostUserIf.class));
try {
customizer.deleteCurrentAttributes(ID, vhostUser, writeContext);
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 d9678621b..ed099f740 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
@@ -23,27 +23,18 @@ 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.anyLong;
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 com.google.common.net.InetAddresses;
-import io.fd.honeycomb.translate.ModificationCache;
import io.fd.honeycomb.translate.v3po.DisabledInterfacesManager;
import io.fd.honeycomb.translate.v3po.test.ContextTestUtils;
-import io.fd.honeycomb.translate.v3po.test.TestHelperUtils;
-import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.CompletionStage;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
+import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
@@ -78,36 +69,21 @@ public class VxlanCustomizerTest extends WriterCustomizerTest {
public void setUp() throws Exception {
InterfaceTypeTestUtils.setupWriteContext(writeContext,
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VxlanTunnel.class);
- // TODO HONEYCOMB-116 create base class for tests using vppApi
- NamingContext namingContext = new NamingContext("generateInterfaceNAme", "test-instance");
- final ModificationCache toBeReturned = new ModificationCache();
- doReturn(toBeReturned).when(writeContext).getModificationCache();
- doReturn(mappingContext).when(writeContext).getMappingContext();
- customizer = new VxlanCustomizer(api, namingContext, disableContext);
+ customizer =
+ new VxlanCustomizer(api, new NamingContext("generateInterfaceNAme", "test-instance"), disableContext);
ifaceName = "eth0";
id = InstanceIdentifier.create(Interfaces.class).child(Interface.class, new InterfaceKey(ifaceName))
.augmentation(VppInterfaceAugmentation.class).child(Vxlan.class);
}
- private void whenVxlanAddDelTunnelThenSuccess()
- throws ExecutionException, InterruptedException, VppInvocationException, TimeoutException {
- final CompletionStage<VxlanAddDelTunnelReply> replyCS = mock(CompletionStage.class);
- final CompletableFuture<VxlanAddDelTunnelReply> replyFuture = mock(CompletableFuture.class);
- when(replyCS.toCompletableFuture()).thenReturn(replyFuture);
- final VxlanAddDelTunnelReply reply = new VxlanAddDelTunnelReply();
- when(replyFuture.get(anyLong(), eq(TimeUnit.SECONDS))).thenReturn(reply);
- when(api.vxlanAddDelTunnel(any(VxlanAddDelTunnel.class))).thenReturn(replyCS);
+ private void whenVxlanAddDelTunnelThenSuccess() {
+ when(api.vxlanAddDelTunnel(any(VxlanAddDelTunnel.class))).thenReturn(future(new VxlanAddDelTunnelReply()));
}
- /**
- * Failure response send
- */
- private void whenVxlanAddDelTunnelThenFailure()
- throws ExecutionException, InterruptedException, VppInvocationException {
- doReturn(TestHelperUtils.<VxlanAddDelTunnelReply>createFutureException()).when(api)
- .vxlanAddDelTunnel(any(VxlanAddDelTunnel.class));
+ private void whenVxlanAddDelTunnelThenFailure() {
+ doReturn(failedFuture()).when(api).vxlanAddDelTunnel(any(VxlanAddDelTunnel.class));
}
private VxlanAddDelTunnel verifyVxlanAddDelTunnelWasInvoked(final Vxlan vxlan) throws VppInvocationException {
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 9d6adff6f..75e0d3bb1 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
@@ -23,10 +23,8 @@ 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.anyLong;
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;
@@ -34,15 +32,9 @@ 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.test.TestHelperUtils;
-import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.CompletionStage;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
+import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
@@ -58,7 +50,6 @@ 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.VxlanGpeBuilder;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.openvpp.jvpp.VppBaseCallException;
-import org.openvpp.jvpp.core.dto.VxlanAddDelTunnelReply;
import org.openvpp.jvpp.core.dto.VxlanGpeAddDelTunnel;
import org.openvpp.jvpp.core.dto.VxlanGpeAddDelTunnelReply;
@@ -83,38 +74,28 @@ public class VxlanGpeCustomizerTest extends WriterCustomizerTest {
ifaceName = "elth0";
id = InstanceIdentifier.create(Interfaces.class).child(Interface.class, new InterfaceKey(ifaceName))
- .augmentation(VppInterfaceAugmentation.class).child(VxlanGpe.class);
+ .augmentation(VppInterfaceAugmentation.class).child(VxlanGpe.class);
}
- private void whenVxlanGpeAddDelTunnelThenSuccess()
- throws ExecutionException, InterruptedException, VppBaseCallException, TimeoutException {
- final CompletionStage<VxlanGpeAddDelTunnelReply> replyCS = mock(CompletionStage.class);
- final CompletableFuture<VxlanGpeAddDelTunnelReply> replyFuture = mock(CompletableFuture.class);
- when(replyCS.toCompletableFuture()).thenReturn(replyFuture);
- final VxlanGpeAddDelTunnelReply reply = new VxlanGpeAddDelTunnelReply();
- when(replyFuture.get(anyLong(), eq(TimeUnit.SECONDS))).thenReturn(reply);
- when(api.vxlanGpeAddDelTunnel(any(VxlanGpeAddDelTunnel.class))).thenReturn(replyCS);
+ private void whenVxlanGpeAddDelTunnelThenSuccess() {
+ when(api.vxlanGpeAddDelTunnel(any(VxlanGpeAddDelTunnel.class)))
+ .thenReturn(future(new VxlanGpeAddDelTunnelReply()));
}
- /**
- * Failure response send
- */
- private void whenVxlanGpeAddDelTunnelThenFailure()
- throws ExecutionException, InterruptedException, VppBaseCallException {
- doReturn(TestHelperUtils.<VxlanAddDelTunnelReply>createFutureException()).when(api)
- .vxlanGpeAddDelTunnel(any(VxlanGpeAddDelTunnel.class));
+ private void whenVxlanGpeAddDelTunnelThenFailure() {
+ doReturn(failedFuture()).when(api).vxlanGpeAddDelTunnel(any(VxlanGpeAddDelTunnel.class));
}
private VxlanGpeAddDelTunnel verifyVxlanGpeAddDelTunnelWasInvoked(final VxlanGpe vxlanGpe)
- throws VppBaseCallException {
+ throws VppBaseCallException {
ArgumentCaptor<VxlanGpeAddDelTunnel> argumentCaptor = ArgumentCaptor.forClass(VxlanGpeAddDelTunnel.class);
verify(api).vxlanGpeAddDelTunnel(argumentCaptor.capture());
final VxlanGpeAddDelTunnel actual = argumentCaptor.getValue();
assertEquals(0, actual.isIpv6);
assertArrayEquals(InetAddresses.forString(vxlanGpe.getLocal().getIpv4Address().getValue()).getAddress(),
- actual.local);
+ actual.local);
assertArrayEquals(InetAddresses.forString(vxlanGpe.getRemote().getIpv4Address().getValue()).getAddress(),
- actual.remote);
+ actual.remote);
assertEquals(vxlanGpe.getVni().getValue().intValue(), actual.vni);
assertEquals(vxlanGpe.getNextProtocol().getIntValue(), actual.protocol);
assertEquals(vxlanGpe.getEncapVrfId().intValue(), actual.encapVrfId);
@@ -127,7 +108,7 @@ public class VxlanGpeCustomizerTest extends WriterCustomizerTest {
assertEquals(ADD_VXLAN_GPE, actual.isAdd);
}
- private void verifyVxlanGpeDeleteWasInvoked(final VxlanGpe vxlanGpe) throws VppBaseCallException{
+ private void verifyVxlanGpeDeleteWasInvoked(final VxlanGpe vxlanGpe) throws VppBaseCallException {
final VxlanGpeAddDelTunnel actual = verifyVxlanGpeAddDelTunnelWasInvoked(vxlanGpe);
assertEquals(DEL_VXLAN_GPE, actual.isAdd);
}
@@ -157,7 +138,7 @@ public class VxlanGpeCustomizerTest extends WriterCustomizerTest {
customizer.writeCurrentAttributes(id, vxlanGpe, writeContext);
verifyVxlanGpeAddWasInvoked(vxlanGpe);
verify(mappingContext).put(eq(getMappingIid(ifaceName, "test-instance")), eq(
- getMapping(ifaceName, 0).get()));
+ getMapping(ifaceName, 0).get()));
}
@Test
@@ -190,8 +171,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(getMappingIid(ifaceName, "test-instance")), eq(
+ getMapping(ifaceName, 0).get()));
return;
}
fail("WriteFailedException.CreateFailedException 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 f3c9e79f7..7b1fb53e0 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
@@ -16,8 +16,6 @@
package io.fd.honeycomb.translate.v3po.interfaces.ip;
-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;
@@ -33,19 +31,15 @@ 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.test.TestHelperUtils;
-import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
+import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
-import java.util.concurrent.CompletableFuture;
import org.junit.Before;
import org.junit.Test;
-import org.mockito.ArgumentCaptor;
import org.mockito.ArgumentMatcher;
-import org.mockito.Captor;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
@@ -65,7 +59,6 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev14061
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DottedQuad;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.openvpp.jvpp.VppBaseCallException;
-import org.openvpp.jvpp.VppInvocationException;
import org.openvpp.jvpp.core.dto.IpAddressDetailsReplyDump;
import org.openvpp.jvpp.core.dto.SwInterfaceAddDelAddress;
import org.openvpp.jvpp.core.dto.SwInterfaceAddDelAddressReply;
@@ -76,9 +69,6 @@ public class Ipv4AddressCustomizerTest extends WriterCustomizerTest {
private static final String IFACE_NAME = "eth0";
private static final int IFACE_ID = 123;
- @Captor
- private ArgumentCaptor<List<Address>> addressesCaptor;
-
@Mock
private SubnetValidator subnetValidator;
@@ -91,10 +81,7 @@ public class Ipv4AddressCustomizerTest extends WriterCustomizerTest {
customizer = new Ipv4AddressCustomizer(api, interfaceContext, subnetValidator);
- CompletableFuture future = new CompletableFuture();
- future.complete(new IpAddressDetailsReplyDump());
-
- when(api.ipAddressDump(Mockito.any())).thenReturn(future);
+ doReturn(future(new IpAddressDetailsReplyDump())).when(api).ipAddressDump(any());
when(writeContext.readAfter(Mockito.any()))
.thenReturn(Optional.of(new Ipv4Builder().setAddress(Collections.emptyList()).build()));
}
@@ -109,34 +96,11 @@ public class Ipv4AddressCustomizerTest extends WriterCustomizerTest {
}
private void whenSwInterfaceAddDelAddressThenSuccess() {
- final CompletableFuture<SwInterfaceAddDelAddressReply> replyFuture = new CompletableFuture<>();
- final SwInterfaceAddDelAddressReply reply = new SwInterfaceAddDelAddressReply();
- replyFuture.complete(reply);
- doReturn(replyFuture).when(api).swInterfaceAddDelAddress(any(SwInterfaceAddDelAddress.class));
+ doReturn(future(new SwInterfaceAddDelAddressReply())).when(api).swInterfaceAddDelAddress(any(SwInterfaceAddDelAddress.class));
}
private void whenSwInterfaceAddDelAddressThenFailure() {
- doReturn(TestHelperUtils.createFutureException()).when(api)
- .swInterfaceAddDelAddress(any(SwInterfaceAddDelAddress.class));
- }
-
- private void verifySwInterfaceAddDelAddressWasInvoked(final SwInterfaceAddDelAddress expected) throws
- VppInvocationException {
- ArgumentCaptor<SwInterfaceAddDelAddress> argumentCaptor =
- ArgumentCaptor.forClass(SwInterfaceAddDelAddress.class);
- verify(api).swInterfaceAddDelAddress(argumentCaptor.capture());
- verifySwInterfaceAddDelAddressWasInvoked(expected, argumentCaptor.getValue());
- }
-
- private void verifySwInterfaceAddDelAddressWasInvoked(final SwInterfaceAddDelAddress expected,
- final SwInterfaceAddDelAddress actual) throws
- VppInvocationException {
- assertArrayEquals(expected.address, actual.address);
- assertEquals(expected.addressLength, actual.addressLength);
- assertEquals(expected.delAll, actual.delAll);
- assertEquals(expected.isAdd, actual.isAdd);
- assertEquals(expected.isIpv6, actual.isIpv6);
- assertEquals(expected.swIfIndex, actual.swIfIndex);
+ doReturn(failedFuture()).when(api).swInterfaceAddDelAddress(any(SwInterfaceAddDelAddress.class));
}
@Test
@@ -155,7 +119,7 @@ public class Ipv4AddressCustomizerTest extends WriterCustomizerTest {
customizer.writeCurrentAttributes(id, data, writeContext);
- verifySwInterfaceAddDelAddressWasInvoked(generateSwInterfaceAddDelAddressRequest(new byte[]{-64, -88, 2, 1},
+ verify(api).swInterfaceAddDelAddress(generateSwInterfaceAddDelAddressRequest(new byte[]{-64, -88, 2, 1},
(byte) 1, (byte) 24));
}
@@ -175,7 +139,7 @@ public class Ipv4AddressCustomizerTest extends WriterCustomizerTest {
customizer.writeCurrentAttributes(id, data, writeContext);
} catch (WriteFailedException e) {
assertTrue(e.getCause() instanceof VppBaseCallException);
- verifySwInterfaceAddDelAddressWasInvoked(
+ verify(api).swInterfaceAddDelAddress(
generateSwInterfaceAddDelAddressRequest(new byte[]{-64, -88, 2, 1},
(byte) 1, (byte) 24));
return;
@@ -211,8 +175,7 @@ public class Ipv4AddressCustomizerTest extends WriterCustomizerTest {
assertTrue(e.getCause() instanceof SubnetValidationException);
//verify that validation call was invoked with data from writeContext
- verify(subnetValidator, times(1)).checkNotAddingToSameSubnet(addressesCaptor.capture());
- assertEquals(addressList, addressesCaptor.getValue());
+ verify(subnetValidator, times(1)).checkNotAddingToSameSubnet(addressList);
}
}
@@ -252,7 +215,7 @@ public class Ipv4AddressCustomizerTest extends WriterCustomizerTest {
customizer.deleteCurrentAttributes(id, data, writeContext);
- verifySwInterfaceAddDelAddressWasInvoked(generateSwInterfaceAddDelAddressRequest(new byte[]{-64, -88, 2, 1},
+ verify(api).swInterfaceAddDelAddress(generateSwInterfaceAddDelAddressRequest(new byte[]{-64, -88, 2, 1},
(byte) 0, (byte) 24));
}
@@ -271,7 +234,7 @@ public class Ipv4AddressCustomizerTest extends WriterCustomizerTest {
customizer.deleteCurrentAttributes(id, data, writeContext);
} catch (WriteFailedException e) {
assertTrue(e.getCause() instanceof VppBaseCallException);
- verifySwInterfaceAddDelAddressWasInvoked(
+ verify(api).swInterfaceAddDelAddress(
generateSwInterfaceAddDelAddressRequest(new byte[]{-64, -88, 2, 1},
(byte) 0, (byte) 24));
return;
@@ -288,17 +251,12 @@ public class Ipv4AddressCustomizerTest extends WriterCustomizerTest {
Address data = new AddressBuilder().setIp(noZoneIp).setSubnet(subnet).build();
ContextTestUtils.mockMapping(mappingContext, IFACE_NAME, IFACE_ID, IFC_CTX_NAME);
-
- final CompletableFuture<SwInterfaceAddDelAddressReply> replyFuture = new CompletableFuture<>();
- replyFuture.complete(new SwInterfaceAddDelAddressReply());
- ArgumentCaptor<SwInterfaceAddDelAddress> argumentCaptor =
- ArgumentCaptor.forClass(SwInterfaceAddDelAddress.class);
- doReturn(replyFuture).when(api).swInterfaceAddDelAddress(argumentCaptor.capture());
+ whenSwInterfaceAddDelAddressThenSuccess();
customizer.writeCurrentAttributes(id, data, writeContext);
- verifySwInterfaceAddDelAddressWasInvoked(generateSwInterfaceAddDelAddressRequest(new byte[]{-64, -88, 2, 1},
- (byte) 1, (byte) expectedPrefixLength), argumentCaptor.getValue());
+ verify(api).swInterfaceAddDelAddress(generateSwInterfaceAddDelAddressRequest(new byte[]{-64, -88, 2, 1},
+ (byte) 1, (byte) expectedPrefixLength));
}
private void testSingleIllegalNetmask(final String stringMask) throws Exception {
@@ -311,12 +269,7 @@ public class Ipv4AddressCustomizerTest extends WriterCustomizerTest {
Address data = new AddressBuilder().setIp(noZoneIp).setSubnet(subnet).build();
ContextTestUtils.mockMapping(mappingContext, IFACE_NAME, IFACE_ID, IFC_CTX_NAME);
-
- final CompletableFuture<SwInterfaceAddDelAddressReply> replyFuture = new CompletableFuture<>();
- replyFuture.complete(new SwInterfaceAddDelAddressReply());
- ArgumentCaptor<SwInterfaceAddDelAddress> argumentCaptor =
- ArgumentCaptor.forClass(SwInterfaceAddDelAddress.class);
- doReturn(replyFuture).when(api).swInterfaceAddDelAddress(argumentCaptor.capture());
+ whenSwInterfaceAddDelAddressThenSuccess();
customizer.writeCurrentAttributes(id, data, writeContext);
} catch (IllegalArgumentException e) {
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 dcde0b43d..745276473 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
@@ -17,21 +17,20 @@
package io.fd.honeycomb.translate.v3po.interfaces.ip;
import static org.junit.Assert.assertEquals;
+import static org.mockito.Matchers.any;
import static org.mockito.Mockito.times;
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.vpp.test.write.WriterCustomizerTest;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
import io.fd.honeycomb.translate.write.WriteFailedException;
-import java.util.concurrent.CompletableFuture;
+import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest;
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
-import org.mockito.Mockito;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.Interfaces;
@@ -61,9 +60,7 @@ public class Ipv4NeighbourCustomizerTest extends WriterCustomizerTest {
customizer = new Ipv4NeighbourCustomizer(api, new NamingContext("prefix", IFC_CTX_NAME));
requestCaptor = ArgumentCaptor.forClass(IpNeighborAddDel.class);
- CompletableFuture<IpNeighborAddDelReply> future = new CompletableFuture<>();
- future.complete(new IpNeighborAddDelReply());
- when(api.ipNeighborAddDel(Mockito.any(IpNeighborAddDel.class))).thenReturn(future);
+ when(api.ipNeighborAddDel(any())).thenReturn(future(new IpNeighborAddDelReply()));
}
@Test
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/AclCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/AclCustomizerTest.java
index d7f4cdd8d..b2a76c5c0 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/AclCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/AclCustomizerTest.java
@@ -23,10 +23,9 @@ import static org.mockito.Mockito.verify;
import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
import io.fd.honeycomb.translate.v3po.test.ContextTestUtils;
-import io.fd.honeycomb.vpp.test.read.ReaderCustomizerTest;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
import io.fd.honeycomb.translate.v3po.vppclassifier.VppClassifierContextManager;
-import java.util.concurrent.CompletableFuture;
+import io.fd.honeycomb.vpp.test.read.ReaderCustomizerTest;
import org.junit.Test;
import org.mockito.Mock;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfacesState;
@@ -89,13 +88,11 @@ public class AclCustomizerTest extends ReaderCustomizerTest<Acl, AclBuilder> {
final InstanceIdentifier<Acl> id = getAclId(IF_NAME);
final AclBuilder builder = mock(AclBuilder.class);
- final CompletableFuture<ClassifyTableByInterfaceReply> replyFuture = new CompletableFuture<>();
final ClassifyTableByInterfaceReply reply = new ClassifyTableByInterfaceReply();
reply.l2TableId = TABLE_INDEX;
reply.ip4TableId = ~0;
reply.ip6TableId = ~0;
- replyFuture.complete(reply);
- doReturn(replyFuture).when(api).classifyTableByInterface(any(ClassifyTableByInterface.class));
+ doReturn(future(reply)).when(api).classifyTableByInterface(any(ClassifyTableByInterface.class));
doReturn(TABLE_NAME).when(classifyTableContext).getTableName(TABLE_INDEX, mappingContext);
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/GreCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/GreCustomizerTest.java
index 9545a926a..0728a5a2a 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/GreCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/GreCustomizerTest.java
@@ -27,13 +27,12 @@ import static org.mockito.Mockito.verifyZeroInteractions;
import com.google.common.collect.Lists;
import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
import io.fd.honeycomb.translate.v3po.test.ContextTestUtils;
-import io.fd.honeycomb.vpp.test.read.ReaderCustomizerTest;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
+import io.fd.honeycomb.vpp.test.read.ReaderCustomizerTest;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.HashMap;
import java.util.Map;
-import java.util.concurrent.CompletableFuture;
import org.junit.Test;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfacesState;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface;
@@ -74,9 +73,6 @@ public class GreCustomizerTest extends ReaderCustomizerTest<Gre, GreBuilder> {
map.put(0, v);
cache.put(InterfaceCustomizer.DUMPED_IFCS_CONTEXT_KEY, map);
- final CompletableFuture<GreTunnelDetailsReplyDump> greTunnelDetailsReplyDumpCompletionStage =
- new CompletableFuture<>();
-
final GreTunnelDetailsReplyDump value = new GreTunnelDetailsReplyDump();
final GreTunnelDetails greTunnelDetails = new GreTunnelDetails();
greTunnelDetails.isIpv6 = 0;
@@ -84,11 +80,9 @@ public class GreCustomizerTest extends ReaderCustomizerTest<Gre, GreBuilder> {
greTunnelDetails.srcAddress = InetAddress.getByName("1.2.3.5").getAddress();
greTunnelDetails.outerFibId = 55;
greTunnelDetails.swIfIndex = 0;
-
value.greTunnelDetails = Lists.newArrayList(greTunnelDetails);
- greTunnelDetailsReplyDumpCompletionStage.complete(value);
- doReturn(greTunnelDetailsReplyDumpCompletionStage).when(api).greTunnelDump(any(GreTunnelDump.class));
+ doReturn(future(value)).when(api).greTunnelDump(any(GreTunnelDump.class));
}
@Test
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/InterfaceCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/InterfaceCustomizerTest.java
index b6ef0ece5..acc407bd3 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/InterfaceCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/InterfaceCustomizerTest.java
@@ -18,18 +18,19 @@ package io.fd.honeycomb.translate.v3po.interfacesstate;
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.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 io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
import io.fd.honeycomb.translate.v3po.DisabledInterfacesManager;
import io.fd.honeycomb.translate.v3po.test.ContextTestUtils;
-import io.fd.honeycomb.translate.v3po.test.InterfaceTestUtils;
-import io.fd.honeycomb.vpp.test.read.ListReaderCustomizerTest;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
+import io.fd.honeycomb.vpp.test.read.ListReaderCustomizerTest;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@@ -44,6 +45,7 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.openvpp.jvpp.VppInvocationException;
import org.openvpp.jvpp.core.dto.SwInterfaceDetails;
+import org.openvpp.jvpp.core.dto.SwInterfaceDetailsReplyDump;
import org.openvpp.jvpp.core.dto.SwInterfaceDump;
public class InterfaceCustomizerTest extends
@@ -86,6 +88,12 @@ public class InterfaceCustomizerTest extends
verify(builder).setInterface(value);
}
+ public void whenSwInterfaceDumpThenReturn(final List<SwInterfaceDetails> interfaceList) {
+ final SwInterfaceDetailsReplyDump reply = new SwInterfaceDetailsReplyDump();
+ reply.swInterfaceDetails = interfaceList;
+ when(api.swInterfaceDump(any(SwInterfaceDump.class))).thenReturn(future(reply));
+ }
+
private void verifySwInterfaceDumpWasInvoked(final int nameFilterValid, final String ifaceName,
final int dumpIfcsInvocationCount)
throws VppInvocationException {
@@ -114,7 +122,7 @@ public class InterfaceCustomizerTest extends
iface.l2AddressLength = 6;
iface.l2Address = new byte[iface.l2AddressLength];
final List<SwInterfaceDetails> interfaceList = Collections.singletonList(iface);
- InterfaceTestUtils.whenSwInterfaceDumpThenReturn(api, interfaceList);
+ whenSwInterfaceDumpThenReturn(interfaceList);
getCustomizer().readCurrentAttributes(id, builder, ctx);
@@ -129,7 +137,7 @@ public class InterfaceCustomizerTest extends
.child(Interface.class, new InterfaceKey(ifaceName));
final InterfaceBuilder builder = getCustomizer().getBuilder(id);
- InterfaceTestUtils.whenSwInterfaceDumpThenReturn(api, Collections.emptyList());
+ whenSwInterfaceDumpThenReturn(Collections.emptyList());
try {
getCustomizer().readCurrentAttributes(id, builder, ctx);
@@ -153,7 +161,7 @@ public class InterfaceCustomizerTest extends
iface.supSwIfIndex = 1;
iface.subId = 1;
final List<SwInterfaceDetails> interfaceList = Collections.singletonList(iface);
- InterfaceTestUtils.whenSwInterfaceDumpThenReturn(api, interfaceList);
+ whenSwInterfaceDumpThenReturn(interfaceList);
getCustomizer().readCurrentAttributes(id, builder, ctx);
@@ -177,7 +185,7 @@ public class InterfaceCustomizerTest extends
swSubIf1.subId = 1;
swSubIf1.supSwIfIndex = 1;
swSubIf1.interfaceName = SUB_IFACE_NAME.getBytes();
- InterfaceTestUtils.whenSwInterfaceDumpThenReturn(api, Arrays.asList(swIf0, swIf1, swSubIf1));
+ whenSwInterfaceDumpThenReturn(Arrays.asList(swIf0, swIf1, swSubIf1));
final List<InterfaceKey> expectedIds = Arrays.asList(new InterfaceKey(IFACE0_NAME), new InterfaceKey(
IFACE1_NAME));
@@ -202,7 +210,7 @@ public class InterfaceCustomizerTest extends
final SwInterfaceDetails swIf1 = new SwInterfaceDetails();
swIf1.swIfIndex = 1;
swIf1.interfaceName = IFACE1_NAME.getBytes();
- InterfaceTestUtils.whenSwInterfaceDumpThenReturn(api, Arrays.asList(swIf0, swIf1));
+ whenSwInterfaceDumpThenReturn(Arrays.asList(swIf0, swIf1));
final List<InterfaceKey> expectedIds = Arrays.asList(new InterfaceKey(IFACE0_NAME));
final List<InterfaceKey> actualIds = getCustomizer().getAllIds(id, ctx);
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/L2CustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/L2CustomizerTest.java
index 729a13ef4..29f0d0eb7 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/L2CustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/L2CustomizerTest.java
@@ -23,14 +23,12 @@ import static org.mockito.Mockito.when;
import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
import io.fd.honeycomb.translate.v3po.test.ContextTestUtils;
-import io.fd.honeycomb.vpp.test.read.ReaderCustomizerTest;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
+import io.fd.honeycomb.vpp.test.read.ReaderCustomizerTest;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.ExecutionException;
import org.junit.Test;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfacesState;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface;
@@ -42,7 +40,6 @@ 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.l2.base.attributes.Interconnection;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.l2.base.attributes.interconnection.BridgeBasedBuilder;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.openvpp.jvpp.VppInvocationException;
import org.openvpp.jvpp.core.dto.BridgeDomainDetails;
import org.openvpp.jvpp.core.dto.BridgeDomainDetailsReplyDump;
import org.openvpp.jvpp.core.dto.BridgeDomainDump;
@@ -86,15 +83,11 @@ public class L2CustomizerTest extends ReaderCustomizerTest<L2, L2Builder> {
}
private void whenBridgeDomainSwIfDumpThenReturn(final List<BridgeDomainSwIfDetails> bdSwIfList,
- final List<BridgeDomainDetails> bridgeDomainDetailses)
- throws ExecutionException, InterruptedException, VppInvocationException {
+ final List<BridgeDomainDetails> bridgeDomainDetailses) {
final BridgeDomainDetailsReplyDump reply = new BridgeDomainDetailsReplyDump();
reply.bridgeDomainSwIfDetails = bdSwIfList;
reply.bridgeDomainDetails = bridgeDomainDetailses;
-
- final CompletableFuture<BridgeDomainDetailsReplyDump> replyFuture = new CompletableFuture<>();
- replyFuture.complete(reply);
- when(api.bridgeDomainSwIfDump(any(BridgeDomainDump.class))).thenReturn(replyFuture);
+ when(api.bridgeDomainSwIfDump(any(BridgeDomainDump.class))).thenReturn(future(reply));
}
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/SubInterfaceCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/SubInterfaceCustomizerTest.java
index ec1baebe2..0d0a2cc83 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/SubInterfaceCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/SubInterfaceCustomizerTest.java
@@ -18,15 +18,16 @@ package io.fd.honeycomb.translate.v3po.interfacesstate;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
+import static org.mockito.Matchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
import io.fd.honeycomb.translate.read.ReadFailedException;
import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
import io.fd.honeycomb.translate.v3po.test.ContextTestUtils;
-import io.fd.honeycomb.translate.v3po.test.InterfaceTestUtils;
-import io.fd.honeycomb.vpp.test.read.ListReaderCustomizerTest;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
+import io.fd.honeycomb.vpp.test.read.ListReaderCustomizerTest;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@@ -47,6 +48,8 @@ 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;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.openvpp.jvpp.core.dto.SwInterfaceDetails;
+import org.openvpp.jvpp.core.dto.SwInterfaceDetailsReplyDump;
+import org.openvpp.jvpp.core.dto.SwInterfaceDump;
public class SubInterfaceCustomizerTest extends
ListReaderCustomizerTest<SubInterface, SubInterfaceKey, SubInterfaceBuilder> {
@@ -130,7 +133,10 @@ public class SubInterfaceCustomizerTest extends
iface.subId = VLAN_IF_ID;
iface.supSwIfIndex = SUPER_IF_INDEX;
final List<SwInterfaceDetails> ifaces = Collections.singletonList(iface);
- InterfaceTestUtils.whenSwInterfaceDumpThenReturn(api, ifaces);
+
+ final SwInterfaceDetailsReplyDump reply = new SwInterfaceDetailsReplyDump();
+ reply.swInterfaceDetails = ifaces;
+ when(api.swInterfaceDump(any(SwInterfaceDump.class))).thenReturn(future(reply));
final List<SubInterfaceKey> allIds =
getCustomizer().getAllIds(getSubInterfaceId(SUPER_IF_NAME, VLAN_IF_ID), ctx);
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/VxlanCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/VxlanCustomizerTest.java
index 40c1e5e69..e71441333 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/VxlanCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/VxlanCustomizerTest.java
@@ -27,13 +27,12 @@ import static org.mockito.Mockito.verifyZeroInteractions;
import com.google.common.collect.Lists;
import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
import io.fd.honeycomb.translate.v3po.test.ContextTestUtils;
-import io.fd.honeycomb.vpp.test.read.ReaderCustomizerTest;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
+import io.fd.honeycomb.vpp.test.read.ReaderCustomizerTest;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.HashMap;
import java.util.Map;
-import java.util.concurrent.CompletableFuture;
import org.junit.Test;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfacesState;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface;
@@ -74,9 +73,6 @@ public class VxlanCustomizerTest extends ReaderCustomizerTest<Vxlan, VxlanBuilde
map.put(0, v);
cache.put(InterfaceCustomizer.DUMPED_IFCS_CONTEXT_KEY, map);
- final CompletableFuture<VxlanTunnelDetailsReplyDump> vxlanTunnelDetailsReplyDumpCompletionStage =
- new CompletableFuture<>();
-
final VxlanTunnelDetailsReplyDump value = new VxlanTunnelDetailsReplyDump();
final VxlanTunnelDetails vxlanTunnelDetails = new VxlanTunnelDetails();
vxlanTunnelDetails.isIpv6 = 0;
@@ -86,12 +82,8 @@ public class VxlanCustomizerTest extends ReaderCustomizerTest<Vxlan, VxlanBuilde
vxlanTunnelDetails.encapVrfId = 55;
vxlanTunnelDetails.swIfIndex = 0;
vxlanTunnelDetails.vni = 9;
-
value.vxlanTunnelDetails = Lists.newArrayList(vxlanTunnelDetails);
- vxlanTunnelDetailsReplyDumpCompletionStage.complete(value);
-
- doReturn(vxlanTunnelDetailsReplyDumpCompletionStage).when(api).vxlanTunnelDump(any(VxlanTunnelDump.class));
-
+ doReturn(future(value)).when(api).vxlanTunnelDump(any(VxlanTunnelDump.class));
}
@Test
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/VxlanGpeCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/VxlanGpeCustomizerTest.java
index bf33be31d..e40962da3 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/VxlanGpeCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/VxlanGpeCustomizerTest.java
@@ -27,13 +27,12 @@ import static org.mockito.Mockito.verifyZeroInteractions;
import com.google.common.collect.Lists;
import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
import io.fd.honeycomb.translate.v3po.test.ContextTestUtils;
-import io.fd.honeycomb.vpp.test.read.ReaderCustomizerTest;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
+import io.fd.honeycomb.vpp.test.read.ReaderCustomizerTest;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.HashMap;
import java.util.Map;
-import java.util.concurrent.CompletableFuture;
import org.junit.Test;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfacesState;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface;
@@ -74,9 +73,6 @@ public class VxlanGpeCustomizerTest extends ReaderCustomizerTest<VxlanGpe, Vxlan
map.put(0, v);
cache.put(InterfaceCustomizer.DUMPED_IFCS_CONTEXT_KEY, map);
- final CompletableFuture<VxlanGpeTunnelDetailsReplyDump> vxlanGpeTunnelDetailsReplyDumpCompletionStage =
- new CompletableFuture<>();
-
final VxlanGpeTunnelDetailsReplyDump value = new VxlanGpeTunnelDetailsReplyDump();
final VxlanGpeTunnelDetails vxlanGpeTunnelDetails = new VxlanGpeTunnelDetails();
vxlanGpeTunnelDetails.isIpv6 = 0;
@@ -87,12 +83,8 @@ public class VxlanGpeCustomizerTest extends ReaderCustomizerTest<VxlanGpe, Vxlan
vxlanGpeTunnelDetails.encapVrfId = 55;
vxlanGpeTunnelDetails.decapVrfId = 66;
vxlanGpeTunnelDetails.swIfIndex = 0;
-
value.vxlanGpeTunnelDetails = Lists.newArrayList(vxlanGpeTunnelDetails);
- vxlanGpeTunnelDetailsReplyDumpCompletionStage.complete(value);
-
- doReturn(vxlanGpeTunnelDetailsReplyDumpCompletionStage).when(api).vxlanGpeTunnelDump(any(VxlanGpeTunnelDump.class));
-
+ doReturn(future(value)).when(api).vxlanGpeTunnelDump(any(VxlanGpeTunnelDump.class));
}
@Test
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/Ipv4AddressCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/Ipv4AddressCustomizerTest.java
index 73e500fa5..be0ef14df 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/Ipv4AddressCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/Ipv4AddressCustomizerTest.java
@@ -29,12 +29,11 @@ import io.fd.honeycomb.translate.ModificationCache;
import io.fd.honeycomb.translate.read.ReadFailedException;
import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
import io.fd.honeycomb.translate.v3po.test.ContextTestUtils;
-import io.fd.honeycomb.vpp.test.read.ListReaderCustomizerTest;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
+import io.fd.honeycomb.vpp.test.read.ListReaderCustomizerTest;
import java.util.Arrays;
import java.util.List;
-import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;
import org.hamcrest.CoreMatchers;
import org.junit.Test;
@@ -136,12 +135,7 @@ public class Ipv4AddressCustomizerTest extends ListReaderCustomizerTest<Address,
IpAddressDetailsReplyDump reply2 = new IpAddressDetailsReplyDump();
reply2.ipAddressDetails = ImmutableList.of(detail2);
- CompletableFuture<IpAddressDetailsReplyDump> future = new CompletableFuture<>();
- future.complete(reply);
- CompletableFuture<IpAddressDetailsReplyDump> future2 = new CompletableFuture<>();
- future2.complete(reply2);
-
- when(api.ipAddressDump(Mockito.any(IpAddressDump.class))).thenReturn(future).thenReturn(future2);
+ when(api.ipAddressDump(Mockito.any(IpAddressDump.class))).thenReturn(future(reply)).thenReturn(future(reply2));
when(ctx.getModificationCache()).thenReturn(cache);
final InstanceIdentifier<Address> id = getId("192.168.2.1", IFACE_NAME);
@@ -179,14 +173,9 @@ public class Ipv4AddressCustomizerTest extends ListReaderCustomizerTest<Address,
IpAddressDetailsReplyDump reply = new IpAddressDetailsReplyDump();
reply.ipAddressDetails = ImmutableList.of(detail1, detail2, detail3);
-
- CompletableFuture<IpAddressDetailsReplyDump> future = new CompletableFuture<>();
- future.complete(reply);
-
- when(api.ipAddressDump(Mockito.any(IpAddressDump.class))).thenReturn(future);
+ when(api.ipAddressDump(Mockito.any(IpAddressDump.class))).thenReturn(future(reply));
when(ctx.getModificationCache()).thenReturn(cache);
-
final AddressBuilder builder = new AddressBuilder();
final InstanceIdentifier<Address> id = getId("192.168.2.1", IFACE_NAME);
@@ -246,11 +235,7 @@ public class Ipv4AddressCustomizerTest extends ListReaderCustomizerTest<Address,
IpAddressDetailsReplyDump reply = new IpAddressDetailsReplyDump();
reply.ipAddressDetails = ImmutableList.of(detail1, detail2, detail3);
-
- CompletableFuture<IpAddressDetailsReplyDump> future = new CompletableFuture<>();
- future.complete(reply);
-
- when(api.ipAddressDump(Mockito.any(IpAddressDump.class))).thenReturn(future);
+ when(api.ipAddressDump(Mockito.any(IpAddressDump.class))).thenReturn(future(reply));
when(ctx.getModificationCache()).thenReturn(cache);
final InstanceIdentifier<Address> id = getId("192.168.2.1", IFACE_NAME);
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/notification/InterfaceChangeNotificationProducerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/notification/InterfaceChangeNotificationProducerTest.java
index 05e48eeee..a227602b4 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/notification/InterfaceChangeNotificationProducerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/notification/InterfaceChangeNotificationProducerTest.java
@@ -25,7 +25,7 @@ import io.fd.honeycomb.notification.NotificationCollector;
import io.fd.honeycomb.translate.MappingContext;
import io.fd.honeycomb.translate.v3po.test.ContextTestUtils;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
-import java.util.concurrent.CompletableFuture;
+import io.fd.honeycomb.vpp.test.util.FutureProducer;
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
@@ -40,7 +40,7 @@ import org.openvpp.jvpp.core.dto.WantInterfaceEventsReply;
import org.openvpp.jvpp.core.future.FutureJVppCore;
import org.openvpp.jvpp.core.notification.CoreNotificationRegistry;
-public class InterfaceChangeNotificationProducerTest {
+public class InterfaceChangeNotificationProducerTest implements FutureProducer {
private static final String IFC_CTX_NAME = "ifc-test-instance";
private static final String IFACE_NAME = "eth0";
@@ -68,13 +68,11 @@ public class InterfaceChangeNotificationProducerTest {
doReturn(notificationListenerReg).when(notificationRegistry).registerSwInterfaceSetFlagsNotificationCallback(
callbackArgumentCaptor.capture());
ContextTestUtils.mockMapping(mappingContext, IFACE_NAME, IFACE_ID, IFC_CTX_NAME);
+ doReturn(future(new WantInterfaceEventsReply())).when(jVpp).wantInterfaceEvents(any(WantInterfaceEvents.class));
}
@Test
public void testStart() throws Exception {
- final CompletableFuture<WantInterfaceEventsReply> response = new CompletableFuture<>();
- response.complete(new WantInterfaceEventsReply());
- doReturn(response).when(jVpp).wantInterfaceEvents(any(WantInterfaceEvents.class));
final InterfaceChangeNotificationProducer interfaceChangeNotificationProducer =
new InterfaceChangeNotificationProducer(jVpp, namingContext, mappingContext);
@@ -91,9 +89,6 @@ public class InterfaceChangeNotificationProducerTest {
@Test
public void testNotification() throws Exception {
- final CompletableFuture<WantInterfaceEventsReply> response = new CompletableFuture<>();
- response.complete(new WantInterfaceEventsReply());
- doReturn(response).when(jVpp).wantInterfaceEvents(any(WantInterfaceEvents.class));
final InterfaceChangeNotificationProducer interfaceChangeNotificationProducer =
new InterfaceChangeNotificationProducer(jVpp, namingContext, mappingContext);
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/test/InterfaceTestUtils.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/test/InterfaceTestUtils.java
deleted file mode 100644
index b93e872c0..000000000
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/test/InterfaceTestUtils.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 2016 Cisco and/or its affiliates.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package io.fd.honeycomb.translate.v3po.test;
-
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyLong;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import java.util.List;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.CompletionStage;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-import org.openvpp.jvpp.VppBaseCallException;
-import org.openvpp.jvpp.core.dto.SwInterfaceDetails;
-import org.openvpp.jvpp.core.dto.SwInterfaceDetailsReplyDump;
-import org.openvpp.jvpp.core.dto.SwInterfaceDump;
-import org.openvpp.jvpp.core.future.FutureJVppCore;
-
-public final class InterfaceTestUtils {
- private InterfaceTestUtils() {
- throw new UnsupportedOperationException("Utility class cannot be instantiated");
- }
-
- public static void whenSwInterfaceDumpThenReturn(final FutureJVppCore api, final List<SwInterfaceDetails> interfaceList)
- throws ExecutionException, InterruptedException, VppBaseCallException, TimeoutException {
- final CompletionStage<SwInterfaceDetailsReplyDump> replyCS = mock(CompletionStage.class);
- final CompletableFuture<SwInterfaceDetailsReplyDump> replyFuture = mock(CompletableFuture.class);
- when(replyCS.toCompletableFuture()).thenReturn(replyFuture);
- final SwInterfaceDetailsReplyDump reply = new SwInterfaceDetailsReplyDump();
- reply.swInterfaceDetails = interfaceList;
- when(replyFuture.get(anyLong(), eq(TimeUnit.SECONDS))).thenReturn(reply);
- when(api.swInterfaceDump(any(SwInterfaceDump.class))).thenReturn(replyCS);
- }
-}
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/test/TestHelperUtils.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/test/TestHelperUtils.java
deleted file mode 100644
index 4cf3a9b77..000000000
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/test/TestHelperUtils.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (c) 2016 Cisco and/or its affiliates.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package io.fd.honeycomb.translate.v3po.test;
-
-import org.openvpp.jvpp.VppCallbackException;
-import org.openvpp.jvpp.dto.JVppReply;
-
-import java.util.concurrent.CompletableFuture;
-
-public class TestHelperUtils {
- private final static int ERROR_RETVAL = -1;
-
- /**
- * Static helper method for creation of Exception failure state in CompletableFuture object
- * with retval = -1
- * @return CompletableFuture with VppCallbackException as a cause
- */
- public static CompletableFuture<? extends JVppReply> createFutureException() {
- final CompletableFuture<? extends JVppReply> replyFuture = new CompletableFuture<>();
- replyFuture.completeExceptionally(new VppCallbackException("test-call", 1, ERROR_RETVAL));
- return replyFuture;
- }
-}
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vpp/ArpTerminationTableEntryCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vpp/ArpTerminationTableEntryCustomizerTest.java
index efd485f10..4a38101af 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vpp/ArpTerminationTableEntryCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vpp/ArpTerminationTableEntryCustomizerTest.java
@@ -26,11 +26,9 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import io.fd.honeycomb.translate.v3po.test.ContextTestUtils;
-import io.fd.honeycomb.translate.v3po.test.TestHelperUtils;
-import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
-import java.util.concurrent.CompletableFuture;
+import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
@@ -89,15 +87,11 @@ public class ArpTerminationTableEntryCustomizerTest extends WriterCustomizerTest
}
private void whenBdIpMacAddDelThenSuccess() {
- final CompletableFuture<BdIpMacAddDelReply> replyFuture = new CompletableFuture<>();
- final BdIpMacAddDelReply reply = new BdIpMacAddDelReply();
- replyFuture.complete(reply);
- doReturn(replyFuture).when(api).bdIpMacAddDel(any(BdIpMacAddDel.class));
+ doReturn(future(new BdIpMacAddDelReply())).when(api).bdIpMacAddDel(any(BdIpMacAddDel.class));
}
private void whenBdIpMacAddDelThenFailure() {
- doReturn(TestHelperUtils.<BdIpMacAddDelReply>createFutureException()).when(api)
- .bdIpMacAddDel(any(BdIpMacAddDel.class));
+ doReturn(failedFuture()).when(api).bdIpMacAddDel(any(BdIpMacAddDel.class));
}
private BdIpMacAddDel generateBdIpMacAddDelRequest(final byte[] ipAddress, final byte[] macAddress,
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vpp/BridgeDomainCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vpp/BridgeDomainCustomizerTest.java
index d08192c87..6029f3faf 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vpp/BridgeDomainCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vpp/BridgeDomainCustomizerTest.java
@@ -16,25 +16,26 @@
package io.fd.honeycomb.translate.v3po.vpp;
+import static io.fd.honeycomb.translate.v3po.util.TranslateUtils.booleanToByte;
import static org.junit.Assert.fail;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import io.fd.honeycomb.translate.v3po.test.ContextTestUtils;
-import io.fd.honeycomb.translate.v3po.test.TestHelperUtils;
-import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.CompletionStage;
-import java.util.concurrent.ExecutionException;
+import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest;
+import javax.annotation.Nullable;
import org.junit.Test;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.BridgeDomains;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.bridge.domains.BridgeDomain;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.bridge.domains.BridgeDomainBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.bridge.domains.BridgeDomainKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
import org.openvpp.jvpp.VppInvocationException;
import org.openvpp.jvpp.core.dto.BridgeDomainAddDel;
import org.openvpp.jvpp.core.dto.BridgeDomainAddDelReply;
@@ -50,6 +51,22 @@ public class BridgeDomainCustomizerTest extends WriterCustomizerTest {
customizer = new BridgeDomainCustomizer(api, new NamingContext("generatedBDName", BD_CTX_NAME));
}
+ @Nullable
+ private static Boolean intToBoolean(final int value) {
+ if (value == 0) {
+ return Boolean.FALSE;
+ }
+ if (value == 1) {
+ return Boolean.TRUE;
+ }
+ return null;
+ }
+
+ private static KeyedInstanceIdentifier<BridgeDomain, BridgeDomainKey> bdIdentifierForName(
+ final String bdName) {
+ return InstanceIdentifier.create(BridgeDomains.class).child(BridgeDomain.class, new BridgeDomainKey(bdName));
+ }
+
private BridgeDomain generateBridgeDomain(final String bdName) {
final byte arpTerm = 0;
final byte flood = 1;
@@ -63,22 +80,22 @@ public class BridgeDomainCustomizerTest extends WriterCustomizerTest {
final int forward, final int learn, final int uuf) {
return new BridgeDomainBuilder()
.setName(bdName)
- .setArpTermination(BridgeDomainTestUtils.intToBoolean(arpTerm))
- .setFlood(BridgeDomainTestUtils.intToBoolean(flood))
- .setForward(BridgeDomainTestUtils.intToBoolean(forward))
- .setLearn(BridgeDomainTestUtils.intToBoolean(learn))
- .setUnknownUnicastFlood(BridgeDomainTestUtils.intToBoolean(uuf))
+ .setArpTermination(intToBoolean(arpTerm))
+ .setFlood(intToBoolean(flood))
+ .setForward(intToBoolean(forward))
+ .setLearn(intToBoolean(learn))
+ .setUnknownUnicastFlood(intToBoolean(uuf))
.build();
}
private void verifyBridgeDomainAddOrUpdateWasInvoked(final BridgeDomain bd, final int bdId)
throws VppInvocationException {
final BridgeDomainAddDel expected = new BridgeDomainAddDel();
- expected.arpTerm = BridgeDomainTestUtils.booleanToByte(bd.isArpTermination());
- expected.flood = BridgeDomainTestUtils.booleanToByte(bd.isFlood());
- expected.forward = BridgeDomainTestUtils.booleanToByte(bd.isForward());
- expected.learn = BridgeDomainTestUtils.booleanToByte(bd.isLearn());
- expected.uuFlood = BridgeDomainTestUtils.booleanToByte(bd.isUnknownUnicastFlood());
+ expected.arpTerm = booleanToByte(bd.isArpTermination());
+ expected.flood = booleanToByte(bd.isFlood());
+ expected.forward = booleanToByte(bd.isForward());
+ expected.learn = booleanToByte(bd.isLearn());
+ expected.uuFlood = booleanToByte(bd.isUnknownUnicastFlood());
expected.isAdd = ADD_OR_UPDATE_BD;
expected.bdId = bdId;
verify(api).bridgeDomainAddDel(expected);
@@ -90,20 +107,12 @@ public class BridgeDomainCustomizerTest extends WriterCustomizerTest {
verify(api).bridgeDomainAddDel(expected);
}
- private void whenBridgeDomainAddDelThenSuccess()
- throws ExecutionException, InterruptedException, VppInvocationException {
- final CompletionStage<BridgeDomainAddDelReply> replyCS = mock(CompletionStage.class);
- final CompletableFuture<BridgeDomainAddDelReply> replyFuture = mock(CompletableFuture.class);
- when(replyCS.toCompletableFuture()).thenReturn(replyFuture);
- final BridgeDomainAddDelReply reply = new BridgeDomainAddDelReply();
- when(replyFuture.get()).thenReturn(reply);
- when(api.bridgeDomainAddDel(any(BridgeDomainAddDel.class))).thenReturn(replyCS);
+ private void whenBridgeDomainAddDelThenSuccess() {
+ when(api.bridgeDomainAddDel(any(BridgeDomainAddDel.class))).thenReturn(future(new BridgeDomainAddDelReply()));
}
- private void whenBridgeDomainAddDelThenFailure()
- throws ExecutionException, InterruptedException, VppInvocationException {
- doReturn(TestHelperUtils.<BridgeDomainAddDelReply>createFutureException()).when(api)
- .bridgeDomainAddDel(any(BridgeDomainAddDel.class));
+ private void whenBridgeDomainAddDelThenFailure() {
+ doReturn(failedFuture()).when(api).bridgeDomainAddDel(any(BridgeDomainAddDel.class));
}
@Test
@@ -115,7 +124,7 @@ public class BridgeDomainCustomizerTest extends WriterCustomizerTest {
whenBridgeDomainAddDelThenSuccess();
- customizer.writeCurrentAttributes(BridgeDomainTestUtils.bdIdentifierForName(bdName), bd, writeContext);
+ customizer.writeCurrentAttributes(bdIdentifierForName(bdName), bd, writeContext);
verifyBridgeDomainAddOrUpdateWasInvoked(bd, bdId);
verify(mappingContext).put(
@@ -131,7 +140,7 @@ public class BridgeDomainCustomizerTest extends WriterCustomizerTest {
whenBridgeDomainAddDelThenSuccess();
- customizer.writeCurrentAttributes(BridgeDomainTestUtils.bdIdentifierForName(bdName), bd, writeContext);
+ customizer.writeCurrentAttributes(bdIdentifierForName(bdName), bd, writeContext);
verifyBridgeDomainAddOrUpdateWasInvoked(bd, bdId);
verify(mappingContext).put(
@@ -148,7 +157,7 @@ public class BridgeDomainCustomizerTest extends WriterCustomizerTest {
whenBridgeDomainAddDelThenFailure();
try {
- customizer.writeCurrentAttributes(BridgeDomainTestUtils.bdIdentifierForName(bdName), bd, writeContext);
+ customizer.writeCurrentAttributes(bdIdentifierForName(bdName), bd, writeContext);
} catch (WriteFailedException.CreateFailedException e) {
verifyBridgeDomainAddOrUpdateWasInvoked(bd, bdId);
return;
@@ -165,7 +174,7 @@ public class BridgeDomainCustomizerTest extends WriterCustomizerTest {
whenBridgeDomainAddDelThenSuccess();
- customizer.deleteCurrentAttributes(BridgeDomainTestUtils.bdIdentifierForName(bdName), bd, writeContext);
+ customizer.deleteCurrentAttributes(bdIdentifierForName(bdName), bd, writeContext);
verifyBridgeDomainDeleteWasInvoked(bdId);
}
@@ -177,7 +186,7 @@ public class BridgeDomainCustomizerTest extends WriterCustomizerTest {
ContextTestUtils.mockEmptyMapping(mappingContext, bdName, BD_CTX_NAME);
try {
- customizer.deleteCurrentAttributes(BridgeDomainTestUtils.bdIdentifierForName(bdName), bd, writeContext);
+ customizer.deleteCurrentAttributes(bdIdentifierForName(bdName), bd, writeContext);
} catch (IllegalArgumentException e) {
verify(api, never()).bridgeDomainAddDel(any(BridgeDomainAddDel.class));
return;
@@ -195,7 +204,7 @@ public class BridgeDomainCustomizerTest extends WriterCustomizerTest {
whenBridgeDomainAddDelThenFailure();
try {
- customizer.deleteCurrentAttributes(BridgeDomainTestUtils.bdIdentifierForName(bdName), bd, writeContext);
+ customizer.deleteCurrentAttributes(bdIdentifierForName(bdName), bd, writeContext);
} catch (WriteFailedException.DeleteFailedException e) {
verifyBridgeDomainDeleteWasInvoked(bdId);
return;
@@ -225,7 +234,7 @@ public class BridgeDomainCustomizerTest extends WriterCustomizerTest {
whenBridgeDomainAddDelThenSuccess();
customizer
- .updateCurrentAttributes(BridgeDomainTestUtils.bdIdentifierForName(bdName), dataBefore, dataAfter,
+ .updateCurrentAttributes(bdIdentifierForName(bdName), dataBefore, dataAfter,
writeContext);
verifyBridgeDomainAddOrUpdateWasInvoked(dataAfter, bdId);
}
@@ -239,7 +248,7 @@ public class BridgeDomainCustomizerTest extends WriterCustomizerTest {
try {
customizer
- .updateCurrentAttributes(BridgeDomainTestUtils.bdIdentifierForName(bdName), bdBefore, bdAfter,
+ .updateCurrentAttributes(bdIdentifierForName(bdName), bdBefore, bdAfter,
writeContext);
} catch (IllegalArgumentException e) {
verify(api, never()).bridgeDomainAddDel(any(BridgeDomainAddDel.class));
@@ -260,7 +269,7 @@ public class BridgeDomainCustomizerTest extends WriterCustomizerTest {
try {
customizer
- .updateCurrentAttributes(BridgeDomainTestUtils.bdIdentifierForName(bdName), bdBefore, bdAfter,
+ .updateCurrentAttributes(bdIdentifierForName(bdName), bdBefore, bdAfter,
writeContext);
} catch (WriteFailedException.UpdateFailedException e) {
verifyBridgeDomainAddOrUpdateWasInvoked(bdAfter, bdId);
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vpp/BridgeDomainTestUtils.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vpp/BridgeDomainTestUtils.java
deleted file mode 100644
index 1c49a9c62..000000000
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vpp/BridgeDomainTestUtils.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 2016 Cisco and/or its affiliates.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package io.fd.honeycomb.translate.v3po.vpp;
-
-import javax.annotation.Nullable;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.BridgeDomains;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.bridge.domains.BridgeDomain;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.bridge.domains.BridgeDomainKey;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
-
-final class BridgeDomainTestUtils {
-
- private BridgeDomainTestUtils() {
- throw new UnsupportedOperationException("Utility class cannot be instantiated.");
- }
-
- public static byte booleanToByte(@Nullable final Boolean value) {
- return value != null && value ? (byte) 1 : (byte) 0;
- }
-
- @Nullable
- public static Boolean intToBoolean(final int value) {
- if (value == 0) {
- return Boolean.FALSE;
- }
- if (value == 1) {
- return Boolean.TRUE;
- }
- return null;
- }
-
- public static KeyedInstanceIdentifier<BridgeDomain, BridgeDomainKey> bdIdentifierForName(
- final String bdName) {
- return InstanceIdentifier.create(BridgeDomains.class).child(BridgeDomain.class, new BridgeDomainKey(bdName));
- }
-} \ No newline at end of file
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vpp/L2FibEntryCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vpp/L2FibEntryCustomizerTest.java
index 1f15788f0..728ba9306 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vpp/L2FibEntryCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vpp/L2FibEntryCustomizerTest.java
@@ -25,11 +25,9 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import io.fd.honeycomb.translate.v3po.test.ContextTestUtils;
-import io.fd.honeycomb.translate.v3po.test.TestHelperUtils;
-import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
-import java.util.concurrent.CompletableFuture;
+import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress;
@@ -46,7 +44,6 @@ import org.openvpp.jvpp.VppBaseCallException;
import org.openvpp.jvpp.VppInvocationException;
import org.openvpp.jvpp.core.dto.L2FibAddDel;
import org.openvpp.jvpp.core.dto.L2FibAddDelReply;
-import org.openvpp.jvpp.core.dto.L2InterfaceVlanTagRewriteReply;
public class L2FibEntryCustomizerTest extends WriterCustomizerTest {
private static final String BD_CTX_NAME = "bd-test-instance";
@@ -76,15 +73,11 @@ public class L2FibEntryCustomizerTest extends WriterCustomizerTest {
}
private void whenL2FibAddDelThenSuccess() {
- final CompletableFuture<L2FibAddDelReply> replyFuture = new CompletableFuture<>();
- final L2FibAddDelReply reply = new L2FibAddDelReply();
- replyFuture.complete(reply);
- doReturn(replyFuture).when(api).l2FibAddDel(any(L2FibAddDel.class));
+ doReturn(future(new L2FibAddDelReply())).when(api).l2FibAddDel(any(L2FibAddDel.class));
}
private void whenL2FibAddDelThenFailure() {
- doReturn(TestHelperUtils.<L2InterfaceVlanTagRewriteReply>createFutureException()).when(api)
- .l2FibAddDel(any(L2FibAddDel.class));
+ doReturn(failedFuture()).when(api).l2FibAddDel(any(L2FibAddDel.class));
}
private L2FibAddDel generateL2FibAddDelRequest(final long mac, final byte isAdd) {
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifySessionReaderTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifySessionReaderTest.java
index ee05d284f..f45367098 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifySessionReaderTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifySessionReaderTest.java
@@ -30,7 +30,6 @@ import io.fd.honeycomb.vpp.test.read.ListReaderCustomizerTest;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
-import java.util.concurrent.CompletableFuture;
import org.junit.Test;
import org.mockito.Mock;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.HexString;
@@ -112,10 +111,7 @@ public class ClassifySessionReaderTest extends
new byte[] {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x04,
(byte) 0x05, (byte) 0x07, 0x00, 0x00, 0x00, 0x00};
dump.classifySessionDetails = Arrays.asList(details1, details2);
-
- final CompletableFuture<ClassifySessionDetailsReplyDump> replyFuture = new CompletableFuture<>();
- replyFuture.complete(dump);
- doReturn(replyFuture).when(api).classifySessionDump(any(ClassifySessionDump.class));
+ doReturn(future(dump)).when(api).classifySessionDump(any(ClassifySessionDump.class));
when(classifierContext.containsTable(TABLE_NAME, mappingContext)).thenReturn(true);
when(classifierContext.getTableIndex(TABLE_NAME, mappingContext)).thenReturn(TABLE_INDEX);
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifySessionWriterTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifySessionWriterTest.java
index b24d93662..bba040651 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifySessionWriterTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifySessionWriterTest.java
@@ -16,8 +16,6 @@
package io.fd.honeycomb.translate.v3po.vppclassifier;
-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;
@@ -27,13 +25,9 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import com.google.common.base.Optional;
-import io.fd.honeycomb.translate.v3po.test.TestHelperUtils;
-import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest;
import io.fd.honeycomb.translate.write.WriteFailedException;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.ExecutionException;
+import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest;
import org.junit.Test;
-import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.HexString;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classifier.rev150603.OpaqueIndex;
@@ -50,7 +44,6 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.openvpp.jvpp.VppBaseCallException;
import org.openvpp.jvpp.core.dto.ClassifyAddDelSession;
import org.openvpp.jvpp.core.dto.ClassifyAddDelSessionReply;
-import org.openvpp.jvpp.core.dto.L2InterfaceVlanTagRewriteReply;
public class ClassifySessionWriterTest extends WriterCustomizerTest {
@@ -92,36 +85,13 @@ public class ClassifySessionWriterTest extends WriterCustomizerTest {
.child(ClassifySession.class, new ClassifySessionKey(new HexString(match)));
}
- private void whenClassifyAddDelSessionThenSuccess() throws ExecutionException, InterruptedException {
- final CompletableFuture<ClassifyAddDelSessionReply> replyFuture = new CompletableFuture<>();
- replyFuture.complete(new ClassifyAddDelSessionReply());
- doReturn(replyFuture).when(api).classifyAddDelSession(any(ClassifyAddDelSession.class));
- }
-
- private void whenClassifyAddDelSessionThenFailure() throws ExecutionException, InterruptedException {
- doReturn(TestHelperUtils.<L2InterfaceVlanTagRewriteReply>createFutureException()).when(api)
+ private void whenClassifyAddDelSessionThenSuccess() {
+ doReturn(future(new ClassifyAddDelSessionReply())).when(api)
.classifyAddDelSession(any(ClassifyAddDelSession.class));
}
- private void verifyClassifyAddDelSessionWasInvoked(final ClassifyAddDelSession expected) {
- ArgumentCaptor<ClassifyAddDelSession> argumentCaptor = ArgumentCaptor.forClass(ClassifyAddDelSession.class);
- verify(api).classifyAddDelSession(argumentCaptor.capture());
- final ClassifyAddDelSession actual = argumentCaptor.getValue();
- assertEquals(expected.opaqueIndex, actual.opaqueIndex);
- assertEquals(expected.isAdd, actual.isAdd);
- assertEquals(expected.tableIndex, actual.tableIndex);
- assertEquals(expected.hitNextIndex, actual.hitNextIndex);
- assertArrayEquals(expected.match, actual.match);
- assertEquals(expected.advance, actual.advance);
- }
-
- private void verifyClassifyAddDelSessionDeleteWasInvoked(final ClassifyAddDelSession expected) {
- ArgumentCaptor<ClassifyAddDelSession> argumentCaptor = ArgumentCaptor.forClass(ClassifyAddDelSession.class);
- verify(api).classifyAddDelSession(argumentCaptor.capture());
- final ClassifyAddDelSession actual = argumentCaptor.getValue();
- assertEquals(expected.opaqueIndex, actual.opaqueIndex);
- assertEquals(expected.isAdd, actual.isAdd);
- assertEquals(expected.tableIndex, actual.tableIndex);
+ private void whenClassifyAddDelSessionThenFailure() {
+ doReturn(failedFuture()).when(api).classifyAddDelSession(any(ClassifyAddDelSession.class));
}
private static ClassifyAddDelSession generateClassifyAddDelSession(final byte isAdd, final int tableIndex,
@@ -148,7 +118,7 @@ public class ClassifySessionWriterTest extends WriterCustomizerTest {
customizer.writeCurrentAttributes(id, classifySession, writeContext);
- verifyClassifyAddDelSessionWasInvoked(generateClassifyAddDelSession((byte) 1, TABLE_INDEX, SESSION_INDEX));
+ verify(api).classifyAddDelSession(generateClassifyAddDelSession((byte) 1, TABLE_INDEX, SESSION_INDEX));
}
@Test
@@ -163,7 +133,7 @@ public class ClassifySessionWriterTest extends WriterCustomizerTest {
customizer.writeCurrentAttributes(id, classifySession, writeContext);
} catch (WriteFailedException.CreateFailedException e) {
assertTrue(e.getCause() instanceof VppBaseCallException);
- verifyClassifyAddDelSessionWasInvoked(generateClassifyAddDelSession((byte) 1, TABLE_INDEX, SESSION_INDEX));
+ verify(api).classifyAddDelSession(generateClassifyAddDelSession((byte) 1, TABLE_INDEX, SESSION_INDEX));
return;
}
fail("WriteFailedException.CreateFailedException was expected");
@@ -184,7 +154,7 @@ public class ClassifySessionWriterTest extends WriterCustomizerTest {
customizer.deleteCurrentAttributes(id, classifySession, writeContext);
- verifyClassifyAddDelSessionDeleteWasInvoked(
+ verify(api).classifyAddDelSession(
generateClassifyAddDelSession((byte) 0, TABLE_INDEX, SESSION_INDEX));
}
@@ -200,7 +170,7 @@ public class ClassifySessionWriterTest extends WriterCustomizerTest {
customizer.deleteCurrentAttributes(id, classifySession, writeContext);
} catch (WriteFailedException.DeleteFailedException e) {
assertTrue(e.getCause() instanceof VppBaseCallException);
- verifyClassifyAddDelSessionDeleteWasInvoked(
+ verify(api).classifyAddDelSession(
generateClassifyAddDelSession((byte) 0, TABLE_INDEX, SESSION_INDEX));
return;
}
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifyTableReaderTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifyTableReaderTest.java
index 198cfbee9..95864ce6e 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifyTableReaderTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifyTableReaderTest.java
@@ -30,7 +30,6 @@ import io.fd.honeycomb.translate.read.ReadFailedException;
import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
import io.fd.honeycomb.vpp.test.read.ListReaderCustomizerTest;
import java.util.List;
-import java.util.concurrent.CompletableFuture;
import org.junit.Test;
import org.mockito.Mock;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.HexString;
@@ -105,9 +104,7 @@ public class ClassifyTableReaderTest extends
@Test
public void testRead() throws ReadFailedException {
- final CompletableFuture<ClassifyTableInfoReply> replyFuture = new CompletableFuture<>();
- replyFuture.complete(generateClassifyTableInfoReply());
- doReturn(replyFuture).when(api).classifyTableInfo(any(ClassifyTableInfo.class));
+ doReturn(future(generateClassifyTableInfoReply())).when(api).classifyTableInfo(any(ClassifyTableInfo.class));
when(classifierContext.containsTable(TABLE_NAME_1, mappingContext)).thenReturn(true);
when(classifierContext.getTableIndex(TABLE_NAME_1, mappingContext)).thenReturn(TABLE_INDEX_1);
@@ -121,11 +118,9 @@ public class ClassifyTableReaderTest extends
@Test
public void testGetAllIds() throws ReadFailedException {
- final CompletableFuture<ClassifyTableIdsReply> replyFuture = new CompletableFuture<>();
final ClassifyTableIdsReply reply = new ClassifyTableIdsReply();
reply.ids = new int[] {1, 2};
- replyFuture.complete(reply);
- doReturn(replyFuture).when(api).classifyTableIds(any(ClassifyTableIds.class));
+ doReturn(future(reply)).when(api).classifyTableIds(any(ClassifyTableIds.class));
when(classifierContext.getTableName(TABLE_INDEX_1, mappingContext)).thenReturn(TABLE_NAME_1);
when(classifierContext.getTableName(TABLE_INDEX_2, mappingContext)).thenReturn(TABLE_NAME_2);
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifyTableWriterTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifyTableWriterTest.java
index c49767d90..ede423a4f 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifyTableWriterTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifyTableWriterTest.java
@@ -16,8 +16,6 @@
package io.fd.honeycomb.translate.v3po.vppclassifier;
-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;
@@ -26,13 +24,9 @@ import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import io.fd.honeycomb.translate.v3po.test.TestHelperUtils;
-import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest;
import io.fd.honeycomb.translate.write.WriteFailedException;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.ExecutionException;
+import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest;
import org.junit.Test;
-import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.HexString;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classifier.rev150603.PacketHandlingAction;
@@ -46,7 +40,6 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.openvpp.jvpp.VppBaseCallException;
import org.openvpp.jvpp.core.dto.ClassifyAddDelTable;
import org.openvpp.jvpp.core.dto.ClassifyAddDelTableReply;
-import org.openvpp.jvpp.core.dto.L2InterfaceVlanTagRewriteReply;
public class ClassifyTableWriterTest extends WriterCustomizerTest {
@@ -81,40 +74,18 @@ public class ClassifyTableWriterTest extends WriterCustomizerTest {
.child(ClassifyTable.class, new ClassifyTableKey(name));
}
- private void whenClassifyAddDelTableThenSuccess() throws ExecutionException, InterruptedException {
- final CompletableFuture<ClassifyAddDelTableReply> replyFuture = new CompletableFuture<>();
+ private void whenClassifyAddDelTableThenSuccess() {
final ClassifyAddDelTableReply reply = new ClassifyAddDelTableReply();
reply.newTableIndex = TABLE_INDEX;
- replyFuture.complete(reply);
- doReturn(replyFuture).when(api).classifyAddDelTable(any(ClassifyAddDelTable.class));
- }
-
- private void whenClassifyAddDelTableThenFailure() throws ExecutionException, InterruptedException {
- doReturn(TestHelperUtils.<L2InterfaceVlanTagRewriteReply>createFutureException()).when(api)
- .classifyAddDelTable(any(ClassifyAddDelTable.class));
+ doReturn(future(reply)).when(api).classifyAddDelTable(any(ClassifyAddDelTable.class));
}
- private void verifyClassifyAddDelTableAddWasInvoked(final ClassifyAddDelTable expected) {
- ArgumentCaptor<ClassifyAddDelTable> argumentCaptor = ArgumentCaptor.forClass(ClassifyAddDelTable.class);
- verify(api).classifyAddDelTable(argumentCaptor.capture());
- final ClassifyAddDelTable actual = argumentCaptor.getValue();
- assertEquals(expected.isAdd, actual.isAdd);
- assertEquals(~0, actual.tableIndex);
- assertEquals(expected.nbuckets, actual.nbuckets);
- assertEquals(expected.memorySize, actual.memorySize);
- assertEquals(expected.skipNVectors, actual.skipNVectors);
- assertEquals(expected.matchNVectors, actual.matchNVectors);
- assertEquals(expected.nextTableIndex, actual.nextTableIndex);
- assertEquals(expected.missNextIndex, actual.missNextIndex);
- assertArrayEquals(expected.mask, actual.mask);
+ private void whenClassifyAddDelTableThenFailure() {
+ doReturn(failedFuture()).when(api).classifyAddDelTable(any(ClassifyAddDelTable.class));
}
- private void verifyClassifyAddDelTableDeleteWasInvoked(final ClassifyAddDelTable expected) {
- ArgumentCaptor<ClassifyAddDelTable> argumentCaptor = ArgumentCaptor.forClass(ClassifyAddDelTable.class);
- verify(api).classifyAddDelTable(argumentCaptor.capture());
- final ClassifyAddDelTable actual = argumentCaptor.getValue();
- assertEquals(expected.isAdd, actual.isAdd);
- assertEquals(expected.tableIndex, actual.tableIndex);
+ private static ClassifyAddDelTable generateClassifyAddDelTable(final byte isAdd) {
+ return generateClassifyAddDelTable(isAdd, -1);
}
private static ClassifyAddDelTable generateClassifyAddDelTable(final byte isAdd, final int tableIndex) {
@@ -142,7 +113,7 @@ public class ClassifyTableWriterTest extends WriterCustomizerTest {
customizer.writeCurrentAttributes(id, classifyTable, writeContext);
- verifyClassifyAddDelTableAddWasInvoked(generateClassifyAddDelTable((byte) 1, TABLE_INDEX));
+ verify(api).classifyAddDelTable(generateClassifyAddDelTable((byte) 1));
verify(classifierContext)
.addTable(TABLE_INDEX, classifyTable.getName(), classifyTable.getClassifierNode(), mappingContext);
}
@@ -158,7 +129,7 @@ public class ClassifyTableWriterTest extends WriterCustomizerTest {
customizer.writeCurrentAttributes(id, classifyTable, writeContext);
} catch (WriteFailedException.CreateFailedException e) {
assertTrue(e.getCause() instanceof VppBaseCallException);
- verifyClassifyAddDelTableAddWasInvoked(generateClassifyAddDelTable((byte) 1, TABLE_INDEX));
+ verify(api).classifyAddDelTable(generateClassifyAddDelTable((byte) 1));
verify(classifierContext, times(0))
.addTable(TABLE_INDEX, classifyTable.getName(), classifyTable.getClassifierNode(), mappingContext);
return;
@@ -177,7 +148,7 @@ public class ClassifyTableWriterTest extends WriterCustomizerTest {
customizer.deleteCurrentAttributes(id, classifyTable, writeContext);
- verifyClassifyAddDelTableDeleteWasInvoked(generateClassifyAddDelTable((byte) 0, TABLE_INDEX));
+ verify(api).classifyAddDelTable(generateClassifyAddDelTable((byte) 0, TABLE_INDEX));
}
@Test
@@ -193,7 +164,7 @@ public class ClassifyTableWriterTest extends WriterCustomizerTest {
customizer.deleteCurrentAttributes(id, classifyTable, writeContext);
} catch (WriteFailedException.DeleteFailedException e) {
assertTrue(e.getCause() instanceof VppBaseCallException);
- verifyClassifyAddDelTableDeleteWasInvoked(generateClassifyAddDelTable((byte) 0, TABLE_INDEX));
+ verify(api).classifyAddDelTable(generateClassifyAddDelTable((byte) 0, TABLE_INDEX));
return;
}
fail("WriteFailedException.DeleteFailedException was expected");
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppstate/L2FibEntryCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppstate/L2FibEntryCustomizerTest.java
index 29908442d..953332da7 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppstate/L2FibEntryCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppstate/L2FibEntryCustomizerTest.java
@@ -28,7 +28,6 @@ import io.fd.honeycomb.translate.v3po.util.NamingContext;
import io.fd.honeycomb.vpp.test.read.ListReaderCustomizerTest;
import java.util.Collections;
import java.util.List;
-import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import org.junit.Test;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress;
@@ -91,10 +90,7 @@ public class L2FibEntryCustomizerTest extends ListReaderCustomizerTest<L2FibEntr
throws ExecutionException, InterruptedException, VppInvocationException {
final L2FibTableEntryReplyDump reply = new L2FibTableEntryReplyDump();
reply.l2FibTableEntry = l2FibTableEntryList;
-
- final CompletableFuture<L2FibTableEntryReplyDump> replyFuture = new CompletableFuture<>();
- replyFuture.complete(reply);
- when(api.l2FibTableDump(any(L2FibTableDump.class))).thenReturn(replyFuture);
+ when(api.l2FibTableDump(any(L2FibTableDump.class))).thenReturn(future(reply));
}
@Test
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppstate/VersionCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppstate/VersionCustomizerTest.java
index 8af2683d1..71b7dccf3 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppstate/VersionCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppstate/VersionCustomizerTest.java
@@ -23,7 +23,6 @@ import static org.mockito.Mockito.when;
import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
import io.fd.honeycomb.vpp.test.read.ReaderCustomizerTest;
-import java.util.concurrent.CompletableFuture;
import org.junit.Test;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VppStateBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.state.Version;
@@ -53,15 +52,13 @@ public class VersionCustomizerTest extends ReaderCustomizerTest<Version, Version
@Test
public void testReadCurrentAttributes() throws Exception {
- final CompletableFuture<ShowVersionReply> replyFuture = new CompletableFuture<>();
final ShowVersionReply reply = new ShowVersionReply();
reply.version = new byte[] {};
reply.program = new byte[] {};
reply.buildDate = new byte[] {};
reply.buildDirectory = new byte[] {};
- replyFuture.complete(reply);
- when(api.showVersion(any(ShowVersion.class))).thenReturn(replyFuture);
+ when(api.showVersion(any(ShowVersion.class))).thenReturn(future(reply));
getCustomizer().readCurrentAttributes(InstanceIdentifier.create(Version.class), new VersionBuilder(), ctx);
verify(api).showVersion(any(ShowVersion.class));
}
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppstate/VppStateTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppstate/VppStateTest.java
index 6b7ab71a2..b8013b59e 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppstate/VppStateTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppstate/VppStateTest.java
@@ -22,7 +22,6 @@ import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
@@ -32,27 +31,30 @@ import com.google.common.collect.Multimap;
import io.fd.honeycomb.translate.MappingContext;
import io.fd.honeycomb.translate.ModificationCache;
import io.fd.honeycomb.translate.impl.read.GenericListReader;
+import io.fd.honeycomb.translate.impl.read.GenericReader;
import io.fd.honeycomb.translate.read.ReadContext;
import io.fd.honeycomb.translate.read.ReadFailedException;
import io.fd.honeycomb.translate.read.registry.ReaderRegistry;
+import io.fd.honeycomb.translate.util.read.registry.CompositeReaderRegistryBuilder;
import io.fd.honeycomb.translate.v3po.test.ContextTestUtils;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
+import io.fd.honeycomb.vpp.test.util.FutureProducer;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.CompletionStage;
-import java.util.concurrent.ExecutionException;
+import javax.annotation.Nonnull;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.mockito.Mock;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VppState;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VppStateBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.l2.fib.attributes.L2FibTable;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.l2.fib.attributes.l2.fib.table.L2FibEntry;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.l2.fib.attributes.l2.fib.table.L2FibEntryKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.state.BridgeDomains;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.state.BridgeDomainsBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.state.Version;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.state.VersionBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.state.bridge.domains.BridgeDomain;
@@ -60,7 +62,6 @@ 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.vpp.state.bridge.domains.BridgeDomainKey;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.openvpp.jvpp.VppInvocationException;
import org.openvpp.jvpp.core.dto.BridgeDomainDetails;
import org.openvpp.jvpp.core.dto.BridgeDomainDetailsReplyDump;
import org.openvpp.jvpp.core.dto.BridgeDomainDump;
@@ -71,7 +72,7 @@ import org.openvpp.jvpp.core.dto.ShowVersion;
import org.openvpp.jvpp.core.dto.ShowVersionReply;
import org.openvpp.jvpp.core.future.FutureJVppCore;
-public class VppStateTest {
+public class VppStateTest implements FutureProducer {
private static final String BD_CTX_NAME = "bd-test-instance";
@Mock
@@ -82,10 +83,37 @@ public class VppStateTest {
private MappingContext mappingContext;
private NamingContext bdContext;
- private NamingContext interfaceContext;
private ReaderRegistry readerRegistry;
+ private static InstanceIdentifier<BridgeDomains> bridgeDomainsId;
+
+ /**
+ * Create root VppState reader with all its children wired.
+ */
+ private static ReaderRegistry getVppStateReader(@Nonnull final FutureJVppCore jVpp,
+ @Nonnull final NamingContext bdContext) {
+ final CompositeReaderRegistryBuilder registry = new CompositeReaderRegistryBuilder();
+
+ // VppState(Structural)
+ final InstanceIdentifier<VppState> vppStateId = InstanceIdentifier.create(VppState.class);
+ registry.addStructuralReader(vppStateId, VppStateBuilder.class);
+ // Version
+ registry.add(new GenericReader<>(vppStateId.child(Version.class), new VersionCustomizer(jVpp)));
+ // BridgeDomains(Structural)
+ bridgeDomainsId = vppStateId.child(BridgeDomains.class);
+ registry.addStructuralReader(bridgeDomainsId, BridgeDomainsBuilder.class);
+ // BridgeDomain
+ registry.add(getBridgeDomainReader(jVpp, bdContext));
+ return registry.build();
+ }
+
+ private static GenericListReader<BridgeDomain, BridgeDomainKey, BridgeDomainBuilder> getBridgeDomainReader(
+ final @Nonnull FutureJVppCore jVpp, final @Nonnull NamingContext bdContext) {
+ final InstanceIdentifier<BridgeDomain> bridgeDomainId = bridgeDomainsId.child(BridgeDomain.class);
+ return new GenericListReader<>(bridgeDomainId, new BridgeDomainCustomizer(jVpp, bdContext));
+ }
+
@Before
public void setUp() throws Exception {
initMocks(this);
@@ -94,8 +122,7 @@ public class VppStateTest {
doReturn(mappingContext).when(ctx).getMappingContext();
bdContext = new NamingContext("generatedBdName", BD_CTX_NAME);
- interfaceContext = new NamingContext("generatedIfaceName", "ifc-test-instance");
- readerRegistry = VppStateTestUtils.getVppStateReader(api, bdContext);
+ readerRegistry = getVppStateReader(api, bdContext);
}
private static Version getVersion() {
@@ -107,38 +134,24 @@ public class VppStateTest {
.build();
}
- private void whenShowVersionThenReturn(int retval, Version version)
- throws ExecutionException, InterruptedException, VppInvocationException {
- final CompletableFuture<ShowVersionReply> replyFuture = new CompletableFuture<>();
+ private void whenShowVersionThenReturn(final Version version) {
final ShowVersionReply reply = new ShowVersionReply();
reply.buildDate = version.getBuildDate().getBytes();
reply.program = version.getName().getBytes();
reply.version = version.getBranch().getBytes();
reply.buildDirectory = version.getBuildDirectory().getBytes();
-
- replyFuture.complete(reply);
- when(api.showVersion(any(ShowVersion.class))).thenReturn(replyFuture);
+ when(api.showVersion(any(ShowVersion.class))).thenReturn(future(reply));
}
- private void whenL2FibTableDumpThenReturn(final List<L2FibTableEntry> entryList)
- throws ExecutionException, InterruptedException, VppInvocationException {
- final CompletionStage<L2FibTableEntryReplyDump> replyCS = mock(CompletionStage.class);
- final CompletableFuture<L2FibTableEntryReplyDump> replyFuture = mock(CompletableFuture.class);
- when(replyCS.toCompletableFuture()).thenReturn(replyFuture);
+ private void whenL2FibTableDumpThenReturn(final List<L2FibTableEntry> entryList) {
final L2FibTableEntryReplyDump reply = new L2FibTableEntryReplyDump();
reply.l2FibTableEntry = entryList;
- when(replyFuture.get()).thenReturn(reply);
- when(api.l2FibTableDump(any(L2FibTableDump.class))).thenReturn(replyCS);
+ when(api.l2FibTableDump(any(L2FibTableDump.class))).thenReturn(future(reply));
}
- private void whenBridgeDomainDumpThenReturn(final List<BridgeDomainDetails> bdList)
- throws ExecutionException, InterruptedException, VppInvocationException {
- final CompletionStage<BridgeDomainDetailsReplyDump> replyCS = mock(CompletionStage.class);
- final CompletableFuture<BridgeDomainDetailsReplyDump> replyFuture = mock(CompletableFuture.class);
- when(replyCS.toCompletableFuture()).thenReturn(replyFuture);
+ private void whenBridgeDomainDumpThenReturn(final List<BridgeDomainDetails> bdList) {
final BridgeDomainDetailsReplyDump reply = new BridgeDomainDetailsReplyDump();
reply.bridgeDomainDetails = bdList;
- when(replyFuture.get()).thenReturn(reply);
doAnswer(invocation -> {
BridgeDomainDump request = (BridgeDomainDump) invocation.getArguments()[0];
@@ -147,14 +160,14 @@ public class VppStateTest {
} else {
reply.bridgeDomainDetails = Collections.singletonList(bdList.get(request.bdId));
}
- return replyCS;
+ return future(reply);
}).when(api).bridgeDomainDump(any(BridgeDomainDump.class));
}
@Test
public void testReadAll() throws Exception {
final Version version = getVersion();
- whenShowVersionThenReturn(0, version);
+ whenShowVersionThenReturn(version);
final BridgeDomainDetails bridgeDomainDetails = new BridgeDomainDetails();
final BridgeDomainDetails bridgeDomainDetails2 = new BridgeDomainDetails();
@@ -178,7 +191,7 @@ public class VppStateTest {
@Test
public void testReadSpecific() throws Exception {
final Version version = getVersion();
- whenShowVersionThenReturn(0, version);
+ whenShowVersionThenReturn(version);
whenBridgeDomainDumpThenReturn(Collections.emptyList());
final Optional<? extends DataObject> read = readerRegistry.read(InstanceIdentifier.create(VppState.class), ctx);
@@ -189,7 +202,7 @@ public class VppStateTest {
@Test
public void testReadBridgeDomains() throws Exception {
final Version version = getVersion();
- whenShowVersionThenReturn(0, version);
+ whenShowVersionThenReturn(version);
final BridgeDomainDetails details = new BridgeDomainDetails();
whenBridgeDomainDumpThenReturn(Collections.singletonList(details));
@@ -246,7 +259,7 @@ public class VppStateTest {
@Test
public void testReadBridgeDomainAll() throws Exception {
final Version version = getVersion();
- whenShowVersionThenReturn(0, version);
+ whenShowVersionThenReturn(version);
final BridgeDomainDetails details = new BridgeDomainDetails();
whenBridgeDomainDumpThenReturn(Collections.singletonList(details));
mockBdMapping(details, "bd2");
@@ -254,7 +267,7 @@ public class VppStateTest {
VppState readRoot = (VppState) readerRegistry.read(InstanceIdentifier.create(VppState.class), ctx).get();
final GenericListReader<BridgeDomain, BridgeDomainKey, BridgeDomainBuilder> bridgeDomainReader =
- VppStateTestUtils.getBridgeDomainReader(api, bdContext);
+ getBridgeDomainReader(api, bdContext);
final List<BridgeDomain> read =
bridgeDomainReader.readList(InstanceIdentifier.create(VppState.class).child(BridgeDomains.class).child(
@@ -271,7 +284,7 @@ public class VppStateTest {
mockBdMapping(bd, bdName);
whenBridgeDomainDumpThenReturn(Collections.singletonList(bd));
- whenShowVersionThenReturn(0, getVersion());
+ whenShowVersionThenReturn(getVersion());
VppState readRoot = (VppState) readerRegistry.read(InstanceIdentifier.create(VppState.class), ctx).get();
@@ -296,7 +309,7 @@ public class VppStateTest {
@Test
public void testReadVersion() throws Exception {
- whenShowVersionThenReturn(0, getVersion());
+ whenShowVersionThenReturn(getVersion());
whenBridgeDomainDumpThenReturn(Collections.emptyList());
VppState readRoot = (VppState) readerRegistry.read(InstanceIdentifier.create(VppState.class), ctx).get();
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppstate/VppStateTestUtils.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppstate/VppStateTestUtils.java
deleted file mode 100644
index d1aea6ef6..000000000
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppstate/VppStateTestUtils.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2016 Cisco and/or its affiliates.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package io.fd.honeycomb.translate.v3po.vppstate;
-
-import io.fd.honeycomb.translate.impl.read.GenericListReader;
-import io.fd.honeycomb.translate.impl.read.GenericReader;
-import io.fd.honeycomb.translate.read.registry.ReaderRegistry;
-import io.fd.honeycomb.translate.util.read.registry.CompositeReaderRegistryBuilder;
-import io.fd.honeycomb.translate.v3po.util.NamingContext;
-import javax.annotation.Nonnull;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VppState;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VppStateBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.state.BridgeDomains;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.state.BridgeDomainsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.state.Version;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.state.bridge.domains.BridgeDomain;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.state.bridge.domains.BridgeDomainBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.state.bridge.domains.BridgeDomainKey;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.openvpp.jvpp.core.future.FutureJVppCore;
-
-final class VppStateTestUtils {
-
- private static InstanceIdentifier<BridgeDomains> bridgeDomainsId;
-
- public VppStateTestUtils() {
- }
-
- /**
- * Create root VppState reader with all its children wired.
- */
- static ReaderRegistry getVppStateReader(@Nonnull final FutureJVppCore jVpp,
- @Nonnull final NamingContext bdContext) {
- final CompositeReaderRegistryBuilder registry = new CompositeReaderRegistryBuilder();
-
- // VppState(Structural)
- final InstanceIdentifier<VppState> vppStateId = InstanceIdentifier.create(VppState.class);
- registry.addStructuralReader(vppStateId, VppStateBuilder.class);
- // Version
- registry.add(new GenericReader<>(vppStateId.child(Version.class), new VersionCustomizer(jVpp)));
- // BridgeDomains(Structural)
- bridgeDomainsId = vppStateId.child(BridgeDomains.class);
- registry.addStructuralReader(bridgeDomainsId, BridgeDomainsBuilder.class);
- // BridgeDomain
- registry.add(getBridgeDomainReader(jVpp, bdContext));
- return registry.build();
- }
-
- static GenericListReader<BridgeDomain, BridgeDomainKey, BridgeDomainBuilder> getBridgeDomainReader(
- final @Nonnull FutureJVppCore jVpp, final @Nonnull NamingContext bdContext) {
- final InstanceIdentifier<BridgeDomain> bridgeDomainId = bridgeDomainsId.child(BridgeDomain.class);
- return new GenericListReader<>(bridgeDomainId, new BridgeDomainCustomizer(jVpp, bdContext));
- }
-}