From 5c416ebacf4baad25de6213661c3cdfff31c0482 Mon Sep 17 00:00:00 2001 From: Tibor Král Date: Tue, 14 May 2019 12:19:44 +0200 Subject: HC2VPP-381: Validation support for V3PO module MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: If288d97dce15bcc6924d4dd65c640a20920f094d Signed-off-by: Tibor Král --- .../interfaces/InterfaceRoutingCustomizerTest.java | 49 ++-------------------- 1 file changed, 3 insertions(+), 46 deletions(-) (limited to 'v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/InterfaceRoutingCustomizerTest.java') 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()); -- cgit 1.2.3-korg