From 927fb75d969b2d39c91ae6735f0127646348b73c Mon Sep 17 00:00:00 2001 From: Jan Srnicek Date: Mon, 21 Nov 2016 14:44:15 +0100 Subject: HONEYCOMB-289 - Type-aware read customizers Refactoring due to https://gerrit.fd.io/r/#/c/3898/ Change-Id: I3ddcc06aca0a730db9fd727a3d2b10cd085f870e Signed-off-by: Jan Srnicek --- .../ip/Ipv4AddressCustomizerTest.java | 29 +++++++++--------- .../ip/SubInterfaceIpv4AddressCustomizerTest.java | 34 +++++++++++----------- 2 files changed, 32 insertions(+), 31 deletions(-) (limited to 'v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate') diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/ip/Ipv4AddressCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/ip/Ipv4AddressCustomizerTest.java index bac21c88f..0ab64b21e 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/ip/Ipv4AddressCustomizerTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/ip/Ipv4AddressCustomizerTest.java @@ -27,13 +27,13 @@ import static org.mockito.Mockito.when; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; +import io.fd.hc2vpp.common.test.read.ListReaderCustomizerTest; +import io.fd.hc2vpp.common.translate.util.Ipv4Translator; +import io.fd.hc2vpp.common.translate.util.NamingContext; import io.fd.honeycomb.translate.read.ReadFailedException; import io.fd.honeycomb.translate.spi.read.ReaderCustomizer; import io.fd.honeycomb.translate.util.read.cache.CacheKeyFactory; -import io.fd.honeycomb.translate.util.read.cache.IdentifierCacheKeyFactory; -import io.fd.hc2vpp.common.translate.util.Ipv4Translator; -import io.fd.hc2vpp.common.translate.util.NamingContext; -import io.fd.hc2vpp.common.test.read.ListReaderCustomizerTest; +import io.fd.honeycomb.translate.util.read.cache.TypeAwareIdentifierCacheKeyFactory; import io.fd.vpp.jvpp.core.dto.IpAddressDetails; import io.fd.vpp.jvpp.core.dto.IpAddressDetailsReplyDump; import io.fd.vpp.jvpp.core.dto.IpAddressDump; @@ -76,6 +76,15 @@ public class Ipv4AddressCustomizerTest extends ListReaderCustomizerTest getId(final String address, final String ifaceName) { + return InstanceIdentifier.builder(InterfacesState.class) + .child(Interface.class, new InterfaceKey(ifaceName)) + .augmentation(Interface2.class) + .child(Ipv4.class) + .child(Address.class, new AddressKey(new Ipv4AddressNoZone(new Ipv4Address(address)))) + .build(); + } + @Override public void setUp() { interfacesContext = new NamingContext("generatedIfaceName", IFC_CTX_NAME); @@ -96,7 +105,8 @@ public class Ipv4AddressCustomizerTest extends ListReaderCustomizerTest getId(final String address, final String ifaceName) { - return InstanceIdentifier.builder(InterfacesState.class) - .child(Interface.class, new InterfaceKey(ifaceName)) - .augmentation(Interface2.class) - .child(Ipv4.class) - .child(Address.class, new AddressKey(new Ipv4AddressNoZone(new Ipv4Address(address)))) - .build(); - } - @Test public void testReadCurrentAttributesFor2Ifcs() throws ReadFailedException { //changed to mock to not store first dumped data(otherwise that double thenReturn on line 118 is not gonna work) diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/ip/SubInterfaceIpv4AddressCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/ip/SubInterfaceIpv4AddressCustomizerTest.java index 4842f5de4..8c67735aa 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/ip/SubInterfaceIpv4AddressCustomizerTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/ip/SubInterfaceIpv4AddressCustomizerTest.java @@ -29,13 +29,13 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import com.google.common.collect.ImmutableSet; +import io.fd.hc2vpp.common.test.read.ListReaderCustomizerTest; +import io.fd.hc2vpp.common.translate.util.Ipv4Translator; +import io.fd.hc2vpp.common.translate.util.NamingContext; import io.fd.honeycomb.translate.read.ReadFailedException; import io.fd.honeycomb.translate.spi.read.ListReaderCustomizer; import io.fd.honeycomb.translate.util.read.cache.CacheKeyFactory; -import io.fd.honeycomb.translate.util.read.cache.IdentifierCacheKeyFactory; -import io.fd.hc2vpp.common.translate.util.Ipv4Translator; -import io.fd.hc2vpp.common.translate.util.NamingContext; -import io.fd.hc2vpp.common.test.read.ListReaderCustomizerTest; +import io.fd.honeycomb.translate.util.read.cache.TypeAwareIdentifierCacheKeyFactory; import io.fd.vpp.jvpp.core.dto.IpAddressDetails; import io.fd.vpp.jvpp.core.dto.IpAddressDetailsReplyDump; import java.util.Arrays; @@ -76,19 +76,26 @@ public class SubInterfaceIpv4AddressCustomizerTest extends ListReaderCustomizerT .augmentation(SubinterfaceStateAugmentation.class) .child(SubInterfaces.class).child(SubInterface.class, new SubInterfaceKey(SUB_IF_ID)) .child(Ipv4.class); - private InstanceIdentifier
ifaceOneAddressOneIdentifier; - private InstanceIdentifier
ifaceTwoAddressOneIdentifier; - private CacheKeyFactory cacheKeyFactory; private static final Ipv4AddressNoZone IP1 = new Ipv4AddressNoZone("10.1.1.1"); private static final Ipv4AddressNoZone IP2 = new Ipv4AddressNoZone("10.1.1.2"); private static final short PREFIX_LENGTH = 16; - + private InstanceIdentifier
ifaceOneAddressOneIdentifier; + private InstanceIdentifier
ifaceTwoAddressOneIdentifier; + private CacheKeyFactory cacheKeyFactory; private NamingContext interfaceContext; public SubInterfaceIpv4AddressCustomizerTest() { super(Address.class, Ipv4Builder.class); } + private static InstanceIdentifier
getId() { + return IP4_IID.child(Address.class); + } + + private static InstanceIdentifier
getId(final Ipv4AddressNoZone ip) { + return IP4_IID.child(Address.class, new AddressKey(ip)); + } + @Override protected void setUp() throws Exception { interfaceContext = new NamingContext("generatedIfaceName", IFC_CTX_NAME); @@ -109,7 +116,8 @@ public class SubInterfaceIpv4AddressCustomizerTest extends ListReaderCustomizerT .child(Address.class, new AddressKey(new Ipv4AddressNoZone("192.168.2.1"))); // to simulate complex key - cacheKeyFactory = new IdentifierCacheKeyFactory(ImmutableSet.of(SubInterface.class)); + cacheKeyFactory = new TypeAwareIdentifierCacheKeyFactory(IpAddressDetailsReplyDump.class, + ImmutableSet.of(SubInterface.class)); defineMapping(mappingContext, IF_NAME, IF_INDEX, IFC_CTX_NAME); defineMapping(mappingContext, SUB_IF_NAME, SUB_IF_INDEX, IFC_CTX_NAME); @@ -121,14 +129,6 @@ public class SubInterfaceIpv4AddressCustomizerTest extends ListReaderCustomizerT return new SubInterfaceIpv4AddressCustomizer(api, interfaceContext); } - private static InstanceIdentifier
getId() { - return IP4_IID.child(Address.class); - } - - private static InstanceIdentifier
getId(final Ipv4AddressNoZone ip) { - return IP4_IID.child(Address.class, new AddressKey(ip)); - } - @Test public void testRead() throws ReadFailedException { final AddressBuilder builder = mock(AddressBuilder.class); -- cgit 1.2.3-korg