l3: remove redundant stubbing for WriteContext.readBefore 47/13047/2
authorMarek Gradzki <[email protected]>
Thu, 14 Jun 2018 10:12:42 +0000 (12:12 +0200)
committerMarek Gradzki <[email protected]>
Thu, 14 Jun 2018 10:18:24 +0000 (10:18 +0000)
Change-Id: I8c4cc2564ad0f4c6452984234d4c9466677db052
Signed-off-by: Marek Gradzki <[email protected]>
l3/impl/src/test/java/io/fd/hc2vpp/l3/write/ipv4/Ipv4AddressCustomizerTest.java
l3/impl/src/test/java/io/fd/hc2vpp/l3/write/ipv4/Ipv4NeighbourCustomizerTest.java
l3/impl/src/test/java/io/fd/hc2vpp/l3/write/ipv6/Ipv6NeighbourCustomizerTest.java

index 850c1ba..efab72b 100644 (file)
@@ -22,9 +22,7 @@ import static org.mockito.Matchers.any;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
 
-import com.google.common.base.Optional;
 import io.fd.hc2vpp.common.test.write.WriterCustomizerTest;
 import io.fd.hc2vpp.common.translate.util.NamingContext;
 import io.fd.honeycomb.translate.write.WriteFailedException;
@@ -95,7 +93,6 @@ public class Ipv4AddressCustomizerTest extends WriterCustomizerTest {
     @Test
     public void testAddPrefixLengthIpv4Address() throws Exception {
         final InstanceIdentifier<Address> id = getAddressId(IFACE_NAME);
-        when(writeContext.readBefore(id)).thenReturn(Optional.absent());
 
         Ipv4AddressNoZone noZoneIp = new Ipv4AddressNoZone(new Ipv4Address("192.168.2.1"));
         PrefixLength length = new PrefixLengthBuilder().setPrefixLength(new Integer(24).shortValue()).build();
@@ -113,7 +110,6 @@ public class Ipv4AddressCustomizerTest extends WriterCustomizerTest {
     @Test
     public void testAddPrefixLengthIpv4AddressFailed() throws Exception {
         final InstanceIdentifier<Address> id = getAddressId(IFACE_NAME);
-        when(writeContext.readBefore(id)).thenReturn(Optional.absent());
 
         Ipv4AddressNoZone noZoneIp = new Ipv4AddressNoZone(new Ipv4Address("192.168.2.1"));
         PrefixLength length = new PrefixLengthBuilder().setPrefixLength(new Integer(24).shortValue()).build();
@@ -197,7 +193,6 @@ public class Ipv4AddressCustomizerTest extends WriterCustomizerTest {
         final int expectedPrefixLength = 1;
         final String stringMask = "128.0.0.0";
         final InstanceIdentifier<Address> id = getAddressId(IFACE_NAME);
-        when(writeContext.readBefore(id)).thenReturn(Optional.absent());
 
         Ipv4AddressNoZone noZoneIp = new Ipv4AddressNoZone(new Ipv4Address("192.168.2.1"));
         Netmask subnet = new NetmaskBuilder().setNetmask(new DottedQuad(stringMask)).build();
@@ -220,7 +215,6 @@ public class Ipv4AddressCustomizerTest extends WriterCustomizerTest {
 
     private void testSingleNetmask(final int expectedPrefixLength, final String stringMask) throws Exception {
         final InstanceIdentifier<Address> id = getAddressId(IFACE_NAME);
-        when(writeContext.readBefore(id)).thenReturn(Optional.absent());
 
         Ipv4AddressNoZone noZoneIp = new Ipv4AddressNoZone(new Ipv4Address("192.168.2.1"));
         Netmask subnet = new NetmaskBuilder().setNetmask(new DottedQuad(stringMask)).build();
@@ -238,7 +232,6 @@ public class Ipv4AddressCustomizerTest extends WriterCustomizerTest {
     private void testSingleIllegalNetmask(final String stringMask) throws Exception {
         try {
             final InstanceIdentifier<Address> id = getAddressId(IFACE_NAME);
-            when(writeContext.readBefore(id)).thenReturn(Optional.absent());
 
             Ipv4AddressNoZone noZoneIp = new Ipv4AddressNoZone(new Ipv4Address("192.168.2.1"));
             Netmask subnet = new NetmaskBuilder().setNetmask(new DottedQuad(stringMask)).build();
index d9050b1..bab261a 100644 (file)
@@ -23,7 +23,6 @@ import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
-import com.google.common.base.Optional;
 import io.fd.hc2vpp.common.test.write.WriterCustomizerTest;
 import io.fd.hc2vpp.common.translate.util.Ipv4Translator;
 import io.fd.hc2vpp.common.translate.util.NamingContext;
@@ -36,16 +35,12 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.Interfaces;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceBuilder;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.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.interfaces._interface.Ipv4;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces._interface.ipv4.Neighbor;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces._interface.ipv4.NeighborBuilder;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev170607.VppInterfaceAugmentation;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev170607.VppInterfaceAugmentationBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev170607.interfaces._interface.RoutingBuilder;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
 public class Ipv4NeighbourCustomizerTest extends WriterCustomizerTest implements Ipv4Translator {
@@ -67,7 +62,6 @@ public class Ipv4NeighbourCustomizerTest extends WriterCustomizerTest implements
 
     @Test
     public void testWriteCurrentAttributes() throws WriteFailedException {
-        when(writeContext.readBefore(IID.firstIdentifierOf(Interface.class))).thenReturn(Optional.absent());
         when(api.ipNeighborAddDel(any())).thenReturn(future(new IpNeighborAddDelReply()));
         customizer.writeCurrentAttributes(IID, getData(), writeContext);
         verify(api).ipNeighborAddDel(getExpectedRequest(true));
@@ -75,7 +69,6 @@ public class Ipv4NeighbourCustomizerTest extends WriterCustomizerTest implements
 
     @Test
     public void testWriteCurrentAttributesFailed() {
-        when(writeContext.readBefore(IID.firstIdentifierOf(Interface.class))).thenReturn(Optional.absent());
         when(api.ipNeighborAddDel(any())).thenReturn(failedFuture());
         try {
             customizer.writeCurrentAttributes(IID, getData(), writeContext);
@@ -93,7 +86,6 @@ public class Ipv4NeighbourCustomizerTest extends WriterCustomizerTest implements
 
     @Test
     public void testDeleteCurrentAttributes() throws WriteFailedException {
-        when(writeContext.readBefore(IID.firstIdentifierOf(Interface.class))).thenReturn(Optional.absent());
         when(api.ipNeighborAddDel(any())).thenReturn(future(new IpNeighborAddDelReply()));
         customizer.deleteCurrentAttributes(IID, getData(), writeContext);
         verify(api).ipNeighborAddDel(getExpectedRequest(false));
@@ -101,7 +93,6 @@ public class Ipv4NeighbourCustomizerTest extends WriterCustomizerTest implements
 
     @Test
     public void testDeleteCurrentAttributesFailed() {
-        when(writeContext.readBefore(IID.firstIdentifierOf(Interface.class))).thenReturn(Optional.absent());
         when(api.ipNeighborAddDel(any())).thenReturn(failedFuture());
         try {
             customizer.deleteCurrentAttributes(IID, getData(), writeContext);
@@ -116,20 +107,6 @@ public class Ipv4NeighbourCustomizerTest extends WriterCustomizerTest implements
     @Test
     public void testVrfExtractionCornerCases() throws WriteFailedException {
         when(api.ipNeighborAddDel(any())).thenReturn(future(new IpNeighborAddDelReply()));
-
-        when(writeContext.readBefore(IID.firstIdentifierOf(Interface.class)))
-                // no augment
-                .thenReturn(Optional.of(new InterfaceBuilder().build()))
-                // empty augment
-                .thenReturn(Optional.of(new InterfaceBuilder()
-                        .addAugmentation(VppInterfaceAugmentation.class, new VppInterfaceAugmentationBuilder().build()).build()))
-                //empty routing
-                .thenReturn(Optional.of(new InterfaceBuilder()
-                        .addAugmentation(VppInterfaceAugmentation.class, new VppInterfaceAugmentationBuilder()
-                                .setRouting(new RoutingBuilder().build())
-                                .build()).build()));
-
-
         customizer.writeCurrentAttributes(IID, getData(), writeContext);
         customizer.writeCurrentAttributes(IID, getData(), writeContext);
         customizer.writeCurrentAttributes(IID, getData(), writeContext);
index f5a28f2..5f11a5d 100644 (file)
@@ -22,7 +22,6 @@ import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
-import com.google.common.base.Optional;
 import io.fd.hc2vpp.common.test.write.WriterCustomizerTest;
 import io.fd.hc2vpp.common.translate.util.Ipv6Translator;
 import io.fd.hc2vpp.common.translate.util.NamingContext;
@@ -35,16 +34,12 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6AddressNoZone;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.Interfaces;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceBuilder;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.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.interfaces._interface.Ipv6;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces._interface.ipv6.Neighbor;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces._interface.ipv6.NeighborBuilder;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev170607.VppInterfaceAugmentation;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev170607.VppInterfaceAugmentationBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev170607.interfaces._interface.RoutingBuilder;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
 public class Ipv6NeighbourCustomizerTest extends WriterCustomizerTest implements Ipv6Translator {
@@ -66,7 +61,6 @@ public class Ipv6NeighbourCustomizerTest extends WriterCustomizerTest implements
 
     @Test
     public void testWriteCurrentAttributes() throws WriteFailedException {
-        when(writeContext.readBefore(IID.firstIdentifierOf(Interface.class))).thenReturn(Optional.absent());
         when(api.ipNeighborAddDel(any())).thenReturn(future(new IpNeighborAddDelReply()));
         customizer.writeCurrentAttributes(IID, getData(), writeContext);
         verify(api).ipNeighborAddDel(getExpectedRequest(true));
@@ -74,7 +68,6 @@ public class Ipv6NeighbourCustomizerTest extends WriterCustomizerTest implements
 
     @Test
     public void testWriteCurrentAttributesFailed() {
-        when(writeContext.readBefore(IID.firstIdentifierOf(Interface.class))).thenReturn(Optional.absent());
         when(api.ipNeighborAddDel(any())).thenReturn(failedFuture());
         try {
             customizer.writeCurrentAttributes(IID, getData(), writeContext);
@@ -93,7 +86,6 @@ public class Ipv6NeighbourCustomizerTest extends WriterCustomizerTest implements
 
     @Test
     public void testDeleteCurrentAttributes() throws WriteFailedException {
-        when(writeContext.readBefore(IID.firstIdentifierOf(Interface.class))).thenReturn(Optional.absent());
         when(api.ipNeighborAddDel(any())).thenReturn(future(new IpNeighborAddDelReply()));
         customizer.deleteCurrentAttributes(IID, getData(), writeContext);
         verify(api).ipNeighborAddDel(getExpectedRequest(false));
@@ -101,7 +93,6 @@ public class Ipv6NeighbourCustomizerTest extends WriterCustomizerTest implements
 
     @Test
     public void testDeleteCurrentAttributesFailed() {
-        when(writeContext.readBefore(IID.firstIdentifierOf(Interface.class))).thenReturn(Optional.absent());
         when(api.ipNeighborAddDel(any())).thenReturn(failedFuture());
         try {
             customizer.deleteCurrentAttributes(IID, getData(), writeContext);
@@ -116,20 +107,6 @@ public class Ipv6NeighbourCustomizerTest extends WriterCustomizerTest implements
     @Test
     public void testVrfExtractionCornerCases() throws WriteFailedException {
         when(api.ipNeighborAddDel(any())).thenReturn(future(new IpNeighborAddDelReply()));
-
-        when(writeContext.readBefore(IID.firstIdentifierOf(Interface.class)))
-                // no augment
-                .thenReturn(Optional.of(new InterfaceBuilder().build()))
-                // empty augment
-                .thenReturn(Optional.of(new InterfaceBuilder()
-                        .addAugmentation(VppInterfaceAugmentation.class, new VppInterfaceAugmentationBuilder().build()).build()))
-                //empty routing
-                .thenReturn(Optional.of(new InterfaceBuilder()
-                        .addAugmentation(VppInterfaceAugmentation.class, new VppInterfaceAugmentationBuilder()
-                                .setRouting(new RoutingBuilder().build())
-                                .build()).build()));
-
-
         customizer.writeCurrentAttributes(IID, getData(), writeContext);
         customizer.writeCurrentAttributes(IID, getData(), writeContext);
         customizer.writeCurrentAttributes(IID, getData(), writeContext);