diff options
Diffstat (limited to 'acl/acl-impl/src/test/java/io')
2 files changed, 50 insertions, 15 deletions
diff --git a/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/util/iface/acl/AclInterfaceAssignmentRequestTest.java b/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/util/iface/acl/AclInterfaceAssignmentRequestTest.java index 3eb1a6267..3427dc7fd 100644 --- a/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/util/iface/acl/AclInterfaceAssignmentRequestTest.java +++ b/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/util/iface/acl/AclInterfaceAssignmentRequestTest.java @@ -23,7 +23,6 @@ import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import static org.mockito.MockitoAnnotations.initMocks; @@ -39,7 +38,6 @@ import io.fd.vpp.jvpp.acl.dto.AclInterfaceSetAclList; import io.fd.vpp.jvpp.acl.dto.AclInterfaceSetAclListReply; import io.fd.vpp.jvpp.acl.future.FutureJVppAclFacade; import java.util.Arrays; -import java.util.Collections; import org.junit.Before; import org.junit.Test; import org.mockito.ArgumentCaptor; @@ -113,15 +111,6 @@ public class AclInterfaceAssignmentRequestTest implements NamingContextHelper, F verifyVariant(create(mappingContext).identifier(validIdentifier)); verifyVariant(create(mappingContext).identifier(validIdentifier).interfaceContext(interfaceContext)); - - verifyVariant(create(mappingContext).identifier(validIdentifier).interfaceContext(interfaceContext) - .standardAclContext(aclContext)); - - verifyVariant(create(mappingContext).identifier(validIdentifier).interfaceContext(interfaceContext) - .standardAclContext(aclContext).inputAclNames(Collections.emptyList())); - - verifyVariant(create(mappingContext).identifier(validIdentifier).interfaceContext(interfaceContext) - .standardAclContext(aclContext).outputAclNames(Collections.emptyList())); } private void verifyVariant(final AclInterfaceAssignmentRequest request) throws WriteFailedException { @@ -132,13 +121,46 @@ public class AclInterfaceAssignmentRequestTest implements NamingContextHelper, F @Test public void executeAsCreate() throws Exception { - createValidRequest().executeAsCreate(api); + + verify(api).aclInterfaceSetAclList(requestCaptor.capture()); + verifyValidRequest(requestCaptor.getValue()); + } + + @Test + public void executeAsUpdate() throws Exception { createValidRequest().executeAsUpdate(api, mock(Acl.class), mock(Acl.class)); + + verify(api).aclInterfaceSetAclList(requestCaptor.capture()); + verifyValidRequest(requestCaptor.getValue()); + } + + @Test + public void executeAsDelete() throws Exception { + create(mappingContext) + .identifier(validIdentifier) + .standardAclContext(aclContext) + .interfaceContext(interfaceContext) + .executeAsDelete(api); + + verify(api).aclInterfaceSetAclList(requestCaptor.capture()); + final AclInterfaceSetAclList request = requestCaptor.getValue(); + assertNotNull(request); + assertEquals(0, request.count); + assertEquals(0, request.nInput); + assertTrue(Arrays.equals(new int[] {}, request.acls)); + } + + @Test + public void executeAsDeleteWithAclNames() throws Exception { createValidRequest().executeAsDelete(api); - verify(api, times(3)).aclInterfaceSetAclList(requestCaptor.capture()); - requestCaptor.getAllValues().forEach(AclInterfaceAssignmentRequestTest::verifyValidRequest); + verify(api).aclInterfaceSetAclList(requestCaptor.capture()); + final AclInterfaceSetAclList request = requestCaptor.getValue(); + assertNotNull(request); + assertEquals(0, request.count); + assertEquals(0, request.nInput); + assertTrue(Arrays.equals(new int[]{}, request.acls)); } private AclInterfaceAssignmentRequest createValidRequest() { diff --git a/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/write/InterfaceAclCustomizerTest.java b/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/write/InterfaceAclCustomizerTest.java index 465351c40..5dc139acc 100644 --- a/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/write/InterfaceAclCustomizerTest.java +++ b/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/write/InterfaceAclCustomizerTest.java @@ -17,6 +17,7 @@ package io.fd.hc2vpp.acl.write; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -27,6 +28,7 @@ import io.fd.hc2vpp.common.translate.util.NamingContext; import io.fd.vpp.jvpp.acl.dto.AclInterfaceSetAclList; import io.fd.vpp.jvpp.acl.dto.AclInterfaceSetAclListReply; import io.fd.vpp.jvpp.acl.future.FutureJVppAclFacade; +import java.util.Collections; import org.junit.Test; import org.mockito.Mock; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.Interfaces; @@ -35,6 +37,9 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces. 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._interface.acl.attributes.AclBuilder; +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.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.acl.rev161214.vpp.acls.base.attributes.VppAclsBuilder; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; public class InterfaceAclCustomizerTest extends WriterCustomizerTest implements AclTestSchemaContext { @@ -83,7 +88,15 @@ public class InterfaceAclCustomizerTest extends WriterCustomizerTest implements @Test public void testDelete() throws Exception { - final Acl acl = new AclBuilder().build(); + final VppAcls + element = mock(VppAcls.class); + final Acl acl = new AclBuilder() + .setIngress(new IngressBuilder() + .setVppAcls(Collections.singletonList(new VppAclsBuilder() + .setName("asd") + .build())) + .build()) + .build(); customizer.deleteCurrentAttributes(ACL_ID, acl, writeContext); final AclInterfaceSetAclList list = new AclInterfaceSetAclList(); list.swIfIndex = IFACE_ID; |