diff options
Diffstat (limited to 'v3po/v3po2vpp/src/test')
2 files changed, 32 insertions, 31 deletions
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<Address, super(Address.class, Ipv4Builder.class); } + private static InstanceIdentifier<Address> 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<Address, .child(Address.class, new AddressKey(new Ipv4AddressNoZone("192.168.2.1"))); // to simulate complex key - cacheKeyFactory = new IdentifierCacheKeyFactory(ImmutableSet.of(Interface.class)); + cacheKeyFactory = new TypeAwareIdentifierCacheKeyFactory(IpAddressDetailsReplyDump.class, + ImmutableSet.of(Interface.class)); } @Override @@ -104,15 +114,6 @@ public class Ipv4AddressCustomizerTest extends ListReaderCustomizerTest<Address, return new Ipv4AddressCustomizer(api, interfacesContext); } - private static InstanceIdentifier<Address> 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<Address> ifaceOneAddressOneIdentifier; - private InstanceIdentifier<Address> 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<Address> ifaceOneAddressOneIdentifier; + private InstanceIdentifier<Address> ifaceTwoAddressOneIdentifier; + private CacheKeyFactory cacheKeyFactory; private NamingContext interfaceContext; public SubInterfaceIpv4AddressCustomizerTest() { super(Address.class, Ipv4Builder.class); } + private static InstanceIdentifier<Address> getId() { + return IP4_IID.child(Address.class); + } + + private static InstanceIdentifier<Address> 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<Address> getId() { - return IP4_IID.child(Address.class); - } - - private static InstanceIdentifier<Address> 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); |