diff options
16 files changed, 53 insertions, 128 deletions
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/AclCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/AclCustomizerTest.java index 00dadddb1..8977a74bf 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/AclCustomizerTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/AclCustomizerTest.java @@ -54,7 +54,7 @@ public class AclCustomizerTest extends ReaderCustomizerTest<Acl, AclBuilder> { private VppClassifierContextManager classifyTableContext; public AclCustomizerTest() { - super(Acl.class); + super(Acl.class, VppInterfaceStateAugmentationBuilder.class); } @Override @@ -68,14 +68,6 @@ public class AclCustomizerTest extends ReaderCustomizerTest<Acl, AclBuilder> { return new AclCustomizer(api, interfaceContext, classifyTableContext); } - @Test - public void testMerge() { - final VppInterfaceStateAugmentationBuilder builder = mock(VppInterfaceStateAugmentationBuilder.class); - final Acl value = mock(Acl.class); - getCustomizer().merge(builder, value); - verify(builder).setAcl(value); - } - private InstanceIdentifier<Acl> getAclId(final String name) { return InstanceIdentifier.create(InterfacesState.class).child(Interface.class, new InterfaceKey(name)) .augmentation( diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/GreCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/GreCustomizerTest.java index e62edadef..519236c16 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/GreCustomizerTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/GreCustomizerTest.java @@ -37,6 +37,7 @@ 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.rev140508.interfaces.state.Interface; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VppInterfaceStateAugmentation; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VppInterfaceStateAugmentationBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces.state._interface.Gre; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces.state._interface.GreBuilder; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; @@ -58,7 +59,7 @@ public class GreCustomizerTest extends ReaderCustomizerTest<Gre, GreBuilder> { .augmentation(VppInterfaceStateAugmentation.class).child(Gre.class); public GreCustomizerTest() { - super(Gre.class); + super(Gre.class, VppInterfaceStateAugmentationBuilder.class); } @Override diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/InterfaceCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/InterfaceCustomizerTest.java index 94dfd077a..a10468ee8 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/InterfaceCustomizerTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/InterfaceCustomizerTest.java @@ -63,7 +63,7 @@ public class InterfaceCustomizerTest extends private DisabledInterfacesManager interfaceDisableContext; public InterfaceCustomizerTest() { - super(Interface.class); + super(Interface.class, InterfacesStateBuilder.class); } @Override @@ -79,15 +79,7 @@ public class InterfaceCustomizerTest extends return new InterfaceCustomizer(api, interfacesContext, interfaceDisableContext); } - @Test - public void testMerge() throws Exception { - final InterfacesStateBuilder builder = mock(InterfacesStateBuilder.class); - final List<Interface> value = Collections.emptyList(); - getCustomizer().merge(builder, value); - verify(builder).setInterface(value); - } - - public void whenSwInterfaceDumpThenReturn(final List<SwInterfaceDetails> interfaceList) { + private void whenSwInterfaceDumpThenReturn(final List<SwInterfaceDetails> interfaceList) { final SwInterfaceDetailsReplyDump reply = new SwInterfaceDetailsReplyDump(); reply.swInterfaceDetails = interfaceList; when(api.swInterfaceDump(any(SwInterfaceDump.class))).thenReturn(future(reply)); diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/L2CustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/L2CustomizerTest.java index 6be759bc5..5583ae348 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/L2CustomizerTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/L2CustomizerTest.java @@ -53,7 +53,7 @@ public class L2CustomizerTest extends ReaderCustomizerTest<L2, L2Builder> { private NamingContext bridgeDomainContext; public L2CustomizerTest() { - super(L2.class); + super(L2.class, VppInterfaceStateAugmentationBuilder.class); } @Override @@ -67,14 +67,6 @@ public class L2CustomizerTest extends ReaderCustomizerTest<L2, L2Builder> { return new L2Customizer(api, interfaceContext, bridgeDomainContext); } - @Test - public void testMerge() { - final VppInterfaceStateAugmentationBuilder builder = mock(VppInterfaceStateAugmentationBuilder.class); - final L2 value = mock(L2.class); - getCustomizer().merge(builder, value); - verify(builder).setL2(value); - } - private InstanceIdentifier<L2> getL2Id(final String name) { return InstanceIdentifier.create(InterfacesState.class).child(Interface.class, new InterfaceKey(name)) .augmentation( diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/RewriteCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/RewriteCustomizerTest.java index ad2d4f6ce..481ac676b 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/RewriteCustomizerTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/RewriteCustomizerTest.java @@ -61,7 +61,7 @@ public class RewriteCustomizerTest extends ReaderCustomizerTest<Rewrite, Rewrite private ArgumentCaptor<List<PushTags>> captor; public RewriteCustomizerTest() { - super(Rewrite.class); + super(Rewrite.class, L2Builder.class); } @Override @@ -75,14 +75,6 @@ public class RewriteCustomizerTest extends ReaderCustomizerTest<Rewrite, Rewrite return new RewriteCustomizer(api, interfacesContext); } - @Test - public void testMerge() { - final L2Builder builder = mock(L2Builder.class); - final Rewrite value = mock(Rewrite.class); - getCustomizer().merge(builder, value); - verify(builder).setRewrite(value); - } - private InstanceIdentifier<Rewrite> getVlanTagRewriteId(final String name, final long index) { final Class<ChildOf<? super SubInterface>> child = (Class)Rewrite.class; final InstanceIdentifier id = diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/SubInterfaceCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/SubInterfaceCustomizerTest.java index 74580bb73..d52cb3fc2 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/SubInterfaceCustomizerTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/SubInterfaceCustomizerTest.java @@ -63,7 +63,7 @@ public class SubInterfaceCustomizerTest extends private NamingContext interfacesContext; public SubInterfaceCustomizerTest() { - super(SubInterface.class); + super(SubInterface.class, SubInterfacesBuilder.class); } @Override @@ -85,14 +85,6 @@ public class SubInterfaceCustomizerTest extends } @Test - public void testMerge() { - final SubInterfacesBuilder builder = mock(SubInterfacesBuilder.class); - final List<SubInterface> value = mock(List.class); - getCustomizer().merge(builder, value); - verify(builder).setSubInterface(value); - } - - @Test public void testRead() throws ReadFailedException { final Map<Integer, SwInterfaceDetails> cachedInterfaceDump = new HashMap<>(); diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/VxlanCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/VxlanCustomizerTest.java index 4bab8fcfa..a4cf9b535 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/VxlanCustomizerTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/VxlanCustomizerTest.java @@ -37,6 +37,7 @@ 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.rev140508.interfaces.state.Interface; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VppInterfaceStateAugmentation; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VppInterfaceStateAugmentationBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces.state._interface.Vxlan; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces.state._interface.VxlanBuilder; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; @@ -58,7 +59,7 @@ public class VxlanCustomizerTest extends ReaderCustomizerTest<Vxlan, VxlanBuilde .augmentation(VppInterfaceStateAugmentation.class).child(Vxlan.class); public VxlanCustomizerTest() { - super(Vxlan.class); + super(Vxlan.class, VppInterfaceStateAugmentationBuilder.class); } @Override diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/VxlanGpeCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/VxlanGpeCustomizerTest.java index 19b3be862..b38f40cea 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/VxlanGpeCustomizerTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/VxlanGpeCustomizerTest.java @@ -37,6 +37,7 @@ 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.rev140508.interfaces.state.Interface; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VppInterfaceStateAugmentation; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VppInterfaceStateAugmentationBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces.state._interface.VxlanGpe; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces.state._interface.VxlanGpeBuilder; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; @@ -58,7 +59,7 @@ public class VxlanGpeCustomizerTest extends ReaderCustomizerTest<VxlanGpe, Vxlan .augmentation(VppInterfaceStateAugmentation.class).child(VxlanGpe.class); public VxlanGpeCustomizerTest() { - super(VxlanGpe.class); + super(VxlanGpe.class, VppInterfaceStateAugmentationBuilder.class); } @Override diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/Ipv4AddressCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/Ipv4AddressCustomizerTest.java index fc189d399..c841b4571 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/Ipv4AddressCustomizerTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/Ipv4AddressCustomizerTest.java @@ -30,7 +30,6 @@ import io.fd.honeycomb.translate.spi.read.ReaderCustomizer; import io.fd.honeycomb.translate.v3po.util.Ipv4Translator; import io.fd.honeycomb.translate.v3po.util.NamingContext; import io.fd.honeycomb.vpp.test.read.ListReaderCustomizerTest; -import java.util.Arrays; import java.util.List; import java.util.concurrent.CompletableFuture; import java.util.stream.Collectors; @@ -66,7 +65,7 @@ public class Ipv4AddressCustomizerTest extends ListReaderCustomizerTest<Address, private NamingContext interfacesContext; public Ipv4AddressCustomizerTest() { - super(Address.class); + super(Address.class, Ipv4Builder.class); } @Override @@ -197,16 +196,4 @@ public class Ipv4AddressCustomizerTest extends ListReaderCustomizerTest<Address, assertEquals(true, "192.168.2.2".equals(ids.get(1).getValue())); assertEquals(true, "192.168.2.3".equals(ids.get(2).getValue())); } - - @Test - public void testMerge() { - - Address address = new AddressBuilder().build(); - Ipv4Builder ipv4Builder = new Ipv4Builder(); - getCustomizer().merge(ipv4Builder, Arrays.asList(address)); - - assertEquals(1, ipv4Builder.getAddress().size()); - assertEquals(true, ipv4Builder.getAddress().contains(address)); - } - } diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifySessionReaderTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifySessionReaderTest.java index f45367098..31a1e1292 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifySessionReaderTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifySessionReaderTest.java @@ -20,7 +20,6 @@ import static org.junit.Assert.assertEquals; 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 io.fd.honeycomb.translate.ModificationCache; @@ -58,7 +57,7 @@ public class ClassifySessionReaderTest extends private VppClassifierContextManager classifierContext; public ClassifySessionReaderTest() { - super(ClassifySession.class); + super(ClassifySession.class, ClassifyTableBuilder.class); } @Override @@ -74,14 +73,6 @@ public class ClassifySessionReaderTest extends } @Test - public void testMerge() { - final ClassifyTableBuilder builder = mock(ClassifyTableBuilder.class); - final List<ClassifySession> value = mock(List.class); - getCustomizer().merge(builder, value); - verify(builder).setClassifySession(value); - } - - @Test public void testReadWithCache() throws ReadFailedException { final InstanceIdentifier<ClassifySession> id = getClassifySessionId(TABLE_NAME, MATCH_1); final ClassifySessionBuilder builder = mock(ClassifySessionBuilder.class); diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifyTableReaderTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifyTableReaderTest.java index 95864ce6e..cc5ac6b7d 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifyTableReaderTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifyTableReaderTest.java @@ -58,7 +58,7 @@ public class ClassifyTableReaderTest extends private VppClassifierContextManager classifierContext; public ClassifyTableReaderTest() { - super(ClassifyTable.class); + super(ClassifyTable.class, VppClassifierStateBuilder.class); } @Override @@ -95,14 +95,6 @@ public class ClassifyTableReaderTest extends } @Test - public void testMerge() { - final VppClassifierStateBuilder builder = mock(VppClassifierStateBuilder.class); - final List<ClassifyTable> value = mock(List.class); - getCustomizer().merge(builder, value); - verify(builder).setClassifyTable(value); - } - - @Test public void testRead() throws ReadFailedException { doReturn(future(generateClassifyTableInfoReply())).when(api).classifyTableInfo(any(ClassifyTableInfo.class)); diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppstate/BridgeDomainCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppstate/BridgeDomainCustomizerTest.java index 67e612868..bbf53caa7 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppstate/BridgeDomainCustomizerTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppstate/BridgeDomainCustomizerTest.java @@ -16,15 +16,9 @@ package io.fd.honeycomb.translate.v3po.vppstate; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; - import io.fd.honeycomb.translate.spi.read.ReaderCustomizer; -import io.fd.honeycomb.vpp.test.read.ListReaderCustomizerTest; import io.fd.honeycomb.translate.v3po.util.NamingContext; -import java.util.Collections; -import java.util.List; -import org.junit.Test; +import io.fd.honeycomb.vpp.test.read.ListReaderCustomizerTest; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.state.BridgeDomainsBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.state.bridge.domains.BridgeDomain; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.state.bridge.domains.BridgeDomainBuilder; @@ -37,7 +31,7 @@ public class BridgeDomainCustomizerTest private NamingContext interfacesContext; public BridgeDomainCustomizerTest() { - super(BridgeDomain.class); + super(BridgeDomain.class, BridgeDomainsBuilder.class); } @Override @@ -46,14 +40,6 @@ public class BridgeDomainCustomizerTest interfacesContext = new NamingContext("generatedIfaceName", "ifc-test-instance"); } - @Test - public void testMerge() throws Exception { - final BridgeDomainsBuilder builder = mock(BridgeDomainsBuilder.class); - final List<BridgeDomain> value = Collections.emptyList(); - getCustomizer().merge(builder, value); - verify(builder).setBridgeDomain(value); - } - @Override protected ReaderCustomizer<BridgeDomain, BridgeDomainBuilder> initCustomizer() { return new BridgeDomainCustomizer(api, bdContext); diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppstate/L2FibEntryCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppstate/L2FibEntryCustomizerTest.java index f837717c7..4c0fcd539 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppstate/L2FibEntryCustomizerTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppstate/L2FibEntryCustomizerTest.java @@ -57,7 +57,7 @@ public class L2FibEntryCustomizerTest extends ListReaderCustomizerTest<L2FibEntr private NamingContext interfacesContext; public L2FibEntryCustomizerTest() { - super(L2FibEntry.class); + super(L2FibEntry.class, L2FibTableBuilder.class); } @Override @@ -72,14 +72,6 @@ public class L2FibEntryCustomizerTest extends ListReaderCustomizerTest<L2FibEntr return new L2FibEntryCustomizer(api, bdContext, interfacesContext); } - @Test - public void testMerge() throws Exception { - final L2FibTableBuilder builder = mock(L2FibTableBuilder.class); - final List<L2FibEntry> value = Collections.emptyList(); - getCustomizer().merge(builder, value); - verify(builder).setL2FibEntry(value); - } - private static InstanceIdentifier<L2FibEntry> getL2FibEntryId(final String bdName, final PhysAddress address) { return InstanceIdentifier.create(BridgeDomains.class).child(BridgeDomain.class, new BridgeDomainKey(bdName)) .child(L2FibTable.class).child(L2FibEntry.class, new L2FibEntryKey(address)); diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppstate/VersionCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppstate/VersionCustomizerTest.java index 71b7dccf3..771e1aa87 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppstate/VersionCustomizerTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppstate/VersionCustomizerTest.java @@ -17,7 +17,6 @@ package io.fd.honeycomb.translate.v3po.vppstate; import static org.mockito.Matchers.any; -import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -34,7 +33,7 @@ import org.openvpp.jvpp.core.dto.ShowVersionReply; public class VersionCustomizerTest extends ReaderCustomizerTest<Version, VersionBuilder> { public VersionCustomizerTest() { - super(Version.class); + super(Version.class, VppStateBuilder.class); } @Override @@ -43,14 +42,6 @@ public class VersionCustomizerTest extends ReaderCustomizerTest<Version, Version } @Test - public void testMerge() { - final VppStateBuilder builder = mock(VppStateBuilder.class); - final Version value = mock(Version.class); - getCustomizer().merge(builder, value); - verify(builder).setVersion(value); - } - - @Test public void testReadCurrentAttributes() throws Exception { final ShowVersionReply reply = new ShowVersionReply(); reply.version = new byte[] {}; diff --git a/vpp-common/vpp-translate-test/src/main/java/io/fd/honeycomb/vpp/test/read/ListReaderCustomizerTest.java b/vpp-common/vpp-translate-test/src/main/java/io/fd/honeycomb/vpp/test/read/ListReaderCustomizerTest.java index 0509ef9e5..8917c02db 100644 --- a/vpp-common/vpp-translate-test/src/main/java/io/fd/honeycomb/vpp/test/read/ListReaderCustomizerTest.java +++ b/vpp-common/vpp-translate-test/src/main/java/io/fd/honeycomb/vpp/test/read/ListReaderCustomizerTest.java @@ -16,15 +16,16 @@ package io.fd.honeycomb.vpp.test.read; -import static org.junit.Assert.assertNotNull; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; import io.fd.honeycomb.translate.spi.read.ListReaderCustomizer; -import org.junit.Test; +import java.lang.reflect.Method; +import java.util.List; import org.opendaylight.yangtools.concepts.Builder; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.Identifiable; import org.opendaylight.yangtools.yang.binding.Identifier; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; /** * Generic test for classes implementing {@link ListReaderCustomizer} interface. @@ -36,8 +37,10 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; public abstract class ListReaderCustomizerTest<D extends DataObject & Identifiable<K>, K extends Identifier<D>, B extends Builder<D>> extends ReaderCustomizerTest<D, B> { - protected ListReaderCustomizerTest(Class<D> dataObjectClass) { - super(dataObjectClass); + protected ListReaderCustomizerTest( + final Class<D> dataObjectClass, + final Class<? extends Builder<? extends DataObject>> parentBuilderClass) { + super(dataObjectClass, parentBuilderClass); } @Override @@ -45,8 +48,13 @@ public abstract class ListReaderCustomizerTest<D extends DataObject & Identifiab return ListReaderCustomizer.class.cast(super.getCustomizer()); } - @Test - public void testGetBuilder() throws Exception { - assertNotNull(getCustomizer().getBuilder(InstanceIdentifier.create(dataObjectClass))); + @Override + public void testMerge() throws Exception { + final Builder<? extends DataObject> parentBuilder = mock(parentBuilderClass); + final List<D> value = (List<D>) mock(List.class); + getCustomizer().merge(parentBuilder, value); + + final Method method = parentBuilderClass.getMethod("set" + dataObjectClass.getSimpleName(), List.class); + method.invoke(verify(parentBuilder), value); } } diff --git a/vpp-common/vpp-translate-test/src/main/java/io/fd/honeycomb/vpp/test/read/ReaderCustomizerTest.java b/vpp-common/vpp-translate-test/src/main/java/io/fd/honeycomb/vpp/test/read/ReaderCustomizerTest.java index 6486c8eb9..22dc2b6fd 100644 --- a/vpp-common/vpp-translate-test/src/main/java/io/fd/honeycomb/vpp/test/read/ReaderCustomizerTest.java +++ b/vpp-common/vpp-translate-test/src/main/java/io/fd/honeycomb/vpp/test/read/ReaderCustomizerTest.java @@ -17,6 +17,8 @@ package io.fd.honeycomb.vpp.test.read; import static org.junit.Assert.assertNotNull; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; import io.fd.honeycomb.translate.MappingContext; import io.fd.honeycomb.translate.ModificationCache; @@ -26,6 +28,7 @@ import io.fd.honeycomb.translate.read.ReadContext; import io.fd.honeycomb.translate.spi.read.ReaderCustomizer; import io.fd.honeycomb.vpp.test.util.FutureProducer; import io.fd.honeycomb.vpp.test.util.NamingContextHelper; +import java.lang.reflect.Method; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; @@ -52,12 +55,16 @@ public abstract class ReaderCustomizerTest<D extends DataObject, B extends Build @Mock protected MappingContext mappingContext; - protected ModificationCache cache; + protected final Class<? extends Builder<? extends DataObject>> parentBuilderClass; protected final Class<D> dataObjectClass; + protected ModificationCache cache; protected ReaderCustomizer<D, B> customizer; - protected ReaderCustomizerTest(Class<D> dataObjectClass) { + public ReaderCustomizerTest( + final Class<D> dataObjectClass, + final Class<? extends Builder<? extends DataObject>> parentBuilderClass) { this.dataObjectClass = dataObjectClass; + this.parentBuilderClass = parentBuilderClass; } @Before @@ -87,5 +94,13 @@ public abstract class ReaderCustomizerTest<D extends DataObject, B extends Build assertNotNull(customizer.getBuilder(InstanceIdentifier.create(dataObjectClass))); } - // TODO HONEYCOMB-116: create generic testMerge() + @Test + public void testMerge() throws Exception { + final Builder<? extends DataObject> parentBuilder = mock(parentBuilderClass); + final D value = mock(dataObjectClass); + getCustomizer().merge(parentBuilder, value); + + final Method method = parentBuilderClass.getMethod("set" + dataObjectClass.getSimpleName(), dataObjectClass); + method.invoke(verify(parentBuilder), value); + } } |