summaryrefslogtreecommitdiffstats
path: root/acl/acl-impl/src/test/java/io/fd
diff options
context:
space:
mode:
Diffstat (limited to 'acl/acl-impl/src/test/java/io/fd')
-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
2 files changed, 36 insertions, 4 deletions
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);
}