From 4f7fb7f2e12687d42a6ae287531bb788636a8bc6 Mon Sep 17 00:00:00 2001 From: Marek Gradzki Date: Thu, 2 Jun 2016 18:13:41 +0200 Subject: Updated tests for new vlan model Change-Id: I2982d52a7d8e319b9b6ed1be5d312296ef843599 Signed-off-by: Marek Gradzki --- .../interfacesstate/InterfaceCustomizerTest.java | 28 ++++++---------------- 1 file changed, 7 insertions(+), 21 deletions(-) (limited to 'v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterfaceCustomizerTest.java') 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 interfaceList) - throws ExecutionException, InterruptedException { - final CompletionStage replyCS = mock(CompletionStage.class); - final CompletableFuture 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 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 expectedIds = Arrays.asList(new InterfaceKey(swIf0Name), new InterfaceKey(swIf1Name)); final List actualIds = getCustomizer().getAllIds(id, ctx); -- cgit 1.2.3-korg