summaryrefslogtreecommitdiffstats
path: root/v3po/v3po2vpp/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'v3po/v3po2vpp/src/test')
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/AfPacketValidatorTest.java88
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/EthernetCustomizerTest.java12
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/EthernetValidatorTest.java76
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/GreValidatorTest.java111
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/InterfaceRoutingCustomizerTest.java49
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/InterfaceRoutingValidatorTest.java146
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/InterfaceUnnumberedValidatorTest.java82
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/InterfaceValidatorTest.java85
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/SubInterfaceCustomizerTest.java28
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/SubInterfaceRoutingCustomizerTest.java45
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/SubInterfaceRoutingValidatorTest.java123
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/SubInterfaceUnnumberedCustomizerTest.java9
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/SubInterfaceUnnumberedValidatorTest.java80
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/SubInterfaceValidatorTest.java85
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/VhostUserCustomizerTest.java4
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/VhostUserValidatorTest.java79
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/VxlanGpeValidatorTest.java151
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/VxlanValidatorTest.java142
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/pbb/PbbRewriteCustomizerTest.java133
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/pbb/PbbRewriteValidatorTest.java189
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/span/MirroredInterfacesCustomizerTest.java1
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/span/MirroredInterfacesValidatorTest.java115
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/VxlanGpeCustomizerTest.java142
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/span/MirroredInterfacesCustomizerTest.java1
24 files changed, 1589 insertions, 387 deletions
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/AfPacketValidatorTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/AfPacketValidatorTest.java
new file mode 100644
index 000000000..ebdc770fe
--- /dev/null
+++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/AfPacketValidatorTest.java
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2019 PANTHEON.tech.
+ *
+ * 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.v3po.interfaces;
+
+import static org.mockito.MockitoAnnotations.initMocks;
+
+import io.fd.hc2vpp.common.translate.util.NamingContext;
+import io.fd.honeycomb.translate.write.DataValidationFailedException.CreateValidationFailedException;
+import io.fd.honeycomb.translate.write.DataValidationFailedException.DeleteValidationFailedException;
+import io.fd.honeycomb.translate.write.DataValidationFailedException.UpdateValidationFailedException;
+import io.fd.honeycomb.translate.write.WriteContext;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.v3po.rev190502.VppInterfaceAugmentation;
+import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.v3po.rev190502.interfaces._interface.AfPacket;
+import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.v3po.rev190502.interfaces._interface.AfPacketBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev180220.Interfaces;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev180220.interfaces.Interface;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev180220.interfaces.InterfaceKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public class AfPacketValidatorTest {
+
+ private AfPacketValidator validator;
+
+ @Mock
+ private WriteContext writeContext;
+
+ private final String IFACE_NAME = "veth1";
+ private final InstanceIdentifier<AfPacket> ID =
+ InstanceIdentifier.create(Interfaces.class).child(Interface.class, new InterfaceKey(IFACE_NAME))
+ .augmentation(VppInterfaceAugmentation.class).child(AfPacket.class);
+
+ @Before
+ public void setUp() {
+ initMocks(this);
+ NamingContext ifcContext = new NamingContext("testInterfaceContext", "testInterfaceContext");
+ validator = new AfPacketValidator(ifcContext);
+ }
+
+ @Test
+ public void testWriteSuccessful() throws CreateValidationFailedException {
+ validator.validateWrite(ID, afPacket(IFACE_NAME), writeContext);
+ }
+
+ @Test(expected = CreateValidationFailedException.class)
+ public void testWriteFailedNoHostName() throws CreateValidationFailedException {
+ validator.validateWrite(ID, afPacket(null), writeContext);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testWriteFailedLongHostName() throws CreateValidationFailedException {
+ validator.validateWrite(ID,
+ afPacket(IntStream.range(1, 64).boxed().map(i -> i.toString()).collect(Collectors.joining(","))),
+ writeContext);
+ }
+
+ @Test
+ public void testUpdateSuccessful() throws UpdateValidationFailedException {
+ validator.validateUpdate(ID, afPacket(IFACE_NAME), afPacket(IFACE_NAME), writeContext);
+ }
+
+ @Test
+ public void testDeleteSuccessful() throws DeleteValidationFailedException {
+ validator.validateDelete(ID, afPacket(IFACE_NAME), writeContext);
+ }
+
+ private AfPacket afPacket(String name) {
+ return new AfPacketBuilder().setHostInterfaceName(name).build();
+ }
+}
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/EthernetCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/EthernetCustomizerTest.java
index 18ec6614d..f7befc4e9 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/EthernetCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/EthernetCustomizerTest.java
@@ -29,7 +29,6 @@ import io.fd.jvpp.core.dto.HwInterfaceSetMtuReply;
import org.junit.Test;
import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.v3po.rev190502.VppInterfaceAugmentation;
import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.v3po.rev190502.interfaces._interface.Ethernet;
-import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.v3po.rev190502.interfaces._interface.EthernetBuilder;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev180703.EthernetCsmacd;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev180220.Interfaces;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev180220.interfaces.Interface;
@@ -57,7 +56,7 @@ public class EthernetCustomizerTest extends WriterCustomizerTest {
public void testWrite() throws WriteFailedException {
when(api.hwInterfaceSetMtu(any())).thenReturn(future(new HwInterfaceSetMtuReply()));
final int mtu = 1234;
- customizer.writeCurrentAttributes(IF_IID, ethernet(mtu), writeContext);
+ customizer.writeCurrentAttributes(IF_IID, EthernetValidatorTest.ethernet(mtu), writeContext);
verify(api).hwInterfaceSetMtu(mtuSetRequest(mtu));
}
@@ -65,7 +64,7 @@ public class EthernetCustomizerTest extends WriterCustomizerTest {
public void testUpdate() throws WriteFailedException {
when(api.hwInterfaceSetMtu(any())).thenReturn(future(new HwInterfaceSetMtuReply()));
final int mtu = 5678;
- customizer.updateCurrentAttributes(IF_IID, mock(Ethernet.class), ethernet(mtu), writeContext);
+ customizer.updateCurrentAttributes(IF_IID, mock(Ethernet.class), EthernetValidatorTest.ethernet(mtu), writeContext);
verify(api).hwInterfaceSetMtu(mtuSetRequest(mtu));
}
@@ -80,11 +79,4 @@ public class EthernetCustomizerTest extends WriterCustomizerTest {
public void testDelete() throws WriteFailedException {
customizer.deleteCurrentAttributes(IF_IID, mock(Ethernet.class), writeContext);
}
-
- private static Ethernet ethernet(final int mtu) {
- final EthernetBuilder ethernet = new EthernetBuilder();
- ethernet.setMtu(mtu);
- return ethernet.build();
- }
-
}
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/EthernetValidatorTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/EthernetValidatorTest.java
new file mode 100644
index 000000000..ce639d22f
--- /dev/null
+++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/EthernetValidatorTest.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2019 PANTHEON.tech.
+ *
+ * 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.v3po.interfaces;
+
+import static org.mockito.MockitoAnnotations.initMocks;
+
+import io.fd.hc2vpp.common.translate.util.NamingContext;
+import io.fd.honeycomb.translate.write.DataValidationFailedException.CreateValidationFailedException;
+import io.fd.honeycomb.translate.write.DataValidationFailedException.UpdateValidationFailedException;
+import io.fd.honeycomb.translate.write.WriteContext;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.v3po.rev190502.VppInterfaceAugmentation;
+import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.v3po.rev190502.interfaces._interface.Ethernet;
+import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.v3po.rev190502.interfaces._interface.EthernetBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev180220.Interfaces;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev180220.interfaces.Interface;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev180220.interfaces.InterfaceKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public class EthernetValidatorTest {
+
+ private EthernetValidator validator;
+
+ @Mock
+ private WriteContext writeContext;
+
+ private static final String IF_NAME = "eth0";
+ private static final int IF_MTU = 1234;
+ private static final InstanceIdentifier<Ethernet> ID =
+ InstanceIdentifier.create(Interfaces.class).child(Interface.class, new InterfaceKey(IF_NAME)).augmentation(
+ VppInterfaceAugmentation.class).child(Ethernet.class);
+
+ @Before
+ public void setUp() {
+ initMocks(this);
+ NamingContext ifcContext = new NamingContext("testInterfaceContext", "testInterfaceContext");
+ validator = new EthernetValidator(ifcContext);
+ }
+
+ @Test
+ public void testWriteSuccessful() throws CreateValidationFailedException {
+ validator.validateWrite(ID, ethernet(IF_MTU), writeContext);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testWriteFailedNoMTU() throws CreateValidationFailedException {
+ validator.validateWrite(ID, ethernet(null), writeContext);
+ }
+
+ @Test
+ public void testUpdateSuccessful() throws UpdateValidationFailedException {
+ validator.validateUpdate(ID, ethernet(IF_MTU), ethernet(IF_MTU + 1), writeContext);
+ }
+
+ static Ethernet ethernet(final Integer mtu) {
+ final EthernetBuilder ethernet = new EthernetBuilder();
+ ethernet.setMtu(mtu);
+ return ethernet.build();
+ }
+}
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/GreValidatorTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/GreValidatorTest.java
new file mode 100644
index 000000000..e7f786bde
--- /dev/null
+++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/GreValidatorTest.java
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2019 PANTHEON.tech.
+ *
+ * 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.v3po.interfaces;
+
+import static org.mockito.MockitoAnnotations.initMocks;
+
+import io.fd.hc2vpp.common.translate.util.NamingContext;
+import io.fd.honeycomb.translate.write.DataValidationFailedException.CreateValidationFailedException;
+import io.fd.honeycomb.translate.write.DataValidationFailedException.DeleteValidationFailedException;
+import io.fd.honeycomb.translate.write.WriteContext;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.v3po.rev190502.VppInterfaceAugmentation;
+import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.v3po.rev190502.interfaces._interface.Gre;
+import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.v3po.rev190502.interfaces._interface.GreBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressNoZone;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6AddressNoZone;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev180220.Interfaces;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev180220.interfaces.Interface;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev180220.interfaces.InterfaceKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public class GreValidatorTest {
+
+ private GreValidator validator;
+
+ @Mock
+ private WriteContext writeContext;
+
+ private static final String IPV6 = "a::100";
+ private static final String IPV4_1 = "192.168.20.10";
+ private static final String IPV4_2 = "192.168.20.11";
+ private static final Long OUT_FIB_ID = Long.valueOf(123);
+ private static final String IFACE_NAME = "eth0";
+ private static final InstanceIdentifier<Gre> ID =
+ InstanceIdentifier.create(Interfaces.class).child(Interface.class, new InterfaceKey(IFACE_NAME))
+ .augmentation(VppInterfaceAugmentation.class).child(Gre.class);
+
+ @Before
+ public void setUp() {
+ initMocks(this);
+ NamingContext ifcContext = new NamingContext("testInterfaceContext", "testInterfaceContext");
+ validator = new GreValidator(ifcContext);
+ }
+
+ @Test
+ public void testWriteSuccessful() throws CreateValidationFailedException {
+ validator.validateWrite(ID, generateCorrectGre(), writeContext);
+ }
+
+ @Test(expected = CreateValidationFailedException.class)
+ public void testWriteFailedMixedIpv4Ipv6() throws CreateValidationFailedException {
+ validator.validateWrite(ID, generateGre(ip4(IPV4_1), ip6(IPV6), OUT_FIB_ID), writeContext);
+ }
+
+ @Test(expected = CreateValidationFailedException.class)
+ public void testWriteFailedNoSrcAddr() throws CreateValidationFailedException {
+ validator.validateWrite(ID, generateGre(null, ip6(IPV6), OUT_FIB_ID), writeContext);
+ }
+
+ @Test(expected = CreateValidationFailedException.class)
+ public void testWriteFailedNoDstAddr() throws CreateValidationFailedException {
+ validator.validateWrite(ID, generateGre(ip4(IPV4_1), null, OUT_FIB_ID), writeContext);
+ }
+
+ @Test(expected = CreateValidationFailedException.class)
+ public void testWriteFailedNoOutFibId() throws CreateValidationFailedException {
+ validator.validateWrite(ID, generateGre(ip4(IPV4_1), ip4(IPV4_2), null), writeContext);
+ }
+
+ @Test
+ public void testDeleteSuccessful() throws DeleteValidationFailedException {
+ validator.validateDelete(ID, generateCorrectGre(), writeContext);
+ }
+
+ private Gre generateCorrectGre() {
+ return generateGre(ip4(IPV4_1), ip4(IPV4_2), OUT_FIB_ID);
+ }
+
+ private Gre generateGre(final IpAddressNoZone srcAddr, final IpAddressNoZone dstAddr, final Long outerFibId) {
+ final GreBuilder builder = new GreBuilder();
+ builder.setSrc(srcAddr);
+ builder.setDst(dstAddr);
+ builder.setOuterFibId(outerFibId);
+ return builder.build();
+ }
+
+ private IpAddressNoZone ip4(String addr) {
+ return new IpAddressNoZone(new Ipv4AddressNoZone(addr));
+ }
+
+ private IpAddressNoZone ip6(String addr) {
+ return new IpAddressNoZone(new Ipv6AddressNoZone(addr));
+ }
+}
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/InterfaceRoutingCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/InterfaceRoutingCustomizerTest.java
index a3028acf7..533c627f6 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/InterfaceRoutingCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/InterfaceRoutingCustomizerTest.java
@@ -20,14 +20,12 @@ import static org.mockito.Matchers.any;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import java.util.Optional;
import io.fd.hc2vpp.common.test.write.WriterCustomizerTest;
import io.fd.hc2vpp.common.translate.util.NamingContext;
-import io.fd.honeycomb.translate.util.RWUtils;
import io.fd.honeycomb.translate.write.WriteFailedException;
import io.fd.jvpp.core.dto.SwInterfaceSetTable;
import io.fd.jvpp.core.dto.SwInterfaceSetTableReply;
-import java.util.Collections;
+import java.util.Optional;
import org.junit.Test;
import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.v3po.rev190502.VppInterfaceAugmentation;
import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.v3po.rev190502.interfaces._interface.Routing;
@@ -37,11 +35,6 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev180220.interfaces.Interface;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev180220.interfaces.InterfaceBuilder;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev180220.interfaces.InterfaceKey;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.Interface1;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.Interface1Builder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces._interface.Ipv4Builder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces._interface.Ipv6Builder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces._interface.ipv4.AddressBuilder;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
public class InterfaceRoutingCustomizerTest extends WriterCustomizerTest {
@@ -76,52 +69,16 @@ public class InterfaceRoutingCustomizerTest extends WriterCustomizerTest {
customizer.writeCurrentAttributes(IID, routing(213), writeContext);
}
- @Test(expected = IllegalStateException.class)
- public void testWriteFailedIpv4Present() throws WriteFailedException {
- when(writeContext.readBefore(RWUtils.cutId(IID, Interface.class)))
- .thenReturn(Optional.of(ifaceWithV4Address()));
- customizer.writeCurrentAttributes(IID, routing(213), writeContext);
- }
-
- @Test(expected = IllegalStateException.class)
- public void testWriteFailedIpv6Present() throws WriteFailedException {
- when(writeContext.readBefore(RWUtils.cutId(IID, Interface.class)))
- .thenReturn(Optional.of(ifaceWithV6Address()));
- customizer.writeCurrentAttributes(IID, routing(213), writeContext);
- }
-
@Test
public void testWriteEmptyIfaceData() throws WriteFailedException {
- when(writeContext.readBefore(any(InstanceIdentifier.class))).thenReturn(Optional.of(new InterfaceBuilder().build()));
+ when(writeContext.readBefore(any(InstanceIdentifier.class)))
+ .thenReturn(Optional.of(new InterfaceBuilder().build()));
final int vrfId = 123;
when(api.swInterfaceSetTable(any())).thenReturn(future(new SwInterfaceSetTableReply()));
customizer.writeCurrentAttributes(IID, routing(vrfId), writeContext);
verify(api).swInterfaceSetTable(expectedRequest(vrfId));
}
- private static Interface ifaceWithV4Address() {
- return new InterfaceBuilder()
- .addAugmentation(Interface1.class, new Interface1Builder()
- .setIpv4(new Ipv4Builder()
- .setAddress(Collections.singletonList(new AddressBuilder().build()))
- .build())
- .build())
- .build();
- }
-
-
- private static Interface ifaceWithV6Address() {
- return new InterfaceBuilder()
- .addAugmentation(Interface1.class, new Interface1Builder()
- .setIpv6(new Ipv6Builder()
- .setAddress(Collections.singletonList(
- new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces._interface.ipv6.AddressBuilder()
- .build()))
- .build())
- .build())
- .build();
- }
-
@Test(expected = WriteFailedException.class)
public void testUpdateFailed() throws WriteFailedException {
when(writeContext.readBefore(any(InstanceIdentifier.class))).thenReturn(Optional.empty());
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/InterfaceRoutingValidatorTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/InterfaceRoutingValidatorTest.java
new file mode 100644
index 000000000..e10aba4a2
--- /dev/null
+++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/InterfaceRoutingValidatorTest.java
@@ -0,0 +1,146 @@
+/*
+ * Copyright (c) 2019 PANTHEON.tech.
+ *
+ * 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.v3po.interfaces;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.when;
+import static org.mockito.MockitoAnnotations.initMocks;
+
+import io.fd.hc2vpp.common.translate.util.NamingContext;
+import io.fd.honeycomb.translate.util.RWUtils;
+import io.fd.honeycomb.translate.write.DataValidationFailedException.CreateValidationFailedException;
+import io.fd.honeycomb.translate.write.DataValidationFailedException.DeleteValidationFailedException;
+import io.fd.honeycomb.translate.write.DataValidationFailedException.UpdateValidationFailedException;
+import io.fd.honeycomb.translate.write.WriteContext;
+import java.util.Collections;
+import java.util.Optional;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.v3po.rev190502.VppInterfaceAugmentation;
+import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.v3po.rev190502.interfaces._interface.Routing;
+import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.v3po.rev190502.interfaces._interface.RoutingBuilder;
+import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.fib.table.management.rev180521.VniReference;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev180220.Interfaces;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev180220.interfaces.Interface;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev180220.interfaces.InterfaceBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev180220.interfaces.InterfaceKey;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.Interface1;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.Interface1Builder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces._interface.Ipv4Builder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces._interface.Ipv6Builder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces._interface.ipv4.AddressBuilder;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public class InterfaceRoutingValidatorTest {
+
+ private InterfaceRoutingValidator validator;
+
+ @Mock
+ private WriteContext writeContext;
+
+ private static final String IF_NAME = "eth1";
+ private static final Long VRF_ID = Long.valueOf(123);
+
+ private static final InstanceIdentifier<Routing> ID =
+ InstanceIdentifier.create(Interfaces.class).child(Interface.class, new InterfaceKey(IF_NAME))
+ .augmentation(VppInterfaceAugmentation.class).child(Routing.class);
+
+ @Before
+ public void setUp() {
+ initMocks(this);
+ NamingContext ifcContext = new NamingContext("testInterfaceContext", "testInterfaceContext");
+ validator = new InterfaceRoutingValidator(ifcContext);
+ }
+
+ @Test
+ public void testWriteSuccessful() throws CreateValidationFailedException {
+ when(writeContext.readBefore(any(InstanceIdentifier.class))).thenReturn(Optional.empty());
+ validator.validateWrite(ID, routing(VRF_ID, true, false), writeContext);
+ }
+
+ @Test(expected = CreateValidationFailedException.class)
+ public void testWriteFailedNoFrfIds() throws CreateValidationFailedException {
+ when(writeContext.readBefore(any(InstanceIdentifier.class))).thenReturn(Optional.empty());
+ validator.validateWrite(ID, routing(null, true, true), writeContext);
+ }
+
+ @Test(expected = CreateValidationFailedException.class)
+ public void testWriteFailedWithV4Address() throws CreateValidationFailedException {
+ when(writeContext.readBefore(RWUtils.cutId(ID, Interface.class)))
+ .thenReturn(Optional.of(ifaceWithV4Address()));
+ validator.validateWrite(ID, routing(VRF_ID, true, false), writeContext);
+ }
+
+ @Test(expected = CreateValidationFailedException.class)
+ public void testWriteFailedWithV6Address() throws CreateValidationFailedException {
+ when(writeContext.readBefore(RWUtils.cutId(ID, Interface.class)))
+ .thenReturn(Optional.of(ifaceWithV6Address()));
+ validator.validateWrite(ID, routing(VRF_ID, true, false), writeContext);
+ }
+
+ @Test
+ public void testUpdateSuccessful() throws UpdateValidationFailedException {
+ when(writeContext.readBefore(any(InstanceIdentifier.class))).thenReturn(Optional.empty());
+ validator.validateUpdate(ID, routing(VRF_ID, true, false),
+ routing(VRF_ID, true, true), writeContext);
+ }
+
+ @Test
+ public void testDeleteSuccessful() throws DeleteValidationFailedException {
+ when(writeContext.readBefore(any(InstanceIdentifier.class))).thenReturn(Optional.empty());
+ validator.validateDelete(ID, routing(VRF_ID, true, false), writeContext);
+ }
+
+ private Routing routing(final Long vrfId, final boolean hasIpv4, final boolean hasIpv6) {
+ VniReference vni = null;
+ if (vrfId != null) {
+ vni = new VniReference(vrfId);
+ }
+
+ RoutingBuilder builder = new RoutingBuilder();
+ if (hasIpv4) {
+ builder.setIpv4VrfId(vni);
+ }
+ if (hasIpv6) {
+ builder.setIpv6VrfId(vni);
+ }
+ return builder.build();
+ }
+
+ private Interface ifaceWithV4Address() {
+ return new InterfaceBuilder()
+ .addAugmentation(Interface1.class, new Interface1Builder()
+ .setIpv4(new Ipv4Builder()
+ .setAddress(Collections.singletonList(new AddressBuilder().build()))
+ .build())
+ .build())
+ .build();
+ }
+
+ private Interface ifaceWithV6Address() {
+ return new InterfaceBuilder()
+ .addAugmentation(Interface1.class, new Interface1Builder()
+ .setIpv6(new Ipv6Builder()
+ .setAddress(Collections.singletonList(
+ new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces._interface.ipv6.AddressBuilder()
+ .build()))
+ .build())
+ .build())
+ .build();
+ }
+}
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/InterfaceUnnumberedValidatorTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/InterfaceUnnumberedValidatorTest.java
new file mode 100644
index 000000000..79b3f9185
--- /dev/null
+++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/InterfaceUnnumberedValidatorTest.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2019 PANTHEON.tech.
+ *
+ * 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.v3po.interfaces;
+
+import static org.mockito.MockitoAnnotations.initMocks;
+
+import io.fd.hc2vpp.common.translate.util.NamingContext;
+import io.fd.honeycomb.translate.write.DataValidationFailedException.CreateValidationFailedException;
+import io.fd.honeycomb.translate.write.DataValidationFailedException.DeleteValidationFailedException;
+import io.fd.honeycomb.translate.write.DataValidationFailedException.UpdateValidationFailedException;
+import io.fd.honeycomb.translate.write.WriteContext;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.unnumbered.interfaces.rev180103.InterfaceUnnumberedAugmentation;
+import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.unnumbered.interfaces.rev180103.unnumbered.config.attributes.Unnumbered;
+import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.unnumbered.interfaces.rev180103.unnumbered.config.attributes.UnnumberedBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev180220.Interfaces;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev180220.interfaces.Interface;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev180220.interfaces.InterfaceKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public class InterfaceUnnumberedValidatorTest {
+
+ private InterfaceUnnumberedValidator validator;
+
+ @Mock
+ private WriteContext writeContext;
+
+ private static final String IF_NAME = "eth2";
+ private static final String TARGET_IFC0_NAME = "eth0";
+ private static final InstanceIdentifier<Unnumbered> ID = InstanceIdentifier.create(Interfaces.class)
+ .child(Interface.class, new InterfaceKey(IF_NAME))
+ .augmentation(InterfaceUnnumberedAugmentation.class)
+ .child(Unnumbered.class);
+
+ @Before
+ public void setUp() {
+ initMocks(this);
+ NamingContext ifcContext = new NamingContext("testInterfaceContext", "testInterfaceContext");
+ validator = new InterfaceUnnumberedValidator(ifcContext);
+ }
+
+ @Test
+ public void testWriteSuccessful() throws CreateValidationFailedException {
+ validator.validateWrite(ID, getUnnumberedIfc(TARGET_IFC0_NAME), writeContext);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testWriteFailedNoUse() throws CreateValidationFailedException {
+ validator.validateWrite(ID, getUnnumberedIfc(null), writeContext);
+ }
+
+ @Test
+ public void testUpdateSuccessful() throws UpdateValidationFailedException {
+ validator.validateUpdate(ID, getUnnumberedIfc(TARGET_IFC0_NAME), getUnnumberedIfc(TARGET_IFC0_NAME),
+ writeContext);
+ }
+
+ @Test
+ public void testDeleteeSuccessful() throws DeleteValidationFailedException {
+ validator.validateDelete(ID, getUnnumberedIfc(TARGET_IFC0_NAME), writeContext);
+ }
+
+ private Unnumbered getUnnumberedIfc(String use) {
+ return new UnnumberedBuilder().setUse(use).build();
+ }
+}
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/InterfaceValidatorTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/InterfaceValidatorTest.java
new file mode 100644
index 000000000..21de26fed
--- /dev/null
+++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/InterfaceValidatorTest.java
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2019 PANTHEON.tech.
+ *
+ * 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.v3po.interfaces;
+
+import static org.mockito.MockitoAnnotations.initMocks;
+
+import io.fd.hc2vpp.common.translate.util.NamingContext;
+import io.fd.honeycomb.translate.write.DataValidationFailedException.CreateValidationFailedException;
+import io.fd.honeycomb.translate.write.DataValidationFailedException.DeleteValidationFailedException;
+import io.fd.honeycomb.translate.write.DataValidationFailedException.UpdateValidationFailedException;
+import io.fd.honeycomb.translate.write.WriteContext;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev180220.Interfaces;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev180220.interfaces.Interface;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev180220.interfaces.InterfaceBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev180220.interfaces.InterfaceKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public class InterfaceValidatorTest {
+
+ private InterfaceValidator validator;
+
+ @Mock
+ private WriteContext writeContext;
+
+ private static final String IF_NAME = "eth0";
+ private static final InstanceIdentifier<Interface> ID =
+ InstanceIdentifier.create(Interfaces.class).child(Interface.class, new InterfaceKey(IF_NAME));
+
+ @Before
+ public void setUp() {
+ initMocks(this);
+ NamingContext ifcContext = new NamingContext("testInterfaceContext", "testInterfaceContext");
+ validator = new InterfaceValidator(ifcContext);
+ }
+
+ @Test
+ public void testWriteSuccessful() throws CreateValidationFailedException {
+ validator.validateWrite(ID, getInterface(true), writeContext);
+ }
+
+ @Test(expected = CreateValidationFailedException.class)
+ public void testWriteFailedNoName() throws CreateValidationFailedException {
+ validator.validateWrite(ID, getInterface(null, true), writeContext);
+ }
+
+ @Test(expected = CreateValidationFailedException.class)
+ public void testWriteFailedNoEnableFlag() throws CreateValidationFailedException {
+ validator.validateWrite(ID, getInterface(null), writeContext);
+ }
+
+ @Test
+ public void testUpdateSuccessful() throws UpdateValidationFailedException {
+ validator.validateUpdate(ID, getInterface(true), getInterface(true), writeContext);
+ }
+
+ @Test
+ public void testDeleteSuccessful() throws DeleteValidationFailedException {
+ validator.validateDelete(ID, getInterface(true), writeContext);
+ }
+
+ private Interface getInterface(final String name, final Boolean enabled) {
+ return new InterfaceBuilder().setName(name).setEnabled(enabled).build();
+ }
+
+ private Interface getInterface(final Boolean enabled) {
+ return new InterfaceBuilder().setName(IF_NAME).setEnabled(enabled).build();
+ }
+}
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/SubInterfaceCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/SubInterfaceCustomizerTest.java
index 6c6a2be09..37a185d6a 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/SubInterfaceCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/SubInterfaceCustomizerTest.java
@@ -95,13 +95,13 @@ public class SubInterfaceCustomizerTest extends WriterCustomizerTest {
return tag.build();
}
- private static Match generateMatch() {
+ static Match generateMatch() {
final MatchBuilder match = new MatchBuilder();
final VlanTaggedBuilder tagged = new VlanTaggedBuilder();
tagged.setMatchExactTags(true);
match.setMatchType(
- new org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.vlan.rev180319.match.attributes.match.type.VlanTaggedBuilder()
- .setVlanTagged(tagged.build()).build());
+ new org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.vlan.rev180319.match.attributes.match.type.VlanTaggedBuilder()
+ .setVlanTagged(tagged.build()).build());
return match.build();
}
@@ -136,8 +136,8 @@ public class SubInterfaceCustomizerTest extends WriterCustomizerTest {
request.twoTags = 1;
request.innerVlanId = innerVlanId;
request.innerVlanIdAny = (byte) (isInnerAny
- ? 1
- : 0);
+ ? 1
+ : 0);
request.dot1Ad = 1;
request.outerVlanId = STAG_ID;
request.exactMatch = 1;
@@ -153,8 +153,8 @@ public class SubInterfaceCustomizerTest extends WriterCustomizerTest {
private InstanceIdentifier<SubInterface> getSubInterfaceId(final String name, final long index) {
return InstanceIdentifier.create(Interfaces.class).child(Interface.class, new InterfaceKey(name)).augmentation(
- SubinterfaceAugmentation.class).child(SubInterfaces.class)
- .child(SubInterface.class, new SubInterfaceKey(index));
+ SubinterfaceAugmentation.class).child(SubInterfaces.class)
+ .child(SubInterface.class, new SubInterfaceKey(index));
}
private void whenCreateSubifThenSuccess() {
@@ -173,7 +173,7 @@ public class SubInterfaceCustomizerTest extends WriterCustomizerTest {
}
private SwInterfaceSetFlags verifySwInterfaceSetFlagsWasInvoked(final SwInterfaceSetFlags expected)
- throws VppBaseCallException {
+ throws VppBaseCallException {
ArgumentCaptor<SwInterfaceSetFlags> argumentCaptor = ArgumentCaptor.forClass(SwInterfaceSetFlags.class);
verify(api).swInterfaceSetFlags(argumentCaptor.capture());
final SwInterfaceSetFlags actual = argumentCaptor.getValue();
@@ -195,8 +195,8 @@ public class SubInterfaceCustomizerTest extends WriterCustomizerTest {
verify(api).createSubif(generateSubInterfaceRequest(SUPER_IF_ID, CTAG_ID, false));
verify(mappingContext)
- .put(eq(mappingIid(SUB_IFACE_NAME, IFC_TEST_INSTANCE)), eq(
- mapping(SUB_IFACE_NAME, 0).get()));
+ .put(eq(mappingIid(SUB_IFACE_NAME, IFC_TEST_INSTANCE)), eq(
+ mapping(SUB_IFACE_NAME, 0).get()));
}
@Test
@@ -211,8 +211,8 @@ public class SubInterfaceCustomizerTest extends WriterCustomizerTest {
verify(api).createSubif(generateSubInterfaceRequest(SUPER_IF_ID, CTAG_ANY_ID, true));
verify(mappingContext)
- .put(eq(mappingIid(SUB_IFACE_NAME, IFC_TEST_INSTANCE)), eq(
- mapping(SUB_IFACE_NAME, 0).get()));
+ .put(eq(mappingIid(SUB_IFACE_NAME, IFC_TEST_INSTANCE)), eq(
+ mapping(SUB_IFACE_NAME, 0).get()));
}
@Test
@@ -228,8 +228,8 @@ public class SubInterfaceCustomizerTest extends WriterCustomizerTest {
assertTrue(e.getCause() instanceof VppBaseCallException);
verify(api).createSubif(generateSubInterfaceRequest(SUPER_IF_ID, CTAG_ID, false));
verify(mappingContext, times(0)).put(
- eq(mappingIid(SUPER_IF_NAME, IFC_TEST_INSTANCE)),
- eq(mapping(SUPER_IF_NAME, 0).get()));
+ eq(mappingIid(SUPER_IF_NAME, IFC_TEST_INSTANCE)),
+ eq(mapping(SUPER_IF_NAME, 0).get()));
return;
}
fail("WriteFailedException.CreateFailedException was expected");
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/SubInterfaceRoutingCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/SubInterfaceRoutingCustomizerTest.java
index 5732d587b..90c9d66c8 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/SubInterfaceRoutingCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/SubInterfaceRoutingCustomizerTest.java
@@ -21,7 +21,6 @@ import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import java.util.Optional;
import com.google.common.collect.ImmutableSet;
import io.fd.hc2vpp.common.test.write.WriterCustomizerTest;
import io.fd.hc2vpp.common.translate.util.ByteDataTranslator;
@@ -30,6 +29,7 @@ import io.fd.honeycomb.translate.write.WriteFailedException;
import io.fd.jvpp.core.dto.SwInterfaceSetTable;
import io.fd.jvpp.core.dto.SwInterfaceSetTableReply;
import java.util.Collections;
+import java.util.Optional;
import java.util.Set;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
@@ -38,11 +38,7 @@ import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.fib.table.managem
import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.vlan.rev180319.SubinterfaceAugmentation;
import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.vlan.rev180319.interfaces._interface.SubInterfaces;
import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.vlan.rev180319.interfaces._interface.sub.interfaces.SubInterface;
-import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.vlan.rev180319.interfaces._interface.sub.interfaces.SubInterfaceBuilder;
import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.vlan.rev180319.interfaces._interface.sub.interfaces.SubInterfaceKey;
-import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.vlan.rev180319.sub._interface.ip4.attributes.Ipv4Builder;
-import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.vlan.rev180319.sub._interface.ip4.attributes.ipv4.AddressBuilder;
-import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.vlan.rev180319.sub._interface.ip6.attributes.Ipv6Builder;
import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.vlan.rev180319.sub._interface.routing.attributes.Routing;
import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.vlan.rev180319.sub._interface.routing.attributes.RoutingBuilder;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev180220.Interfaces;
@@ -80,20 +76,6 @@ public class SubInterfaceRoutingCustomizerTest extends WriterCustomizerTest impl
when(api.swInterfaceSetTable(any())).thenReturn(future(new SwInterfaceSetTableReply()));
}
- @Test(expected = IllegalStateException.class)
- public void testWriteFailedV4AddressPresent() throws WriteFailedException {
- when(writeContext.readBefore(any(InstanceIdentifier.class))).thenReturn(Optional.of(v4AddressPresent()));
- final Routing v4Routing = new RoutingBuilder().setIpv4VrfId(new VniReference(4L)).build();
- customizer.writeCurrentAttributes(VALID_ID, v4Routing, writeContext);
- }
-
- @Test(expected = IllegalStateException.class)
- public void testWriteFailedV6AddressPresent() throws WriteFailedException {
- when(writeContext.readBefore(any(InstanceIdentifier.class))).thenReturn(Optional.of(v6AddressPresent()));
- final Routing v4Routing = new RoutingBuilder().setIpv4VrfId(new VniReference(4L)).build();
- customizer.writeCurrentAttributes(VALID_ID, v4Routing, writeContext);
- }
-
@Test
public void testWriteIpv4Vrf() throws WriteFailedException {
when(writeContext.readBefore(any(InstanceIdentifier.class))).thenReturn(Optional.empty());
@@ -102,7 +84,6 @@ public class SubInterfaceRoutingCustomizerTest extends WriterCustomizerTest impl
verifySetTableRequest(1, Collections.singleton(request(false, SUBIF_INDEX, 4)));
}
-
@Test
public void testWriteIpv6Vrf() throws WriteFailedException {
when(writeContext.readBefore(any(InstanceIdentifier.class))).thenReturn(Optional.empty());
@@ -115,9 +96,9 @@ public class SubInterfaceRoutingCustomizerTest extends WriterCustomizerTest impl
public void testUpdateIpv4Vrf() throws WriteFailedException {
when(writeContext.readBefore(any(InstanceIdentifier.class))).thenReturn(Optional.empty());
final Routing routingBefore = new RoutingBuilder().setIpv6VrfId(new VniReference(3L))
- .setIpv4VrfId(new VniReference(4L)).build();
+ .setIpv4VrfId(new VniReference(4L)).build();
final Routing routingAfter = new RoutingBuilder().setIpv6VrfId(new VniReference(3L))
- .setIpv4VrfId(new VniReference(5L)).build();
+ .setIpv4VrfId(new VniReference(5L)).build();
customizer.updateCurrentAttributes(VALID_ID, routingBefore, routingAfter, writeContext);
verifySetTableRequest(2, ImmutableSet.of(request(false, SUBIF_INDEX, 5),
request(true, SUBIF_INDEX, 3)));
@@ -127,9 +108,9 @@ public class SubInterfaceRoutingCustomizerTest extends WriterCustomizerTest impl
public void testUpdateIpv6Vrf() throws WriteFailedException {
when(writeContext.readBefore(any(InstanceIdentifier.class))).thenReturn(Optional.empty());
final Routing routingBefore = new RoutingBuilder().setIpv6VrfId(new VniReference(3L))
- .setIpv4VrfId(new VniReference(4L)).build();
+ .setIpv4VrfId(new VniReference(4L)).build();
final Routing routingAfter = new RoutingBuilder().setIpv6VrfId(new VniReference(8L))
- .setIpv4VrfId(new VniReference(4L)).build();
+ .setIpv4VrfId(new VniReference(4L)).build();
customizer.updateCurrentAttributes(VALID_ID, routingBefore, routingAfter, writeContext);
verifySetTableRequest(2, ImmutableSet.of(request(false, SUBIF_INDEX, 4),
request(true, SUBIF_INDEX, 8)));
@@ -164,20 +145,4 @@ public class SubInterfaceRoutingCustomizerTest extends WriterCustomizerTest impl
verify(api, times(times)).swInterfaceSetTable(requestCaptor.capture());
requestCaptor.getAllValues().containsAll(requests);
}
-
- private static SubInterface v4AddressPresent() {
- return new SubInterfaceBuilder()
- .setIpv4(new Ipv4Builder()
- .setAddress(Collections.singletonList(new AddressBuilder().build()))
- .build())
- .build();
- }
-
- private static SubInterface v6AddressPresent(){
- return new SubInterfaceBuilder()
- .setIpv6(new Ipv6Builder()
- .setAddress(Collections.singletonList(new org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.vlan.rev180319.sub._interface.ip6.attributes.ipv6.AddressBuilder().build()))
- .build())
- .build();
- }
}
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/SubInterfaceRoutingValidatorTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/SubInterfaceRoutingValidatorTest.java
new file mode 100644
index 000000000..510887e70
--- /dev/null
+++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/SubInterfaceRoutingValidatorTest.java
@@ -0,0 +1,123 @@
+/*
+ * Copyright (c) 2019 PANTHEON.tech.
+ *
+ * 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.v3po.interfaces;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.when;
+import static org.mockito.MockitoAnnotations.initMocks;
+
+import io.fd.hc2vpp.common.translate.util.NamingContext;
+import io.fd.honeycomb.translate.write.DataValidationFailedException.CreateValidationFailedException;
+import io.fd.honeycomb.translate.write.DataValidationFailedException.DeleteValidationFailedException;
+import io.fd.honeycomb.translate.write.DataValidationFailedException.UpdateValidationFailedException;
+import io.fd.honeycomb.translate.write.WriteContext;
+import java.util.Collections;
+import java.util.Optional;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.fib.table.management.rev180521.VniReference;
+import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.vlan.rev180319.SubinterfaceAugmentation;
+import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.vlan.rev180319.interfaces._interface.SubInterfaces;
+import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.vlan.rev180319.interfaces._interface.sub.interfaces.SubInterface;
+import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.vlan.rev180319.interfaces._interface.sub.interfaces.SubInterfaceBuilder;
+import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.vlan.rev180319.interfaces._interface.sub.interfaces.SubInterfaceKey;
+import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.vlan.rev180319.sub._interface.ip4.attributes.Ipv4Builder;
+import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.vlan.rev180319.sub._interface.ip4.attributes.ipv4.AddressBuilder;
+import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.vlan.rev180319.sub._interface.ip6.attributes.Ipv6Builder;
+import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.vlan.rev180319.sub._interface.routing.attributes.Routing;
+import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.vlan.rev180319.sub._interface.routing.attributes.RoutingBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev180220.Interfaces;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev180220.interfaces.Interface;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev180220.interfaces.InterfaceKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public class SubInterfaceRoutingValidatorTest {
+
+ private SubInterfaceRoutingValidator validator;
+
+ @Mock
+ private WriteContext writeContext;
+
+ private static final String IF_NAME = "eth1";
+ private static final int SUBIF_INDEX = 0;
+ private static final InstanceIdentifier<Routing> ID =
+ InstanceIdentifier.create(Interfaces.class).child(Interface.class, new InterfaceKey(IF_NAME))
+ .augmentation(SubinterfaceAugmentation.class)
+ .child(SubInterfaces.class)
+ .child(SubInterface.class, new SubInterfaceKey((long) SUBIF_INDEX))
+ .child(Routing.class);
+
+ @Before
+ public void setUp() {
+ initMocks(this);
+ NamingContext ifcContext = new NamingContext("testInterfaceContext", "testInterfaceContext");
+ validator = new SubInterfaceRoutingValidator(ifcContext);
+ }
+
+ @Test
+ public void testWriteSuccessful() throws CreateValidationFailedException {
+ when(writeContext.readBefore(any(InstanceIdentifier.class))).thenReturn(Optional.empty());
+ validator.validateWrite(ID, getRouting(), writeContext);
+ }
+
+ @Test(expected = CreateValidationFailedException.class)
+ public void testWriteFailedV4AddressPresent() throws CreateValidationFailedException {
+ when(writeContext.readBefore(any(InstanceIdentifier.class))).thenReturn(Optional.of(v4AddressPresent()));
+ validator.validateWrite(ID, getRouting(), writeContext);
+ }
+
+ @Test(expected = CreateValidationFailedException.class)
+ public void testWriteFailedV6AddressPresent() throws CreateValidationFailedException {
+ when(writeContext.readBefore(any(InstanceIdentifier.class))).thenReturn(Optional.of(v6AddressPresent()));
+ validator.validateWrite(ID, getRouting(), writeContext);
+ }
+
+ @Test
+ public void testUpdateSuccessful() throws UpdateValidationFailedException {
+ when(writeContext.readBefore(any(InstanceIdentifier.class))).thenReturn(Optional.empty());
+ validator.validateUpdate(ID, getRouting(), getRouting(), writeContext);
+ }
+
+ @Test
+ public void testDeleteSuccessful() throws DeleteValidationFailedException {
+ when(writeContext.readBefore(any(InstanceIdentifier.class))).thenReturn(Optional.empty());
+ validator.validateDelete(ID, getRouting(), writeContext);
+ }
+
+ private Routing getRouting() {
+ return new RoutingBuilder().setIpv4VrfId(new VniReference(4L)).build();
+ }
+
+ private SubInterface v4AddressPresent() {
+ return new SubInterfaceBuilder()
+ .setIpv4(new Ipv4Builder()
+ .setAddress(Collections.singletonList(new AddressBuilder().build()))
+ .build())
+ .build();
+ }
+
+ private SubInterface v6AddressPresent() {
+ return new SubInterfaceBuilder()
+ .setIpv6(new Ipv6Builder()
+ .setAddress(Collections.singletonList(
+ new org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.vlan.rev180319.sub._interface.ip6.attributes.ipv6.AddressBuilder()
+ .build()))
+ .build())
+ .build();
+ }
+}
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/SubInterfaceUnnumberedCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/SubInterfaceUnnumberedCustomizerTest.java
index 5c640d204..fdaf6f925 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/SubInterfaceUnnumberedCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/SubInterfaceUnnumberedCustomizerTest.java
@@ -34,10 +34,10 @@ public class SubInterfaceUnnumberedCustomizerTest extends AbstractUnnumberedCust
private static final int UNNUMBERED_IFC_ID = 2;
private static final long UNNUMBERED_IFC_NUMBER = 123;
private static final InstanceIdentifier<Unnumbered> UNNUMBERED_IFC_IID = InstanceIdentifier.create(Interfaces.class)
- .child(Interface.class, new InterfaceKey(PARENT_IFC_NAME))
- .augmentation(SubinterfaceAugmentation.class).child(SubInterfaces.class)
- .child(SubInterface.class, new SubInterfaceKey(UNNUMBERED_IFC_NUMBER)).augmentation(
- SubinterfaceUnnumberedAugmentation.class).child(Unnumbered.class);
+ .child(Interface.class, new InterfaceKey(PARENT_IFC_NAME))
+ .augmentation(SubinterfaceAugmentation.class).child(SubInterfaces.class)
+ .child(SubInterface.class, new SubInterfaceKey(UNNUMBERED_IFC_NUMBER))
+ .augmentation(SubinterfaceUnnumberedAugmentation.class).child(Unnumbered.class);
@Override
protected int getUnnumberedIfcId() {
@@ -58,5 +58,4 @@ public class SubInterfaceUnnumberedCustomizerTest extends AbstractUnnumberedCust
protected AbstractUnnumberedCustomizer getCustomizer() {
return new SubInterfaceUnnumberedCustomizer(api, new NamingContext("ifc-prefix", IFC_CTX_NAME));
}
-
}
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/SubInterfaceUnnumberedValidatorTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/SubInterfaceUnnumberedValidatorTest.java
new file mode 100644
index 000000000..73043be8b
--- /dev/null
+++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/SubInterfaceUnnumberedValidatorTest.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2019 PANTHEON.tech.
+ *
+ * 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.v3po.interfaces;
+
+import static org.mockito.MockitoAnnotations.initMocks;
+
+import io.fd.hc2vpp.common.translate.util.NamingContext;
+import io.fd.honeycomb.translate.write.DataValidationFailedException;
+import io.fd.honeycomb.translate.write.WriteContext;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.unnumbered.interfaces.rev180103.InterfaceUnnumberedAugmentation;
+import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.unnumbered.interfaces.rev180103.unnumbered.config.attributes.Unnumbered;
+import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.unnumbered.interfaces.rev180103.unnumbered.config.attributes.UnnumberedBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev180220.Interfaces;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev180220.interfaces.Interface;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev180220.interfaces.InterfaceKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public class SubInterfaceUnnumberedValidatorTest {
+
+ private SubInterfaceUnnumberedValidator validator;
+
+ @Mock
+ private WriteContext writeContext;
+
+ private static final String IF_NAME = "eth2";
+ private static final String TARGET_IFC0_NAME = "eth0";
+ private static final InstanceIdentifier<Unnumbered> ID = InstanceIdentifier.create(Interfaces.class)
+ .child(Interface.class, new InterfaceKey(IF_NAME))
+ .augmentation(InterfaceUnnumberedAugmentation.class)
+ .child(Unnumbered.class);
+
+ @Before
+ public void setUp() {
+ initMocks(this);
+ NamingContext ifcContext = new NamingContext("testInterfaceContext", "testInterfaceContext");
+ validator = new SubInterfaceUnnumberedValidator(ifcContext);
+ }
+
+ @Test
+ public void testWriteSuccessful() throws DataValidationFailedException.CreateValidationFailedException {
+ validator.validateWrite(ID, getUnnumberedIfc(TARGET_IFC0_NAME), writeContext);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testWriteFailedNoUse() throws DataValidationFailedException.CreateValidationFailedException {
+ validator.validateWrite(ID, getUnnumberedIfc(null), writeContext);
+ }
+
+ @Test
+ public void testUpdateSuccessful() throws DataValidationFailedException.UpdateValidationFailedException {
+ validator.validateUpdate(ID, getUnnumberedIfc(TARGET_IFC0_NAME), getUnnumberedIfc(TARGET_IFC0_NAME),
+ writeContext);
+ }
+
+ @Test
+ public void testDeleteeSuccessful() throws DataValidationFailedException.DeleteValidationFailedException {
+ validator.validateDelete(ID, getUnnumberedIfc(TARGET_IFC0_NAME), writeContext);
+ }
+
+ private Unnumbered getUnnumberedIfc(String use) {
+ return new UnnumberedBuilder().setUse(use).build();
+ }
+}
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/SubInterfaceValidatorTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/SubInterfaceValidatorTest.java
new file mode 100644
index 000000000..e7b9e668b
--- /dev/null
+++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/SubInterfaceValidatorTest.java
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2019 PANTHEON.tech.
+ *
+ * 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.v3po.interfaces;
+
+import static org.mockito.MockitoAnnotations.initMocks;
+
+import io.fd.hc2vpp.common.translate.util.NamingContext;
+import io.fd.honeycomb.translate.write.DataValidationFailedException.CreateValidationFailedException;
+import io.fd.honeycomb.translate.write.WriteContext;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.vlan.rev180319.SubinterfaceAugmentation;
+import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.vlan.rev180319.interfaces._interface.SubInterfaces;
+import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.vlan.rev180319.interfaces._interface.sub.interfaces.SubInterface;
+import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.vlan.rev180319.interfaces._interface.sub.interfaces.SubInterfaceBuilder;
+import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.vlan.rev180319.interfaces._interface.sub.interfaces.SubInterfaceKey;
+import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.vlan.rev180319.sub._interface.base.attributes.Match;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev180220.Interfaces;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev180220.interfaces.Interface;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev180220.interfaces.InterfaceKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public class SubInterfaceValidatorTest {
+
+ private SubInterfaceValidator validator;
+
+ @Mock
+ private WriteContext writeContext;
+
+ private static final String SUPER_IF_NAME = "local0";
+ private static final String SUB_IFACE_NAME = "local0.11";
+ private static final long SUBIF_INDEX = 11;
+ private static final InstanceIdentifier<SubInterface> ID =
+ InstanceIdentifier.create(Interfaces.class).child(Interface.class, new InterfaceKey(SUPER_IF_NAME))
+ .augmentation(
+ SubinterfaceAugmentation.class).child(SubInterfaces.class)
+ .child(SubInterface.class, new SubInterfaceKey(SUBIF_INDEX));
+
+ @Before
+ public void setUp() {
+ initMocks(this);
+ NamingContext ifcContext = new NamingContext("testInterfaceContext", "testInterfaceContext");
+ validator = new SubInterfaceValidator(ifcContext);
+ }
+
+ @Test
+ public void testWriteSuccessful() throws CreateValidationFailedException {
+ validator
+ .validateWrite(ID, generateSubInterface(11L, SubInterfaceCustomizerTest.generateMatch()), writeContext);
+ }
+
+ @Test(expected = CreateValidationFailedException.class)
+ public void testWriteFailedNoIdentifier() throws CreateValidationFailedException {
+ validator.validateWrite(ID, generateSubInterface(null, SubInterfaceCustomizerTest.generateMatch()),
+ writeContext);
+ }
+
+ @Test(expected = CreateValidationFailedException.class)
+ public void testWriteFailedNoMatch() throws CreateValidationFailedException {
+ validator.validateWrite(ID, generateSubInterface(11L, null), writeContext);
+ }
+
+ private SubInterface generateSubInterface(final Long identifier, final Match match) {
+ return new SubInterfaceBuilder()
+ .setIdentifier(identifier)
+ .setMatch(match)
+ .setEnabled(true)
+ .build();
+ }
+}
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/VhostUserCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/VhostUserCustomizerTest.java
index ea3b699a7..db190ee06 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/VhostUserCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/VhostUserCustomizerTest.java
@@ -61,7 +61,7 @@ public class VhostUserCustomizerTest extends WriterCustomizerTest implements Ipv
.augmentation(VppInterfaceAugmentation.class).child(VhostUser.class);
private VhostUserCustomizer customizer;
- private static VhostUser generateVhostUser(final VhostUserRole role, final String socketName) {
+ static VhostUser generateVhostUser(final VhostUserRole role, final String socketName) {
VhostUserBuilder builder = new VhostUserBuilder();
builder.setRole(role);
builder.setSocket(socketName);
@@ -121,7 +121,7 @@ public class VhostUserCustomizerTest extends WriterCustomizerTest implements Ipv
customizer.writeCurrentAttributes(ID, vhostUser, writeContext);
verifyCreateVhostUserIfWasInvoked(vhostUser);
verify(mappingContext).put(eq(mappingIid(IFACE_NAME, "test-instance")), eq(
- mapping(IFACE_NAME, 0).get()));
+ mapping(IFACE_NAME, 0).get()));
}
@Test
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/VhostUserValidatorTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/VhostUserValidatorTest.java
new file mode 100644
index 000000000..eb8541270
--- /dev/null
+++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/VhostUserValidatorTest.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2019 PANTHEON.tech.
+ *
+ * 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.v3po.interfaces;
+
+import static org.mockito.MockitoAnnotations.initMocks;
+
+import io.fd.hc2vpp.common.translate.util.NamingContext;
+import io.fd.honeycomb.translate.write.DataValidationFailedException;
+import io.fd.honeycomb.translate.write.WriteContext;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.v3po.rev190502.VhostUserRole;
+import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.v3po.rev190502.VppInterfaceAugmentation;
+import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.v3po.rev190502.interfaces._interface.VhostUser;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev180220.Interfaces;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev180220.interfaces.Interface;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev180220.interfaces.InterfaceKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public class VhostUserValidatorTest {
+
+ private VhostUserValidator validator;
+
+ @Mock
+ private WriteContext writeContext;
+
+ private static final String SOCKET = "testSocket";
+ private static final String IFACE_NAME = "eth0";
+ private static final InstanceIdentifier<VhostUser> ID =
+ InstanceIdentifier.create(Interfaces.class).child(Interface.class, new InterfaceKey(IFACE_NAME))
+ .augmentation(VppInterfaceAugmentation.class).child(VhostUser.class);
+
+ @Before
+ public void setUp() {
+ initMocks(this);
+ NamingContext ifcContext = new NamingContext("testInterfaceContext", "testInterfaceContext");
+ validator = new VhostUserValidator(ifcContext);
+ }
+
+ @Test
+ public void testWriteSuccessful() throws DataValidationFailedException.CreateValidationFailedException {
+ validator.validateWrite(ID, getVhostUser(SOCKET), writeContext);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testWriteFailedNoSocket() throws DataValidationFailedException.CreateValidationFailedException {
+ validator.validateWrite(ID, getVhostUser(null), writeContext);
+ }
+
+ @Test
+ public void testUpdateSuccessful() throws DataValidationFailedException.UpdateValidationFailedException {
+ validator.validateUpdate(ID, getVhostUser(SOCKET),
+ getVhostUser(SOCKET), writeContext);
+ }
+
+ @Test
+ public void testDeleteeSuccessful() throws DataValidationFailedException.DeleteValidationFailedException {
+ validator.validateDelete(ID, getVhostUser(SOCKET), writeContext);
+ }
+
+ private VhostUser getVhostUser(final String socketName) {
+ return VhostUserCustomizerTest.generateVhostUser(VhostUserRole.Client, socketName);
+ }
+}
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/VxlanGpeValidatorTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/VxlanGpeValidatorTest.java
new file mode 100644
index 000000000..c4955d881
--- /dev/null
+++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/VxlanGpeValidatorTest.java
@@ -0,0 +1,151 @@
+/*
+ * Copyright (c) 2019 PANTHEON.tech.
+ *
+ * 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.v3po.interfaces;
+
+import static org.mockito.MockitoAnnotations.initMocks;
+
+import io.fd.hc2vpp.common.translate.util.NamingContext;
+import io.fd.hc2vpp.v3po.DisabledInterfacesManager;
+import io.fd.honeycomb.translate.write.DataValidationFailedException.CreateValidationFailedException;
+import io.fd.honeycomb.translate.write.DataValidationFailedException.DeleteValidationFailedException;
+import io.fd.honeycomb.translate.write.WriteContext;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.v3po.rev190502.VppInterfaceAugmentation;
+import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.v3po.rev190502.VxlanGpeNextProtocol;
+import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.v3po.rev190502.VxlanGpeVni;
+import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.v3po.rev190502.interfaces._interface.VxlanGpe;
+import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.v3po.rev190502.interfaces._interface.VxlanGpeBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressNoZone;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6AddressNoZone;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev180220.Interfaces;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev180220.interfaces.Interface;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev180220.interfaces.InterfaceKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public class VxlanGpeValidatorTest {
+
+ private VxlanGpeValidator validator;
+
+ @Mock
+ private WriteContext writeContext;
+ @Mock
+ private DisabledInterfacesManager interfaceDisableContext;
+
+ private static final String IPV6 = "a::100";
+ private static final String IPV4_1 = "192.168.20.10";
+ private static final String IPV4_2 = "192.168.20.11";
+ private static final Long VNI = Long.valueOf(11);
+ private static final Long ENCAP = Long.valueOf(123);
+ private static final Long DECAP = Long.valueOf(321);
+ private static final String IFACE_NAME = "eth0";
+ private static final InstanceIdentifier<VxlanGpe> ID =
+ InstanceIdentifier.create(Interfaces.class).child(Interface.class, new InterfaceKey(IFACE_NAME))
+ .augmentation(VppInterfaceAugmentation.class).child(VxlanGpe.class);
+
+ @Before
+ public void setUp() {
+ initMocks(this);
+ NamingContext ifcContext = new NamingContext("testInterfaceContext", "testInterfaceContext");
+ validator = new VxlanGpeValidator(ifcContext, interfaceDisableContext);
+ }
+
+ @Test
+ public void testWriteSuccessful() throws CreateValidationFailedException {
+ validator.validateWrite(ID, generateVxlanCorrect(), writeContext);
+ }
+
+ @Test(expected = CreateValidationFailedException.class)
+ public void testWriteFailedMixedIpFamilies() throws CreateValidationFailedException {
+ validator.validateWrite(ID, generateVxlanMixedIpFamilies(), writeContext);
+ }
+
+ @Test(expected = CreateValidationFailedException.class)
+ public void testWriteFailedNoLocal() throws CreateValidationFailedException {
+ validator.validateWrite(ID, generateVxlanSetFields(false, true, true, true, true, true), writeContext);
+ }
+
+ @Test(expected = CreateValidationFailedException.class)
+ public void testWriteFailedNoRemote() throws CreateValidationFailedException {
+ validator.validateWrite(ID, generateVxlanSetFields(true, false, true, true, true, true), writeContext);
+ }
+
+ @Test(expected = CreateValidationFailedException.class)
+ public void testWriteFailedNoEncapVrfId() throws CreateValidationFailedException {
+ validator.validateWrite(ID, generateVxlanSetFields(true, true, false, true, true, true), writeContext);
+ }
+
+ @Test(expected = CreateValidationFailedException.class)
+ public void testWriteFailedNoDecapVrfId() throws CreateValidationFailedException {
+ validator.validateWrite(ID, generateVxlanSetFields(true, true, true, false, true, true), writeContext);
+ }
+
+ @Test(expected = CreateValidationFailedException.class)
+ public void testWriteFailedNoVNI() throws CreateValidationFailedException {
+ validator.validateWrite(ID, generateVxlanSetFields(true, true, true, true, false, true), writeContext);
+ }
+
+ @Test(expected = CreateValidationFailedException.class)
+ public void testWriteFailedNoNextProtocol() throws CreateValidationFailedException {
+ validator.validateWrite(ID, generateVxlanSetFields(true, true, true, true, true, false), writeContext);
+ }
+
+ @Test
+ public void testDeleteSuccessful() throws DeleteValidationFailedException {
+ validator.validateDelete(ID, generateVxlanCorrect(), writeContext);
+ }
+
+ private VxlanGpe generateVxlanSetFields(final boolean src, final boolean dst, final boolean encapVrfId,
+ final boolean decapVrfId, final boolean vni, final boolean protocol) {
+ final VxlanGpeBuilder builder = new VxlanGpeBuilder();
+ builder.setLocal(src
+ ? new IpAddressNoZone(new Ipv4AddressNoZone(IPV4_1))
+ : null);
+ builder.setRemote(dst
+ ? new IpAddressNoZone(new Ipv4AddressNoZone(IPV4_2))
+ : null);
+ builder.setEncapVrfId(encapVrfId
+ ? ENCAP
+ : null);
+ builder.setDecapVrfId(decapVrfId
+ ? DECAP
+ : null);
+ builder.setVni(vni
+ ? new VxlanGpeVni(VNI)
+ : null);
+ builder.setNextProtocol(protocol
+ ? VxlanGpeNextProtocol.forValue(1)
+ : null);
+ return builder.build();
+ }
+
+ private VxlanGpe generateVxlanCorrect() {
+ return generateVxlanSetFields(true, true, true, true, true, true);
+ }
+
+ private VxlanGpe generateVxlanMixedIpFamilies() {
+ return new VxlanGpeBuilder()
+ .setLocal(new IpAddressNoZone(new Ipv6AddressNoZone(IPV6)))
+ .setRemote(new IpAddressNoZone(new Ipv4AddressNoZone(IPV4_1)))
+ .setEncapVrfId(ENCAP).setDecapVrfId(DECAP)
+ .setVni(new VxlanGpeVni(VNI))
+ .setNextProtocol(VxlanGpeNextProtocol.forValue(1))
+ .build();
+ }
+}
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/VxlanValidatorTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/VxlanValidatorTest.java
new file mode 100644
index 000000000..587b9f313
--- /dev/null
+++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/VxlanValidatorTest.java
@@ -0,0 +1,142 @@
+/*
+ * Copyright (c) 2019 PANTHEON.tech.
+ *
+ * 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.v3po.interfaces;
+
+import static org.mockito.MockitoAnnotations.initMocks;
+
+import io.fd.hc2vpp.common.translate.util.NamingContext;
+import io.fd.hc2vpp.v3po.DisabledInterfacesManager;
+import io.fd.honeycomb.translate.write.DataValidationFailedException.CreateValidationFailedException;
+import io.fd.honeycomb.translate.write.DataValidationFailedException.DeleteValidationFailedException;
+import io.fd.honeycomb.translate.write.WriteContext;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.v3po.rev190502.L2Input;
+import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.v3po.rev190502.VppInterfaceAugmentation;
+import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.v3po.rev190502.VxlanVni;
+import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.v3po.rev190502.interfaces._interface.Vxlan;
+import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.v3po.rev190502.interfaces._interface.VxlanBuilder;
+import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.fib.table.management.rev180521.VniReference;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressNoZone;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6AddressNoZone;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev180220.Interfaces;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev180220.interfaces.Interface;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev180220.interfaces.InterfaceKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public class VxlanValidatorTest {
+
+ private VxlanValidator validator;
+
+ @Mock
+ private WriteContext writeContext;
+ @Mock
+ private DisabledInterfacesManager interfaceDisableContext;
+
+ private static final String IPV6 = "a::100";
+ private static final String IPV4_1 = "192.168.20.10";
+ private static final String IPV4_2 = "192.168.20.11";
+ private static final Long VNI = Long.valueOf(11);
+ private static final Long ENCAP = Long.valueOf(123);
+ private static final String IFACE_NAME = "eth0";
+ private static final InstanceIdentifier<Vxlan> ID =
+ InstanceIdentifier.create(Interfaces.class).child(Interface.class, new InterfaceKey(IFACE_NAME))
+ .augmentation(VppInterfaceAugmentation.class).child(Vxlan.class);
+
+ @Before
+ public void setUp() {
+ initMocks(this);
+ NamingContext ifcContext = new NamingContext("testInterfaceContext", "testInterfaceContext");
+ validator = new VxlanValidator(ifcContext, interfaceDisableContext);
+ }
+
+ @Test
+ public void testWriteSuccessful() throws CreateValidationFailedException {
+ validator.validateWrite(ID, generateVxlanCorrect(), writeContext);
+ }
+
+ @Test(expected = CreateValidationFailedException.class)
+ public void testWriteFailedMixedIpFamilies() throws CreateValidationFailedException {
+ validator.validateWrite(ID, generateVxlanMixedIpFamilies(), writeContext);
+ }
+
+ @Test(expected = CreateValidationFailedException.class)
+ public void testWriteFailedNoSrc() throws CreateValidationFailedException {
+ validator.validateWrite(ID, generateVxlanSetFields(false, true, true, true), writeContext);
+ }
+
+ @Test(expected = CreateValidationFailedException.class)
+ public void testWriteFailedNoDst() throws CreateValidationFailedException {
+ validator.validateWrite(ID, generateVxlanSetFields(true, false, true, true), writeContext);
+ }
+
+ @Test(expected = CreateValidationFailedException.class)
+ public void testWriteFailedNoEncap() throws CreateValidationFailedException {
+ validator.validateWrite(ID, generateVxlanSetFields(true, true, false, true), writeContext);
+ }
+
+ @Test(expected = CreateValidationFailedException.class)
+ public void testWriteFailedNoVNI() throws CreateValidationFailedException {
+ validator.validateWrite(ID, generateVxlanSetFields(true, true, true, false), writeContext);
+ }
+
+ @Test
+ public void testDeleteSuccessful() throws DeleteValidationFailedException {
+ validator.validateDelete(ID, generateVxlanCorrect(), writeContext);
+ }
+
+ private Vxlan generateVxlan(final IpAddressNoZone src, final IpAddressNoZone dst, final VniReference encapVrfId,
+ final long vni) {
+ final VxlanBuilder builder = new VxlanBuilder();
+ builder.setSrc(src);
+ builder.setDst(dst);
+ builder.setEncapVrfId(encapVrfId);
+ builder.setVni(new VxlanVni(vni));
+ builder.setDecapNext(L2Input.class);
+ return builder.build();
+ }
+
+ private Vxlan generateVxlanSetFields(final boolean src, final boolean dst, final boolean encapVrfId,
+ final boolean vni) {
+ final VxlanBuilder builder = new VxlanBuilder();
+ builder.setSrc(src
+ ? new IpAddressNoZone(new Ipv4AddressNoZone(IPV4_1))
+ : null);
+ builder.setDst(dst
+ ? new IpAddressNoZone(new Ipv4AddressNoZone(IPV4_2))
+ : null);
+ builder.setEncapVrfId(encapVrfId
+ ? new VniReference(ENCAP)
+ : null);
+ builder.setVni(vni
+ ? new VxlanVni(VNI)
+ : null);
+ builder.setDecapNext(L2Input.class);
+ return builder.build();
+ }
+
+ private Vxlan generateVxlanCorrect() {
+ return generateVxlanSetFields(true, true, true, true);
+ }
+
+ private Vxlan generateVxlanMixedIpFamilies() {
+ return generateVxlan(new IpAddressNoZone(new Ipv6AddressNoZone(IPV6)),
+ new IpAddressNoZone(new Ipv4AddressNoZone(IPV4_2)), new VniReference(ENCAP), VNI);
+ }
+}
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/pbb/PbbRewriteCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/pbb/PbbRewriteCustomizerTest.java
index d2c9ed3a8..206a5a086 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/pbb/PbbRewriteCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/pbb/PbbRewriteCustomizerTest.java
@@ -38,11 +38,9 @@ import org.mockito.Captor;
import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.pbb.types.rev161214.Operation;
import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.pbb.rev161214.PbbRewriteInterfaceAugmentation;
import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.pbb.rev161214.interfaces._interface.PbbRewrite;
-import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.pbb.rev161214.interfaces._interface.PbbRewriteBuilder;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev180220.Interfaces;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev180220.interfaces.Interface;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev180220.interfaces.InterfaceKey;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
public class PbbRewriteCustomizerTest extends WriterCustomizerTest {
@@ -72,14 +70,14 @@ public class PbbRewriteCustomizerTest extends WriterCustomizerTest {
@Test
public void testWrite() throws WriteFailedException {
whenRewriteThenSuccess();
- customizer.writeCurrentAttributes(validId, validData(), writeContext);
+ customizer.writeCurrentAttributes(validId, PbbRewriteValidatorTest.validData(), writeContext);
verifyRewriteRequest(desiredSetResult());
}
@Test
public void testWriteFailedCallFailed() {
whenRewriteThenFail();
- final PbbRewrite validData = validData();
+ final PbbRewrite validData = PbbRewriteValidatorTest.validData();
try {
customizer.writeCurrentAttributes(validId, validData, writeContext);
} catch (Exception e) {
@@ -96,18 +94,9 @@ public class PbbRewriteCustomizerTest extends WriterCustomizerTest {
}
@Test
- public void testWriteFailedInvalidData() {
- verifyInvalidWriteDataCombination(invalidDataNoDestination());
- verifyInvalidWriteDataCombination(invalidDataNoSource());
- verifyInvalidWriteDataCombination(invalidDataNoItag());
- verifyInvalidWriteDataCombination(invalidDataNoOperation());
- verifyInvalidWriteDataCombination(invalidDataNoVlan());
- }
-
- @Test
public void testUpdate() throws WriteFailedException {
whenRewriteThenSuccess();
- final PbbRewrite rewrite = validData();
+ final PbbRewrite rewrite = PbbRewriteValidatorTest.validData();
customizer.updateCurrentAttributes(validId, rewrite, rewrite, writeContext);
verifyRewriteRequest(desiredSetResult());
}
@@ -115,8 +104,8 @@ public class PbbRewriteCustomizerTest extends WriterCustomizerTest {
@Test
public void testUpdateFailedCallFailed() {
whenRewriteThenFail();
- final PbbRewrite invalidData = invalidDataNoVlan();
- final PbbRewrite validData = validData();
+ final PbbRewrite invalidData = PbbRewriteValidatorTest.invalidDataNoVlan();
+ final PbbRewrite validData = PbbRewriteValidatorTest.validData();
try {
customizer.updateCurrentAttributes(validId, invalidData, validData, writeContext);
} catch (Exception e) {
@@ -134,25 +123,16 @@ public class PbbRewriteCustomizerTest extends WriterCustomizerTest {
}
@Test
- public void testUpdateFailedInvalidData() {
- verifyInvalidUpdateDataCombination(invalidDataNoDestination());
- verifyInvalidUpdateDataCombination(invalidDataNoSource());
- verifyInvalidUpdateDataCombination(invalidDataNoItag());
- verifyInvalidUpdateDataCombination(invalidDataNoOperation());
- verifyInvalidUpdateDataCombination(invalidDataNoVlan());
- }
-
- @Test
public void testDelete() throws WriteFailedException {
whenRewriteThenSuccess();
- customizer.deleteCurrentAttributes(validId, validData(), writeContext);
+ customizer.deleteCurrentAttributes(validId, PbbRewriteValidatorTest.validData(), writeContext);
verifyRewriteRequest(desiredDisableResult());
}
@Test
public void testDeleteFailedCallFailed() {
whenRewriteThenFail();
- final PbbRewrite validData = validData();
+ final PbbRewrite validData = PbbRewriteValidatorTest.validData();
try {
customizer.deleteCurrentAttributes(validId, validData, writeContext);
} catch (Exception e) {
@@ -165,15 +145,6 @@ public class PbbRewriteCustomizerTest extends WriterCustomizerTest {
fail("Test should have failed");
}
- @Test
- public void testDeleteFailedInvalidData() {
- verifyInvalidDeleteDataCombination(invalidDataNoDestination());
- verifyInvalidDeleteDataCombination(invalidDataNoSource());
- verifyInvalidDeleteDataCombination(invalidDataNoItag());
- verifyInvalidDeleteDataCombination(invalidDataNoOperation());
- verifyInvalidDeleteDataCombination(invalidDataNoVlan());
- }
-
private void whenRewriteThenSuccess() {
when(api.l2InterfacePbbTagRewrite(any())).thenReturn(future(new L2InterfacePbbTagRewriteReply()));
}
@@ -182,41 +153,6 @@ public class PbbRewriteCustomizerTest extends WriterCustomizerTest {
when(api.l2InterfacePbbTagRewrite(any())).thenReturn(failedFuture());
}
- private void verifyInvalidWriteDataCombination(final PbbRewrite invalidData) {
- try {
- customizer.writeCurrentAttributes(validId, invalidData, writeContext);
- } catch (Exception e) {
- assertTrue(e instanceof NullPointerException);
- return;
- }
-
- fail("Verifying of invalid combination failed");
- }
-
- private void verifyInvalidUpdateDataCombination(final PbbRewrite invalidData) {
- try {
- customizer.updateCurrentAttributes(validId, validData(), invalidData, writeContext);
- } catch (Exception e) {
- assertTrue(e instanceof NullPointerException);
- return;
- }
-
- fail("Verifying of invalid combination failed");
- }
-
-
- private void verifyInvalidDeleteDataCombination(final PbbRewrite invalidData) {
- try {
- customizer.deleteCurrentAttributes(validId, invalidData, writeContext);
- } catch (Exception e) {
- assertTrue(e instanceof NullPointerException);
- return;
- }
-
- fail("Verifying of invalid combination failed");
- }
-
-
private L2InterfacePbbTagRewrite desiredSetResult() {
final L2InterfacePbbTagRewrite desiredResult = new L2InterfacePbbTagRewrite();
desiredResult.swIfIndex = 1;
@@ -254,59 +190,4 @@ public class PbbRewriteCustomizerTest extends WriterCustomizerTest {
assertArrayEquals(actualRequest.bDmac, desiredResult.bDmac);
assertArrayEquals(actualRequest.bSmac, desiredResult.bSmac);
}
-
- private PbbRewrite invalidDataNoDestination() {
- return new PbbRewriteBuilder()
- .setBVlanTagVlanId(1234)
- .setITagIsid(2L)
- .setSourceAddress(new MacAddress("aa:aa:aa:aa:aa:aa"))
- .setInterfaceOperation(Operation.Pop2)
- .build();
- }
-
- private PbbRewrite invalidDataNoSource() {
- return new PbbRewriteBuilder()
- .setBVlanTagVlanId(1234)
- .setITagIsid(2L)
- .setDestinationAddress(new MacAddress("bb:bb:bb:bb:bb:bb"))
- .setInterfaceOperation(Operation.Pop2)
- .build();
- }
-
- private PbbRewrite invalidDataNoItag() {
- return new PbbRewriteBuilder()
- .setBVlanTagVlanId(1234)
- .setSourceAddress(new MacAddress("aa:aa:aa:aa:aa:aa"))
- .setDestinationAddress(new MacAddress("bb:bb:bb:bb:bb:bb"))
- .setInterfaceOperation(Operation.Pop2)
- .build();
- }
-
- private PbbRewrite invalidDataNoVlan() {
- return new PbbRewriteBuilder()
- .setITagIsid(2L)
- .setSourceAddress(new MacAddress("aa:aa:aa:aa:aa:aa"))
- .setDestinationAddress(new MacAddress("bb:bb:bb:bb:bb:bb"))
- .setInterfaceOperation(Operation.Pop2)
- .build();
- }
-
- private PbbRewrite invalidDataNoOperation() {
- return new PbbRewriteBuilder()
- .setITagIsid(2L)
- .setSourceAddress(new MacAddress("aa:aa:aa:aa:aa:aa"))
- .setDestinationAddress(new MacAddress("bb:bb:bb:bb:bb:bb"))
- .setInterfaceOperation(Operation.Pop2)
- .build();
- }
-
- private PbbRewrite validData() {
- return new PbbRewriteBuilder()
- .setBVlanTagVlanId(1234)
- .setITagIsid(2L)
- .setSourceAddress(new MacAddress("aa:aa:aa:aa:aa:aa"))
- .setDestinationAddress(new MacAddress("bb:bb:bb:bb:bb:bb"))
- .setInterfaceOperation(Operation.Pop2)
- .build();
- }
}
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/pbb/PbbRewriteValidatorTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/pbb/PbbRewriteValidatorTest.java
new file mode 100644
index 000000000..114a1bc19
--- /dev/null
+++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/pbb/PbbRewriteValidatorTest.java
@@ -0,0 +1,189 @@
+/*
+ * Copyright (c) 2019 PANTHEON.tech.
+ *
+ * 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.v3po.interfaces.pbb;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.mockito.MockitoAnnotations.initMocks;
+
+import io.fd.hc2vpp.common.translate.util.NamingContext;
+import io.fd.honeycomb.translate.write.DataValidationFailedException.CreateValidationFailedException;
+import io.fd.honeycomb.translate.write.DataValidationFailedException.DeleteValidationFailedException;
+import io.fd.honeycomb.translate.write.DataValidationFailedException.UpdateValidationFailedException;
+import io.fd.honeycomb.translate.write.WriteContext;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.pbb.types.rev161214.Operation;
+import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.pbb.rev161214.PbbRewriteInterfaceAugmentation;
+import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.pbb.rev161214.interfaces._interface.PbbRewrite;
+import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.pbb.rev161214.interfaces._interface.PbbRewriteBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev180220.Interfaces;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev180220.interfaces.Interface;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev180220.interfaces.InterfaceKey;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public class PbbRewriteValidatorTest {
+
+ private PbbRewriteValidator validator;
+ private InstanceIdentifier<PbbRewrite> validId;
+ private InstanceIdentifier<PbbRewrite> invalidId;
+
+ @Mock
+ private WriteContext writeContext;
+
+ @Before
+ public void setUp() {
+ initMocks(this);
+ NamingContext ifcContext = new NamingContext("testInterfaceContext", "testInterfaceContext");
+ validator = new PbbRewriteValidator(ifcContext);
+ validId = InstanceIdentifier.create(Interfaces.class)
+ .child(Interface.class, new InterfaceKey("pbb-interface"))
+ .augmentation(PbbRewriteInterfaceAugmentation.class)
+ .child(PbbRewrite.class);
+
+ invalidId = InstanceIdentifier.create(PbbRewrite.class);
+ }
+
+ @Test
+ public void testWriteSuccessful()
+ throws CreateValidationFailedException {
+ validator.validateWrite(validId, validData(), writeContext);
+ }
+
+ @Test(expected = CreateValidationFailedException.class)
+ public void testWriteFailedInvalidIID()
+ throws CreateValidationFailedException {
+ validator.validateWrite(invalidId, validData(), writeContext);
+ }
+
+ @Test
+ public void testWriteFailedInvalidData() {
+ verifyInvalidWriteDataCombination(invalidDataNoDestination());
+ verifyInvalidWriteDataCombination(invalidDataNoSource());
+ verifyInvalidWriteDataCombination(invalidDataNoItag());
+ verifyInvalidWriteDataCombination(invalidDataNoOperation());
+ verifyInvalidWriteDataCombination(invalidDataNoVlan());
+ }
+
+ @Test
+ public void testUpdateFailedInvalidData() {
+ verifyInvalidUpdateDataCombination(invalidDataNoDestination());
+ verifyInvalidUpdateDataCombination(invalidDataNoSource());
+ verifyInvalidUpdateDataCombination(invalidDataNoItag());
+ verifyInvalidUpdateDataCombination(invalidDataNoOperation());
+ verifyInvalidUpdateDataCombination(invalidDataNoVlan());
+ }
+
+ @Test
+ public void testDeleteFailedInvalidData() {
+ verifyInvalidDeleteDataCombination(invalidDataNoDestination());
+ verifyInvalidDeleteDataCombination(invalidDataNoSource());
+ verifyInvalidDeleteDataCombination(invalidDataNoItag());
+ verifyInvalidDeleteDataCombination(invalidDataNoOperation());
+ verifyInvalidDeleteDataCombination(invalidDataNoVlan());
+ }
+
+ private void verifyInvalidWriteDataCombination(final PbbRewrite invalidData) {
+ try {
+ validator.validateWrite(validId, invalidData, writeContext);
+ } catch (Exception e) {
+ assertTrue(e instanceof CreateValidationFailedException);
+ return;
+ }
+
+ fail("Verifying of invalid combination failed");
+ }
+
+ private void verifyInvalidUpdateDataCombination(final PbbRewrite invalidData) {
+ try {
+ validator.validateUpdate(validId, validData(), invalidData, writeContext);
+ } catch (Exception e) {
+ assertTrue(e instanceof UpdateValidationFailedException);
+ return;
+ }
+
+ fail("Verifying of invalid combination failed");
+ }
+
+ private void verifyInvalidDeleteDataCombination(final PbbRewrite invalidData) {
+ try {
+ validator.validateDelete(validId, invalidData, writeContext);
+ } catch (Exception e) {
+ assertTrue(e instanceof DeleteValidationFailedException);
+ return;
+ }
+
+ fail("Verifying of invalid combination failed");
+ }
+
+ static PbbRewrite invalidDataNoDestination() {
+ return new PbbRewriteBuilder()
+ .setBVlanTagVlanId(1234)
+ .setITagIsid(2L)
+ .setSourceAddress(new MacAddress("aa:aa:aa:aa:aa:aa"))
+ .setInterfaceOperation(Operation.Pop2)
+ .build();
+ }
+
+ static PbbRewrite invalidDataNoSource() {
+ return new PbbRewriteBuilder()
+ .setBVlanTagVlanId(1234)
+ .setITagIsid(2L)
+ .setDestinationAddress(new MacAddress("bb:bb:bb:bb:bb:bb"))
+ .setInterfaceOperation(Operation.Pop2)
+ .build();
+ }
+
+ static PbbRewrite invalidDataNoItag() {
+ return new PbbRewriteBuilder()
+ .setBVlanTagVlanId(1234)
+ .setSourceAddress(new MacAddress("aa:aa:aa:aa:aa:aa"))
+ .setDestinationAddress(new MacAddress("bb:bb:bb:bb:bb:bb"))
+ .setInterfaceOperation(Operation.Pop2)
+ .build();
+ }
+
+ static PbbRewrite invalidDataNoVlan() {
+ return new PbbRewriteBuilder()
+ .setITagIsid(2L)
+ .setSourceAddress(new MacAddress("aa:aa:aa:aa:aa:aa"))
+ .setDestinationAddress(new MacAddress("bb:bb:bb:bb:bb:bb"))
+ .setInterfaceOperation(Operation.Pop2)
+ .build();
+ }
+
+ static PbbRewrite invalidDataNoOperation() {
+ return new PbbRewriteBuilder()
+ .setITagIsid(2L)
+ .setSourceAddress(new MacAddress("aa:aa:aa:aa:aa:aa"))
+ .setDestinationAddress(new MacAddress("bb:bb:bb:bb:bb:bb"))
+ .setInterfaceOperation(Operation.Pop2)
+ .build();
+ }
+
+ static PbbRewrite validData() {
+ return new PbbRewriteBuilder()
+ .setBVlanTagVlanId(1234)
+ .setITagIsid(2L)
+ .setSourceAddress(new MacAddress("aa:aa:aa:aa:aa:aa"))
+ .setDestinationAddress(new MacAddress("bb:bb:bb:bb:bb:bb"))
+ .setInterfaceOperation(Operation.Pop2)
+ .build();
+ }
+}
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/span/MirroredInterfacesCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/span/MirroredInterfacesCustomizerTest.java
index 9a8ef72ef..e73106a57 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/span/MirroredInterfacesCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/span/MirroredInterfacesCustomizerTest.java
@@ -110,5 +110,4 @@ public class MirroredInterfacesCustomizerTest extends WriterCustomizerTest {
assertEquals(IFACE_INDEX, deleteRequest.swIfIndexTo);
assertEquals(SRC_IFACE_INDEX, deleteRequest.swIfIndexFrom);
}
-
}
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/span/MirroredInterfacesValidatorTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/span/MirroredInterfacesValidatorTest.java
new file mode 100644
index 000000000..e596c130f
--- /dev/null
+++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/span/MirroredInterfacesValidatorTest.java
@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) 2019 PANTHEON.tech.
+ *
+ * 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.v3po.interfaces.span;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.mockito.MockitoAnnotations.initMocks;
+
+import io.fd.hc2vpp.common.translate.util.NamingContext;
+import io.fd.honeycomb.translate.write.DataValidationFailedException;
+import io.fd.honeycomb.translate.write.WriteContext;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.v3po.rev190502.SpanState;
+import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.v3po.rev190502.VppInterfaceAugmentation;
+import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.v3po.rev190502.interfaces._interface.Span;
+import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.v3po.rev190502.span.attributes.MirroredInterfaces;
+import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.v3po.rev190502.span.attributes.mirrored.interfaces.MirroredInterface;
+import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.v3po.rev190502.span.attributes.mirrored.interfaces.MirroredInterfaceBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev180220.Interfaces;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev180220.interfaces.Interface;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev180220.interfaces.InterfaceKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public class MirroredInterfacesValidatorTest {
+
+ private InstanceIdentifier<MirroredInterface> validId;
+ private MirroredInterfaceValidator validator;
+ private static final String IFACE_NAME = "iface";
+ private static final String SRC_IFACE_NAME = "src-iface";
+
+ @Mock
+ private WriteContext writeContext;
+
+ @Before
+ public void setUp() {
+ initMocks(this);
+ NamingContext ifcContext = new NamingContext("testInterfaceContext", "testInterfaceContext");
+ validator = new MirroredInterfaceValidator(ifcContext, id -> id.firstKeyOf(Interface.class).getName());
+ validId = InstanceIdentifier.create(Interfaces.class).child(Interface.class, new InterfaceKey(IFACE_NAME))
+ .augmentation(VppInterfaceAugmentation.class).child(Span.class)
+ .child(MirroredInterfaces.class)
+ .child(MirroredInterface.class);
+ }
+
+ @Test
+ public void testWriteSuccessful()
+ throws DataValidationFailedException.CreateValidationFailedException {
+ validator.validateWrite(validId, validData(), writeContext);
+ }
+
+ @Test
+ public void testWriteFailed() {
+ validateWritingIncorrectData(incorrectDataNoIfaceRef());
+ validateWritingIncorrectData(incorrectDataNoSpanState());
+ }
+
+ @Test
+ public void testUpdateSuccessful()
+ throws DataValidationFailedException.UpdateValidationFailedException {
+ validator.validateUpdate(validId, validData(), validData(), writeContext);
+ }
+
+ @Test
+ public void testDeleteSuccessful()
+ throws DataValidationFailedException.DeleteValidationFailedException {
+ validator.validateDelete(validId, validData(), writeContext);
+ }
+
+ private void validateWritingIncorrectData(final MirroredInterface data) {
+ try {
+ validator.validateWrite(validId, data, writeContext);
+ } catch (DataValidationFailedException.CreateValidationFailedException e) {
+ assertTrue(e instanceof DataValidationFailedException.CreateValidationFailedException);
+ return;
+ }
+ fail("Verifying of invalid combination failed");
+ }
+
+ private MirroredInterface incorrectDataNoIfaceRef() {
+ return new MirroredInterfaceBuilder()
+ .setIfaceRef(null)
+ .setState(SpanState.Receive)
+ .build();
+ }
+
+ private MirroredInterface incorrectDataNoSpanState() {
+ return new MirroredInterfaceBuilder()
+ .setIfaceRef(SRC_IFACE_NAME)
+ .setState(null)
+ .build();
+ }
+
+ private MirroredInterface validData() {
+ return new MirroredInterfaceBuilder()
+ .setIfaceRef(SRC_IFACE_NAME)
+ .setState(SpanState.Receive)
+ .build();
+ }
+}
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/VxlanGpeCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/VxlanGpeCustomizerTest.java
index 2b89df0bb..e5bd6dc34 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/VxlanGpeCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/VxlanGpeCustomizerTest.java
@@ -139,145 +139,3 @@ public class VxlanGpeCustomizerTest extends ReaderCustomizerTest<VxlanGpe, Vxlan
return new VxlanGpeCustomizer(api, interfacesContext, dumpCacheManager);
}
}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/span/MirroredInterfacesCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/span/MirroredInterfacesCustomizerTest.java
index da7c8792e..c13775c75 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/span/MirroredInterfacesCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/span/MirroredInterfacesCustomizerTest.java
@@ -104,7 +104,6 @@ public class MirroredInterfacesCustomizerTest
MirroredInterfacesBuilder builder = new MirroredInterfacesBuilder();
getCustomizer().readCurrentAttributes(validId, builder, ctx);
-
final MirroredInterfaces data = builder.build();
// 1,2 should be returned,0 should be filtered out because of disabled state