From 3168c3f65abddac9ecf5321b93752d31a4edd9fa Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Thu, 5 Sep 2019 11:31:41 -0400 Subject: Add junit coverage Add junit test for asdcApi Change-Id: Ic564aa18795dabd32e664569be802cff7d823516 Issue-ID: CCSDK-1694 Signed-off-by: Timoney, Dan (dt5972) Add junit coverage Add junit test for asdcApi Change-Id: I21873f325177da0b03b7dd15c20bea962a641d4a Issue-ID: CCSDK-1694 Signed-off-by: Timoney, Dan (dt5972) --- .../sli/northbound/asdcapi/TestAsdcApiApi.java | 34 ++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) (limited to 'asdcApi') diff --git a/asdcApi/provider/src/test/java/org/onap/ccsdk/sli/northbound/asdcapi/TestAsdcApiApi.java b/asdcApi/provider/src/test/java/org/onap/ccsdk/sli/northbound/asdcapi/TestAsdcApiApi.java index 6ad9a829f..1f266365c 100644 --- a/asdcApi/provider/src/test/java/org/onap/ccsdk/sli/northbound/asdcapi/TestAsdcApiApi.java +++ b/asdcApi/provider/src/test/java/org/onap/ccsdk/sli/northbound/asdcapi/TestAsdcApiApi.java @@ -25,18 +25,23 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; import static org.junit.Assert.fail; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + import org.junit.Before; import org.junit.Test; import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; import org.opendaylight.controller.md.sal.binding.test.AbstractConcurrentDataBrokerTest; import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; +import org.opendaylight.yang.gen.v1.http.xmlns.onap.org.asdc.license.model._1._0.rev160427.vf.license.model.grouping.VfLicenseModelBuilder; import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev170201.VfLicenseModelUpdateInputBuilder; import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev170201.VfLicenseModelUpdateOutput; import org.opendaylight.yangtools.yang.common.RpcResult; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.Properties; + public class TestAsdcApiApi extends AbstractConcurrentDataBrokerTest { private AsdcApiProvider asdcApiProvider; @@ -49,6 +54,13 @@ public class TestAsdcApiApi extends AbstractConcurrentDataBrokerTest { NotificationPublishService mockNotification = mock(NotificationPublishService.class); RpcProviderRegistry mockRpcRegistry = mock(RpcProviderRegistry.class); AsdcApiSliClient mockSliClient = mock(AsdcApiSliClient.class); + Properties respProps = new Properties(); + respProps.setProperty("error-code", "200"); + respProps.setProperty("error-message", "Success"); + + when(mockSliClient.hasGraph("ASDC-API", "vf-license-model-update" , null, "sync")).thenReturn(true); + when(mockSliClient.execute("ASDC-API", "vf-license-model-update", null, "sync", respProps)).thenReturn(respProps); + asdcApiProvider = new AsdcApiProvider(dataBroker, mockNotification, mockRpcRegistry, mockSliClient); } } @@ -72,7 +84,7 @@ public class TestAsdcApiApi extends AbstractConcurrentDataBrokerTest { fail("Error : " + e); } LOG.info("result: {}", rpcResult); - assertEquals("503", rpcResult.getResult().getAsdcApiResponseCode()); + assertEquals("200", rpcResult.getResult().getAsdcApiResponseCode()); } //Input parameter validation @@ -89,11 +101,20 @@ public class TestAsdcApiApi extends AbstractConcurrentDataBrokerTest { assertNull(future); } - @Test(expected = IllegalArgumentException.class) + @Test public void testVfLicenseModelUpdateValidation1() { VfLicenseModelUpdateInputBuilder inputBuilder = new VfLicenseModelUpdateInputBuilder(); + inputBuilder.setArtifactName("license1"); + inputBuilder.setArtifactVersion("version1"); + + VfLicenseModelBuilder vfLicenseModelBuilder = new VfLicenseModelBuilder(); + vfLicenseModelBuilder.setVfId("123"); + vfLicenseModelBuilder.setVendorName("acme"); + inputBuilder.setVfLicenseModel(vfLicenseModelBuilder.build()); + + java.util.concurrent.Future> future = asdcApiProvider .vfLicenseModelUpdate(inputBuilder.build()); RpcResult rpcResult = null; @@ -103,4 +124,13 @@ public class TestAsdcApiApi extends AbstractConcurrentDataBrokerTest { fail("Error : " + e); } } + + + + + @Test + public void testAddArtifactVersion() { + asdcApiProvider.addArtifactVersion("artifact1", + "version1"); + } } -- cgit 1.2.3-korg