summaryrefslogtreecommitdiffstats
path: root/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/InterfaceRoutingCustomizerTest.java
diff options
context:
space:
mode:
authorTibor Král <tibor.kral@pantheon.tech>2019-05-14 12:19:44 +0200
committerMichal Cmarada <mcmarada@cisco.com>2019-05-27 08:25:05 +0200
commit5c416ebacf4baad25de6213661c3cdfff31c0482 (patch)
treed2fe4889f01e4adbdeb50ea83b47aa44102a5f49 /v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/InterfaceRoutingCustomizerTest.java
parent83206cb1b6b0a6a3bbe45d646ed69a5f2b587fed (diff)
HC2VPP-381: Validation support for V3PO module
Change-Id: If288d97dce15bcc6924d4dd65c640a20920f094d Signed-off-by: Tibor Král <tibor.kral@pantheon.tech>
Diffstat (limited to 'v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/InterfaceRoutingCustomizerTest.java')
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/InterfaceRoutingCustomizerTest.java49
1 files changed, 3 insertions, 46 deletions
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());