summaryrefslogtreecommitdiffstats
path: root/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterfaceCustomizerTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterfaceCustomizerTest.java')
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterfaceCustomizerTest.java28
1 files changed, 7 insertions, 21 deletions
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterfaceCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterfaceCustomizerTest.java
index 822b16c2b..a43bb136f 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterfaceCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterfaceCustomizerTest.java
@@ -16,18 +16,17 @@
package io.fd.honeycomb.v3po.translate.v3po.interfacesstate;
-import static io.fd.honeycomb.v3po.translate.v3po.ContextTestUtils.getMapping;
-import static io.fd.honeycomb.v3po.translate.v3po.ContextTestUtils.getMappingIid;
import static io.fd.honeycomb.v3po.translate.v3po.interfacesstate.InterfaceUtils.yangIfIndexToVpp;
+import static io.fd.honeycomb.v3po.translate.v3po.test.ContextTestUtils.getMapping;
+import static io.fd.honeycomb.v3po.translate.v3po.test.ContextTestUtils.getMappingIid;
+import static io.fd.honeycomb.v3po.translate.v3po.test.InterfaceTestUtils.whenSwInterfaceDumpThenReturn;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
-import static org.mockito.Matchers.any;
import static org.mockito.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.base.Optional;
import com.google.common.collect.Lists;
@@ -37,9 +36,6 @@ import io.fd.honeycomb.v3po.translate.v3po.util.NamingContext;
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 org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.naming.context.rev160513.contexts.naming.context.Mappings;
@@ -54,7 +50,6 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
import org.openvpp.jvpp.dto.SwInterfaceDetails;
-import org.openvpp.jvpp.dto.SwInterfaceDetailsReplyDump;
import org.openvpp.jvpp.dto.SwInterfaceDump;
public class InterfaceCustomizerTest extends
@@ -113,16 +108,7 @@ public class InterfaceCustomizerTest extends
assertEquals(iface.getPhysAddress().getValue(), InterfaceUtils.vppPhysAddrToYang(details.l2Address));
}
- private void whenSwInterfaceDumpThenReturn(final List<SwInterfaceDetails> interfaceList)
- throws ExecutionException, InterruptedException {
- 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()).thenReturn(reply);
- when(api.swInterfaceDump(any(SwInterfaceDump.class))).thenReturn(replyCS);
- }
+
@Test
public void testReadCurrentAttributes() throws Exception {
@@ -138,7 +124,7 @@ public class InterfaceCustomizerTest extends
iface.l2AddressLength = 6;
iface.l2Address = new byte[iface.l2AddressLength];
final List<SwInterfaceDetails> interfaceList = Collections.singletonList(iface);
- whenSwInterfaceDumpThenReturn(interfaceList);
+ whenSwInterfaceDumpThenReturn(api, interfaceList);
getCustomizer().readCurrentAttributes(id, builder, ctx);
@@ -153,7 +139,7 @@ public class InterfaceCustomizerTest extends
.child(Interface.class, new InterfaceKey(ifaceName));
final InterfaceBuilder builder = getCustomizer().getBuilder(id);
- whenSwInterfaceDumpThenReturn(Collections.emptyList());
+ whenSwInterfaceDumpThenReturn(api, Collections.emptyList());
try {
getCustomizer().readCurrentAttributes(id, builder, ctx);
@@ -178,7 +164,7 @@ public class InterfaceCustomizerTest extends
final SwInterfaceDetails swIf1 = new SwInterfaceDetails();
swIf1.swIfIndex = 1;
swIf1.interfaceName = swIf1Name.getBytes();
- whenSwInterfaceDumpThenReturn(Arrays.asList(swIf0, swIf1));
+ whenSwInterfaceDumpThenReturn(api, Arrays.asList(swIf0, swIf1));
final List<InterfaceKey> expectedIds = Arrays.asList(new InterfaceKey(swIf0Name), new InterfaceKey(swIf1Name));
final List<InterfaceKey> actualIds = getCustomizer().getAllIds(id, ctx);