diff options
author | Joss Armstrong <joss.armstrong@ericsson.com> | 2019-02-04 17:20:41 +0000 |
---|---|---|
committer | Patrick Brady <patrick.brady@att.com> | 2019-02-05 21:11:04 +0000 |
commit | 472b9a54b62f7ca1ddfd66a18e5d171417bf3be6 (patch) | |
tree | bd1cbe40f10d24b85810d051c9e6ee71d902e8c7 /appc-sequence-generator/appc-sequence-generator-bundle/src/test/java | |
parent | 6d90b168b366e90a0b13d1589830b2c3c83164bd (diff) |
Add coverage for seqgen-provider
Added coverage for untested package
Issue-ID: APPC-1386
Change-Id: I6b6d74c54982dd327176a2e1e5f3c873be9dbb89
Signed-off-by: Joss Armstrong <joss.armstrong@ericsson.com>
Diffstat (limited to 'appc-sequence-generator/appc-sequence-generator-bundle/src/test/java')
-rw-r--r-- | appc-sequence-generator/appc-sequence-generator-bundle/src/test/java/org/onap/appc/seqgen/provider/SequenceGeneratorProviderTest.java | 119 |
1 files changed, 119 insertions, 0 deletions
diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/test/java/org/onap/appc/seqgen/provider/SequenceGeneratorProviderTest.java b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/java/org/onap/appc/seqgen/provider/SequenceGeneratorProviderTest.java new file mode 100644 index 000000000..7f54718f0 --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/java/org/onap/appc/seqgen/provider/SequenceGeneratorProviderTest.java @@ -0,0 +1,119 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2019 Ericsson + * ================================================================================ + * 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. + * + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.seqgen.provider; + +import static org.junit.Assert.assertTrue; +import java.util.ArrayList; +import java.util.List; +import org.junit.Test; +import org.mockito.Mockito; +import org.opendaylight.controller.md.sal.binding.api.DataBroker; +import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; +import org.opendaylight.controller.sal.binding.api.NotificationProviderService; +import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; +import org.opendaylight.yang.gen.v1.org.onap.appc.sequencegenerator.rev170706.GenerateSequenceInput; +import org.opendaylight.yang.gen.v1.org.onap.appc.sequencegenerator.rev170706.GenerateSequenceInputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.appc.sequencegenerator.rev170706.SequenceGeneratorService; +import org.opendaylight.yang.gen.v1.org.onap.appc.sequencegenerator.rev170706.dependency.info.DependencyInfo; +import org.opendaylight.yang.gen.v1.org.onap.appc.sequencegenerator.rev170706.dependency.info.DependencyInfoBuilder; +import org.opendaylight.yang.gen.v1.org.onap.appc.sequencegenerator.rev170706.dependency.info.dependency.info.Vnfcs; +import org.opendaylight.yang.gen.v1.org.onap.appc.sequencegenerator.rev170706.dependency.info.dependency.info.VnfcsBuilder; +import org.opendaylight.yang.gen.v1.org.onap.appc.sequencegenerator.rev170706.inventory.info.InventoryInfo; +import org.opendaylight.yang.gen.v1.org.onap.appc.sequencegenerator.rev170706.inventory.info.InventoryInfoBuilder; +import org.opendaylight.yang.gen.v1.org.onap.appc.sequencegenerator.rev170706.inventory.info.inventory.info.VnfInfo; +import org.opendaylight.yang.gen.v1.org.onap.appc.sequencegenerator.rev170706.inventory.info.inventory.info.VnfInfoBuilder; +import org.opendaylight.yang.gen.v1.org.onap.appc.sequencegenerator.rev170706.inventory.info.inventory.info.vnf.info.Vm; +import org.opendaylight.yang.gen.v1.org.onap.appc.sequencegenerator.rev170706.inventory.info.inventory.info.vnf.info.VmBuilder; +import org.opendaylight.yang.gen.v1.org.onap.appc.sequencegenerator.rev170706.inventory.info.inventory.info.vnf.info.vm.Vnfc; +import org.opendaylight.yang.gen.v1.org.onap.appc.sequencegenerator.rev170706.inventory.info.inventory.info.vnf.info.vm.VnfcBuilder; +import org.opendaylight.yang.gen.v1.org.onap.appc.sequencegenerator.rev170706.request.info.RequestInfo; +import org.opendaylight.yang.gen.v1.org.onap.appc.sequencegenerator.rev170706.request.info.RequestInfo.Action; +import org.opendaylight.yang.gen.v1.org.onap.appc.sequencegenerator.rev170706.request.info.RequestInfo.ActionLevel; +import org.opendaylight.yang.gen.v1.org.onap.appc.sequencegenerator.rev170706.request.info.RequestInfoBuilder; +import org.opendaylight.yangtools.yang.common.RpcResult; + + +public class SequenceGeneratorProviderTest { + + private DataBroker dataBroker = Mockito.mock(DataBroker.class); + private RpcProviderRegistry rpcRegistry = Mockito.mock(RpcProviderRegistry.class); + private NotificationProviderService notificationService = Mockito.mock(NotificationProviderService.class); + + @Test + public void testClose() throws Exception { + BindingAwareBroker.RpcRegistration<SequenceGeneratorService> registration = + (BindingAwareBroker.RpcRegistration<SequenceGeneratorService>) Mockito.mock(BindingAwareBroker.RpcRegistration.class); + Mockito.doReturn(registration).when(rpcRegistry).addRpcImplementation(Mockito.any(), Mockito.any()); + SequenceGeneratorProvider provider = new SequenceGeneratorProvider(dataBroker, notificationService, rpcRegistry); + provider.close(); + Mockito.verify(provider.rpcRegistration).close(); + } + + @Test + public void testGenerateSequence() throws Exception { + BindingAwareBroker.RpcRegistration<SequenceGeneratorService> registration = + (BindingAwareBroker.RpcRegistration<SequenceGeneratorService>) Mockito.mock(BindingAwareBroker.RpcRegistration.class); + Mockito.doReturn(registration).when(rpcRegistry).addRpcImplementation(Mockito.any(), Mockito.any()); + SequenceGeneratorProvider provider = new SequenceGeneratorProvider(dataBroker, notificationService, rpcRegistry); + GenerateSequenceInputBuilder builder = new GenerateSequenceInputBuilder(); + RequestInfoBuilder riBuilder = new RequestInfoBuilder(); + riBuilder.setAction(Action.Start); + riBuilder.setActionLevel(ActionLevel.Vm); + riBuilder.setPayload("PAYLOAD"); + RequestInfo info = riBuilder.build(); + builder.setRequestInfo(info); + InventoryInfoBuilder iiBuilder = new InventoryInfoBuilder(); + VnfInfoBuilder viBuilder = new VnfInfoBuilder(); + viBuilder.setVnfId("VNF_ID"); + List<Vm> vmList = new ArrayList<Vm>(); + VmBuilder vmBuilder = new VmBuilder(); + vmBuilder.setVmId("VM_ID"); + vmBuilder.setVserverId("VSERVER_ID"); + VnfcBuilder vnfcBuilder = new VnfcBuilder(); + vnfcBuilder.setVnfcName("VNFC_NAME"); + vnfcBuilder.setVnfcType("VNFC_TYPE"); + Vnfc vnfc = vnfcBuilder.build(); + vmBuilder.setVnfc(vnfc); + Vm vm = vmBuilder.build(); + vmList.add(vm); + viBuilder.setVm(vmList); + VnfInfo vnfInfo = viBuilder.build(); + iiBuilder.setVnfInfo(vnfInfo); + InventoryInfo iInfo = iiBuilder.build(); + builder.setInventoryInfo(iInfo); + DependencyInfoBuilder dependencyBuilder = new DependencyInfoBuilder(); + List<Vnfcs> vnfcsList = new ArrayList<>(); + VnfcsBuilder vnfcsBuilder = new VnfcsBuilder(); + vnfcsBuilder.setVnfcType("VNFC_TYPE"); + List<String> parentList = new ArrayList<>(); + parentList.add("VNFC_TYPE"); + vnfcsBuilder.setParents(parentList); + Vnfcs vnfcs = vnfcsBuilder.build(); + vnfcsList.add(vnfcs); + dependencyBuilder.setVnfcs(vnfcsList); + DependencyInfo dependencyInfo = dependencyBuilder.build(); + builder.setDependencyInfo(dependencyInfo); + GenerateSequenceInput input = builder.build(); + assertTrue(provider.generateSequence(input).get() instanceof RpcResult); + } + +} |