update MSO configuration URL
[vid.git] / vid-app-common / src / test / java / org / onap / vid / mso / MsoBusinessLogicImplTest.java
index 207e635..558dc26 100644 (file)
 
 package org.onap.vid.mso;
 
+import static net.javacrumbs.jsonunit.JsonMatchers.jsonEquals;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
+import static org.assertj.core.api.Assertions.tuple;
+import static org.hamcrest.Matchers.allOf;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.hasEntry;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.startsWith;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyBoolean;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.argThat;
+import static org.mockito.ArgumentMatchers.endsWith;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.ArgumentMatchers.isA;
+import static org.mockito.BDDMockito.given;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import static org.onap.vid.controller.MsoController.CONFIGURATION_ID;
+import static org.onap.vid.controller.MsoController.REQUEST_TYPE;
+import static org.onap.vid.controller.MsoController.SVC_INSTANCE_ID;
+import static org.onap.vid.controller.MsoController.VNF_INSTANCE_ID;
+import static org.onap.vid.model.probes.ExternalComponentStatus.Component.MSO;
+import static org.onap.vid.mso.MsoBusinessLogicImpl.validateEndpointPath;
+
 import com.fasterxml.jackson.core.type.TypeReference;
 import com.fasterxml.jackson.databind.ObjectMapper;
-import com.google.common.collect.Lists;
-import com.google.gson.Gson;
 import io.joshworks.restclient.http.HttpResponse;
+import java.io.IOException;
+import java.net.URL;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import java.util.stream.Collectors;
+import javax.ws.rs.BadRequestException;
 import org.apache.commons.io.IOUtils;
+import org.apache.http.HttpException;
+import org.hamcrest.Matcher;
+import org.hamcrest.MatcherAssert;
 import org.jetbrains.annotations.NotNull;
-import org.mockito.hamcrest.MockitoHamcrest;
-import org.onap.vid.changeManagement.WorkflowRequestDetail;
-import org.onap.vid.model.SOWorkflowList;
-import org.onap.vid.model.probes.ExternalComponentStatus;
-import org.onap.vid.mso.rest.RequestList;
-import org.onap.vid.mso.rest.RequestWrapper;
-import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
 import org.mockito.ArgumentMatcher;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
+import org.mockito.hamcrest.MockitoHamcrest;
 import org.onap.portalsdk.core.util.SystemProperties;
+import org.onap.vid.aai.ExceptionWithRequestInfo;
+import org.onap.vid.aai.HttpResponseWithRequestInfo;
 import org.onap.vid.changeManagement.ChangeManagementRequest;
+import org.onap.vid.changeManagement.WorkflowRequestDetail;
 import org.onap.vid.controller.OperationalEnvironmentController;
 import org.onap.vid.exceptions.GenericUncheckedException;
-import org.onap.vid.model.RequestReferencesContainer;
+import org.onap.vid.model.SOWorkflowList;
 import org.onap.vid.model.SoftDeleteRequest;
+import org.onap.vid.model.probes.ErrorMetadata;
+import org.onap.vid.model.probes.ExternalComponentStatus;
+import org.onap.vid.model.probes.HttpRequestMetadata;
 import org.onap.vid.mso.model.CloudConfiguration;
 import org.onap.vid.mso.model.ModelInfo;
 import org.onap.vid.mso.model.OperationalEnvironmentActivateInfo;
 import org.onap.vid.mso.model.OperationalEnvironmentDeactivateInfo;
-import org.onap.vid.mso.model.RequestInfo;
 import org.onap.vid.mso.model.RequestParameters;
-import org.onap.vid.mso.model.RequestReferences;
 import org.onap.vid.mso.rest.OperationalEnvironment.OperationEnvironmentRequestDetails;
 import org.onap.vid.mso.rest.Request;
 import org.onap.vid.mso.rest.RequestDetails;
 import org.onap.vid.mso.rest.RequestDetailsWrapper;
 import org.onap.vid.mso.rest.Task;
-import org.onap.vid.properties.Features;
+import org.onap.vid.testUtils.TestUtils;
+import org.springframework.http.HttpMethod;
 import org.springframework.http.HttpStatus;
 import org.springframework.test.context.ContextConfiguration;
-import org.togglz.core.manager.FeatureManager;
-
-import javax.ws.rs.BadRequestException;
-import java.io.IOException;
-import java.net.URL;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-import java.util.stream.Collectors;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.tuple;
-import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
-import static org.hamcrest.Matchers.allOf;
-import static org.hamcrest.Matchers.hasEntry;
-import static org.junit.Assert.assertEquals;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyBoolean;
-import static org.mockito.ArgumentMatchers.anyString;
-import static org.mockito.ArgumentMatchers.argThat;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.ArgumentMatchers.isA;
-import static org.mockito.ArgumentMatchers.endsWith;
-import static org.mockito.BDDMockito.given;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.doThrow;
-import static org.mockito.Mockito.mock;
-import static org.onap.vid.controller.MsoController.CONFIGURATION_ID;
-import static org.onap.vid.controller.MsoController.REQUEST_TYPE;
-import static org.onap.vid.controller.MsoController.SVC_INSTANCE_ID;
-import static org.onap.vid.controller.MsoController.VNF_INSTANCE_ID;
-import static org.onap.vid.mso.MsoBusinessLogicImpl.validateEndpointPath;
+import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
 
 @ContextConfiguration(classes = {SystemProperties.class})
 public class MsoBusinessLogicImplTest extends AbstractTestNGSpringContextTests {
 
     private static final ObjectMapper objectMapper = new ObjectMapper();
-
-    @Mock
-    private FeatureManager featureManager;
+    private static final String MY_PRETTY_URL = "my pretty url";
 
     @Mock
     private MsoInterface msoInterface;
@@ -126,14 +131,14 @@ public class MsoBusinessLogicImplTest extends AbstractTestNGSpringContextTests {
     @BeforeClass
     public void setUp() {
         MockitoAnnotations.initMocks(this);
-        msoBusinessLogic = new MsoBusinessLogicImpl(msoInterface, featureManager);
+        msoBusinessLogic = new MsoBusinessLogicImpl(msoInterface);
     }
 
     @Test
     public void shouldProperlyCreateConfigurationInstanceWithCorrectServiceInstanceId() throws Exception {
         // given
         String serviceInstanceId = "3f93c7cb-2fd0-4557-9514-e189b7b04f9d";
-        String endpointTemplate = String.format("/serviceInstances/v6/%s/configurations", serviceInstanceId);
+        String endpointTemplate = String.format("/serviceInstantiation/v7/serviceInstances/%s/configurations", serviceInstanceId);
         RequestDetailsWrapper requestDetailsWrapper = createRequestDetails();
         MsoResponseWrapper expectedResponse = createOkResponse();
         given(msoInterface.createConfigurationInstance(requestDetailsWrapper, endpointTemplate))
@@ -179,7 +184,7 @@ public class MsoBusinessLogicImplTest extends AbstractTestNGSpringContextTests {
     public void shouldProperlyCreateSvcInstanceWithProperParameters() {
 
         MsoResponseWrapper expectedResponse = createOkResponse();
-        String svcEndpoint = SystemProperties.getProperty(MsoProperties.MSO_REST_API_SVC_INSTANCE);
+        String svcEndpoint = SystemProperties.getProperty(MsoProperties.MSO_RESTAPI_SERVICE_INSTANCE);
         given(msoInterface.createSvcInstance(msoRequest, svcEndpoint)).willReturn(expectedResponse);
 
         MsoResponseWrapper response = msoBusinessLogic.createSvcInstance(msoRequest);
@@ -282,39 +287,48 @@ public class MsoBusinessLogicImplTest extends AbstractTestNGSpringContextTests {
         assertThat(response).isEqualToComparingFieldByField(expectedResponse);
     }
 
-    @Test
-    public void shouldProperlyDeleteSvcInstanceWithProperParametersAndFalseFeatureFlag() {
+    @DataProvider
+    public Object[][] deleteSvcInstanceShouldDelete() {
+        return new Object[][]{{"Active"}, {"unexpected-status"}};
+    }
+
+    @DataProvider
+    public Object[][] deleteSvcInstanceShouldUnassign() {
+        return new Object[][]{{"Created"}, {"Pendingdelete"}, {"pending-Delete"}, {"Assigned"}};
+    }
+
+
+    @Test(dataProvider = "deleteSvcInstanceShouldDelete")
+    public void shouldProperlyDeleteSvcInstanceWithProperParametersShouldDelete(String status) {
         // given
-        String endpointTemplate = "/serviceInstances/v5/%s";
+        String endpointTemplate = "/serviceInstantiation/v7/serviceInstances/%s";
         String serviceInstanceId = "3f93c7cb-2fd0-4557-9514-e189b7b04f9d";
         String svcEndpoint = String.format(endpointTemplate, serviceInstanceId);
         RequestDetails requestDetails = new RequestDetails();
         MsoResponseWrapper expectedResponse = createOkResponse();
         given(msoInterface.deleteSvcInstance(requestDetails, svcEndpoint)).willReturn(expectedResponse);
-        given(featureManager.isActive(Features.FLAG_UNASSIGN_SERVICE)).willReturn(false);
 
         // when
         MsoResponseWrapper msoResponseWrapper = msoBusinessLogic
-                .deleteSvcInstance(requestDetails, serviceInstanceId, "unAssignOrDeleteParams");
+                .deleteSvcInstance(requestDetails, serviceInstanceId, status);
 
         // then
         assertThat(msoResponseWrapper).isEqualToComparingFieldByField(expectedResponse);
     }
 
-    @Test
-    public void shouldProperlyDeleteSvcInstanceWithProperParametersAndTrueFeatureFlag() {
+    @Test(dataProvider = "deleteSvcInstanceShouldUnassign")
+    public void shouldProperlyDeleteSvcInstanceWithProperParametersShouldUnassign(String status) {
         // given
-        String endpointTemplate = "/serviceInstantiation/v5/serviceInstances/%s/unassign";
+        String endpointTemplate = "/serviceInstantiation/v7/serviceInstances/%s/unassign";
         String serviceInstanceId = "3f93c7cb-2fd0-4557-9514-e189b7b04f9d";
         String svcEndpoint = String.format(endpointTemplate, serviceInstanceId);
         RequestDetails requestDetails = new RequestDetails();
         MsoResponseWrapper expectedResponse = createOkResponse();
         given(msoInterface.unassignSvcInstance(requestDetails, svcEndpoint)).willReturn(expectedResponse);
-        given(featureManager.isActive(Features.FLAG_UNASSIGN_SERVICE)).willReturn(true);
 
         // when
         MsoResponseWrapper msoResponseWrapper = msoBusinessLogic
-                .deleteSvcInstance(requestDetails, serviceInstanceId, "assigned");
+                .deleteSvcInstance(requestDetails, serviceInstanceId, status);
 
         // then
         assertThat(msoResponseWrapper).isEqualToComparingFieldByField(expectedResponse);
@@ -323,7 +337,7 @@ public class MsoBusinessLogicImplTest extends AbstractTestNGSpringContextTests {
     @Test
     public void shouldProperlyDeleteVnfWithProperParameters() {
         // when
-        String endpointTemplate = "/serviceInstances/v5/%s/vnfs/%s";
+        String endpointTemplate = "/serviceInstantiation/v7/serviceInstances/%s/vnfs/%s";
         String serviceInstanceId = "3f93c7cb-2fd0-4557-9514-e189b7b04f9d";
         String vnfInstanceId = "testVnfInstanceTempId";
         String vnfEndpoint = String.format(endpointTemplate, serviceInstanceId, vnfInstanceId);
@@ -342,7 +356,7 @@ public class MsoBusinessLogicImplTest extends AbstractTestNGSpringContextTests {
     @Test
     public void shouldProperlyDeleteVfModuleWithProperParameters() {
         // when
-        String endpointTemplate = "/serviceInstances/v7/%s/vnfs/%s/vfModules/%s";
+        String endpointTemplate = "/serviceInstantiation/v7/serviceInstances/%s/vnfs/%s/vfModules/%s";
         String serviceInstanceId = "3f93c7cb-2fd0-4557-9514-e189b7b04f9d";
         String vnfInstanceId = "testVnfInstanceTempId";
         String vfModuleId = "testVfModuleId";
@@ -495,12 +509,8 @@ public class MsoBusinessLogicImplTest extends AbstractTestNGSpringContextTests {
         String vnfModelTypeOrchestrationRequests = getFileContentAsString("mso_model_info_sample_response.json");
         String scaleOutActionOrchestrationRequests = getFileContentAsString("mso_action_scaleout_sample_response.json");
 
-        MsoResponseWrapper msoResponseWrapperMock = mock(MsoResponseWrapper.class);
-        given(msoInterface
-                .getOrchestrationRequest(any(String.class), any(String.class), any(String.class),
-                        any(RestObject.class), anyBoolean()))
-                .willReturn(msoResponseWrapperMock);
-        given(msoResponseWrapperMock.getEntity())
+        HttpResponse<String> httpResponse = mockForGetOrchestrationRequest();
+        given(httpResponse.getBody())
                 .willReturn(vnfModelTypeOrchestrationRequests, scaleOutActionOrchestrationRequests);
 
         //when
@@ -522,13 +532,7 @@ public class MsoBusinessLogicImplTest extends AbstractTestNGSpringContextTests {
         //given
         String vnfModelTypeOrchestrationRequests = getFileContentAsString("mso_model_info_sample_wrong_response.json");
 
-        MsoResponseWrapper msoResponseWrapperMock = mock(MsoResponseWrapper.class);
-        given(msoInterface
-                .getOrchestrationRequest(any(String.class), any(String.class), any(String.class),
-                        any(RestObject.class), anyBoolean()))
-                .willReturn(msoResponseWrapperMock);
-        given(msoResponseWrapperMock.getEntity())
-                .willReturn(vnfModelTypeOrchestrationRequests);
+        mockForGetOrchestrationRequest(200, vnfModelTypeOrchestrationRequests);
 
         //when
         msoBusinessLogic.getOrchestrationRequestsForDashboard();
@@ -829,7 +833,7 @@ public class MsoBusinessLogicImplTest extends AbstractTestNGSpringContextTests {
     public void shouldProperlyGetActivateFabricConfigurationPathWithProperParameters() {
         // given
         String serviceInstanceId = "testServiceId";
-        String path = validateEndpointPath(MsoProperties.MSO_REST_API_SERVICE_INSTANCE_CREATE);
+        String path = validateEndpointPath(MsoProperties.MSO_RESTAPI_SERVICE_INSTANCE);
         path += "/" + serviceInstanceId + "/activateFabricConfiguration";
 
         // when
@@ -841,56 +845,22 @@ public class MsoBusinessLogicImplTest extends AbstractTestNGSpringContextTests {
 
     @Test
     public void shouldProperlyGetDeactivateAndCloudDeletePathWithProperParameters() {
-        // given
-        String serviceInstanceId = "testServiceId";
-        String vnfInstanceId = "testVnfInstanceId";
-        String vfModuleInstanceId = "testVfModuleInstanceId";
-        String path = validateEndpointPath(MsoProperties.MSO_REST_API_VF_MODULE_INSTANCE);
-        path = path.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId);
-        path = path.replaceFirst(VNF_INSTANCE_ID, vnfInstanceId);
-        path += "/" + vfModuleInstanceId + "/deactivateAndCloudDelete";
 
         // when
-        String response = msoBusinessLogic.getDeactivateAndCloudDeletePath(serviceInstanceId, vnfInstanceId, vfModuleInstanceId);
+        String response = msoBusinessLogic.getDeactivateAndCloudDeletePath("testServiceId", "testVnfInstanceId", "testVfModuleInstanceId");
 
         // then
-        assertThat(response).isEqualTo(path);
+        String expectedPath = "/serviceInstantiation/v7/serviceInstances/testServiceId/vnfs/testVnfInstanceId/"+
+            "vfModules/testVfModuleInstanceId/deactivateAndCloudDelete";
+        assertThat(response).isEqualTo(expectedPath);
     }
 
     @Test
-    public void shouldProperlyBuildRequestDetailsForSoftDeleteWithProperParameters() {
-        //  given
-        SoftDeleteRequest softDeleteRequest = new SoftDeleteRequest();
-        RequestDetails requestDetails = new RequestDetails();
-
-        String userId = "testUserID";
-        String tenantId = "testTenantId ";
-        String cloudRegionId = "testCloudId";
-
-
-        RequestInfo requestInfo = new RequestInfo();
-        requestInfo.setSource("VID");
-        requestInfo.setRequestorId(userId);
-        requestDetails.setRequestInfo(requestInfo);
-
-        CloudConfiguration cloudConfiguration = new CloudConfiguration();
-        cloudConfiguration.setTenantId(tenantId);
-        cloudConfiguration.setLcpCloudRegionId(cloudRegionId);
-        requestDetails.setCloudConfiguration(cloudConfiguration);
-
-        setModelInfoForRequestDetails(requestDetails);
-
-        setRequestParametersForRequestDetails(requestDetails);
-
-        softDeleteRequest.setLcpCloudRegionId(cloudRegionId);
-        softDeleteRequest.setTenantId(tenantId);
-        softDeleteRequest.setUserId(userId);
-
-        //  when
-        RequestDetails response = msoBusinessLogic.buildRequestDetailsForSoftDelete(softDeleteRequest);
-
-        //  then
-        assertThat(response).isEqualTo(requestDetails);
+    public void shouldProperlyBuildRequestDetailsForSoftDeleteWithProperParameters() throws IOException {
+        SoftDeleteRequest request = new SoftDeleteRequest("testTenantId", "testCloudId", "testUserID");
+        String expected = IOUtils.toString(this.getClass().getResource("/payload_jsons/vfModuleDeactivateAndCloudDelete.json"), "UTF-8");
+        final RequestDetails result = msoBusinessLogic.buildRequestDetailsForSoftDelete(request);
+        MatcherAssert.assertThat(result, jsonEquals(expected));
     }
 
     private void setRequestParametersForRequestDetails(RequestDetails requestDetails) {
@@ -905,58 +875,6 @@ public class MsoBusinessLogicImplTest extends AbstractTestNGSpringContextTests {
         requestDetails.setModelInfo(modelInfo);
     }
 
-    @Test
-    public void shouldProperlyDeactivateAndCloudDeleteWithProperParameters() {
-        //  given
-        String serviceInstanceId = "testServiceId";
-        String vnfInstanceId = "testVnfInstanceId";
-        String vfModuleInstanceId = "testVfModuleInstanceId";
-        RequestDetails requestDetails = new RequestDetails();
-
-        String path = msoBusinessLogic.getDeactivateAndCloudDeletePath(serviceInstanceId, vnfInstanceId, vfModuleInstanceId);
-
-        RequestReferences requestReferences = new RequestReferences();
-        requestReferences.setInstanceId("testInstance");
-        requestReferences.setRequestId("testRequest");
-
-        HttpResponse<RequestReferencesContainer> expectedResponse = HttpResponse.fallback(new RequestReferencesContainer(requestReferences));
-
-        MsoResponseWrapper2 responseWrapped = new MsoResponseWrapper2<>(expectedResponse);
-
-        given(msoInterface.post(eq(path), any(RequestDetails.class), eq(RequestReferencesContainer.class))).willReturn(expectedResponse);
-
-        //  when
-        MsoResponseWrapper2 response = msoBusinessLogic.deactivateAndCloudDelete(serviceInstanceId, vnfInstanceId, vfModuleInstanceId, requestDetails);
-
-        //  then
-        assertThat(response).isEqualToComparingFieldByField(responseWrapped);
-    }
-
-    @Test
-    public void shouldProperlyActivateFabricConfigurationWithProperParameters() {
-        //  given
-        String serviceInstanceId = "testServiceId";
-        RequestDetails requestDetails = new RequestDetails();
-
-        String path = msoBusinessLogic.getActivateFabricConfigurationPath(serviceInstanceId);
-
-        RequestReferences requestReferences = new RequestReferences();
-        requestReferences.setInstanceId("testInstance");
-        requestReferences.setRequestId("testRequest");
-
-        HttpResponse<RequestReferencesContainer> expectedResponse = HttpResponse.fallback(new RequestReferencesContainer(requestReferences));
-
-        MsoResponseWrapper2 responseWrapped = new MsoResponseWrapper2<>(expectedResponse);
-
-        given(msoInterface.post(eq(path), any(RequestDetails.class), eq(RequestReferencesContainer.class))).willReturn(expectedResponse);
-
-        //  when
-        MsoResponseWrapper2 response = msoBusinessLogic.activateFabricConfiguration(serviceInstanceId, requestDetails);
-
-        //  then
-        assertThat(response).isEqualToComparingFieldByField(responseWrapped);
-    }
-
     @Test
     public void shouldProperlyUpdateVnfSoftwareWithProperParameters() {
         //  given
@@ -1369,9 +1287,15 @@ public class MsoBusinessLogicImplTest extends AbstractTestNGSpringContextTests {
 
     @Test
     public void probeShouldReturnOrchestrationRequestsAndConnectionStatus(){
-        MsoResponseWrapper wrapper = getMsoResponseWrapper();
-        given(msoInterface.getOrchestrationRequest(anyString(),anyString(),
-                anyString(),any(RestObject.class),anyBoolean())).willReturn(wrapper);
+        String body =
+                "{"
+                + "  \"requestList\":"
+                + "  [{"
+                + "      \"request\": {}"
+                + "    }"
+                + "  ]"
+                + "}";
+        mockForGetOrchestrationRequest(200, body);
 
         ExternalComponentStatus externalComponentStatus = msoBusinessLogic.probeComponent();
 
@@ -1379,18 +1303,6 @@ public class MsoBusinessLogicImplTest extends AbstractTestNGSpringContextTests {
         assertThat(externalComponentStatus.getComponent()).isEqualTo(ExternalComponentStatus.Component.MSO);
     }
 
-    @NotNull
-    private MsoResponseWrapper getMsoResponseWrapper() {
-        MsoResponseWrapper wrapper=new MsoResponseWrapper();
-        RequestWrapper requestWrapper = new RequestWrapper();
-        requestWrapper.setRequest(new Request());
-        RequestList requestList = new RequestList();
-        List<RequestWrapper> response = Lists.newArrayList(requestWrapper);
-        requestList.setRequestList(response);
-        wrapper.setEntity(new Gson().toJson(requestList));
-        return wrapper;
-    }
-
     private WorkflowRequestDetail createWorkflowRequestDetail() {
         WorkflowRequestDetail workflowRequestDetail = new WorkflowRequestDetail();
         org.onap.vid.changeManagement.RequestParameters requestParameters = new org.onap.vid.changeManagement.RequestParameters();
@@ -1480,5 +1392,189 @@ public class MsoBusinessLogicImplTest extends AbstractTestNGSpringContextTests {
             super(testException);
         }
     }
+
+    //you need to add mocks to httpResponse
+    private HttpResponse<String> mockForGetOrchestrationRequest() {
+
+        HttpResponse<String> httpResponse = mock(HttpResponse.class);
+        HttpResponseWithRequestInfo<String> httpResponseWithRequestInfo = new HttpResponseWithRequestInfo<>(httpResponse, MY_PRETTY_URL, HttpMethod.GET);
+        when(msoInterface.getOrchestrationRequest(any(String.class),anyBoolean()))
+            .thenReturn(httpResponseWithRequestInfo);
+        return httpResponse;
+    }
+
+    private HttpResponse<String> mockForGetOrchestrationRequest(int statusCode, String body) {
+
+        HttpResponse<String> httpResponse = mockForGetOrchestrationRequest();
+        when(httpResponse.getStatus()).thenReturn(statusCode);
+        when(httpResponse.getBody()).thenReturn(body);
+        TestUtils.mockGetRawBodyWithStringBody(httpResponse, body);
+        return httpResponse;
+    }
+
+    @Test
+    public void probeComponent_verifyGoodRequest(){
+        String responseString = "" +
+            "{ " +
+            " \"requestList\": [{ " +
+            "   \"request\": { " +
+            "    \"requestDetails\": { " +
+            "     \"cloudConfiguration\": { " +
+            "      \"lcpCloudRegionId\": \"hvf6\", " +
+            "      \"cloudOwner\": \"irma-aic\", " +
+            "      \"tenantId\": \"ffdf52b5e5104b0e8f329b0b1637ee2e\" " +
+            "     }, " +
+            "     \"modelInfo\": { " +
+            "      \"modelCustomizationName\": \"VSP1710PID298109_vWINIFRED 0\", " +
+            "      \"modelCustomizationId\": \"24d43fdb-9aa6-4287-a68e-1e702ea89d13\", " +
+            "      \"modelInvariantId\": \"e7961100-cde6-4b5a-bcda-b8945086950a\", " +
+            "      \"modelVersionId\": \"959a7ba0-89ee-4984-9af6-65d5bdda4b0e\", " +
+            "      \"modelName\": \"VSP1710PID298109_vWINIFRED\", " +
+            "      \"modelType\": \"vnf\", " +
+            "      \"modelVersion\": \"1.0\" " +
+            "     }, " +
+            "     \"relatedModelList\": [{ " +
+            "       \"relatedInstance\": { " +
+            "        \"instanceId\": \"6dd0f8de-93c7-48a2-914b-1a8d58e0eb48\", " +
+            "        \"modelInfo\": { " +
+            "         \"modelInvariantId\": \"57e00952-0af7-4f0f-b19a-408a6f73c8df\", " +
+            "         \"modelType\": \"service\", " +
+            "         \"modelName\": \"ServicevWINIFREDPID298109\", " +
+            "         \"modelVersion\": \"1.0\", " +
+            "         \"modelVersionId\": \"fe6985cd-ea33-3346-ac12-ab121484a3fe\" " +
+            "        } " +
+            "       } " +
+            "      } " +
+            "     ], " +
+            "     \"requestInfo\": { " +
+            "      \"source\": \"VID\", " +
+            "      \"suppressRollback\": false, " +
+            "      \"requestorId\": \"ds828e\" " +
+            "     }, " +
+            "     \"requestParameters\": { " +
+            "      \"userParams\": [ " +
+            "      ], " +
+            "      \"aLaCarte\": false, " +
+            "      \"usePreload\": true, " +
+            "      \"rebuildVolumeGroups\": false, " +
+            "      \"autoBuildVfModules\": false, " +
+            "      \"cascadeDelete\": false " +
+            "     }, " +
+            "     \"relatedInstanceList\": [{ " +
+            "       \"relatedInstance\": { " +
+            "        \"instanceId\": \"6dd0f8de-93c7-48a2-914b-1a8d58e0eb48\", " +
+            "        \"modelInfo\": { " +
+            "         \"modelInvariantId\": \"57e00952-0af7-4f0f-b19a-408a6f73c8df\", " +
+            "         \"modelType\": \"service\", " +
+            "         \"modelName\": \"ServicevWINIFREDPID298109\", " +
+            "         \"modelVersion\": \"1.0\", " +
+            "         \"modelVersionId\": \"fe6985cd-ea33-3346-ac12-ab121484a3fe\" " +
+            "        } " +
+            "       } " +
+            "      } " +
+            "     ] " +
+            "    }, " +
+            "    \"requestId\": \"d352c70d-5ef8-4977-9ea8-4c8cbe860422\", " +
+            "    \"requestScope\": \"vnf\", " +
+            "    \"requestStatus\": { " +
+            "     \"percentProgress\": 100.0, " +
+            "     \"requestState\": \"Some Unknown Value\", " +
+            "     \"statusMessage\": \"Update Is In Progress\", " +
+            "     \"finishTime\": \"Fri, 08 Sep 2017 19:34:33 GMT\" " +
+            "    }, " +
+            "    \"requestType\": \"updateInstance\", " +
+            "    \"startTime\": \"<IN_PROGRESS_DATE>\", " +
+            "    \"instanceReferences\": { " +
+            "     \"serviceInstanceId\": \"6dd0f8de-93c7-48a2-914b-1a8d58e0eb48\", " +
+            "     \"vnfInstanceId\": \"7c00cc1e-6425-4fc3-afc3-0289db288d4c\", " +
+            "     \"requestorId\": \"ds828e\" " +
+            "    } " +
+            "   } " +
+            "  } " +
+            " ] " +
+            "} ";
+
+        mockForGetOrchestrationRequest(200, responseString);
+
+        final ExternalComponentStatus msoStatus = msoBusinessLogic.probeComponent();
+
+        assertMsoStatus(msoStatus, true);
+        assertMetadata(msoStatus, 200, startsWith(responseString.substring(0, 400)), MY_PRETTY_URL, equalTo("OK"));
+    }
+
+    @Test
+    public void probeComponent_response200OkButEmptyPayload_shouldDescribeCorrectly() {
+        String responseString = "" +
+            "{ " +
+            " \"requestList\": []" +
+            "}";
+
+        mockForGetOrchestrationRequest(200, responseString);
+
+        final ExternalComponentStatus msoStatus = msoBusinessLogic.probeComponent();
+
+        assertMsoStatus(msoStatus, true);
+
+        assertMetadata(msoStatus, 200, equalTo(responseString), MY_PRETTY_URL, containsString("OK"));
+    }
+
+    @Test
+    public void probeComponent_response200OkButInvalidPayload_shouldDescribeCorrectly() {
+        String responseString = "this payload is an invalid json";
+
+        mockForGetOrchestrationRequest(200, responseString);
+
+        final ExternalComponentStatus msoStatus = msoBusinessLogic.probeComponent();
+
+        assertMsoStatus(msoStatus, false);
+
+        assertMetadata(msoStatus, 200, equalTo(responseString), MY_PRETTY_URL, containsString("JsonParseException: Unrecognized token"));
+    }
+
+    @Test
+    public void probeComponent_verifyResponse406() {
+        String responseString = "my raw data";
+
+        when(msoInterface.getOrchestrationRequest(any(), eq(true))).thenThrow(
+            new ExceptionWithRequestInfo(HttpMethod.GET, MY_PRETTY_URL, responseString, 406,
+                new GenericUncheckedException(
+                    new HttpException("Simulating as 406 was returned (200 or 202 expected)"))));
+
+        final ExternalComponentStatus msoStatus = msoBusinessLogic.probeComponent();
+
+        assertMsoStatus(msoStatus, false);
+
+        assertMetadata(msoStatus, 406, equalTo(responseString), MY_PRETTY_URL, containsString("HttpException: Simulating as 406 was returned"));
+    }
+
+
+    @Test
+    public void probeComponent_throwNullPointerException_resultIsWithErrorMetadata() {
+        when(msoInterface.getOrchestrationRequest(any(), eq(true))).thenThrow(new NullPointerException());
+
+        final ExternalComponentStatus msoStatus = msoBusinessLogic.probeComponent();
+
+        MatcherAssert.assertThat(msoStatus.isAvailable(), is(false));
+        MatcherAssert.assertThat(msoStatus.getComponent(), is(MSO));
+        MatcherAssert.assertThat(msoStatus.getMetadata(), instanceOf(ErrorMetadata.class));
+
+        final ErrorMetadata metadata = ((ErrorMetadata) msoStatus.getMetadata());
+        org.junit.Assert.assertThat(metadata.getDescription(), containsString("NullPointerException"));
+    }
+
+    private void assertMsoStatus(ExternalComponentStatus msoStatus, boolean isAvailable) {
+        MatcherAssert.assertThat(msoStatus.isAvailable(), is(isAvailable));
+        MatcherAssert.assertThat(msoStatus.getComponent(), is(MSO));
+        MatcherAssert.assertThat(msoStatus.getMetadata(), instanceOf(HttpRequestMetadata.class));
+    }
+
+    private void assertMetadata(ExternalComponentStatus msoStatus, int httpCode, Matcher<String> rawData, String url, Matcher<String> descriptionMatcher) {
+        final HttpRequestMetadata metadata = ((HttpRequestMetadata) msoStatus.getMetadata());
+        org.junit.Assert.assertThat(metadata.getHttpMethod(), equalTo(HttpMethod.GET));
+        org.junit.Assert.assertThat(metadata.getHttpCode(), equalTo(httpCode));
+        org.junit.Assert.assertThat(metadata.getUrl(), equalTo(url));
+        org.junit.Assert.assertThat(metadata.getRawData(), rawData);
+        org.junit.Assert.assertThat(metadata.getDescription(), descriptionMatcher);
+    }
 }