Added test case to increase SONAR coverage 00/92900/6
authorprakash.e <prakash.e@huawei.com>
Wed, 7 Aug 2019 13:03:30 +0000 (18:33 +0530)
committerDan Timoney <dtimoney@att.com>
Fri, 9 Aug 2019 18:29:57 +0000 (18:29 +0000)
Added new case for delete flow in ServiceTopologyOperationRPCTest
Change-Id: Ic793c6ae1d67420f84445704952e8034c1df715b
Issue-ID: SDNC-840
Signed-off-by: Prakash.E <prakash.e@huawei.com>
generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/ServiceTopologyOperationRPCTest.java

index faacd22..bbd0afd 100644 (file)
@@ -163,6 +163,49 @@ public class ServiceTopologyOperationRPCTest extends GenericResourceApiProviderT
         assertEquals("Y", output.getAckFinalIndicator());
     }
 
         assertEquals("Y", output.getAckFinalIndicator());
     }
 
+    @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);
     @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) {
 
     private ServiceTopologyOperationOutput createExpectedSTOO(PropBuilder expectedSvcResultProp,
         ServiceTopologyOperationInput expectedServiceTopologyOperationInput) {