summaryrefslogtreecommitdiffstats
path: root/lisp/lisp2vpp/src/test/java
diff options
context:
space:
mode:
authorJan Srnicek <jsrnicek@cisco.com>2017-03-22 10:35:49 +0100
committerJan Srnicek <jsrnicek@cisco.com>2017-03-22 11:03:13 +0000
commitd474f0648427615a70c81f40d4bfdd2ec8c76b74 (patch)
tree22a59520ae9f9a27ad8013229900085a86ff3138 /lisp/lisp2vpp/src/test/java
parent00046200da55e56e62d03d39248a75b0e4c49bd6 (diff)
HC2VPP-115 - lisp state check before write/read
- checks lisp state before read,disabled state will result in returning empty data - checks lisp state before write,disabled state will result in throwing IllegalStateException - fixes ordering issues for lisp gpe interfaces Change-Id: I6dcfc6c7f514aad57841f2aac1b2ee0c6b868c3c Signed-off-by: Jan Srnicek <jsrnicek@cisco.com>
Diffstat (limited to 'lisp/lisp2vpp/src/test/java')
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/ItrRemoteLocatorSetCustomizerTest.java6
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/LispInitializingListReaderCustomizerTest.java70
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/LispInitializingReaderCustomizerTest.java59
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/LocatorSetCustomizerTest.java26
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/MapRegisterCustomizerTest.java6
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/MapRequestModeCustomizerTest.java8
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/MapResolverCustomizerTest.java6
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/MapServerCustomizerTest.java6
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/PetrCfgCustomizerTest.java10
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/PitrCfgCustomizerTest.java9
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/RlocProbeCustomizerTest.java6
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/VniTableCustomizerTest.java6
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/service/LispStateCheckServiceImplTest.java93
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/ItrRemoteLocatorSetCustomizerTest.java5
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/LispWriterCustomizerTest.java38
-rwxr-xr-xlisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/LocatorSetCustomizerTest.java34
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/MapRegisterCustomizerTest.java47
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/MapRequestModeCustomizerTest.java34
-rwxr-xr-xlisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/MapResolverCustomizerTest.java33
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/MapServerCustomizerTest.java33
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/PetrCfgCustomizerTest.java46
-rwxr-xr-xlisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/PitrCfgCustomizerTest.java46
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/RlocProbeCustomizerTest.java46
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/VniTableCustomizerTest.java32
24 files changed, 628 insertions, 77 deletions
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/ItrRemoteLocatorSetCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/ItrRemoteLocatorSetCustomizerTest.java
index 77cb77808..1ae56ac49 100644
--- a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/ItrRemoteLocatorSetCustomizerTest.java
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/ItrRemoteLocatorSetCustomizerTest.java
@@ -28,7 +28,6 @@ import static org.mockito.Mockito.when;
import io.fd.honeycomb.translate.read.ReadFailedException;
import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
-import io.fd.hc2vpp.common.test.read.ReaderCustomizerTest;
import io.fd.vpp.jvpp.VppCallbackException;
import io.fd.vpp.jvpp.core.dto.LispGetMapRequestItrRlocs;
import io.fd.vpp.jvpp.core.dto.LispGetMapRequestItrRlocsReply;
@@ -46,7 +45,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
public class ItrRemoteLocatorSetCustomizerTest
- extends ReaderCustomizerTest<ItrRemoteLocatorSet, ItrRemoteLocatorSetBuilder> {
+ extends LispInitializingReaderCustomizerTest<ItrRemoteLocatorSet, ItrRemoteLocatorSetBuilder> {
private static final String EXPECTED_LOCATOR_SET_NAME = "loc-set";
@@ -61,11 +60,12 @@ public class ItrRemoteLocatorSetCustomizerTest
public void setUp() throws Exception {
validId = InstanceIdentifier.create(ItrRemoteLocatorSet.class);
builder = new ItrRemoteLocatorSetBuilder();
+ mockLispEnabled();
}
@Override
protected ReaderCustomizer<ItrRemoteLocatorSet, ItrRemoteLocatorSetBuilder> initCustomizer() {
- return new ItrRemoteLocatorSetCustomizer(api);
+ return new ItrRemoteLocatorSetCustomizer(api, lispStateCheckService);
}
@Test
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/LispInitializingListReaderCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/LispInitializingListReaderCustomizerTest.java
new file mode 100644
index 000000000..b1af21fca
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/LispInitializingListReaderCustomizerTest.java
@@ -0,0 +1,70 @@
+/*
+ * 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.read;
+
+import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.when;
+
+import io.fd.hc2vpp.common.test.read.InitializingListReaderCustomizerTest;
+import io.fd.hc2vpp.lisp.translate.service.LispStateCheckService;
+import io.fd.honeycomb.translate.read.ReadContext;
+import io.fd.honeycomb.translate.read.ReadFailedException;
+import java.util.List;
+import java.util.Objects;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.opendaylight.yangtools.concepts.Builder;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.Identifiable;
+import org.opendaylight.yangtools.yang.binding.Identifier;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public abstract class LispInitializingListReaderCustomizerTest<D extends DataObject & Identifiable<K>, K extends Identifier<D>, B extends Builder<D>>
+ extends InitializingListReaderCustomizerTest<D, K, B> {
+
+ @Mock
+ protected LispStateCheckService lispStateCheckService;
+
+ protected LispInitializingListReaderCustomizerTest(final Class<D> dataObjectClass,
+ final Class<? extends Builder<? extends DataObject>> parentBuilderClass) {
+ super(dataObjectClass, parentBuilderClass);
+ }
+
+ protected void mockLispEnabled() {
+ when(lispStateCheckService.lispEnabled(any(ReadContext.class))).thenReturn(true);
+ }
+
+ @Test
+ public void testNoInteractionsWhenLispDisabledOnReadSpecific() throws ReadFailedException {
+ when(lispStateCheckService.lispEnabled(any(ReadContext.class))).thenReturn(false);
+ final InstanceIdentifier<D> identifier = InstanceIdentifier.create(dataObjectClass);
+ final B builderTouched = getCustomizer().getBuilder(identifier);
+ final B builderUntouched = getCustomizer().getBuilder(identifier);
+ getCustomizer().readCurrentAttributes(identifier, builderTouched, ctx);
+ assertTrue("No interactions with builder expected while lisp is disabled",
+ Objects.equals(builderTouched.build(), builderUntouched.build()));
+ }
+
+ @Test
+ public void testNoInteractionsWhenLispDisabledOnReadAll() throws ReadFailedException {
+ when(lispStateCheckService.lispEnabled(any(ReadContext.class))).thenReturn(false);
+ final InstanceIdentifier<D> identifier = InstanceIdentifier.create(dataObjectClass);
+ final List<K> allIds = getCustomizer().getAllIds(identifier, ctx);
+ assertTrue("No ids should be returned while lisp is disabled", allIds.isEmpty());
+ }
+}
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/LispInitializingReaderCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/LispInitializingReaderCustomizerTest.java
new file mode 100644
index 000000000..a686a86d3
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/LispInitializingReaderCustomizerTest.java
@@ -0,0 +1,59 @@
+/*
+ * 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.read;
+
+import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.when;
+
+import io.fd.hc2vpp.common.test.read.InitializingReaderCustomizerTest;
+import io.fd.hc2vpp.lisp.translate.service.LispStateCheckService;
+import io.fd.honeycomb.translate.read.ReadContext;
+import io.fd.honeycomb.translate.read.ReadFailedException;
+import java.util.Objects;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.opendaylight.yangtools.concepts.Builder;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public abstract class LispInitializingReaderCustomizerTest<D extends DataObject, B extends Builder<D>> extends
+ InitializingReaderCustomizerTest<D, B> {
+
+ @Mock
+ protected LispStateCheckService lispStateCheckService;
+
+ public LispInitializingReaderCustomizerTest(final Class<D> dataObjectClass,
+ final Class<? extends Builder<? extends DataObject>> parentBuilderClass) {
+ super(dataObjectClass, parentBuilderClass);
+ }
+
+ protected void mockLispEnabled() {
+ when(lispStateCheckService.lispEnabled(any(ReadContext.class))).thenReturn(true);
+ }
+
+ @Test
+ public void testNoInteractionsWhileLispDisabled() throws ReadFailedException {
+ when(lispStateCheckService.lispEnabled(any(ReadContext.class))).thenReturn(false);
+ final InstanceIdentifier<D> identifier = InstanceIdentifier.create(dataObjectClass);
+ final B builderTouched = getCustomizer().getBuilder(identifier);
+ final B builderUntouched = getCustomizer().getBuilder(identifier);
+ getCustomizer().readCurrentAttributes(identifier, builderTouched, ctx);
+ assertTrue("No interactions with builder expected while lisp is disabled",
+ Objects.equals(builderTouched.build(), builderUntouched.build()));
+ }
+}
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/LocatorSetCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/LocatorSetCustomizerTest.java
index b6773d2b2..82c4ceff2 100644
--- a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/LocatorSetCustomizerTest.java
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/LocatorSetCustomizerTest.java
@@ -16,21 +16,23 @@
package io.fd.hc2vpp.lisp.translate.read;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.when;
+
import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableSet;
-import io.fd.hc2vpp.common.test.read.InitializingListReaderCustomizerTest;
import io.fd.hc2vpp.common.translate.util.NamingContext;
import io.fd.honeycomb.test.tools.HoneycombTestRunner;
import io.fd.honeycomb.test.tools.annotations.InjectTestData;
-import io.fd.honeycomb.test.tools.annotations.InjectablesProcessor;
-import io.fd.honeycomb.test.tools.annotations.SchemaContextProvider;
import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
import io.fd.vpp.jvpp.core.dto.LispLocatorSetDetails;
import io.fd.vpp.jvpp.core.dto.LispLocatorSetDetailsReplyDump;
+import java.nio.charset.StandardCharsets;
+import java.util.List;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.$YangModuleInfoImpl;
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.LispState;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.lisp.feature.data.grouping.LispFeatureData;
@@ -39,21 +41,12 @@ 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.locator.sets.grouping.locator.sets.LocatorSet;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.locator.sets.grouping.locator.sets.LocatorSetBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.locator.sets.grouping.locator.sets.LocatorSetKey;
-import org.opendaylight.yangtools.sal.binding.generator.impl.ModuleInfoBackedContext;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
-import java.nio.charset.StandardCharsets;
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.when;
-
@RunWith(HoneycombTestRunner.class)
public class LocatorSetCustomizerTest
- extends InitializingListReaderCustomizerTest<LocatorSet, LocatorSetKey, LocatorSetBuilder>
+ extends LispInitializingListReaderCustomizerTest<LocatorSet, LocatorSetKey, LocatorSetBuilder>
implements LispInitTest {
private static final String LOC_1_PATH = "/lisp:lisp-state" +
@@ -74,6 +67,7 @@ public class LocatorSetCustomizerTest
defineDumpData();
defineMapping(mappingContext, "loc-set", 1, "locator-set-context");
+ mockLispEnabled();
}
private void defineDumpData() {
@@ -125,6 +119,6 @@ public class LocatorSetCustomizerTest
@Override
protected ReaderCustomizer<LocatorSet, LocatorSetBuilder> initCustomizer() {
- return new LocatorSetCustomizer(api, new NamingContext("loc", "locator-set-context"));
+ return new LocatorSetCustomizer(api, new NamingContext("loc", "locator-set-context"), lispStateCheckService);
}
} \ No newline at end of file
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/MapRegisterCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/MapRegisterCustomizerTest.java
index 9dc1913c5..1b582cd4d 100644
--- a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/MapRegisterCustomizerTest.java
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/MapRegisterCustomizerTest.java
@@ -20,7 +20,6 @@ import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
-import io.fd.hc2vpp.common.test.read.InitializingReaderCustomizerTest;
import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
import io.fd.vpp.jvpp.core.dto.ShowLispMapRegisterStateReply;
import org.junit.Before;
@@ -30,7 +29,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.map.register.grouping.MapRegisterBuilder;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-public class MapRegisterCustomizerTest extends InitializingReaderCustomizerTest implements LispInitTest {
+public class MapRegisterCustomizerTest extends LispInitializingReaderCustomizerTest implements LispInitTest {
private static final InstanceIdentifier<MapRegister> STATE_IID = LISP_STATE_FTR_IID.child(MapRegister.class);
private static final InstanceIdentifier<MapRegister> CONFIG_IID = LISP_FTR_IID.child(MapRegister.class);
@@ -44,6 +43,7 @@ public class MapRegisterCustomizerTest extends InitializingReaderCustomizerTest
final ShowLispMapRegisterStateReply reply = new ShowLispMapRegisterStateReply();
reply.isEnabled = 1;
when(api.showLispMapRegisterState(any())).thenReturn(future(reply));
+ mockLispEnabled();
}
@Test
@@ -61,6 +61,6 @@ public class MapRegisterCustomizerTest extends InitializingReaderCustomizerTest
@Override
protected ReaderCustomizer initCustomizer() {
- return new MapRegisterCustomizer(api);
+ return new MapRegisterCustomizer(api, lispStateCheckService);
}
} \ No newline at end of file
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/MapRequestModeCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/MapRequestModeCustomizerTest.java
index 85e6231f0..6479f992a 100644
--- a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/MapRequestModeCustomizerTest.java
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/MapRequestModeCustomizerTest.java
@@ -21,19 +21,16 @@ import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
import static org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.MapRequestMode.DestinationOnly;
-import io.fd.hc2vpp.common.test.read.InitializingReaderCustomizerTest;
-import io.fd.honeycomb.test.tools.HoneycombTestRunner;
import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
import io.fd.vpp.jvpp.core.dto.ShowLispMapRequestModeReply;
import org.junit.Before;
import org.junit.Test;
-import org.junit.runner.RunWith;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.lisp.feature.data.grouping.LispFeatureDataBuilder;
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 InitializingReaderCustomizerTest implements LispInitTest {
+public class MapRequestModeCustomizerTest extends LispInitializingReaderCustomizerTest implements LispInitTest {
private static final InstanceIdentifier<MapRequestMode> STATE_IID = LISP_STATE_FTR_IID.child(MapRequestMode.class);
private static final InstanceIdentifier<MapRequestMode> CONFIG_IID = LISP_FTR_IID.child(MapRequestMode.class);
@@ -47,6 +44,7 @@ public class MapRequestModeCustomizerTest extends InitializingReaderCustomizerTe
final ShowLispMapRequestModeReply reply = new ShowLispMapRequestModeReply();
reply.mode = ((byte) DestinationOnly.getIntValue());
when(api.showLispMapRequestMode(any())).thenReturn(future(reply));
+ mockLispEnabled();
}
@Test
@@ -64,6 +62,6 @@ public class MapRequestModeCustomizerTest extends InitializingReaderCustomizerTe
@Override
protected ReaderCustomizer initCustomizer() {
- return new MapRequestModeCustomizer(api);
+ return new MapRequestModeCustomizer(api, lispStateCheckService);
}
} \ No newline at end of file
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/MapResolverCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/MapResolverCustomizerTest.java
index 5d0be3705..e4a0d9990 100644
--- a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/MapResolverCustomizerTest.java
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/MapResolverCustomizerTest.java
@@ -23,7 +23,6 @@ import static org.mockito.Mockito.when;
import com.google.common.collect.ImmutableList;
import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
-import io.fd.hc2vpp.common.test.read.ListReaderCustomizerTest;
import io.fd.vpp.jvpp.core.dto.LispMapResolverDetails;
import io.fd.vpp.jvpp.core.dto.LispMapResolverDetailsReplyDump;
import java.util.List;
@@ -40,7 +39,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
public class MapResolverCustomizerTest
- extends ListReaderCustomizerTest<MapResolver, MapResolverKey, MapResolverBuilder> {
+ extends LispInitializingListReaderCustomizerTest<MapResolver, MapResolverKey, MapResolverBuilder> {
private static final IpAddress IP_ADDRESS_REVERTED =
new IpAddress(new Ipv4AddressNoZone("1.2.168.192"));
@@ -59,6 +58,7 @@ public class MapResolverCustomizerTest
validId = InstanceIdentifier.create(MapResolvers.class)
.child(MapResolver.class, new MapResolverKey(IP_ADDRESS_REVERTED));
defineDumpData();
+ mockLispEnabled();
}
@Test
@@ -97,6 +97,6 @@ public class MapResolverCustomizerTest
@Override
protected ReaderCustomizer<MapResolver, MapResolverBuilder> initCustomizer() {
- return new MapResolverCustomizer(api);
+ return new MapResolverCustomizer(api, lispStateCheckService);
}
} \ No newline at end of file
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/MapServerCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/MapServerCustomizerTest.java
index 1af22931e..ace07e078 100644
--- a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/MapServerCustomizerTest.java
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/MapServerCustomizerTest.java
@@ -23,7 +23,6 @@ import static org.junit.Assert.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
-import io.fd.hc2vpp.common.test.read.InitializingListReaderCustomizerTest;
import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
import io.fd.vpp.jvpp.core.dto.LispMapServerDetails;
import io.fd.vpp.jvpp.core.dto.LispMapServerDetailsReplyDump;
@@ -44,7 +43,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
public class MapServerCustomizerTest
- extends InitializingListReaderCustomizerTest<MapServer, MapServerKey, MapServerBuilder>
+ extends LispInitializingListReaderCustomizerTest<MapServer, MapServerKey, MapServerBuilder>
implements LispInitTest {
private static final MapServerKey
@@ -79,6 +78,7 @@ public class MapServerCustomizerTest
reply.lispMapServerDetails = Arrays.asList(server1, server2, server3);
when(api.lispMapServerDump(any(LispMapServerDump.class))).thenReturn(future(reply));
+ mockLispEnabled();
}
@Test
@@ -107,6 +107,6 @@ public class MapServerCustomizerTest
@Override
protected ReaderCustomizer<MapServer, MapServerBuilder> initCustomizer() {
- return new MapServerCustomizer(api);
+ return new MapServerCustomizer(api, lispStateCheckService);
}
} \ No newline at end of file
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/PetrCfgCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/PetrCfgCustomizerTest.java
index 107523292..4052b161f 100644
--- a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/PetrCfgCustomizerTest.java
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/PetrCfgCustomizerTest.java
@@ -21,7 +21,6 @@ import static org.junit.Assert.assertNull;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
-import io.fd.hc2vpp.common.test.read.InitializingReaderCustomizerTest;
import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
import io.fd.vpp.jvpp.core.dto.ShowLispUsePetrReply;
import org.junit.Test;
@@ -32,7 +31,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.use.petr.cfg.grouping.PetrCfgBuilder;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-public class PetrCfgCustomizerTest extends InitializingReaderCustomizerTest implements LispInitTest {
+public class PetrCfgCustomizerTest extends LispInitializingReaderCustomizerTest implements LispInitTest {
private static final InstanceIdentifier<PetrCfg> STATE_IID = LISP_STATE_FTR_IID.child(PetrCfg.class);
private static final InstanceIdentifier<PetrCfg> CONFIG_IID = LISP_FTR_IID.child(PetrCfg.class);
@@ -54,6 +53,11 @@ public class PetrCfgCustomizerTest extends InitializingReaderCustomizerTest impl
when(api.showLispUsePetr(any())).thenReturn(future(reply));
}
+ @Override
+ protected void setUp() throws Exception {
+ mockLispEnabled();
+ }
+
@Test
public void readCurrentAttributesEnabled() throws Exception {
mockEnabledReply();
@@ -79,6 +83,6 @@ public class PetrCfgCustomizerTest extends InitializingReaderCustomizerTest impl
@Override
protected ReaderCustomizer initCustomizer() {
- return new PetrCfgCustomizer(api);
+ return new PetrCfgCustomizer(api, lispStateCheckService);
}
} \ No newline at end of file
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/PitrCfgCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/PitrCfgCustomizerTest.java
index c1ffc17ea..c61c13b49 100644
--- a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/PitrCfgCustomizerTest.java
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/PitrCfgCustomizerTest.java
@@ -22,19 +22,17 @@ import static org.mockito.Matchers.any;
import static org.mockito.Mockito.when;
import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
-import io.fd.hc2vpp.common.test.read.ReaderCustomizerTest;
+import io.fd.vpp.jvpp.core.dto.ShowLispPitrReply;
import java.nio.charset.StandardCharsets;
import org.junit.Before;
import org.junit.Test;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.LispStateBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.lisp.feature.data.grouping.LispFeatureDataBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.pitr.cfg.grouping.PitrCfg;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.pitr.cfg.grouping.PitrCfgBuilder;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import io.fd.vpp.jvpp.core.dto.ShowLispPitrReply;
-public class PitrCfgCustomizerTest extends ReaderCustomizerTest<PitrCfg, PitrCfgBuilder> {
+public class PitrCfgCustomizerTest extends LispInitializingReaderCustomizerTest<PitrCfg, PitrCfgBuilder> {
private static final byte[] LOC_SET_NAME_BYTES = "loc-set".getBytes(StandardCharsets.UTF_8);
@@ -49,6 +47,7 @@ public class PitrCfgCustomizerTest extends ReaderCustomizerTest<PitrCfg, PitrCfg
emptyId = InstanceIdentifier.create(PitrCfg.class);
mockDumpData();
+ mockLispEnabled();
}
@Test
@@ -72,6 +71,6 @@ public class PitrCfgCustomizerTest extends ReaderCustomizerTest<PitrCfg, PitrCfg
@Override
protected ReaderCustomizer<PitrCfg, PitrCfgBuilder> initCustomizer() {
- return new PitrCfgCustomizer(api);
+ return new PitrCfgCustomizer(api, lispStateCheckService);
}
} \ No newline at end of file
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/RlocProbeCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/RlocProbeCustomizerTest.java
index f5d235358..2afe7120f 100644
--- a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/RlocProbeCustomizerTest.java
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/RlocProbeCustomizerTest.java
@@ -20,7 +20,6 @@ import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
-import io.fd.hc2vpp.common.test.read.InitializingReaderCustomizerTest;
import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
import io.fd.vpp.jvpp.core.dto.ShowLispRlocProbeStateReply;
import org.junit.Before;
@@ -30,7 +29,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.rloc.probing.grouping.RlocProbeBuilder;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-public class RlocProbeCustomizerTest extends InitializingReaderCustomizerTest implements LispInitTest {
+public class RlocProbeCustomizerTest extends LispInitializingReaderCustomizerTest implements LispInitTest {
private static final InstanceIdentifier<RlocProbe> STATE_IID = LISP_STATE_FTR_IID.child(RlocProbe.class);
private static final InstanceIdentifier<RlocProbe> CONFIG_IID = LISP_FTR_IID.child(RlocProbe.class);
@@ -44,6 +43,7 @@ public class RlocProbeCustomizerTest extends InitializingReaderCustomizerTest im
final ShowLispRlocProbeStateReply reply = new ShowLispRlocProbeStateReply();
reply.isEnabled = 1;
when(api.showLispRlocProbeState(any())).thenReturn(future(reply));
+ mockLispEnabled();
}
@Test
@@ -62,6 +62,6 @@ public class RlocProbeCustomizerTest extends InitializingReaderCustomizerTest im
@Override
protected ReaderCustomizer initCustomizer() {
- return new RlocProbeCustomizer(api);
+ return new RlocProbeCustomizer(api, lispStateCheckService);
}
} \ No newline at end of file
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/VniTableCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/VniTableCustomizerTest.java
index c25906e9c..f9610a1aa 100644
--- a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/VniTableCustomizerTest.java
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/VniTableCustomizerTest.java
@@ -26,7 +26,6 @@ import static org.mockito.Mockito.when;
import com.google.common.collect.ImmutableList;
import io.fd.honeycomb.translate.read.ReadFailedException;
import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
-import io.fd.hc2vpp.common.test.read.ListReaderCustomizerTest;
import io.fd.vpp.jvpp.VppCallbackException;
import io.fd.vpp.jvpp.core.dto.LispEidTableVniDetails;
import io.fd.vpp.jvpp.core.dto.LispEidTableVniDetailsReplyDump;
@@ -42,7 +41,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.VniTableKey;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-public class VniTableCustomizerTest extends ListReaderCustomizerTest<VniTable, VniTableKey, VniTableBuilder> {
+public class VniTableCustomizerTest extends LispInitializingListReaderCustomizerTest<VniTable, VniTableKey, VniTableBuilder> {
private InstanceIdentifier<VniTable> validId;
@@ -53,6 +52,7 @@ public class VniTableCustomizerTest extends ListReaderCustomizerTest<VniTable, V
@Before
public void init() {
validId = InstanceIdentifier.create(EidTable.class).child(VniTable.class, new VniTableKey(12L));
+ mockLispEnabled();
}
@Test
@@ -116,6 +116,6 @@ public class VniTableCustomizerTest extends ListReaderCustomizerTest<VniTable, V
@Override
protected ReaderCustomizer<VniTable, VniTableBuilder> initCustomizer() {
- return new VniTableCustomizer(api);
+ return new VniTableCustomizer(api, lispStateCheckService);
}
} \ No newline at end of file
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/service/LispStateCheckServiceImplTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/service/LispStateCheckServiceImplTest.java
new file mode 100644
index 000000000..d5a351ca8
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/service/LispStateCheckServiceImplTest.java
@@ -0,0 +1,93 @@
+/*
+ * 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.service;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.when;
+import static org.mockito.MockitoAnnotations.initMocks;
+
+import com.google.common.base.Optional;
+import io.fd.hc2vpp.common.test.util.FutureProducer;
+import io.fd.honeycomb.translate.ModificationCache;
+import io.fd.honeycomb.translate.read.ReadContext;
+import io.fd.honeycomb.translate.write.WriteContext;
+import io.fd.vpp.jvpp.core.dto.ShowLispStatusReply;
+import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+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.LispBuilder;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public class LispStateCheckServiceImplTest implements FutureProducer {
+
+ private LispStateCheckService impl;
+
+ @Mock
+ private FutureJVppCore vppApi;
+
+ @Mock
+ private WriteContext writeContext;
+
+ @Mock
+ private ReadContext readContext;
+
+ @Before
+ public void init() {
+ initMocks(this);
+ impl = new LispStateCheckServiceImpl(vppApi);
+ when(readContext.getModificationCache()).thenReturn(new ModificationCache());
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testCheckLispEnabledNoConfig() throws Exception {
+ when(writeContext.readAfter(InstanceIdentifier.create(Lisp.class))).thenReturn(Optional.absent());
+ impl.checkLispEnabled(writeContext);
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testCheckLispEnabledDisabledConfig() throws Exception {
+ when(writeContext.readAfter(InstanceIdentifier.create(Lisp.class)))
+ .thenReturn(Optional.of(new LispBuilder().setEnable(false).build()));
+ impl.checkLispEnabled(writeContext);
+ }
+
+ @Test
+ public void testCheckLispEnabledEnabledConfig() throws Exception {
+ // no exception should be thrown here
+ when(writeContext.readAfter(InstanceIdentifier.create(Lisp.class)))
+ .thenReturn(Optional.of(new LispBuilder().setEnable(true).build()));
+ impl.checkLispEnabled(writeContext);
+ }
+
+ @Test
+ public void testLispEnabledDisabledDump() throws Exception {
+ when(vppApi.showLispStatus(any())).thenReturn(future(new ShowLispStatusReply()));
+ assertFalse(impl.lispEnabled(readContext));
+ }
+
+ @Test
+ public void testLispEnabledEnabledDump() throws Exception {
+ final ShowLispStatusReply reply = new ShowLispStatusReply();
+ reply.featureStatus = 1;
+ when(vppApi.showLispStatus(any())).thenReturn(future(reply));
+ assertTrue(impl.lispEnabled(readContext));
+ }
+} \ No newline at end of file
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/ItrRemoteLocatorSetCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/ItrRemoteLocatorSetCustomizerTest.java
index 22d1298a7..e11ec4262 100644
--- a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/ItrRemoteLocatorSetCustomizerTest.java
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/ItrRemoteLocatorSetCustomizerTest.java
@@ -26,7 +26,6 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
-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.VppCallbackException;
@@ -44,7 +43,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.itr.remote.locator.sets.grouping.ItrRemoteLocatorSetBuilder;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-public class ItrRemoteLocatorSetCustomizerTest extends WriterCustomizerTest implements ByteDataTranslator {
+public class ItrRemoteLocatorSetCustomizerTest extends LispWriterCustomizerTest implements ByteDataTranslator {
private static final String VALID_NAME = "loc-set";
@@ -58,7 +57,7 @@ public class ItrRemoteLocatorSetCustomizerTest extends WriterCustomizerTest impl
@Before
public void setUpTest() throws Exception {
initMocks(this);
- customizer = new ItrRemoteLocatorSetCustomizer(api);
+ customizer = new ItrRemoteLocatorSetCustomizer(api, lispStateCheckService);
validId = InstanceIdentifier.create(ItrRemoteLocatorSet.class);
validData = new ItrRemoteLocatorSetBuilder().setRemoteLocatorSetName(VALID_NAME).build();
}
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/LispWriterCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/LispWriterCustomizerTest.java
new file mode 100644
index 000000000..a2d772159
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/LispWriterCustomizerTest.java
@@ -0,0 +1,38 @@
+/*
+ * 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.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.doThrow;
+
+import io.fd.hc2vpp.common.test.write.WriterCustomizerTest;
+import io.fd.hc2vpp.lisp.translate.service.LispStateCheckService;
+import io.fd.honeycomb.translate.write.WriteContext;
+import org.mockito.Mock;
+
+public abstract class LispWriterCustomizerTest extends WriterCustomizerTest{
+
+ @Mock
+ protected LispStateCheckService lispStateCheckService;
+
+ protected void mockLispDisabled(){
+ doThrow(IllegalArgumentException.class)
+ .when(lispStateCheckService).checkLispEnabled(any(WriteContext.class));
+ }
+
+
+}
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/LocatorSetCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/LocatorSetCustomizerTest.java
index 65544903b..50cba9dd5 100755
--- a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/LocatorSetCustomizerTest.java
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/LocatorSetCustomizerTest.java
@@ -24,11 +24,11 @@ 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.verifyZeroInteractions;
import static org.mockito.Mockito.when;
import com.google.common.base.Optional;
import com.google.common.collect.ImmutableList;
-import io.fd.hc2vpp.common.test.write.WriterCustomizerTest;
import io.fd.hc2vpp.common.translate.util.NamingContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
import io.fd.vpp.jvpp.core.dto.LispAddDelLocatorSet;
@@ -55,7 +55,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.locator.sets.grouping.locator.sets.locator.set.InterfaceBuilder;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-public class LocatorSetCustomizerTest extends WriterCustomizerTest {
+public class LocatorSetCustomizerTest extends LispWriterCustomizerTest {
private static final InstanceIdentifier<EidTable>
EID_TABLE_ID = InstanceIdentifier.create(Lisp.class)
@@ -68,9 +68,13 @@ public class LocatorSetCustomizerTest extends WriterCustomizerTest {
private LocatorSetCustomizer customizer;
+ private final InstanceIdentifier<LocatorSet> EMPTY_ID = InstanceIdentifier.create(LocatorSet.class);
+ private final LocatorSet EMPTY_DATA = new LocatorSetBuilder().build();
+
@Override
public void setUpTest() {
- customizer = new LocatorSetCustomizer(api, new NamingContext("locator-set", "locator-set-context"));
+ customizer = new LocatorSetCustomizer(api, new NamingContext("locator-set", "locator-set-context"),
+ lispStateCheckService);
}
@Test(expected = NullPointerException.class)
@@ -197,6 +201,30 @@ public class LocatorSetCustomizerTest extends WriterCustomizerTest {
fail("testDeleteReferenced should have failed");
}
+ @Test
+ public void testWriteLispDisabled() throws WriteFailedException {
+ mockLispDisabled();
+ try {
+ customizer.writeCurrentAttributes(EMPTY_ID, EMPTY_DATA, writeContext);
+ } catch (IllegalArgumentException e) {
+ verifyZeroInteractions(api);
+ return;
+ }
+ fail("Test should have thrown IllegalArgumentException");
+ }
+
+ @Test
+ public void testDeleteLispDisabled() throws WriteFailedException {
+ mockLispDisabled();
+ try {
+ customizer.deleteCurrentAttributes(EMPTY_ID, EMPTY_DATA, writeContext);
+ } catch (IllegalArgumentException e) {
+ verifyZeroInteractions(api);
+ return;
+ }
+ fail("Test should have thrown IllegalArgumentException");
+ }
+
private static Optional<EidTable> eidTableData() {
return Optional.of(new EidTableBuilder()
.setVniTable(
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
index 0eb5d1148..30ab07cb8 100644
--- 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
@@ -17,13 +17,15 @@
package io.fd.hc2vpp.lisp.translate.write;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
import static org.mockito.ArgumentMatchers.any;
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.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.LispMapRegisterEnableDisable;
import io.fd.vpp.jvpp.core.dto.LispMapRegisterEnableDisableReply;
import org.junit.Test;
@@ -33,7 +35,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.map.register.grouping.MapRegisterBuilder;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-public class MapRegisterCustomizerTest extends WriterCustomizerTest implements ByteDataTranslator {
+public class MapRegisterCustomizerTest extends LispWriterCustomizerTest implements ByteDataTranslator {
private static final InstanceIdentifier<MapRegister> ID = InstanceIdentifier.create(MapRegister.class);
private MapRegisterCustomizer customizer;
@@ -42,10 +44,13 @@ public class MapRegisterCustomizerTest extends WriterCustomizerTest implements B
@Captor
private ArgumentCaptor<LispMapRegisterEnableDisable> requestCaptor;
+ private InstanceIdentifier<MapRegister> EMPTY_ID = InstanceIdentifier.create(MapRegister.class);
+ private MapRegister EMPTY_DATA = new MapRegisterBuilder().setEnabled(false).build();
+
@Override
protected void setUpTest() throws Exception {
- customizer = new MapRegisterCustomizer(api);
+ customizer = new MapRegisterCustomizer(api, lispStateCheckService);
enabledRegister = new MapRegisterBuilder()
.setEnabled(true)
@@ -83,6 +88,42 @@ public class MapRegisterCustomizerTest extends WriterCustomizerTest implements B
verifyRequest(false);
}
+ @Test
+ public void testWriteLispDisabled() throws WriteFailedException {
+ mockLispDisabled();
+ try {
+ customizer.writeCurrentAttributes(EMPTY_ID, EMPTY_DATA, writeContext);
+ } catch (IllegalArgumentException e) {
+ verifyZeroInteractions(api);
+ return;
+ }
+ fail("Test should have thrown IllegalArgumentException");
+ }
+
+ @Test
+ public void testUpdateLispDisabled() throws WriteFailedException {
+ mockLispDisabled();
+ try {
+ customizer.updateCurrentAttributes(EMPTY_ID, EMPTY_DATA,EMPTY_DATA, writeContext);
+ } catch (IllegalArgumentException e) {
+ verifyZeroInteractions(api);
+ return;
+ }
+ fail("Test should have thrown IllegalArgumentException");
+ }
+
+ @Test
+ public void testDeleteLispDisabled() throws WriteFailedException {
+ mockLispDisabled();
+ try {
+ customizer.deleteCurrentAttributes(EMPTY_ID, EMPTY_DATA, writeContext);
+ } catch (IllegalArgumentException e) {
+ verifyZeroInteractions(api);
+ return;
+ }
+ fail("Test should have thrown IllegalArgumentException");
+ }
+
private void verifyRequest(final boolean enabled) {
verify(api, times(1)).lispMapRegisterEnableDisable(requestCaptor.capture());
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
index d66097ad2..66384a495 100644
--- 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
@@ -17,14 +17,16 @@
package io.fd.hc2vpp.lisp.translate.write;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
import static org.mockito.ArgumentMatchers.any;
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 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.honeycomb.translate.write.WriteFailedException;
import io.fd.vpp.jvpp.core.dto.LispMapRequestMode;
import io.fd.vpp.jvpp.core.dto.LispMapRequestModeReply;
import org.junit.Test;
@@ -34,7 +36,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.map.request.mode.grouping.MapRequestModeBuilder;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-public class MapRequestModeCustomizerTest extends WriterCustomizerTest {
+public class MapRequestModeCustomizerTest extends LispWriterCustomizerTest {
private static final InstanceIdentifier<MapRequestMode> ID = InstanceIdentifier.create(MapRequestMode.class);
private MapRequestModeCustomizer customizer;
@@ -43,10 +45,12 @@ public class MapRequestModeCustomizerTest extends WriterCustomizerTest {
@Captor
private ArgumentCaptor<LispMapRequestMode> requestCaptor;
+ private InstanceIdentifier<MapRequestMode> EMPTY_ID = InstanceIdentifier.create(MapRequestMode.class);
+ private MapRequestMode EMPTY_DATA = new MapRequestModeBuilder().build();
@Override
protected void setUpTest() throws Exception {
- customizer = new MapRequestModeCustomizer(api);
+ customizer = new MapRequestModeCustomizer(api, lispStateCheckService);
sourceDestinationMode = new MapRequestModeBuilder()
.setMode(SourceDestination)
.build();
@@ -73,6 +77,30 @@ public class MapRequestModeCustomizerTest extends WriterCustomizerTest {
verify(api, times(0)).lispMapRequestMode(any());
}
+ @Test
+ public void testWriteLispDisabled() throws WriteFailedException {
+ mockLispDisabled();
+ try {
+ customizer.writeCurrentAttributes(EMPTY_ID, EMPTY_DATA, writeContext);
+ } catch (IllegalArgumentException e) {
+ verifyZeroInteractions(api);
+ return;
+ }
+ fail("Test should have thrown IllegalArgumentException");
+ }
+
+ @Test
+ public void testUpdateLispDisabled() throws WriteFailedException {
+ mockLispDisabled();
+ try {
+ customizer.updateCurrentAttributes(EMPTY_ID, EMPTY_DATA,EMPTY_DATA, writeContext);
+ } catch (IllegalArgumentException e) {
+ verifyZeroInteractions(api);
+ return;
+ }
+ fail("Test should have thrown IllegalArgumentException");
+ }
+
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());
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/MapResolverCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/MapResolverCustomizerTest.java
index 474e20f65..76017a439 100755
--- a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/MapResolverCustomizerTest.java
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/MapResolverCustomizerTest.java
@@ -17,12 +17,13 @@
package io.fd.hc2vpp.lisp.translate.write;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
import static org.mockito.Matchers.any;
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.hc2vpp.common.test.write.WriterCustomizerTest;
import io.fd.hc2vpp.common.translate.util.Ipv4Translator;
import io.fd.honeycomb.translate.write.WriteFailedException;
import io.fd.vpp.jvpp.core.dto.LispAddDelMapResolver;
@@ -34,15 +35,18 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.
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.resolvers.grouping.map.resolvers.MapResolver;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.map.resolvers.grouping.map.resolvers.MapResolverBuilder;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-public class MapResolverCustomizerTest extends WriterCustomizerTest implements Ipv4Translator {
+public class MapResolverCustomizerTest extends LispWriterCustomizerTest implements Ipv4Translator {
private MapResolverCustomizer customizer;
+ private InstanceIdentifier<MapResolver> EMPTY_ID = InstanceIdentifier.create(MapResolver.class);
+ private MapResolver EMPTY_DATA = new MapResolverBuilder().build();
@Override
public void setUpTest() {
- customizer = new MapResolverCustomizer(api);
+ customizer = new MapResolverCustomizer(api, lispStateCheckService);
}
private void whenLispAddDelMapResolverThenSuccess() {
@@ -100,4 +104,27 @@ public class MapResolverCustomizerTest extends WriterCustomizerTest implements I
assertEquals("192.168.2.1", arrayToIpv4AddressNoZone(request.ipAddress).getValue());
}
+ @Test
+ public void testWriteLispDisabled() throws WriteFailedException {
+ mockLispDisabled();
+ try {
+ customizer.writeCurrentAttributes(EMPTY_ID, EMPTY_DATA, writeContext);
+ } catch (IllegalArgumentException e) {
+ verifyZeroInteractions(api);
+ return;
+ }
+ fail("Test should have thrown IllegalArgumentException");
+ }
+
+ @Test
+ public void testDeleteLispDisabled() throws WriteFailedException {
+ mockLispDisabled();
+ try {
+ customizer.deleteCurrentAttributes(EMPTY_ID, EMPTY_DATA, writeContext);
+ } catch (IllegalArgumentException e) {
+ verifyZeroInteractions(api);
+ return;
+ }
+ fail("Test should have thrown IllegalArgumentException");
+ }
}
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
index b69a44e68..a13905847 100644
--- 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
@@ -18,12 +18,13 @@ package io.fd.hc2vpp.lisp.translate.write;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import static org.mockito.ArgumentMatchers.any;
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.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;
@@ -40,7 +41,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.map.servers.grouping.map.servers.MapServerKey;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-public class MapServerCustomizerTest extends WriterCustomizerTest implements ByteDataTranslator {
+public class MapServerCustomizerTest extends LispWriterCustomizerTest implements ByteDataTranslator {
private static final MapServerKey MAP_SERVER_KEY = new MapServerKey(
new IpAddress(new Ipv4Address("192.168.2.1")));
@@ -49,13 +50,15 @@ public class MapServerCustomizerTest extends WriterCustomizerTest implements Byt
private MapServerCustomizer customizer;
private MapServer data;
+ private InstanceIdentifier<MapServer> EMPTY_ID = InstanceIdentifier.create(MapServer.class);
+ private MapServer EMPTY_DATA = new MapServerBuilder().build();
@Captor
private ArgumentCaptor<LispAddDelMapServer> requestCaptor;
@Override
protected void setUpTest() throws Exception {
- customizer = new MapServerCustomizer(api);
+ customizer = new MapServerCustomizer(api, lispStateCheckService);
data = new MapServerBuilder()
.setIpAddress(MAP_SERVER_KEY.getIpAddress())
.build();
@@ -86,6 +89,30 @@ public class MapServerCustomizerTest extends WriterCustomizerTest implements Byt
verifyRequest(false);
}
+ @Test
+ public void testWriteLispDisabled() throws WriteFailedException {
+ mockLispDisabled();
+ try {
+ customizer.writeCurrentAttributes(EMPTY_ID, EMPTY_DATA, writeContext);
+ } catch (IllegalArgumentException e) {
+ verifyZeroInteractions(api);
+ return;
+ }
+ fail("Test should have thrown IllegalArgumentException");
+ }
+
+ @Test
+ public void testDeleteLispDisabled() throws WriteFailedException {
+ mockLispDisabled();
+ try {
+ customizer.deleteCurrentAttributes(EMPTY_ID, EMPTY_DATA, writeContext);
+ } catch (IllegalArgumentException e) {
+ verifyZeroInteractions(api);
+ return;
+ }
+ fail("Test should have thrown IllegalArgumentException");
+ }
+
private void verifyRequest(final boolean add) {
verify(api, times(1)).lispAddDelMapServer(requestCaptor.capture());
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
index bd7475bb1..40660a727 100644
--- 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
@@ -19,12 +19,14 @@ 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.junit.Assert.fail;
import static org.mockito.ArgumentMatchers.any;
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.hc2vpp.common.test.write.WriterCustomizerTest;
+import io.fd.honeycomb.translate.write.WriteFailedException;
import io.fd.vpp.jvpp.core.dto.LispUsePetr;
import io.fd.vpp.jvpp.core.dto.LispUsePetrReply;
import java.util.Arrays;
@@ -37,7 +39,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.use.petr.cfg.grouping.PetrCfgBuilder;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-public class PetrCfgCustomizerTest extends WriterCustomizerTest {
+public class PetrCfgCustomizerTest extends LispWriterCustomizerTest {
private static final InstanceIdentifier<PetrCfg> ID = InstanceIdentifier.create(PetrCfg.class);
@@ -47,10 +49,12 @@ public class PetrCfgCustomizerTest extends WriterCustomizerTest {
@Captor
private ArgumentCaptor<LispUsePetr> requestCaptor;
+ private InstanceIdentifier<PetrCfg> EMPTY_ID = InstanceIdentifier.create(PetrCfg.class);
+ private PetrCfg EMPTY_DATA = new PetrCfgBuilder().build();
@Override
public void setUpTest() throws Exception {
- customizer = new PetrCfgCustomizer(api);
+ customizer = new PetrCfgCustomizer(api, lispStateCheckService);
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()));
@@ -80,6 +84,42 @@ public class PetrCfgCustomizerTest extends WriterCustomizerTest {
verifyDisabledInvoked();
}
+ @Test
+ public void testWriteLispDisabled() throws WriteFailedException {
+ mockLispDisabled();
+ try {
+ customizer.writeCurrentAttributes(EMPTY_ID, EMPTY_DATA, writeContext);
+ } catch (IllegalArgumentException e) {
+ verifyZeroInteractions(api);
+ return;
+ }
+ fail("Test should have thrown IllegalArgumentException");
+ }
+
+ @Test
+ public void testUpdateLispDisabled() throws WriteFailedException {
+ mockLispDisabled();
+ try {
+ customizer.updateCurrentAttributes(EMPTY_ID, EMPTY_DATA,EMPTY_DATA, writeContext);
+ } catch (IllegalArgumentException e) {
+ verifyZeroInteractions(api);
+ return;
+ }
+ fail("Test should have thrown IllegalArgumentException");
+ }
+
+ @Test
+ public void testDeleteLispDisabled() throws WriteFailedException {
+ mockLispDisabled();
+ try {
+ customizer.deleteCurrentAttributes(EMPTY_ID, EMPTY_DATA, writeContext);
+ } catch (IllegalArgumentException e) {
+ verifyZeroInteractions(api);
+ return;
+ }
+ fail("Test should have thrown IllegalArgumentException");
+ }
+
private void verifyEnabledInvoked() {
verify(api, times(1)).lispUsePetr(requestCaptor.capture());
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/PitrCfgCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/PitrCfgCustomizerTest.java
index 477509179..ae1b145da 100755
--- a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/PitrCfgCustomizerTest.java
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/PitrCfgCustomizerTest.java
@@ -17,13 +17,14 @@
package io.fd.hc2vpp.lisp.translate.write;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
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.verifyZeroInteractions;
import static org.mockito.Mockito.when;
-import io.fd.hc2vpp.common.test.write.WriterCustomizerTest;
import io.fd.honeycomb.translate.write.WriteFailedException;
import io.fd.vpp.jvpp.core.dto.LispPitrSetLocatorSet;
import io.fd.vpp.jvpp.core.dto.LispPitrSetLocatorSetReply;
@@ -32,15 +33,18 @@ import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.pitr.cfg.grouping.PitrCfg;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.pitr.cfg.grouping.PitrCfgBuilder;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-public class PitrCfgCustomizerTest extends WriterCustomizerTest {
+public class PitrCfgCustomizerTest extends LispWriterCustomizerTest {
private PitrCfgCustomizer customizer;
+ private InstanceIdentifier<PitrCfg> EMPTY_ID = InstanceIdentifier.create(PitrCfg.class);
+ private PitrCfg EMPTY_DATA = new PitrCfgBuilder().build();
@Override
public void setUpTest() {
- customizer = new PitrCfgCustomizer(api);
+ customizer = new PitrCfgCustomizer(api, lispStateCheckService);
}
private void whenLispPitrSetLocatorSetThenSuccess() {
@@ -114,4 +118,40 @@ public class PitrCfgCustomizerTest extends WriterCustomizerTest {
assertEquals("Locator", new String(request.lsName));
}
+ @Test
+ public void testWriteLispDisabled() throws WriteFailedException {
+ mockLispDisabled();
+ try {
+ customizer.writeCurrentAttributes(EMPTY_ID, EMPTY_DATA, writeContext);
+ } catch (IllegalArgumentException e) {
+ verifyZeroInteractions(api);
+ return;
+ }
+ fail("Test should have thrown IllegalArgumentException");
+ }
+
+ @Test
+ public void testUpdateLispDisabled() throws WriteFailedException {
+ mockLispDisabled();
+ try {
+ customizer.updateCurrentAttributes(EMPTY_ID, EMPTY_DATA,EMPTY_DATA, writeContext);
+ } catch (IllegalArgumentException e) {
+ verifyZeroInteractions(api);
+ return;
+ }
+ fail("Test should have thrown IllegalArgumentException");
+ }
+
+ @Test
+ public void testDeleteLispDisabled() throws WriteFailedException {
+ mockLispDisabled();
+ try {
+ customizer.deleteCurrentAttributes(EMPTY_ID, EMPTY_DATA, writeContext);
+ } catch (IllegalArgumentException e) {
+ verifyZeroInteractions(api);
+ return;
+ }
+ fail("Test should have thrown IllegalArgumentException");
+ }
+
}
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
index 829853e66..e2a6b3e9f 100644
--- 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
@@ -17,13 +17,15 @@
package io.fd.hc2vpp.lisp.translate.write;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
import static org.mockito.ArgumentMatchers.any;
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.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.LispRlocProbeEnableDisable;
import io.fd.vpp.jvpp.core.dto.LispRlocProbeEnableDisableReply;
import org.junit.Test;
@@ -33,7 +35,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.rloc.probing.grouping.RlocProbeBuilder;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-public class RlocProbeCustomizerTest extends WriterCustomizerTest implements ByteDataTranslator {
+public class RlocProbeCustomizerTest extends LispWriterCustomizerTest implements ByteDataTranslator {
private static final InstanceIdentifier<RlocProbe> ID = InstanceIdentifier.create(RlocProbe.class);
private RlocProbeCustomizer customizer;
@@ -42,10 +44,12 @@ public class RlocProbeCustomizerTest extends WriterCustomizerTest implements Byt
@Captor
private ArgumentCaptor<LispRlocProbeEnableDisable> requestCaptor;
+ private InstanceIdentifier<RlocProbe> EMPTY_ID = InstanceIdentifier.create(RlocProbe.class);
+ private RlocProbe EMPTY_DATA = new RlocProbeBuilder().build();
@Override
protected void setUpTest() throws Exception {
- customizer = new RlocProbeCustomizer(api);
+ customizer = new RlocProbeCustomizer(api, lispStateCheckService);
enabledProbe = rlocProbe(true);
disabledProbe = rlocProbe(false);
when(api.lispRlocProbeEnableDisable(any(LispRlocProbeEnableDisable.class)))
@@ -76,6 +80,42 @@ public class RlocProbeCustomizerTest extends WriterCustomizerTest implements Byt
verifyRequest(false);
}
+ @Test
+ public void testWriteLispDisabled() throws WriteFailedException {
+ mockLispDisabled();
+ try {
+ customizer.writeCurrentAttributes(EMPTY_ID, EMPTY_DATA, writeContext);
+ } catch (IllegalArgumentException e) {
+ verifyZeroInteractions(api);
+ return;
+ }
+ fail("Test should have thrown IllegalArgumentException");
+ }
+
+ @Test
+ public void testUpdateLispDisabled() throws WriteFailedException {
+ mockLispDisabled();
+ try {
+ customizer.updateCurrentAttributes(EMPTY_ID, EMPTY_DATA,EMPTY_DATA, writeContext);
+ } catch (IllegalArgumentException e) {
+ verifyZeroInteractions(api);
+ return;
+ }
+ fail("Test should have thrown IllegalArgumentException");
+ }
+
+ @Test
+ public void testDeleteLispDisabled() throws WriteFailedException {
+ mockLispDisabled();
+ try {
+ customizer.deleteCurrentAttributes(EMPTY_ID, EMPTY_DATA, writeContext);
+ } catch (IllegalArgumentException e) {
+ verifyZeroInteractions(api);
+ return;
+ }
+ fail("Test should have thrown IllegalArgumentException");
+ }
+
private static RlocProbe rlocProbe(final boolean enabled) {
return new RlocProbeBuilder().setEnabled(enabled).build();
}
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/VniTableCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/VniTableCustomizerTest.java
index 531907025..1bf4b772f 100644
--- a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/VniTableCustomizerTest.java
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/VniTableCustomizerTest.java
@@ -18,12 +18,12 @@ package io.fd.hc2vpp.lisp.translate.write;
import static org.junit.Assert.fail;
+import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import com.google.common.base.Optional;
import io.fd.honeycomb.translate.write.WriteFailedException;
-import io.fd.hc2vpp.common.test.write.WriterCustomizerTest;
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.eid.table.grouping.eid.table.VniTable;
@@ -31,16 +31,18 @@ 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.vni.table.VrfSubtableBuilder;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-public class VniTableCustomizerTest extends WriterCustomizerTest {
+public class VniTableCustomizerTest extends LispWriterCustomizerTest {
private VniTableCustomizer customizer;
private InstanceIdentifier<VniTable> validId;
private VniTable validData;
+ private InstanceIdentifier<VniTable> EMPTY_ID = InstanceIdentifier.create(VniTable.class);
+ private VniTable EMPTY_DATA = new VniTableBuilder().build();
@Before
public void init() {
initMocks(this);
- customizer = new VniTableCustomizer(api);
+ customizer = new VniTableCustomizer(api, lispStateCheckService);
validId = InstanceIdentifier.create(VniTable.class);
validData = new VniTableBuilder()
@@ -85,6 +87,30 @@ public class VniTableCustomizerTest extends WriterCustomizerTest {
customizer.deleteCurrentAttributes(validId, validData, writeContext);
}
+ @Test
+ public void testWriteLispDisabled() throws WriteFailedException {
+ mockLispDisabled();
+ try {
+ customizer.writeCurrentAttributes(EMPTY_ID, EMPTY_DATA, writeContext);
+ } catch (IllegalArgumentException e) {
+ verifyZeroInteractions(api);
+ return;
+ }
+ fail("Test should have thrown IllegalArgumentException");
+ }
+
+ @Test
+ public void testDeleteLispDisabled() throws WriteFailedException {
+ mockLispDisabled();
+ try {
+ customizer.deleteCurrentAttributes(EMPTY_ID, EMPTY_DATA, writeContext);
+ } catch (IllegalArgumentException e) {
+ verifyZeroInteractions(api);
+ return;
+ }
+ fail("Test should have thrown IllegalArgumentException");
+ }
+
private void whenReadBeforeReturnValid() {
when(writeContext.readBefore(validId)).thenReturn(Optional.of(validData));
}