From 7f961994184897bba90003e2d6d324e1041946af Mon Sep 17 00:00:00 2001 From: Marek Gradzki Date: Fri, 23 Dec 2016 08:03:10 +0100 Subject: HONEYCOMB-310: initializers for interface acl assignment Change-Id: I6dcc1ef1abc9d314906d6d4fcc746dcfd28ec5fc Signed-off-by: Marek Gradzki --- .../hc2vpp/acl/read/AbstractVppAclCustomizer.java | 28 +++++++++++++- .../fd/hc2vpp/acl/read/EgressVppAclCustomizer.java | 11 ++++++ .../hc2vpp/acl/read/IngressVppAclCustomizer.java | 11 ++++++ .../fd/hc2vpp/acl/read/VppMacIpAclCustomizer.java | 22 ++++++++++- .../read/factory/InterfaceAclReaderFactory.java | 10 ++--- .../acl/read/AbstractVppAclCustomizerTest.java | 21 +++++++++- .../hc2vpp/acl/read/VppMacIpAclCustomizerTest.java | 19 ++++++++- .../read/InitializingListReaderCustomizerTest.java | 45 ++++++++++++++++++++++ .../read/InitializingReaderCustomizerTest.java | 42 ++++++++++++++++++++ 9 files changed, 196 insertions(+), 13 deletions(-) create mode 100644 vpp-common/vpp-translate-test/src/main/java/io/fd/hc2vpp/common/test/read/InitializingListReaderCustomizerTest.java create mode 100644 vpp-common/vpp-translate-test/src/main/java/io/fd/hc2vpp/common/test/read/InitializingReaderCustomizerTest.java diff --git a/acl/acl-impl/src/main/java/io/fd/hc2vpp/acl/read/AbstractVppAclCustomizer.java b/acl/acl-impl/src/main/java/io/fd/hc2vpp/acl/read/AbstractVppAclCustomizer.java index ed853eeea..782c1c007 100644 --- a/acl/acl-impl/src/main/java/io/fd/hc2vpp/acl/read/AbstractVppAclCustomizer.java +++ b/acl/acl-impl/src/main/java/io/fd/hc2vpp/acl/read/AbstractVppAclCustomizer.java @@ -24,7 +24,8 @@ import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer; import io.fd.hc2vpp.common.translate.util.NamingContext; import io.fd.honeycomb.translate.read.ReadContext; import io.fd.honeycomb.translate.read.ReadFailedException; -import io.fd.honeycomb.translate.spi.read.ListReaderCustomizer; +import io.fd.honeycomb.translate.spi.read.Initialized; +import io.fd.honeycomb.translate.spi.read.InitializingListReaderCustomizer; import io.fd.honeycomb.translate.util.read.cache.DumpCacheManager; import io.fd.honeycomb.translate.util.read.cache.DumpCacheManager.DumpCacheManagerBuilder; import io.fd.honeycomb.translate.util.read.cache.EntityDumpExecutor; @@ -41,8 +42,11 @@ import java.util.List; import java.util.stream.Collectors; import java.util.stream.IntStream; import javax.annotation.Nonnull; +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.state.Interface; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.HexString; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.acl.rev161214.VppAclInterfaceAugmentation; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.acl.rev161214._interface.acl.attributes.Acl; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.acl.rev161214.vpp.acls.base.attributes.VppAcls; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.acl.rev161214.vpp.acls.base.attributes.VppAclsBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.acl.rev161214.vpp.acls.base.attributes.VppAclsKey; @@ -50,7 +54,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.acl. import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; abstract class AbstractVppAclCustomizer extends FutureJVppAclCustomizer - implements ListReaderCustomizer, JvppReplyConsumer, ByteDataTranslator { + implements InitializingListReaderCustomizer, JvppReplyConsumer, + ByteDataTranslator { private final NamingContext interfaceContext; private final NamingContext standardAclContext; @@ -79,6 +84,15 @@ abstract class AbstractVppAclCustomizer extends FutureJVppAclCustomizer .build(); } + protected static InstanceIdentifier getAclCfgId( + final InstanceIdentifier id) { + return InstanceIdentifier.create(Interfaces.class).child( + org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface.class, + new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey( + id.firstKeyOf(Interface.class).getName())).augmentation(VppAclInterfaceAugmentation.class) + .child(Acl.class); + } + private EntityDumpExecutor createAclExecutor() { return (identifier, params) -> { AclDump request = new AclDump(); @@ -160,4 +174,14 @@ abstract class AbstractVppAclCustomizer extends FutureJVppAclCustomizer new IllegalArgumentException(String.format("Acl with name %s not found", aclName))); } } + + @Nonnull + @Override + public Initialized init(@Nonnull final InstanceIdentifier id, + @Nonnull final VppAcls vppAcls, + @Nonnull final ReadContext readContext) { + return Initialized.create(getCfgId(id), vppAcls); + } + + protected abstract InstanceIdentifier getCfgId(final InstanceIdentifier id); } diff --git a/acl/acl-impl/src/main/java/io/fd/hc2vpp/acl/read/EgressVppAclCustomizer.java b/acl/acl-impl/src/main/java/io/fd/hc2vpp/acl/read/EgressVppAclCustomizer.java index 536b27fcc..eaabb0bff 100644 --- a/acl/acl-impl/src/main/java/io/fd/hc2vpp/acl/read/EgressVppAclCustomizer.java +++ b/acl/acl-impl/src/main/java/io/fd/hc2vpp/acl/read/EgressVppAclCustomizer.java @@ -17,16 +17,20 @@ package io.fd.hc2vpp.acl.read; import io.fd.hc2vpp.common.translate.util.NamingContext; +import io.fd.honeycomb.translate.util.RWUtils; import io.fd.vpp.jvpp.acl.dto.AclInterfaceListDetails; import io.fd.vpp.jvpp.acl.future.FutureJVppAclFacade; import java.util.Arrays; import java.util.List; import java.util.stream.IntStream; import javax.annotation.Nonnull; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.acl.rev161214._interface.acl.attributes.Acl; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.acl.rev161214._interface.acl.attributes.acl.Egress; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.acl.rev161214._interface.acl.attributes.acl.EgressBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.acl.rev161214.vpp.acls.base.attributes.VppAcls; import org.opendaylight.yangtools.concepts.Builder; import org.opendaylight.yangtools.yang.binding.DataObject; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; public final class EgressVppAclCustomizer extends AbstractVppAclCustomizer { @@ -45,4 +49,11 @@ public final class EgressVppAclCustomizer extends AbstractVppAclCustomizer { public void merge(@Nonnull final Builder builder, @Nonnull final List readData) { EgressBuilder.class.cast(builder).setVppAcls(readData); } + + @Override + protected InstanceIdentifier getCfgId( + final InstanceIdentifier id) { + return getAclCfgId(RWUtils.cutId(id, Acl.class)).child(Egress.class) + .child(VppAcls.class, id.firstKeyOf(VppAcls.class)); + } } diff --git a/acl/acl-impl/src/main/java/io/fd/hc2vpp/acl/read/IngressVppAclCustomizer.java b/acl/acl-impl/src/main/java/io/fd/hc2vpp/acl/read/IngressVppAclCustomizer.java index 8a31032d7..e8c79c967 100644 --- a/acl/acl-impl/src/main/java/io/fd/hc2vpp/acl/read/IngressVppAclCustomizer.java +++ b/acl/acl-impl/src/main/java/io/fd/hc2vpp/acl/read/IngressVppAclCustomizer.java @@ -17,16 +17,20 @@ package io.fd.hc2vpp.acl.read; import io.fd.hc2vpp.common.translate.util.NamingContext; +import io.fd.honeycomb.translate.util.RWUtils; import io.fd.vpp.jvpp.acl.dto.AclInterfaceListDetails; import io.fd.vpp.jvpp.acl.future.FutureJVppAclFacade; import java.util.Arrays; import java.util.List; import java.util.stream.IntStream; import javax.annotation.Nonnull; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.acl.rev161214._interface.acl.attributes.Acl; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.acl.rev161214._interface.acl.attributes.acl.Ingress; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.acl.rev161214._interface.acl.attributes.acl.IngressBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.acl.rev161214.vpp.acls.base.attributes.VppAcls; import org.opendaylight.yangtools.concepts.Builder; import org.opendaylight.yangtools.yang.binding.DataObject; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; public final class IngressVppAclCustomizer extends AbstractVppAclCustomizer { @@ -45,4 +49,11 @@ public final class IngressVppAclCustomizer extends AbstractVppAclCustomizer { public void merge(@Nonnull final Builder builder, @Nonnull final List readData) { IngressBuilder.class.cast(builder).setVppAcls(readData); } + + @Override + protected InstanceIdentifier getCfgId( + final InstanceIdentifier id) { + return getAclCfgId(RWUtils.cutId(id, Acl.class)).child(Ingress.class) + .child(VppAcls.class, id.firstKeyOf(VppAcls.class)); + } } diff --git a/acl/acl-impl/src/main/java/io/fd/hc2vpp/acl/read/VppMacIpAclCustomizer.java b/acl/acl-impl/src/main/java/io/fd/hc2vpp/acl/read/VppMacIpAclCustomizer.java index 7786afee5..81799e1fa 100644 --- a/acl/acl-impl/src/main/java/io/fd/hc2vpp/acl/read/VppMacIpAclCustomizer.java +++ b/acl/acl-impl/src/main/java/io/fd/hc2vpp/acl/read/VppMacIpAclCustomizer.java @@ -16,6 +16,7 @@ package io.fd.hc2vpp.acl.read; +import static io.fd.hc2vpp.acl.read.AbstractVppAclCustomizer.getAclCfgId; import static io.fd.honeycomb.translate.util.read.cache.EntityDumpExecutor.NO_PARAMS; import com.google.common.base.Optional; @@ -27,7 +28,9 @@ import io.fd.honeycomb.translate.MappingContext; import io.fd.honeycomb.translate.ModificationCache; import io.fd.honeycomb.translate.read.ReadContext; import io.fd.honeycomb.translate.read.ReadFailedException; -import io.fd.honeycomb.translate.spi.read.ReaderCustomizer; +import io.fd.honeycomb.translate.spi.read.Initialized; +import io.fd.honeycomb.translate.spi.read.InitializingReaderCustomizer; +import io.fd.honeycomb.translate.util.RWUtils; import io.fd.honeycomb.translate.util.read.cache.DumpCacheManager; import io.fd.honeycomb.translate.util.read.cache.EntityDumpExecutor; import io.fd.vpp.jvpp.acl.dto.MacipAclDetails; @@ -39,6 +42,8 @@ import io.fd.vpp.jvpp.acl.future.FutureJVppAclFacade; import javax.annotation.Nonnull; 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.yang.types.rev130715.HexString; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.acl.rev161214._interface.acl.attributes.Acl; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.acl.rev161214._interface.acl.attributes.acl.Ingress; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.acl.rev161214._interface.acl.attributes.acl.IngressBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.acl.rev161214.vpp.macip.acls.base.attributes.VppMacipAcl; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.acl.rev161214.vpp.macip.acls.base.attributes.VppMacipAclBuilder; @@ -49,7 +54,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class VppMacIpAclCustomizer extends FutureJVppAclCustomizer - implements ReaderCustomizer, JvppReplyConsumer, ByteDataTranslator { + implements InitializingReaderCustomizer, JvppReplyConsumer, ByteDataTranslator { private static final Logger LOG = LoggerFactory.getLogger(VppMacIpAclCustomizer.class); @@ -78,6 +83,11 @@ public class VppMacIpAclCustomizer extends FutureJVppAclCustomizer this.macIpAclContext = macIpAclContext; } + private static InstanceIdentifier getCfgId( + final InstanceIdentifier id) { + return getAclCfgId(RWUtils.cutId(id, Acl.class)).child(Ingress.class).child(VppMacipAcl.class); + } + private EntityDumpExecutor createMacIpDumpExecutor() { return (identifier, params) -> { MacipAclDump request = new MacipAclDump(); @@ -142,4 +152,12 @@ public class VppMacIpAclCustomizer extends FutureJVppAclCustomizer @Nonnull final VppMacipAcl readValue) { IngressBuilder.class.cast(parentBuilder).setVppMacipAcl(readValue); } + + @Nonnull + @Override + public Initialized init(@Nonnull final InstanceIdentifier id, + @Nonnull final VppMacipAcl readValue, + @Nonnull final ReadContext ctx) { + return Initialized.create(getCfgId(id), readValue); + } } diff --git a/acl/acl-impl/src/main/java/io/fd/hc2vpp/acl/read/factory/InterfaceAclReaderFactory.java b/acl/acl-impl/src/main/java/io/fd/hc2vpp/acl/read/factory/InterfaceAclReaderFactory.java index 691479e64..5b627fbc3 100644 --- a/acl/acl-impl/src/main/java/io/fd/hc2vpp/acl/read/factory/InterfaceAclReaderFactory.java +++ b/acl/acl-impl/src/main/java/io/fd/hc2vpp/acl/read/factory/InterfaceAclReaderFactory.java @@ -23,8 +23,8 @@ import io.fd.hc2vpp.acl.read.EgressVppAclCustomizer; import io.fd.hc2vpp.acl.read.IngressVppAclCustomizer; import io.fd.hc2vpp.acl.read.VppMacIpAclCustomizer; import io.fd.hc2vpp.common.translate.util.NamingContext; -import io.fd.honeycomb.translate.impl.read.GenericListReader; -import io.fd.honeycomb.translate.impl.read.GenericReader; +import io.fd.honeycomb.translate.impl.read.GenericInitListReader; +import io.fd.honeycomb.translate.impl.read.GenericInitReader; import io.fd.honeycomb.translate.read.ReaderFactory; import io.fd.honeycomb.translate.read.registry.ModifiableReaderRegistryBuilder; import io.fd.vpp.jvpp.acl.future.FutureJVppAclFacade; @@ -73,14 +73,14 @@ public class InterfaceAclReaderFactory implements ReaderFactory { final InstanceIdentifier ingressInstanceIdentifier = ACL_IID.child(Ingress.class); registry.addStructuralReader(ingressInstanceIdentifier, IngressBuilder.class); - registry.addAfter(new GenericListReader<>(ingressInstanceIdentifier.child(VppAcls.class), + registry.addAfter(new GenericInitListReader<>(ingressInstanceIdentifier.child(VppAcls.class), new IngressVppAclCustomizer(futureAclFacade, interfaceContext, standardAclContext)), IFC_ID); - registry.addAfter(new GenericReader<>(ingressInstanceIdentifier.child(VppMacipAcl.class), + registry.addAfter(new GenericInitReader<>(ingressInstanceIdentifier.child(VppMacipAcl.class), new VppMacIpAclCustomizer(futureAclFacade, interfaceContext, macIpAClContext)), IFC_ID); final InstanceIdentifier egressInstanceIdentifier = ACL_IID.child(Egress.class); registry.addStructuralReader(egressInstanceIdentifier, EgressBuilder.class); - registry.addAfter(new GenericListReader<>(egressInstanceIdentifier.child(VppAcls.class), + registry.addAfter(new GenericInitListReader<>(egressInstanceIdentifier.child(VppAcls.class), new EgressVppAclCustomizer(futureAclFacade, interfaceContext, standardAclContext)), IFC_ID); } } diff --git a/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/read/AbstractVppAclCustomizerTest.java b/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/read/AbstractVppAclCustomizerTest.java index 47e99ebac..e885ef033 100644 --- a/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/read/AbstractVppAclCustomizerTest.java +++ b/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/read/AbstractVppAclCustomizerTest.java @@ -18,15 +18,17 @@ package io.fd.hc2vpp.acl.read; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import io.fd.hc2vpp.common.test.read.ListReaderCustomizerTest; +import io.fd.hc2vpp.common.test.read.InitializingListReaderCustomizerTest; import io.fd.hc2vpp.common.translate.util.NamingContext; import io.fd.honeycomb.translate.read.ReadFailedException; +import io.fd.honeycomb.translate.spi.read.Initialized; import io.fd.vpp.jvpp.acl.dto.AclDetails; import io.fd.vpp.jvpp.acl.dto.AclDetailsReplyDump; import io.fd.vpp.jvpp.acl.dto.AclInterfaceListDetails; @@ -51,7 +53,7 @@ import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; public abstract class AbstractVppAclCustomizerTest - extends ListReaderCustomizerTest { + extends InitializingListReaderCustomizerTest { protected static final String IF_NAME = "eth1"; protected static final int IF_ID = 1; @@ -123,6 +125,21 @@ public abstract class AbstractVppAclCustomizerTest assertEquals(0, getCustomizer().getAllIds(getWildcardedIid(IF_NAME_NO_ACL), ctx).size()); } + @Test + public void testInit() { + final String aclName = "acl-name"; + final Class aclType = VppAcl.class; + defineMapping(mappingContext, aclName, 1, ACL_CTX_NAME); + + final VppAcls readValue = new VppAclsBuilder().build(); + final Initialized cfgValue = + getCustomizer().init(getIid(IF_NAME, new VppAclsKey(aclName, aclType)), readValue, ctx); + assertEquals(readValue, cfgValue.getData()); + assertNotNull(cfgValue.getId().firstKeyOf( + org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface.class)); + assertEquals(cfgValue.getId().getTargetType(), VppAcls.class); + } + protected AclInterfaceListDump aclInterfaceRequest(final int swIfIndex) { final AclInterfaceListDump request = new AclInterfaceListDump(); request.swIfIndex = swIfIndex; diff --git a/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/read/VppMacIpAclCustomizerTest.java b/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/read/VppMacIpAclCustomizerTest.java index 97169cf06..29df6ac22 100644 --- a/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/read/VppMacIpAclCustomizerTest.java +++ b/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/read/VppMacIpAclCustomizerTest.java @@ -17,15 +17,18 @@ package io.fd.hc2vpp.acl.read; import static io.fd.hc2vpp.acl.read.AbstractVppAclCustomizerTest.getAclId; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.Mockito.when; -import io.fd.hc2vpp.common.test.read.ReaderCustomizerTest; +import io.fd.hc2vpp.common.test.read.InitializingReaderCustomizerTest; import io.fd.hc2vpp.common.translate.util.NamingContext; import io.fd.honeycomb.translate.read.ReadFailedException; +import io.fd.honeycomb.translate.spi.read.Initialized; import io.fd.vpp.jvpp.acl.dto.MacipAclDetails; import io.fd.vpp.jvpp.acl.dto.MacipAclDetailsReplyDump; import io.fd.vpp.jvpp.acl.dto.MacipAclDump; @@ -35,13 +38,15 @@ import javax.annotation.Nonnull; import org.junit.Test; import org.mockito.Mock; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160708.AclBase; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.acl.rev161214._interface.acl.attributes.acl.Ingress; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.acl.rev161214._interface.acl.attributes.acl.IngressBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.acl.rev161214.vpp.macip.acls.base.attributes.VppMacipAcl; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.acl.rev161214.vpp.macip.acls.base.attributes.VppMacipAclBuilder; +import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -public class VppMacIpAclCustomizerTest extends ReaderCustomizerTest { +public class VppMacIpAclCustomizerTest extends InitializingReaderCustomizerTest { protected static final String IF_NAME_NO_ACL = "eth2"; protected static final int IF_ID_NO_ACL = 2; @@ -104,6 +109,16 @@ public class VppMacIpAclCustomizerTest extends ReaderCustomizerTest cfgValue = getCustomizer().init(getIid(IF_NAME), readValue, ctx); + assertEquals(cfgValue.getData(), readValue); + assertNotNull(cfgValue.getId().firstKeyOf(Interface.class)); + assertEquals(cfgValue.getId().getTargetType(), VppMacipAcl.class); + + } + protected InstanceIdentifier getIid(@Nonnull final String ifName) { return getAclId(ifName).child(Ingress.class).child(VppMacipAcl.class); } diff --git a/vpp-common/vpp-translate-test/src/main/java/io/fd/hc2vpp/common/test/read/InitializingListReaderCustomizerTest.java b/vpp-common/vpp-translate-test/src/main/java/io/fd/hc2vpp/common/test/read/InitializingListReaderCustomizerTest.java new file mode 100644 index 000000000..b6089c4da --- /dev/null +++ b/vpp-common/vpp-translate-test/src/main/java/io/fd/hc2vpp/common/test/read/InitializingListReaderCustomizerTest.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2016 Cisco and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.fd.hc2vpp.common.test.read; + +import io.fd.honeycomb.translate.spi.read.InitializingListReaderCustomizer; +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; + +/** + * Generic test for classes implementing {@link InitializingListReaderCustomizer} interface. + * + * @param Specific DataObject derived type (Identifiable), that is handled by this customizer + * @param Specific Identifier for handled type (D) + * @param Specific Builder for handled type (D) + */ +public abstract class InitializingListReaderCustomizerTest, K extends Identifier, B extends Builder> extends + ListReaderCustomizerTest { + + protected InitializingListReaderCustomizerTest( + final Class dataObjectClass, + final Class> parentBuilderClass) { + super(dataObjectClass, parentBuilderClass); + } + + @Override + protected InitializingListReaderCustomizer getCustomizer() { + return InitializingListReaderCustomizer.class.cast(super.getCustomizer()); + } +} diff --git a/vpp-common/vpp-translate-test/src/main/java/io/fd/hc2vpp/common/test/read/InitializingReaderCustomizerTest.java b/vpp-common/vpp-translate-test/src/main/java/io/fd/hc2vpp/common/test/read/InitializingReaderCustomizerTest.java new file mode 100644 index 000000000..e102ef827 --- /dev/null +++ b/vpp-common/vpp-translate-test/src/main/java/io/fd/hc2vpp/common/test/read/InitializingReaderCustomizerTest.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2016 Cisco and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.fd.hc2vpp.common.test.read; + +import io.fd.honeycomb.translate.spi.read.InitializingReaderCustomizer; +import org.opendaylight.yangtools.concepts.Builder; +import org.opendaylight.yangtools.yang.binding.DataObject; + +/** + * Generic test for classes implementing {@link InitializingReaderCustomizer} interface. + * + * @param Specific DataObject derived type (Identifiable), that is handled by this customizer + * @param Specific Builder for handled type (D) + */ +public abstract class InitializingReaderCustomizerTest> extends + ReaderCustomizerTest { + + protected InitializingReaderCustomizerTest( + final Class dataObjectClass, + final Class> parentBuilderClass) { + super(dataObjectClass, parentBuilderClass); + } + + @Override + protected InitializingReaderCustomizer getCustomizer() { + return InitializingReaderCustomizer.class.cast(super.getCustomizer()); + } +} -- cgit