From 163008c4770de406175e1ebe9f049beee7ba7cd2 Mon Sep 17 00:00:00 2001 From: "prakash.e" Date: Fri, 9 Aug 2019 18:36:52 +0530 Subject: Test case added for code coverage Added new test case for GenericConfigurationTopologyOperation Change-Id: Ie660b70e109725618d2470c0af30d0f326c125b2 Issue-ID: SDNC-840 Signed-off-by: Prakash.E --- ...nericConfigurationTopologyOperationRPCTest.java | 53 ++++++++++++++++++++++ .../org/onap/sdnc/northbound/util/MDSALUtil.java | 8 ++++ 2 files changed, 61 insertions(+) create mode 100644 generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/GenericConfigurationTopologyOperationRPCTest.java (limited to 'generic-resource-api/provider/src') diff --git a/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/GenericConfigurationTopologyOperationRPCTest.java b/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/GenericConfigurationTopologyOperationRPCTest.java new file mode 100644 index 00000000..3962484a --- /dev/null +++ b/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/GenericConfigurationTopologyOperationRPCTest.java @@ -0,0 +1,53 @@ +package org.onap.sdnc.northbound; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mockito; +import org.mockito.runners.MockitoJUnitRunner; +import org.onap.sdnc.northbound.util.PropBuilder; +import org.opendaylight.controller.md.sal.binding.api.DataBroker; +import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; +import org.opendaylight.controller.md.sal.common.api.data.TransactionChainClosedException; +import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.GenericConfigurationTopologyOperationInput; +import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.GenericConfigurationTopologyOperationOutput; +import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.request.information.RequestInformation; +import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.sdnc.request.header.SdncRequestHeader.SvcAction; +import org.opendaylight.yangtools.yang.common.RpcResult; + +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; +import static org.onap.sdnc.northbound.GenericResourceApiProvider.APP_NAME; +import static org.onap.sdnc.northbound.GenericResourceApiProvider.NO_SERVICE_LOGIC_ACTIVE; +import static org.onap.sdnc.northbound.util.MDSALUtil.*; + +@RunWith(MockitoJUnitRunner.class) +public class GenericConfigurationTopologyOperationRPCTest extends GenericResourceApiProviderTest { + + private static final String SVC_OPERATION = "generic-configuration-topology-operation"; + + @Before + public void setUp() throws Exception { + super.setUp(); + svcClient.setScvOperation(SVC_OPERATION); + } + + @Test + public void should_fail_when_invalid_vnf_topology() throws Exception { + + GenericConfigurationTopologyOperationInput input = build(GenericConfigurationTopologyOperationInput()); + + GenericConfigurationTopologyOperationOutput output = + exec(genericResourceApiProvider::genericConfigurationTopologyOperation, input, RpcResult::getResult); + + assertEquals("404", output.getResponseCode()); + assertEquals("invalid input, null or empty service-instance-id", output.getResponseMessage()); + assertEquals("Y", output.getAckFinalIndicator()); + } + + + +} + + diff --git a/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/util/MDSALUtil.java b/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/util/MDSALUtil.java index d959b9f2..a6300d6a 100644 --- a/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/util/MDSALUtil.java +++ b/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/util/MDSALUtil.java @@ -36,6 +36,10 @@ import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.re import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PreloadNetworkTopologyOperationOutputBuilder; import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PreloadVfModuleTopologyOperationInputBuilder; import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PreloadVfModuleTopologyOperationOutputBuilder; + +import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.GenericConfigurationTopologyOperationInputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.GenericConfigurationTopologyOperationOutputBuilder; + import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.SecurityZoneTopologyOperationInputBuilder; import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.SecurityZoneTopologyOperationOutputBuilder; import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.ServiceTopologyOperationInputBuilder; @@ -111,6 +115,10 @@ public class MDSALUtil { return new PreloadVfModuleTopologyOperationInputBuilder(); } + public static GenericConfigurationTopologyOperationInputBuilder GenericConfigurationTopologyOperationInput() { + return new GenericConfigurationTopologyOperationInputBuilder(); + } + public static PreloadVfModuleTopologyOperationOutputBuilder preloadVfModuleTopologyOperationOutput() { return new PreloadVfModuleTopologyOperationOutputBuilder(); } -- cgit 1.2.3-korg