summaryrefslogtreecommitdiffstats
path: root/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write')
-rwxr-xr-xlisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/LocalMappingCustomizerTest.java52
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/MapRegisterCustomizerTest.java92
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/MapRequestModeCustomizerTest.java83
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/MapServerCustomizerTest.java98
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/PetrCfgCustomizerTest.java99
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/RlocProbeCustomizerTest.java88
6 files changed, 512 insertions, 0 deletions
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/LocalMappingCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/LocalMappingCustomizerTest.java
index 6f4a623ed..8855f0564 100755
--- a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/LocalMappingCustomizerTest.java
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/LocalMappingCustomizerTest.java
@@ -18,6 +18,7 @@ package io.fd.hc2vpp.lisp.translate.write;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
@@ -32,6 +33,8 @@ import io.fd.hc2vpp.lisp.context.util.EidMappingContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
import io.fd.vpp.jvpp.core.dto.LispAddDelLocalEid;
import io.fd.vpp.jvpp.core.dto.LispAddDelLocalEidReply;
+import java.nio.charset.StandardCharsets;
+import java.util.Arrays;
import java.util.concurrent.ExecutionException;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
@@ -40,6 +43,7 @@ import org.mockito.Mock;
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.lisp.address.types.rev151105.Ipv4Afi;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv4Builder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.HmacKeyType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.Lisp;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.MappingId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.dp.subtable.grouping.LocalMappings;
@@ -52,6 +56,7 @@ 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.rev170315.eid.table.grouping.eid.table.VniTable;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.eid.table.grouping.eid.table.VniTableKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.eid.table.grouping.eid.table.vni.table.VrfSubtable;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.hmac.key.grouping.HmacKeyBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.lisp.feature.data.grouping.LispFeatureData;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
@@ -64,6 +69,7 @@ public class LocalMappingCustomizerTest extends WriterCustomizerTest implements
private InstanceIdentifier<LocalMapping> id;
private LocalMapping mapping;
+ private LocalMapping mappingWithHmacKey;
private LocalMappingCustomizer customizer;
@Override
@@ -82,6 +88,13 @@ public class LocalMappingCustomizerTest extends WriterCustomizerTest implements
.setLocatorSet("Locator")
.build();
+ mappingWithHmacKey = new LocalMappingBuilder(mapping)
+ .setHmacKey(new HmacKeyBuilder()
+ .setKey("abcd")
+ .setKeyType(HmacKeyType.Sha256128Key)
+ .build())
+ .build();
+
id = InstanceIdentifier.builder(Lisp.class)
.child(LispFeatureData.class)
.child(EidTable.class)
@@ -138,6 +151,25 @@ public class LocalMappingCustomizerTest extends WriterCustomizerTest implements
assertEquals("Locator", toString(request.locatorSetName));
}
+ @Test
+ public void testWriteCurrentAttributesWithHmacKey() throws WriteFailedException {
+ customizer.writeCurrentAttributes(id, mappingWithHmacKey, writeContext);
+
+ verify(api, times(1)).lispAddDelLocalEid(mappingCaptor.capture());
+
+ LispAddDelLocalEid request = mappingCaptor.getValue();
+
+ assertNotNull(request);
+ assertEquals("Locator", new String(request.locatorSetName));
+ assertEquals("192.168.2.1", arrayToIpv4AddressNoZone(request.eid).getValue());
+ assertEquals(0, request.eidType);
+ assertEquals(1, request.isAdd);
+ assertEquals(25, request.vni);
+ assertEquals("Locator", toString(request.locatorSetName));
+ assertTrue(Arrays.equals("abcd".getBytes(StandardCharsets.UTF_8), request.key));
+ assertEquals(HmacKeyType.Sha256128Key.getIntValue(), request.keyId);
+ }
+
@Test(expected = UnsupportedOperationException.class)
public void testUpdateCurrentAttributes() throws WriteFailedException {
customizer.updateCurrentAttributes(null, null, null, writeContext);
@@ -160,4 +192,24 @@ public class LocalMappingCustomizerTest extends WriterCustomizerTest implements
assertEquals(25, request.vni);
assertEquals("Locator", toString(request.locatorSetName));
}
+
+ @Test
+ public void testDeleteCurrentAttributesWithHmacKey() throws WriteFailedException, InterruptedException, ExecutionException {
+ when(eidMappingContext.containsEid(any(), eq(mappingContext))).thenReturn(true);
+ customizer.deleteCurrentAttributes(id, mappingWithHmacKey, writeContext);
+
+ verify(api, times(1)).lispAddDelLocalEid(mappingCaptor.capture());
+
+ LispAddDelLocalEid request = mappingCaptor.getValue();
+
+ assertNotNull(request);
+ assertEquals("Locator", new String(request.locatorSetName));
+ assertEquals("192.168.2.1", arrayToIpv4AddressNoZone(request.eid).getValue());
+ assertEquals(0, request.eidType);
+ assertEquals(0, request.isAdd);
+ assertEquals(25, request.vni);
+ assertEquals("Locator", toString(request.locatorSetName));
+ assertTrue(Arrays.equals("abcd".getBytes(StandardCharsets.UTF_8), request.key));
+ assertEquals(HmacKeyType.Sha256128Key.getIntValue(), request.keyId);
+ }
}
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/MapRegisterCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/MapRegisterCustomizerTest.java
new file mode 100644
index 000000000..0eb5d1148
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/MapRegisterCustomizerTest.java
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2017 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.hc2vpp.lisp.translate.write;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import io.fd.hc2vpp.common.test.write.WriterCustomizerTest;
+import io.fd.hc2vpp.common.translate.util.ByteDataTranslator;
+import io.fd.vpp.jvpp.core.dto.LispMapRegisterEnableDisable;
+import io.fd.vpp.jvpp.core.dto.LispMapRegisterEnableDisableReply;
+import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Captor;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.map.register.grouping.MapRegister;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.map.register.grouping.MapRegisterBuilder;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public class MapRegisterCustomizerTest extends WriterCustomizerTest implements ByteDataTranslator {
+
+ private static final InstanceIdentifier<MapRegister> ID = InstanceIdentifier.create(MapRegister.class);
+ private MapRegisterCustomizer customizer;
+ private MapRegister enabledRegister;
+ private MapRegister disabledRegister;
+
+ @Captor
+ private ArgumentCaptor<LispMapRegisterEnableDisable> requestCaptor;
+
+ @Override
+ protected void setUpTest() throws Exception {
+ customizer = new MapRegisterCustomizer(api);
+
+ enabledRegister = new MapRegisterBuilder()
+ .setEnabled(true)
+ .build();
+
+ disabledRegister = new MapRegisterBuilder()
+ .setEnabled(false)
+ .build();
+
+ when(api.lispMapRegisterEnableDisable(any(LispMapRegisterEnableDisable.class)))
+ .thenReturn(future(new LispMapRegisterEnableDisableReply()));
+ }
+
+ @Test
+ public void writeCurrentAttributes() throws Exception {
+ customizer.writeCurrentAttributes(ID, enabledRegister, writeContext);
+ verifyRequest(true);
+ }
+
+ @Test
+ public void updateCurrentAttributesToDisabled() throws Exception {
+ customizer.updateCurrentAttributes(ID, enabledRegister, disabledRegister, writeContext);
+ verifyRequest(false);
+ }
+
+ @Test
+ public void updateCurrentAttributesToEnabled() throws Exception {
+ customizer.updateCurrentAttributes(ID, disabledRegister, enabledRegister, writeContext);
+ verifyRequest(true);
+ }
+
+ @Test
+ public void deleteCurrentAttributes() throws Exception {
+ customizer.deleteCurrentAttributes(ID, disabledRegister, writeContext);
+ verifyRequest(false);
+ }
+
+ private void verifyRequest(final boolean enabled) {
+ verify(api, times(1)).lispMapRegisterEnableDisable(requestCaptor.capture());
+
+ final LispMapRegisterEnableDisable request = requestCaptor.getValue();
+ assertEquals(booleanToByte(enabled), request.isEnabled);
+ }
+} \ No newline at end of file
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/MapRequestModeCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/MapRequestModeCustomizerTest.java
new file mode 100644
index 000000000..d66097ad2
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/MapRequestModeCustomizerTest.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2017 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.hc2vpp.lisp.translate.write;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import static org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.MapRequestMode.DestinationOnly;
+import static org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.MapRequestMode.SourceDestination;
+
+import io.fd.hc2vpp.common.test.write.WriterCustomizerTest;
+import io.fd.vpp.jvpp.core.dto.LispMapRequestMode;
+import io.fd.vpp.jvpp.core.dto.LispMapRequestModeReply;
+import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Captor;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.map.request.mode.grouping.MapRequestMode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.map.request.mode.grouping.MapRequestModeBuilder;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public class MapRequestModeCustomizerTest extends WriterCustomizerTest {
+
+ private static final InstanceIdentifier<MapRequestMode> ID = InstanceIdentifier.create(MapRequestMode.class);
+ private MapRequestModeCustomizer customizer;
+ private MapRequestMode sourceDestinationMode;
+ private MapRequestMode destinationOnlyMode;
+
+ @Captor
+ private ArgumentCaptor<LispMapRequestMode> requestCaptor;
+
+ @Override
+ protected void setUpTest() throws Exception {
+ customizer = new MapRequestModeCustomizer(api);
+ sourceDestinationMode = new MapRequestModeBuilder()
+ .setMode(SourceDestination)
+ .build();
+ destinationOnlyMode = new MapRequestModeBuilder()
+ .setMode(DestinationOnly)
+ .build();
+ when(api.lispMapRequestMode(any(LispMapRequestMode.class))).thenReturn(future(new LispMapRequestModeReply()));
+ }
+
+ @Test
+ public void writeCurrentAttributes() throws Exception {
+ customizer.writeCurrentAttributes(ID, sourceDestinationMode, writeContext);
+ verifyModeRequest(SourceDestination);
+ }
+
+ @Test
+ public void updateCurrentAttributes() throws Exception {
+ customizer.updateCurrentAttributes(ID, sourceDestinationMode, destinationOnlyMode, writeContext);
+ verifyModeRequest(DestinationOnly);
+ }
+
+ @Test
+ public void deleteCurrentAttributes() throws Exception {
+ verify(api, times(0)).lispMapRequestMode(any());
+ }
+
+ private void verifyModeRequest(
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.MapRequestMode mode) {
+ verify(api, times(1)).lispMapRequestMode(requestCaptor.capture());
+
+ final LispMapRequestMode request = requestCaptor.getValue();
+ assertEquals(mode.getIntValue(), request.mode);
+ }
+} \ No newline at end of file
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/MapServerCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/MapServerCustomizerTest.java
new file mode 100644
index 000000000..b69a44e68
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/MapServerCustomizerTest.java
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2017 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.hc2vpp.lisp.translate.write;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import io.fd.hc2vpp.common.test.write.WriterCustomizerTest;
+import io.fd.hc2vpp.common.translate.util.ByteDataTranslator;
+import io.fd.honeycomb.translate.write.WriteFailedException;
+import io.fd.vpp.jvpp.core.dto.LispAddDelMapServer;
+import io.fd.vpp.jvpp.core.dto.LispAddDelMapServerReply;
+import java.util.Arrays;
+import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Captor;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.map.servers.grouping.MapServers;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.map.servers.grouping.map.servers.MapServer;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.map.servers.grouping.map.servers.MapServerBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.map.servers.grouping.map.servers.MapServerKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public class MapServerCustomizerTest extends WriterCustomizerTest implements ByteDataTranslator {
+
+ private static final MapServerKey MAP_SERVER_KEY = new MapServerKey(
+ new IpAddress(new Ipv4Address("192.168.2.1")));
+ private static final InstanceIdentifier<MapServer> ID = InstanceIdentifier.create(MapServers.class)
+ .child(MapServer.class, MAP_SERVER_KEY);
+
+ private MapServerCustomizer customizer;
+ private MapServer data;
+
+ @Captor
+ private ArgumentCaptor<LispAddDelMapServer> requestCaptor;
+
+ @Override
+ protected void setUpTest() throws Exception {
+ customizer = new MapServerCustomizer(api);
+ data = new MapServerBuilder()
+ .setIpAddress(MAP_SERVER_KEY.getIpAddress())
+ .build();
+ when(api.lispAddDelMapServer(any())).thenReturn(future(new LispAddDelMapServerReply()));
+ }
+
+ @Test
+ public void writeCurrentAttributes() throws Exception {
+ customizer.writeCurrentAttributes(ID, data, writeContext);
+ verifyRequest(true);
+ }
+
+
+ @Test
+ public void updateCurrentAttributes() throws Exception {
+ try {
+ customizer.updateCurrentAttributes(ID, data, data, writeContext);
+ } catch (WriteFailedException e) {
+ assertTrue(e instanceof WriteFailedException.UpdateFailedException);
+ assertTrue(e.getCause() instanceof UnsupportedOperationException);
+ verify(api, times(0)).lispAddDelMapServer(any());
+ }
+ }
+
+ @Test
+ public void deleteCurrentAttributes() throws Exception {
+ customizer.deleteCurrentAttributes(ID, data, writeContext);
+ verifyRequest(false);
+ }
+
+ private void verifyRequest(final boolean add) {
+ verify(api, times(1)).lispAddDelMapServer(requestCaptor.capture());
+
+ final LispAddDelMapServer request = requestCaptor.getValue();
+
+ assertEquals(booleanToByte(add), request.isAdd);
+ assertEquals(0, request.isIpv6);
+ assertTrue(Arrays.equals(new byte[]{-64, -88, 2, 1}, request.ipAddress));
+ }
+} \ No newline at end of file
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/PetrCfgCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/PetrCfgCustomizerTest.java
new file mode 100644
index 000000000..bd7475bb1
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/PetrCfgCustomizerTest.java
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2017 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.hc2vpp.lisp.translate.write;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import io.fd.hc2vpp.common.test.write.WriterCustomizerTest;
+import io.fd.vpp.jvpp.core.dto.LispUsePetr;
+import io.fd.vpp.jvpp.core.dto.LispUsePetrReply;
+import java.util.Arrays;
+import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Captor;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.use.petr.cfg.grouping.PetrCfg;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.use.petr.cfg.grouping.PetrCfgBuilder;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public class PetrCfgCustomizerTest extends WriterCustomizerTest {
+
+ private static final InstanceIdentifier<PetrCfg> ID = InstanceIdentifier.create(PetrCfg.class);
+
+ private PetrCfgCustomizer customizer;
+ private PetrCfg enabledCfg;
+ private PetrCfg disabledCfg;
+
+ @Captor
+ private ArgumentCaptor<LispUsePetr> requestCaptor;
+
+ @Override
+ public void setUpTest() throws Exception {
+ customizer = new PetrCfgCustomizer(api);
+ enabledCfg = new PetrCfgBuilder().setPetrAddress(new IpAddress(new Ipv4Address("192.168.2.1"))).build();
+ disabledCfg = new PetrCfgBuilder().build();
+ when(api.lispUsePetr(any(LispUsePetr.class))).thenReturn(future(new LispUsePetrReply()));
+ }
+
+ @Test
+ public void testWriteCurrentAttributes() throws Exception {
+ customizer.writeCurrentAttributes(ID, enabledCfg, writeContext);
+ verifyEnabledInvoked();
+ }
+
+ @Test
+ public void testUpdateCurrentAttributesToEnabled() throws Exception {
+ customizer.updateCurrentAttributes(ID, disabledCfg, enabledCfg, writeContext);
+ verifyEnabledInvoked();
+ }
+
+ @Test
+ public void testUpdateCurrentAttributesToDisabled() throws Exception {
+ customizer.updateCurrentAttributes(ID, enabledCfg, disabledCfg, writeContext);
+ verifyDisabledInvoked();
+ }
+
+ @Test
+ public void testDeleteCurrentAttributes() throws Exception {
+ customizer.deleteCurrentAttributes(ID, disabledCfg, writeContext);
+ verifyDisabledInvoked();
+ }
+
+ private void verifyEnabledInvoked() {
+ verify(api, times(1)).lispUsePetr(requestCaptor.capture());
+
+ final LispUsePetr cfg = requestCaptor.getValue();
+ assertEquals(1, cfg.isIp4);
+ assertTrue(Arrays.equals(new byte[]{-64, -88, 2, 1}, cfg.address));
+ assertEquals(1, cfg.isAdd);
+ }
+
+ private void verifyDisabledInvoked() {
+ verify(api, times(1)).lispUsePetr(requestCaptor.capture());
+
+ final LispUsePetr cfg = requestCaptor.getValue();
+ assertNull(cfg.address);
+ assertEquals(0, cfg.isAdd);
+ }
+} \ No newline at end of file
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/RlocProbeCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/RlocProbeCustomizerTest.java
new file mode 100644
index 000000000..829853e66
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/RlocProbeCustomizerTest.java
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2017 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.hc2vpp.lisp.translate.write;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import io.fd.hc2vpp.common.test.write.WriterCustomizerTest;
+import io.fd.hc2vpp.common.translate.util.ByteDataTranslator;
+import io.fd.vpp.jvpp.core.dto.LispRlocProbeEnableDisable;
+import io.fd.vpp.jvpp.core.dto.LispRlocProbeEnableDisableReply;
+import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Captor;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.rloc.probing.grouping.RlocProbe;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.rloc.probing.grouping.RlocProbeBuilder;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public class RlocProbeCustomizerTest extends WriterCustomizerTest implements ByteDataTranslator {
+
+ private static final InstanceIdentifier<RlocProbe> ID = InstanceIdentifier.create(RlocProbe.class);
+ private RlocProbeCustomizer customizer;
+ private RlocProbe enabledProbe;
+ private RlocProbe disabledProbe;
+
+ @Captor
+ private ArgumentCaptor<LispRlocProbeEnableDisable> requestCaptor;
+
+ @Override
+ protected void setUpTest() throws Exception {
+ customizer = new RlocProbeCustomizer(api);
+ enabledProbe = rlocProbe(true);
+ disabledProbe = rlocProbe(false);
+ when(api.lispRlocProbeEnableDisable(any(LispRlocProbeEnableDisable.class)))
+ .thenReturn(future(new LispRlocProbeEnableDisableReply()));
+ }
+
+ @Test
+ public void testWriteCurrentAttributes() throws Exception {
+ customizer.writeCurrentAttributes(ID, enabledProbe, writeContext);
+ verifyRequest(true);
+ }
+
+ @Test
+ public void testUpdateCurrentAttributesToDisabled() throws Exception {
+ customizer.updateCurrentAttributes(ID, enabledProbe, disabledProbe, writeContext);
+ verifyRequest(false);
+ }
+
+ @Test
+ public void testUpdateCurrentAttributesToEnabled() throws Exception {
+ customizer.updateCurrentAttributes(ID, disabledProbe, enabledProbe, writeContext);
+ verifyRequest(true);
+ }
+
+ @Test
+ public void testDeleteCurrentAttributes() throws Exception {
+ customizer.deleteCurrentAttributes(ID, disabledProbe, writeContext);
+ verifyRequest(false);
+ }
+
+ private static RlocProbe rlocProbe(final boolean enabled) {
+ return new RlocProbeBuilder().setEnabled(enabled).build();
+ }
+
+ private void verifyRequest(final boolean enabled) {
+ verify(api, times(1)).lispRlocProbeEnableDisable(requestCaptor.capture());
+ final LispRlocProbeEnableDisable request = requestCaptor.getValue();
+ assertEquals(booleanToByte(enabled), request.isEnabled);
+ }
+} \ No newline at end of file