summaryrefslogtreecommitdiffstats
path: root/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/InterfaceCustomizerTest.java
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
commite7a0775b21c2ea6b7bb8efb63b5384df26e27fbb (patch)
treed007d5f9df01f759d6996d2b1b9b1bd04bb8f35f /v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/InterfaceCustomizerTest.java
parenta4928d560b31df507472b17ac641c3f242d17b3a (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/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/InterfaceCustomizerTest.java')
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/InterfaceCustomizerTest.java22
1 files changed, 15 insertions, 7 deletions
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);