aboutsummaryrefslogtreecommitdiffstats
path: root/asdcApi/provider/src
diff options
context:
space:
mode:
authorTimoney, Dan (dt5972) <dtimoney@att.com>2019-09-05 11:31:41 -0400
committerTimoney, Dan (dt5972) <dtimoney@att.com>2019-09-05 13:44:01 -0400
commit3168c3f65abddac9ecf5321b93752d31a4edd9fa (patch)
tree9182122c26381c8af21e4c59458e88e25334b98b /asdcApi/provider/src
parent6a146258879e64344b5837dfa6dee566edba4dda (diff)
Add junit coverage
Add junit test for asdcApi Change-Id: Ic564aa18795dabd32e664569be802cff7d823516 Issue-ID: CCSDK-1694 Signed-off-by: Timoney, Dan (dt5972) <dtimoney@att.com> Add junit coverage Add junit test for asdcApi Change-Id: I21873f325177da0b03b7dd15c20bea962a641d4a Issue-ID: CCSDK-1694 Signed-off-by: Timoney, Dan (dt5972) <dtimoney@att.com>
Diffstat (limited to 'asdcApi/provider/src')
-rw-r--r--asdcApi/provider/src/test/java/org/onap/ccsdk/sli/northbound/asdcapi/TestAsdcApiApi.java34
1 files changed, 32 insertions, 2 deletions
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 6ad9a829..1f266365 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<RpcResult<VfLicenseModelUpdateOutput>> future = asdcApiProvider
.vfLicenseModelUpdate(inputBuilder.build());
RpcResult<VfLicenseModelUpdateOutput> rpcResult = null;
@@ -103,4 +124,13 @@ public class TestAsdcApiApi extends AbstractConcurrentDataBrokerTest {
fail("Error : " + e);
}
}
+
+
+
+
+ @Test
+ public void testAddArtifactVersion() {
+ asdcApiProvider.addArtifactVersion("artifact1",
+ "version1");
+ }
}