summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarek Gradzki <mgradzki@cisco.com>2016-12-23 08:03:10 +0100
committerMarek Gradzki <mgradzki@cisco.com>2016-12-23 09:17:24 +0100
commit7f961994184897bba90003e2d6d324e1041946af (patch)
tree72cdb45545b69368706ff984761acb6da8624bd2
parentcfcc0585d9801a15ec4b36ac627662dc7f0fe789 (diff)
HONEYCOMB-310: initializers for interface acl assignment
Change-Id: I6dcc1ef1abc9d314906d6d4fcc746dcfd28ec5fc Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
-rw-r--r--acl/acl-impl/src/main/java/io/fd/hc2vpp/acl/read/AbstractVppAclCustomizer.java28
-rw-r--r--acl/acl-impl/src/main/java/io/fd/hc2vpp/acl/read/EgressVppAclCustomizer.java11
-rw-r--r--acl/acl-impl/src/main/java/io/fd/hc2vpp/acl/read/IngressVppAclCustomizer.java11
-rw-r--r--acl/acl-impl/src/main/java/io/fd/hc2vpp/acl/read/VppMacIpAclCustomizer.java22
-rw-r--r--acl/acl-impl/src/main/java/io/fd/hc2vpp/acl/read/factory/InterfaceAclReaderFactory.java10
-rw-r--r--acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/read/AbstractVppAclCustomizerTest.java21
-rw-r--r--acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/read/VppMacIpAclCustomizerTest.java19
-rw-r--r--vpp-common/vpp-translate-test/src/main/java/io/fd/hc2vpp/common/test/read/InitializingListReaderCustomizerTest.java45
-rw-r--r--vpp-common/vpp-translate-test/src/main/java/io/fd/hc2vpp/common/test/read/InitializingReaderCustomizerTest.java42
9 files changed, 196 insertions, 13 deletions
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<VppAcls, VppAclsKey, VppAclsBuilder>, JvppReplyConsumer, ByteDataTranslator {
+ implements InitializingListReaderCustomizer<VppAcls, VppAclsKey, VppAclsBuilder>, JvppReplyConsumer,
+ ByteDataTranslator {
private final NamingContext interfaceContext;
private final NamingContext standardAclContext;
@@ -79,6 +84,15 @@ abstract class AbstractVppAclCustomizer extends FutureJVppAclCustomizer
.build();
}
+ protected static InstanceIdentifier<Acl> getAclCfgId(
+ final InstanceIdentifier<Acl> 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<AclDetailsReplyDump, Integer> 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<VppAcls> init(@Nonnull final InstanceIdentifier<VppAcls> id,
+ @Nonnull final VppAcls vppAcls,
+ @Nonnull final ReadContext readContext) {
+ return Initialized.create(getCfgId(id), vppAcls);
+ }
+
+ protected abstract InstanceIdentifier<VppAcls> getCfgId(final InstanceIdentifier<VppAcls> 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<? extends DataObject> builder, @Nonnull final List<VppAcls> readData) {
EgressBuilder.class.cast(builder).setVppAcls(readData);
}
+
+ @Override
+ protected InstanceIdentifier<VppAcls> getCfgId(
+ final InstanceIdentifier<VppAcls> 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<? extends DataObject> builder, @Nonnull final List<VppAcls> readData) {
IngressBuilder.class.cast(builder).setVppAcls(readData);
}
+
+ @Override
+ protected InstanceIdentifier<VppAcls> getCfgId(
+ final InstanceIdentifier<VppAcls> 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<VppMacipAcl, VppMacipAclBuilder>, JvppReplyConsumer, ByteDataTranslator {
+ implements InitializingReaderCustomizer<VppMacipAcl, VppMacipAclBuilder>, 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<VppMacipAcl> getCfgId(
+ final InstanceIdentifier<VppMacipAcl> id) {
+ return getAclCfgId(RWUtils.cutId(id, Acl.class)).child(Ingress.class).child(VppMacipAcl.class);
+ }
+
private EntityDumpExecutor<MacipAclDetailsReplyDump, Integer> 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<? extends DataObject> init(@Nonnull final InstanceIdentifier<VppMacipAcl> 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<Ingress> 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<Egress> 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<VppAcls, VppAclsKey, VppAclsBuilder> {
+ extends InitializingListReaderCustomizerTest<VppAcls, VppAclsKey, VppAclsBuilder> {
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<VppAcl> aclType = VppAcl.class;
+ defineMapping(mappingContext, aclName, 1, ACL_CTX_NAME);
+
+ final VppAcls readValue = new VppAclsBuilder().build();
+ final Initialized<? extends DataObject> 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<VppMacipAcl, VppMacipAclBuilder> {
+public class VppMacIpAclCustomizerTest extends InitializingReaderCustomizerTest<VppMacipAcl, VppMacipAclBuilder> {
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<VppMacipAcl,
verifyZeroInteractions(builder);
}
+ @Test
+ public void testInit() {
+ final VppMacipAcl readValue = new VppMacipAclBuilder().build();
+ final Initialized<? extends DataObject> 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<VppMacipAcl> 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 <D> Specific DataObject derived type (Identifiable), that is handled by this customizer
+ * @param <K> Specific Identifier for handled type (D)
+ * @param <B> Specific Builder for handled type (D)
+ */
+public abstract class InitializingListReaderCustomizerTest<D extends DataObject & Identifiable<K>, K extends Identifier<D>, B extends Builder<D>> extends
+ ListReaderCustomizerTest<D, K, B> {
+
+ protected InitializingListReaderCustomizerTest(
+ final Class<D> dataObjectClass,
+ final Class<? extends Builder<? extends DataObject>> parentBuilderClass) {
+ super(dataObjectClass, parentBuilderClass);
+ }
+
+ @Override
+ protected InitializingListReaderCustomizer<D, K, B> 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 <D> Specific DataObject derived type (Identifiable), that is handled by this customizer
+ * @param <B> Specific Builder for handled type (D)
+ */
+public abstract class InitializingReaderCustomizerTest<D extends DataObject, B extends Builder<D>> extends
+ ReaderCustomizerTest<D, B> {
+
+ protected InitializingReaderCustomizerTest(
+ final Class<D> dataObjectClass,
+ final Class<? extends Builder<? extends DataObject>> parentBuilderClass) {
+ super(dataObjectClass, parentBuilderClass);
+ }
+
+ @Override
+ protected InitializingReaderCustomizer<D, B> getCustomizer() {
+ return InitializingReaderCustomizer.class.cast(super.getCustomizer());
+ }
+}