X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=v3po%2Fv3po2vpp%2Fsrc%2Ftest%2Fjava%2Fio%2Ffd%2Fhoneycomb%2Ftranslate%2Fv3po%2Finterfacesstate%2FInterfaceCustomizerTest.java;h=acc407bd341985886053fae5dcf2b3c7a231c392;hb=e7a0775b21c2ea6b7bb8efb63b5384df26e27fbb;hp=b6ef0ece5805253b7750a78eff7c622b4dc0b446;hpb=a4928d560b31df507472b17ac641c3f242d17b3a;p=honeycomb.git 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 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 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 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 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 expectedIds = Arrays.asList(new InterfaceKey(IFACE0_NAME)); final List actualIds = getCustomizer().getAllIds(id, ctx);