summaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp')
-rwxr-xr-xlisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/InterfaceCustomizerTest.java10
-rwxr-xr-xlisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/LispCustomizerTest.java75
-rwxr-xr-xlisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/LocalMappingCustomizerTest.java8
-rwxr-xr-xlisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/LocatorSetCustomizerTest.java36
-rwxr-xr-xlisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/MapResolverCustomizerTest.java60
-rwxr-xr-xlisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/PitrCfgCustomizerTest.java75
-rwxr-xr-xlisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/RemoteMappingCustomizerTest.java9
7 files changed, 100 insertions, 173 deletions
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/InterfaceCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/InterfaceCustomizerTest.java
index 0608c4a04..5f4fdcd97 100755
--- a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/InterfaceCustomizerTest.java
+++ b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/InterfaceCustomizerTest.java
@@ -29,7 +29,6 @@ import io.fd.honeycomb.translate.v3po.util.NamingContext;
import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
import io.fd.honeycomb.translate.write.WriteFailedException;
import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest;
-import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
@@ -56,8 +55,6 @@ public class InterfaceCustomizerTest extends WriterCustomizerTest {
private NamingContext namingContext;
private InstanceIdentifier<Interface> id;
- private CompletableFuture<LispAddDelLocatorReply> completeFuture;
- private LispAddDelLocatorReply fakeReply;
private Interface intf;
private InterfaceCustomizer customizer;
@@ -78,14 +75,9 @@ public class InterfaceCustomizerTest extends WriterCustomizerTest {
customizer = new InterfaceCustomizer(api, namingContext);
- fakeReply = new LispAddDelLocatorReply();
-
- completeFuture = new CompletableFuture<>();
- completeFuture.complete(fakeReply);
-
when(mappingContext.read(Mockito.any()))
.thenReturn(Optional.of((DataObject) new MappingBuilder().setIndex(5).setName("interface").build()));
- when(api.lispAddDelLocator(any(LispAddDelLocator.class))).thenReturn(completeFuture);
+ when(api.lispAddDelLocator(any(LispAddDelLocator.class))).thenReturn(future(new LispAddDelLocatorReply()));
}
@Test(expected = NullPointerException.class)
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/LispCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/LispCustomizerTest.java
index aaa73303c..171377cab 100755
--- a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/LispCustomizerTest.java
+++ b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/LispCustomizerTest.java
@@ -25,8 +25,7 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import io.fd.honeycomb.translate.write.WriteFailedException;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.ExecutionException;
+import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.Lisp;
@@ -36,7 +35,18 @@ import org.openvpp.jvpp.core.dto.LispEnableDisableReply;
import org.openvpp.jvpp.core.future.FutureJVppCore;
-public class LispCustomizerTest {
+public class LispCustomizerTest extends WriterCustomizerTest {
+
+ private LispCustomizer customizer;
+
+ @Override
+ public void setUp() {
+ customizer = new LispCustomizer(api);
+ }
+
+ private void whenlispEnableDisableThenSuccess() {
+ when(api.lispEnableDisable(any(LispEnableDisable.class))).thenReturn(future(new LispEnableDisableReply()));
+ }
@Test(expected = NullPointerException.class)
public void testWriteCurrentAttributesNullData() throws WriteFailedException {
@@ -44,22 +54,14 @@ public class LispCustomizerTest {
}
@Test
- public void testWriteCurrentAttributes() throws InterruptedException, ExecutionException, WriteFailedException {
- FutureJVppCore fakeJvpp = mock(FutureJVppCore.class);
+ public void testWriteCurrentAttributes() throws WriteFailedException {
Lisp intf = new LispBuilder().setEnable(true).build();
- ArgumentCaptor<LispEnableDisable> mappingCaptor = ArgumentCaptor.forClass(LispEnableDisable.class);
-
- LispEnableDisableReply fakeReply = new LispEnableDisableReply();
-
- CompletableFuture<LispEnableDisableReply> completeFuture = new CompletableFuture<>();
- completeFuture.complete(fakeReply);
-
- when(fakeJvpp.lispEnableDisable(any(LispEnableDisable.class))).thenReturn(completeFuture);
+ whenlispEnableDisableThenSuccess();
+ customizer.writeCurrentAttributes(null, intf, null);
- new LispCustomizer(fakeJvpp).writeCurrentAttributes(null, intf, null);
-
- verify(fakeJvpp, times(1)).lispEnableDisable(mappingCaptor.capture());
+ ArgumentCaptor<LispEnableDisable> mappingCaptor = ArgumentCaptor.forClass(LispEnableDisable.class);
+ verify(api, times(1)).lispEnableDisable(mappingCaptor.capture());
LispEnableDisable request = mappingCaptor.getValue();
@@ -69,26 +71,18 @@ public class LispCustomizerTest {
@Test(expected = NullPointerException.class)
public void testUpdateCurrentAttributesNullData() throws WriteFailedException {
- new LispCustomizer(mock(FutureJVppCore.class)).updateCurrentAttributes(null, null, null, null);
+ customizer.updateCurrentAttributes(null, null, null, null);
}
@Test
- public void testUpdateCurrentAttributes() throws WriteFailedException, InterruptedException, ExecutionException {
- FutureJVppCore fakeJvpp = mock(FutureJVppCore.class);
+ public void testUpdateCurrentAttributes() throws WriteFailedException {
Lisp lisp = new LispBuilder().setEnable(true).build();
- ArgumentCaptor<LispEnableDisable> lispCaptor = ArgumentCaptor.forClass(LispEnableDisable.class);
-
- LispEnableDisableReply fakeReply = new LispEnableDisableReply();
-
- CompletableFuture<LispEnableDisableReply> completeFuture = new CompletableFuture<>();
- completeFuture.complete(fakeReply);
-
- when(fakeJvpp.lispEnableDisable(any(LispEnableDisable.class))).thenReturn(completeFuture);
+ whenlispEnableDisableThenSuccess();
+ customizer.updateCurrentAttributes(null, null, lisp, null);
- new LispCustomizer(fakeJvpp).updateCurrentAttributes(null, null, lisp, null);
-
- verify(fakeJvpp, times(1)).lispEnableDisable(lispCaptor.capture());
+ ArgumentCaptor<LispEnableDisable> lispCaptor = ArgumentCaptor.forClass(LispEnableDisable.class);
+ verify(api, times(1)).lispEnableDisable(lispCaptor.capture());
LispEnableDisable request = lispCaptor.getValue();
@@ -98,31 +92,22 @@ public class LispCustomizerTest {
@Test(expected = NullPointerException.class)
public void testDeleteCurrentAttributesNullData() throws WriteFailedException {
- new LispCustomizer(mock(FutureJVppCore.class)).deleteCurrentAttributes(null, null, null);
+ customizer.deleteCurrentAttributes(null, null, null);
}
@Test
- public void testDeleteCurrentAttributes() throws WriteFailedException, InterruptedException, ExecutionException {
- FutureJVppCore fakeJvpp = mock(FutureJVppCore.class);
+ public void testDeleteCurrentAttributes() throws WriteFailedException {
Lisp lisp = new LispBuilder().setEnable(true).build();
- ArgumentCaptor<LispEnableDisable> lispCaptor = ArgumentCaptor.forClass(LispEnableDisable.class);
-
- LispEnableDisableReply fakeReply = new LispEnableDisableReply();
-
- CompletableFuture<LispEnableDisableReply> completeFuture = new CompletableFuture<>();
- completeFuture.complete(fakeReply);
-
- when(fakeJvpp.lispEnableDisable(any(LispEnableDisable.class))).thenReturn(completeFuture);
+ whenlispEnableDisableThenSuccess();
+ customizer.deleteCurrentAttributes(null, lisp, null);
- new LispCustomizer(fakeJvpp).deleteCurrentAttributes(null, lisp, null);
-
- verify(fakeJvpp, times(1)).lispEnableDisable(lispCaptor.capture());
+ ArgumentCaptor<LispEnableDisable> lispCaptor = ArgumentCaptor.forClass(LispEnableDisable.class);
+ verify(api, times(1)).lispEnableDisable(lispCaptor.capture());
LispEnableDisable request = lispCaptor.getValue();
assertNotNull(request);
assertEquals(0, request.isEn);
}
-
}
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/LocalMappingCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/LocalMappingCustomizerTest.java
index da9d50e7f..c4bd65295 100755
--- a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/LocalMappingCustomizerTest.java
+++ b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/LocalMappingCustomizerTest.java
@@ -28,7 +28,6 @@ import io.fd.honeycomb.lisp.context.util.EidMappingContext;
import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
import io.fd.honeycomb.translate.write.WriteFailedException;
import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest;
-import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
@@ -60,8 +59,6 @@ public class LocalMappingCustomizerTest extends WriterCustomizerTest {
private MappingId mappingId;
private InstanceIdentifier<LocalMapping> id;
private LocalMapping mapping;
- private LispAddDelLocalEidReply fakeReply;
- private CompletableFuture<LispAddDelLocalEidReply> completeFuture;
private LocalMappingCustomizer customizer;
private EidMappingContext localMappingContext;
@@ -91,12 +88,9 @@ public class LocalMappingCustomizerTest extends WriterCustomizerTest {
.child(LocalMapping.class, new LocalMappingKey(new MappingId("local")))
.build();
- fakeReply = new LispAddDelLocalEidReply();
- completeFuture = new CompletableFuture<>();
- completeFuture.complete(fakeReply);
customizer = new LocalMappingCustomizer(api, localMappingContext);
- when(api.lispAddDelLocalEid(any(LispAddDelLocalEid.class))).thenReturn(completeFuture);
+ when(api.lispAddDelLocalEid(any(LispAddDelLocalEid.class))).thenReturn(future(new LispAddDelLocalEidReply()));
when(mappingContext.read(Mockito.any())).thenReturn(com.google.common.base.Optional
.of(new LocalMappingBuilder().setKey(key).setId(mappingId).setEid(eid).build()));
}
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/LocatorSetCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/LocatorSetCustomizerTest.java
index 1bb695cc0..444b9b658 100755
--- a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/LocatorSetCustomizerTest.java
+++ b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/LocatorSetCustomizerTest.java
@@ -31,7 +31,6 @@ import io.fd.honeycomb.translate.write.WriteFailedException;
import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
-import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
@@ -48,27 +47,26 @@ import org.openvpp.jvpp.core.dto.LispLocatorSetDetailsReplyDump;
public class LocatorSetCustomizerTest extends WriterCustomizerTest {
- private NamingContext locatorSetContext;
+ private LocatorSetCustomizer customizer;
@Override
public void setUp() {
- locatorSetContext = new NamingContext("locator-set", "instance");
+ customizer = new LocatorSetCustomizer(api, new NamingContext("locator-set", "instance"));
}
@Test(expected = NullPointerException.class)
public void testWriteCurrentAttributesNullData() throws WriteFailedException {
- new LocatorSetCustomizer(api, locatorSetContext).writeCurrentAttributes(null, null, null);
+ customizer.writeCurrentAttributes(null, null, null);
}
@Test(expected = NullPointerException.class)
public void testWriteCurrentAttributesBadData() throws WriteFailedException {
- new LocatorSetCustomizer(api, locatorSetContext)
+ customizer
.writeCurrentAttributes(null, mock(LocatorSet.class), null);
}
@Test
public void testWriteCurrentAttributes() throws WriteFailedException, InterruptedException, ExecutionException {
-
LocatorSet locatorSet = new LocatorSetBuilder()
.setName("Locator")
.setInterface(Arrays.asList(new InterfaceBuilder().build()))
@@ -80,12 +78,7 @@ public class LocatorSetCustomizerTest extends WriterCustomizerTest {
ArgumentCaptor<LispAddDelLocatorSet> locatorSetCaptor = ArgumentCaptor.forClass(LispAddDelLocatorSet.class);
- LispAddDelLocatorSetReply fakeReply = new LispAddDelLocatorSetReply();
-
- CompletableFuture<LispAddDelLocatorSetReply> completeFuture = new CompletableFuture<>();
- completeFuture.complete(fakeReply);
-
- when(api.lispAddDelLocatorSet(any(LispAddDelLocatorSet.class))).thenReturn(completeFuture);
+ when(api.lispAddDelLocatorSet(any(LispAddDelLocatorSet.class))).thenReturn(future(new LispAddDelLocatorSetReply()));
when(writeContext.readAfter(validId)).thenReturn(Optional.of(locatorSet));
final LispLocatorSetDetailsReplyDump reply = new LispLocatorSetDetailsReplyDump();
@@ -95,7 +88,7 @@ public class LocatorSetCustomizerTest extends WriterCustomizerTest {
cache.put(io.fd.honeycomb.lisp.translate.read.LocatorSetCustomizer.LOCATOR_SETS_CACHE_ID, reply);
- new LocatorSetCustomizer(api, locatorSetContext).writeCurrentAttributes(validId, locatorSet, writeContext);
+ customizer.writeCurrentAttributes(validId, locatorSet, writeContext);
verify(api, times(1)).lispAddDelLocatorSet(locatorSetCaptor.capture());
@@ -108,37 +101,30 @@ public class LocatorSetCustomizerTest extends WriterCustomizerTest {
@Test(expected = UnsupportedOperationException.class)
public void testUpdateCurrentAttributes() throws WriteFailedException {
- new LocatorSetCustomizer(api, locatorSetContext).updateCurrentAttributes(null, null, null, null);
+ customizer.updateCurrentAttributes(null, null, null, null);
}
@Test(expected = NullPointerException.class)
public void testDeleteCurrentAttributesNullData() throws WriteFailedException {
- new LocatorSetCustomizer(api, locatorSetContext).deleteCurrentAttributes(null, null, null);
+ customizer.deleteCurrentAttributes(null, null, null);
}
@Test(expected = NullPointerException.class)
public void testDeleteCurrentAttributesBadData() throws WriteFailedException {
- new LocatorSetCustomizer(api, locatorSetContext)
- .deleteCurrentAttributes(null, mock(LocatorSet.class), null);
+ customizer.deleteCurrentAttributes(null, mock(LocatorSet.class), null);
}
@Test
public void testDeleteCurrentAttributes() throws InterruptedException, ExecutionException, WriteFailedException {
-
LocatorSet locatorSet = new LocatorSetBuilder()
.setName("Locator")
.build();
ArgumentCaptor<LispAddDelLocatorSet> locatorSetCaptor = ArgumentCaptor.forClass(LispAddDelLocatorSet.class);
- LispAddDelLocatorSetReply fakeReply = new LispAddDelLocatorSetReply();
-
- CompletableFuture<LispAddDelLocatorSetReply> completeFuture = new CompletableFuture<>();
- completeFuture.complete(fakeReply);
-
- when(api.lispAddDelLocatorSet(any(LispAddDelLocatorSet.class))).thenReturn(completeFuture);
+ when(api.lispAddDelLocatorSet(any(LispAddDelLocatorSet.class))).thenReturn(future(new LispAddDelLocatorSetReply()));
- new LocatorSetCustomizer(api, locatorSetContext).deleteCurrentAttributes(null, locatorSet, writeContext);
+ customizer.deleteCurrentAttributes(null, locatorSet, writeContext);
verify(api, times(1)).lispAddDelLocatorSet(locatorSetCaptor.capture());
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/MapResolverCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/MapResolverCustomizerTest.java
index 63be37a23..0b2051b43 100755
--- a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/MapResolverCustomizerTest.java
+++ b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/MapResolverCustomizerTest.java
@@ -18,14 +18,13 @@ package io.fd.honeycomb.lisp.translate.write;
import static org.junit.Assert.assertEquals;
import static org.mockito.Matchers.any;
-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 io.fd.honeycomb.translate.v3po.util.TranslateUtils;
import io.fd.honeycomb.translate.write.WriteFailedException;
-import java.util.concurrent.CompletableFuture;
+import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest;
import java.util.concurrent.ExecutionException;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
@@ -35,41 +34,43 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.map.resolvers.grouping.map.resolvers.MapResolverBuilder;
import org.openvpp.jvpp.core.dto.LispAddDelMapResolver;
import org.openvpp.jvpp.core.dto.LispAddDelMapResolverReply;
-import org.openvpp.jvpp.core.future.FutureJVppCore;
-public class MapResolverCustomizerTest {
+public class MapResolverCustomizerTest extends WriterCustomizerTest {
+
+ private MapResolverCustomizer customizer;
+
+ @Override
+ public void setUp() {
+ customizer = new MapResolverCustomizer(api);
+ }
+
+ private void whenLispAddDelMapResolverThenSuccess() {
+ when(api.lispAddDelMapResolver(any(LispAddDelMapResolver.class)))
+ .thenReturn(future(new LispAddDelMapResolverReply()));
+ }
@Test(expected = NullPointerException.class)
public void testWriteCurrentAttributesNullData() throws WriteFailedException {
- new MapResolverCustomizer(mock(FutureJVppCore.class)).writeCurrentAttributes(null, null, null);
+ customizer.writeCurrentAttributes(null, null, null);
}
@Test(expected = NullPointerException.class)
public void testWriteCurrentAttributesBadData() throws WriteFailedException {
- new MapResolverCustomizer(mock(FutureJVppCore.class))
- .writeCurrentAttributes(null, new MapResolverBuilder().build(), null);
+ customizer.writeCurrentAttributes(null, new MapResolverBuilder().build(), null);
}
@Test
- public void testWriteCurrentAttributes() throws WriteFailedException, InterruptedException, ExecutionException {
- FutureJVppCore fakeJvpp = mock(FutureJVppCore.class);
-
- MapResolverCustomizer customizer = new MapResolverCustomizer(fakeJvpp);
+ public void testWriteCurrentAttributes() throws WriteFailedException {
Ipv4Address address = new Ipv4Address("192.168.2.1");
MapResolver resolver = new MapResolverBuilder().setIpAddress(new IpAddress(address)).build();
- ArgumentCaptor<LispAddDelMapResolver> resolverCaptor = ArgumentCaptor.forClass(LispAddDelMapResolver.class);
-
- LispAddDelMapResolverReply fakeReply = new LispAddDelMapResolverReply();
-
- CompletableFuture<LispAddDelMapResolverReply> finalStage = new CompletableFuture<>();
- finalStage.complete(fakeReply);
-
- when(fakeJvpp.lispAddDelMapResolver(any(LispAddDelMapResolver.class))).thenReturn(finalStage);
+ whenLispAddDelMapResolverThenSuccess();
customizer.writeCurrentAttributes(null, resolver, null);
- verify(fakeJvpp, times(1)).lispAddDelMapResolver(resolverCaptor.capture());
+
+ ArgumentCaptor<LispAddDelMapResolver> resolverCaptor = ArgumentCaptor.forClass(LispAddDelMapResolver.class);
+ verify(api, times(1)).lispAddDelMapResolver(resolverCaptor.capture());
LispAddDelMapResolver request = resolverCaptor.getValue();
assertEquals(1, request.isAdd);
@@ -79,29 +80,20 @@ public class MapResolverCustomizerTest {
@Test(expected = UnsupportedOperationException.class)
public void testUpdateCurrentAttributes() throws WriteFailedException {
- new MapResolverCustomizer(mock(FutureJVppCore.class)).updateCurrentAttributes(null, null, null, null);
+ customizer.updateCurrentAttributes(null, null, null, null);
}
@Test
public void testDeleteCurrentAttributes() throws InterruptedException, ExecutionException, WriteFailedException {
-
- FutureJVppCore fakeJvpp = mock(FutureJVppCore.class);
-
- MapResolverCustomizer customizer = new MapResolverCustomizer(fakeJvpp);
Ipv4Address address = new Ipv4Address("192.168.2.1");
MapResolver resolver = new MapResolverBuilder().setIpAddress(new IpAddress(address)).build();
- ArgumentCaptor<LispAddDelMapResolver> resolverCaptor = ArgumentCaptor.forClass(LispAddDelMapResolver.class);
-
- LispAddDelMapResolverReply fakeReply = new LispAddDelMapResolverReply();
-
- CompletableFuture<LispAddDelMapResolverReply> finalStage = new CompletableFuture<>();
- finalStage.complete(fakeReply);
-
- when(fakeJvpp.lispAddDelMapResolver(any(LispAddDelMapResolver.class))).thenReturn(finalStage);
+ whenLispAddDelMapResolverThenSuccess();
customizer.deleteCurrentAttributes(null, resolver, null);
- verify(fakeJvpp, times(1)).lispAddDelMapResolver(resolverCaptor.capture());
+
+ ArgumentCaptor<LispAddDelMapResolver> resolverCaptor = ArgumentCaptor.forClass(LispAddDelMapResolver.class);
+ verify(api, times(1)).lispAddDelMapResolver(resolverCaptor.capture());
LispAddDelMapResolver request = resolverCaptor.getValue();
assertEquals(0, request.isAdd);
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/PitrCfgCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/PitrCfgCustomizerTest.java
index 5f1ffb888..9ab44bba9 100755
--- a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/PitrCfgCustomizerTest.java
+++ b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/PitrCfgCustomizerTest.java
@@ -24,7 +24,7 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import io.fd.honeycomb.translate.write.WriteFailedException;
-import java.util.concurrent.CompletableFuture;
+import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest;
import java.util.concurrent.ExecutionException;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
@@ -32,39 +32,40 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.pitr.cfg.grouping.PitrCfgBuilder;
import org.openvpp.jvpp.core.dto.LispPitrSetLocatorSet;
import org.openvpp.jvpp.core.dto.LispPitrSetLocatorSetReply;
-import org.openvpp.jvpp.core.future.FutureJVppCore;
-public class PitrCfgCustomizerTest {
+public class PitrCfgCustomizerTest extends WriterCustomizerTest {
+
+ private PitrCfgCustomizer customizer;
+
+ @Override
+ public void setUp() {
+ customizer = new PitrCfgCustomizer(api);
+ }
+
+ private void whenLispPitrSetLocatorSetThenSuccess() {
+ when(api.lispPitrSetLocatorSet(any(LispPitrSetLocatorSet.class))).thenReturn(future(new LispPitrSetLocatorSetReply()));
+ }
@Test(expected = NullPointerException.class)
public void testWriteCurrentAttributesNullData() throws WriteFailedException {
- new PitrCfgCustomizer(mock(FutureJVppCore.class)).writeCurrentAttributes(null, null, null);
+ customizer.writeCurrentAttributes(null, null, null);
}
@Test(expected = NullPointerException.class)
public void testWriteCurrentAttributesBadData() throws WriteFailedException {
- new PitrCfgCustomizer(mock(FutureJVppCore.class)).writeCurrentAttributes(null, mock(PitrCfg.class), null);
+ customizer.writeCurrentAttributes(null, mock(PitrCfg.class), null);
}
@Test
- public void testWriteCurrentAttributes() throws InterruptedException, ExecutionException, WriteFailedException {
- FutureJVppCore fakeJvpp = mock(FutureJVppCore.class);
-
- PitrCfgCustomizer customizer = new PitrCfgCustomizer(fakeJvpp);
+ public void testWriteCurrentAttributes() throws WriteFailedException {
PitrCfg cfg = new PitrCfgBuilder().setLocatorSet("Locator").build();
- ArgumentCaptor<LispPitrSetLocatorSet> cfgCaptor = ArgumentCaptor.forClass(LispPitrSetLocatorSet.class);
-
- LispPitrSetLocatorSetReply fakeReply = new LispPitrSetLocatorSetReply();
-
- CompletableFuture<LispPitrSetLocatorSetReply> finalStage = new CompletableFuture<>();
- finalStage.complete(fakeReply);
-
- when(fakeJvpp.lispPitrSetLocatorSet(any(LispPitrSetLocatorSet.class))).thenReturn(finalStage);
-
+ whenLispPitrSetLocatorSetThenSuccess();
customizer.writeCurrentAttributes(null, cfg, null);
- verify(fakeJvpp, times(1)).lispPitrSetLocatorSet(cfgCaptor.capture());
+
+ ArgumentCaptor<LispPitrSetLocatorSet> cfgCaptor = ArgumentCaptor.forClass(LispPitrSetLocatorSet.class);
+ verify(api, times(1)).lispPitrSetLocatorSet(cfgCaptor.capture());
LispPitrSetLocatorSet request = cfgCaptor.getValue();
assertEquals(1, request.isAdd);
@@ -73,22 +74,14 @@ public class PitrCfgCustomizerTest {
@Test
public void testUpdateCurrentAttributes() throws WriteFailedException {
- FutureJVppCore fakeJvpp = mock(FutureJVppCore.class);
-
- PitrCfgCustomizer customizer = new PitrCfgCustomizer(fakeJvpp);
PitrCfg cfg = new PitrCfgBuilder().setLocatorSet("Locator").build();
- ArgumentCaptor<LispPitrSetLocatorSet> cfgCaptor = ArgumentCaptor.forClass(LispPitrSetLocatorSet.class);
-
- LispPitrSetLocatorSetReply fakeReply = new LispPitrSetLocatorSetReply();
-
- CompletableFuture<LispPitrSetLocatorSetReply> finalStage = new CompletableFuture<>();
- finalStage.complete(fakeReply);
-
- when(fakeJvpp.lispPitrSetLocatorSet(any(LispPitrSetLocatorSet.class))).thenReturn(finalStage);
+ whenLispPitrSetLocatorSetThenSuccess();
customizer.writeCurrentAttributes(null, cfg, null);
- verify(fakeJvpp, times(1)).lispPitrSetLocatorSet(cfgCaptor.capture());
+
+ ArgumentCaptor<LispPitrSetLocatorSet> cfgCaptor = ArgumentCaptor.forClass(LispPitrSetLocatorSet.class);
+ verify(api, times(1)).lispPitrSetLocatorSet(cfgCaptor.capture());
LispPitrSetLocatorSet request = cfgCaptor.getValue();
assertEquals(1, request.isAdd);
@@ -97,32 +90,24 @@ public class PitrCfgCustomizerTest {
@Test(expected = NullPointerException.class)
public void testDeleteCurrentAttributesNullData() throws WriteFailedException {
- new PitrCfgCustomizer(mock(FutureJVppCore.class)).deleteCurrentAttributes(null, null, null);
+ customizer.deleteCurrentAttributes(null, null, null);
}
@Test(expected = NullPointerException.class)
public void testDeleteCurrentAttributesBadData() throws WriteFailedException {
- new PitrCfgCustomizer(mock(FutureJVppCore.class)).deleteCurrentAttributes(null, mock(PitrCfg.class), null);
+ customizer.deleteCurrentAttributes(null, mock(PitrCfg.class), null);
}
@Test
public void testDeleteCurrentAttributes() throws WriteFailedException, InterruptedException, ExecutionException {
- FutureJVppCore fakeJvpp = mock(FutureJVppCore.class);
-
- PitrCfgCustomizer customizer = new PitrCfgCustomizer(fakeJvpp);
PitrCfg cfg = new PitrCfgBuilder().setLocatorSet("Locator").build();
- ArgumentCaptor<LispPitrSetLocatorSet> cfgCaptor = ArgumentCaptor.forClass(LispPitrSetLocatorSet.class);
-
- LispPitrSetLocatorSetReply fakeReply = new LispPitrSetLocatorSetReply();
-
- CompletableFuture<LispPitrSetLocatorSetReply> finalStage = new CompletableFuture<>();
- finalStage.complete(fakeReply);
-
- when(fakeJvpp.lispPitrSetLocatorSet(any(LispPitrSetLocatorSet.class))).thenReturn(finalStage);
+ whenLispPitrSetLocatorSetThenSuccess();
customizer.deleteCurrentAttributes(null, cfg, null);
- verify(fakeJvpp, times(1)).lispPitrSetLocatorSet(cfgCaptor.capture());
+
+ ArgumentCaptor<LispPitrSetLocatorSet> cfgCaptor = ArgumentCaptor.forClass(LispPitrSetLocatorSet.class);
+ verify(api, times(1)).lispPitrSetLocatorSet(cfgCaptor.capture());
LispPitrSetLocatorSet request = cfgCaptor.getValue();
assertEquals(0, request.isAdd);
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/RemoteMappingCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/RemoteMappingCustomizerTest.java
index 30c168e72..9eca7cf67 100755
--- a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/RemoteMappingCustomizerTest.java
+++ b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/RemoteMappingCustomizerTest.java
@@ -27,7 +27,6 @@ import io.fd.honeycomb.lisp.context.util.EidMappingContext;
import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
import io.fd.honeycomb.translate.write.WriteFailedException;
import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest;
-import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
@@ -61,8 +60,6 @@ public class RemoteMappingCustomizerTest extends WriterCustomizerTest {
private MappingId mappingId;
private RemoteMappingCustomizer customizer;
private RemoteMapping intf;
- private LispAddDelRemoteMappingReply fakeReply;
- private CompletableFuture<LispAddDelRemoteMappingReply> completeFuture;
private InstanceIdentifier<RemoteMapping> id;
private EidMappingContext remoteMappingContext;
@@ -78,7 +75,6 @@ public class RemoteMappingCustomizerTest extends WriterCustomizerTest {
final RemoteMappingKey key = new RemoteMappingKey(mappingId);
remoteMappingContext = new EidMappingContext("remote");
-
intf = new RemoteMappingBuilder()
.setEid(
eid)
@@ -90,12 +86,9 @@ public class RemoteMappingCustomizerTest extends WriterCustomizerTest {
.child(RemoteMappings.class)
.child(RemoteMapping.class, key).build();
- fakeReply = new LispAddDelRemoteMappingReply();
- completeFuture = new CompletableFuture<>();
- completeFuture.complete(fakeReply);
customizer = new RemoteMappingCustomizer(api, remoteMappingContext);
- when(api.lispAddDelRemoteMapping(Mockito.any())).thenReturn(completeFuture);
+ when(api.lispAddDelRemoteMapping(Mockito.any())).thenReturn(future(new LispAddDelRemoteMappingReply()));
when(mappingContext.read(Mockito.any())).thenReturn(com.google.common.base.Optional
.of(new RemoteMappingBuilder().setKey(key).setId(mappingId).setEid(eid).build()));
}