aboutsummaryrefslogtreecommitdiffstats
path: root/generic-resource-api/provider/src
diff options
context:
space:
mode:
authorDan Timoney <dtimoney@att.com>2019-08-09 20:01:40 +0000
committerGerrit Code Review <gerrit@onap.org>2019-08-09 20:01:40 +0000
commit1c38dbabc0dcc9787e9d8eb1bce8b206f8941ac2 (patch)
tree5b337f184281814eb207c850c2f9138e086ee6c6 /generic-resource-api/provider/src
parent87c44cd4cf59af338fb84714e662ea81a2ecb47f (diff)
parent7894d15ee8d0094ae36c838f1e961fa60f42843b (diff)
Merge "Added test case to increase SONAR coverage"
Diffstat (limited to 'generic-resource-api/provider/src')
-rw-r--r--generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/ServiceTopologyOperationRPCTest.java79
1 files changed, 79 insertions, 0 deletions
diff --git a/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/ServiceTopologyOperationRPCTest.java b/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/ServiceTopologyOperationRPCTest.java
index faacd220..bbd0afdf 100644
--- a/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/ServiceTopologyOperationRPCTest.java
+++ b/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/ServiceTopologyOperationRPCTest.java
@@ -164,6 +164,49 @@ public class ServiceTopologyOperationRPCTest extends GenericResourceApiProviderT
}
@Test
+ public void delete_fail_when_client_execution_failed() throws Exception {
+
+ //mock svcClient to perform a successful execution with the expected parameters
+ svcClient.mockHasGraph(true);
+ PropBuilder svcResultProp = svcClient.createExecuteOKResult();
+ svcClient.mockExecute(svcResultProp);
+
+ ServiceTopologyOperationInput input = deleteSTOI();
+
+ //execute the mdsal exec
+ ServiceTopologyOperationOutput output = exec(
+ genericResourceApiProvider::serviceTopologyOperation
+ , input
+ , RpcResult::getResult
+ );
+
+ assertEquals("200", output.getResponseCode());
+ assertEquals("OK", output.getResponseMessage());
+ assertEquals("Y", output.getAckFinalIndicator());
+ }
+
+ @Test
+ public void delete_service_fail_when_client_execution_failed() throws Exception {
+
+ //mock svcClient to perform a successful execution with the expected parameters
+ svcClient.mockHasGraph(true);
+ PropBuilder svcResultProp = svcClient.createExecuteOKResult();
+ svcClient.mockExecute(svcResultProp);
+
+ ServiceTopologyOperationInput input = deleteServiceSTOI();
+
+ //execute the mdsal exec
+ ServiceTopologyOperationOutput output = exec(
+ genericResourceApiProvider::serviceTopologyOperation
+ , input
+ , RpcResult::getResult
+ );
+
+ assertEquals("500", output.getResponseCode());
+ assertEquals("Y", output.getAckFinalIndicator());
+ }
+
+ @Test
public void should_fail_when_client_has_no_graph() throws Exception {
svcClient.mockHasGraph(false);
@@ -225,6 +268,42 @@ public class ServiceTopologyOperationRPCTest extends GenericResourceApiProviderT
);
}
+ private ServiceTopologyOperationInput deleteSTOI() {
+
+ return build(
+ serviceTopologyOperationInput()
+ .setSdncRequestHeader(build(sdncRequestHeader()
+ .setSvcRequestId("svc-request-id: xyz")
+ .setSvcAction(SvcAction.Unassign)
+ ))
+ .setRequestInformation(build(requestInformation()
+ .setRequestId("request-id: xyz")
+ .setRequestAction(RequestInformation.RequestAction.DeleteServiceInstance)
+ ))
+ .setServiceInformation(build(serviceInformationBuilder()
+ .setServiceInstanceId("service-instance-id: xyz")
+ ))
+ );
+ }
+
+ private ServiceTopologyOperationInput deleteServiceSTOI() {
+
+ return build(
+ serviceTopologyOperationInput()
+ .setSdncRequestHeader(build(sdncRequestHeader()
+ .setSvcRequestId("svc-request-id: xyz")
+ .setSvcAction(SvcAction.Delete)
+ ))
+ .setRequestInformation(build(requestInformation()
+ .setRequestId("request-id: xyz")
+ .setRequestAction(RequestInformation.RequestAction.DeleteServiceInstance)
+ ))
+ .setServiceInformation(build(serviceInformationBuilder()
+ .setServiceInstanceId("service-instance-id: xyz")
+ ))
+ );
+ }
+
private ServiceTopologyOperationOutput createExpectedSTOO(PropBuilder expectedSvcResultProp,
ServiceTopologyOperationInput expectedServiceTopologyOperationInput) {