summaryrefslogtreecommitdiffstats
path: root/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv4NeighbourCustomizerTest.java
diff options
context:
space:
mode:
authorMarek Gradzki <mgradzki@cisco.com>2016-09-22 13:17:00 +0200
committerMarek Gradzki <mgradzki@cisco.com>2016-09-22 14:28:04 +0200
commita4928d560b31df507472b17ac641c3f242d17b3a (patch)
tree245e5759232a58c369444eb68f3f971f96015fe7 /v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv4NeighbourCustomizerTest.java
parentea4d1f9960997c62e3cd3172355ef8a862dc8a11 (diff)
HONEYCOMB-116: base classes for testing customizers
- adds base class for testing writers - moves base classes to vpp-translate-test, subproject of vpp-common Change-Id: Ia42e2be3a95a33866d1996dd42a9bd1773b970a7 Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
Diffstat (limited to 'v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv4NeighbourCustomizerTest.java')
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv4NeighbourCustomizerTest.java40
1 files changed, 8 insertions, 32 deletions
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 d7f9c0c1c..dcde0b43d 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
@@ -22,20 +22,16 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import com.google.common.io.BaseEncoding;
-import io.fd.honeycomb.translate.MappingContext;
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.WriteContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
import java.util.concurrent.CompletableFuture;
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
-import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
-import org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.naming.context.rev160513.contexts.naming.context.mappings.Mapping;
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;
@@ -49,45 +45,25 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.openvpp.jvpp.core.dto.IpNeighborAddDel;
import org.openvpp.jvpp.core.dto.IpNeighborAddDelReply;
-import org.openvpp.jvpp.core.future.FutureJVppCore;
-public class Ipv4NeighbourCustomizerTest {
+public class Ipv4NeighbourCustomizerTest extends WriterCustomizerTest {
private static final String IFC_CTX_NAME = "ifc-test-instance";
private static final String IFACE_NAME = "parent";
private static final int IFACE_ID = 5;
- @Mock
- private FutureJVppCore jvpp;
-
- @Mock
- private WriteContext context;
-
- @Mock
- private MappingContext mappingContext;
-
- @Mock
- private Mapping mapping;
-
private ArgumentCaptor<IpNeighborAddDel> requestCaptor;
private Ipv4NeighbourCustomizer customizer;
- private NamingContext namingContext;
-
@Before
public void init() {
- MockitoAnnotations.initMocks(this);
- when(context.getMappingContext()).thenReturn(mappingContext);
-
- namingContext = new NamingContext("prefix", IFC_CTX_NAME);
ContextTestUtils.mockMapping(mappingContext, IFACE_NAME, IFACE_ID, IFC_CTX_NAME);
-
- customizer = new Ipv4NeighbourCustomizer(jvpp,namingContext);
+ 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(jvpp.ipNeighborAddDel(Mockito.any(IpNeighborAddDel.class))).thenReturn(future);
+ when(api.ipNeighborAddDel(Mockito.any(IpNeighborAddDel.class))).thenReturn(future);
}
@Test
@@ -103,9 +79,9 @@ public class Ipv4NeighbourCustomizerTest {
Neighbor data = new NeighborBuilder().setIp(noZoneIp).setLinkLayerAddress(mac).build();
- customizer.writeCurrentAttributes(id, data, context);
+ customizer.writeCurrentAttributes(id, data, writeContext);
- verify(jvpp, times(1)).ipNeighborAddDel(requestCaptor.capture());
+ verify(api, times(1)).ipNeighborAddDel(requestCaptor.capture());
IpNeighborAddDel request = requestCaptor.getValue();
@@ -129,9 +105,9 @@ public class Ipv4NeighbourCustomizerTest {
Neighbor data = new NeighborBuilder().setIp(noZoneIp).setLinkLayerAddress(mac).build();
- customizer.deleteCurrentAttributes(id, data, context);
+ customizer.deleteCurrentAttributes(id, data, writeContext);
- verify(jvpp, times(1)).ipNeighborAddDel(requestCaptor.capture());
+ verify(api, times(1)).ipNeighborAddDel(requestCaptor.capture());
IpNeighborAddDel request = requestCaptor.getValue();