Search in sources :

Example 96 with InfraActiveRequests

use of org.onap.so.db.request.beans.InfraActiveRequests in project so by onap.

the class OrchestrationStatusValidatorTest method test_validateOrchestrationStatusSecondStageOfMultiStageDisabledVfModule.

@Test
public void test_validateOrchestrationStatusSecondStageOfMultiStageDisabledVfModule() throws Exception {
    String flowToBeCalled = "CreateVfModuleBB";
    execution.setVariable("orchestrationStatusValidationResult", OrchestrationStatusValidationDirective.SILENT_SUCCESS);
    execution.setVariable("aLaCarte", true);
    execution.setVariable("flowToBeCalled", flowToBeCalled);
    GenericVnf genericVnf = buildGenericVnf();
    ModelInfoGenericVnf modelInfoGenericVnf = genericVnf.getModelInfoGenericVnf();
    modelInfoGenericVnf.setMultiStageDesign("false");
    setGenericVnf().setModelInfoGenericVnf(modelInfoGenericVnf);
    setVfModule().setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION);
    BuildingBlockDetail buildingBlockDetail = getBuildingBlockDetail("CreateVfModuleBB", ResourceType.VF_MODULE, OrchestrationAction.CREATE);
    doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled);
    org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule = new org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule();
    vfModule.setVfModuleId("vfModuleId");
    vfModule.setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION);
    when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
    OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = getOrchestrationStatusStateTransitionDirective(OrchestrationStatusValidationDirective.SILENT_SUCCESS, OrchestrationStatus.PENDING_ACTIVATION, ResourceType.VF_MODULE, OrchestrationAction.CREATE);
    doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient).getOrchestrationStatusStateTransitionDirective(ResourceType.VF_MODULE, OrchestrationStatus.PENDING_ACTIVATION, OrchestrationAction.CREATE);
    InfraActiveRequests request = new InfraActiveRequests();
    request.setRequestId("testVfModuleId1");
    request.setResourceStatusMessage(vfModuleExistExpectedMessage);
    Mockito.doNothing().when(requestsDbClient).patchInfraActiveRequests(request);
    orchestrationStatusValidator.validateOrchestrationStatus(execution);
    assertEquals(OrchestrationStatusValidationDirective.SILENT_SUCCESS, execution.getVariable("orchestrationStatusValidationResult"));
    ArgumentCaptor<InfraActiveRequests> argument = ArgumentCaptor.forClass(InfraActiveRequests.class);
    Mockito.verify(requestsDbClient).patchInfraActiveRequests(argument.capture());
    assertEquals(vfModuleExistExpectedMessage, argument.getValue().getResourceStatusMessage());
}
Also used : ModelInfoGenericVnf(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) ModelInfoGenericVnf(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf) InfraActiveRequests(org.onap.so.db.request.beans.InfraActiveRequests) OrchestrationStatusStateTransitionDirective(org.onap.so.db.catalog.beans.OrchestrationStatusStateTransitionDirective) BuildingBlockDetail(org.onap.so.db.catalog.beans.BuildingBlockDetail) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Example 97 with InfraActiveRequests

use of org.onap.so.db.request.beans.InfraActiveRequests in project so by onap.

the class OrchestrationStatusValidatorTest method test_validateOrchestrationStatusDeleteVfModuleSilentSuccess.

@Test
public void test_validateOrchestrationStatusDeleteVfModuleSilentSuccess() throws Exception {
    String flowToBeCalled = "DeleteVfModuleBB";
    execution.setVariable("orchestrationStatusValidationResult", OrchestrationStatusValidationDirective.SILENT_SUCCESS);
    execution.setVariable("aLaCarte", true);
    execution.setVariable("flowToBeCalled", flowToBeCalled);
    GenericVnf genericVnf = buildGenericVnf();
    ModelInfoGenericVnf modelInfoGenericVnf = genericVnf.getModelInfoGenericVnf();
    modelInfoGenericVnf.setMultiStageDesign("true");
    setGenericVnf().setModelInfoGenericVnf(modelInfoGenericVnf);
    setVfModule().setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION);
    org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule = new org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule();
    vfModule.setVfModuleId("vfModuleId");
    vfModule.setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION);
    when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
    BuildingBlockDetail buildingBlockDetail = getBuildingBlockDetail("DeleteVfModuleBB", ResourceType.VF_MODULE, OrchestrationAction.CREATE);
    doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled);
    OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = getOrchestrationStatusStateTransitionDirective(OrchestrationStatusValidationDirective.SILENT_SUCCESS, OrchestrationStatus.PENDING_ACTIVATION, ResourceType.VF_MODULE, OrchestrationAction.CREATE);
    doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient).getOrchestrationStatusStateTransitionDirective(ResourceType.VF_MODULE, OrchestrationStatus.PENDING_ACTIVATION, OrchestrationAction.CREATE);
    InfraActiveRequests request = new InfraActiveRequests();
    request.setRequestId("testVfModuleId1");
    request.setResourceStatusMessage(vfModuleNotExistExpectedMessage);
    Mockito.doNothing().when(requestsDbClient).patchInfraActiveRequests(request);
    orchestrationStatusValidator.validateOrchestrationStatus(execution);
    assertEquals(OrchestrationStatusValidationDirective.SILENT_SUCCESS, execution.getVariable("orchestrationStatusValidationResult"));
    ArgumentCaptor<InfraActiveRequests> argument = ArgumentCaptor.forClass(InfraActiveRequests.class);
    Mockito.verify(requestsDbClient).patchInfraActiveRequests(argument.capture());
    assertEquals(vfModuleNotExistExpectedMessage, argument.getValue().getResourceStatusMessage());
}
Also used : ModelInfoGenericVnf(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) ModelInfoGenericVnf(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf) InfraActiveRequests(org.onap.so.db.request.beans.InfraActiveRequests) OrchestrationStatusStateTransitionDirective(org.onap.so.db.catalog.beans.OrchestrationStatusStateTransitionDirective) BuildingBlockDetail(org.onap.so.db.catalog.beans.BuildingBlockDetail) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Example 98 with InfraActiveRequests

use of org.onap.so.db.request.beans.InfraActiveRequests in project so by onap.

the class OrchestrationStatusValidatorTest method test_validateOrchestrationStatusSecondStageOfMultiStageWrongPrevStatusVfModule.

@Test
public void test_validateOrchestrationStatusSecondStageOfMultiStageWrongPrevStatusVfModule() throws Exception {
    String flowToBeCalled = "CreateVfModuleBB";
    execution.setVariable("orchestrationStatusValidationResult", OrchestrationStatusValidationDirective.CONTINUE);
    execution.setVariable("aLaCarte", true);
    execution.setVariable("flowToBeCalled", flowToBeCalled);
    GenericVnf genericVnf = buildGenericVnf();
    ModelInfoGenericVnf modelInfoGenericVnf = genericVnf.getModelInfoGenericVnf();
    modelInfoGenericVnf.setMultiStageDesign("true");
    setGenericVnf().setModelInfoGenericVnf(modelInfoGenericVnf);
    setVfModule().setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION);
    org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule = new org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule();
    vfModule.setVfModuleId("vfModuleId");
    vfModule.setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION);
    when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
    BuildingBlockDetail buildingBlockDetail = getBuildingBlockDetail("CreateVfModuleBB", ResourceType.VF_MODULE, OrchestrationAction.CREATE);
    doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled);
    OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = getOrchestrationStatusStateTransitionDirective(OrchestrationStatusValidationDirective.SILENT_SUCCESS, OrchestrationStatus.PENDING_ACTIVATION, ResourceType.VF_MODULE, OrchestrationAction.CREATE);
    doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient).getOrchestrationStatusStateTransitionDirective(ResourceType.VF_MODULE, OrchestrationStatus.PENDING_ACTIVATION, OrchestrationAction.CREATE);
    InfraActiveRequests request = new InfraActiveRequests();
    request.setRequestId("testVfModuleId1");
    request.setResourceStatusMessage(vfModuleExistExpectedMessage);
    Mockito.doNothing().when(requestsDbClient).patchInfraActiveRequests(request);
    orchestrationStatusValidator.validateOrchestrationStatus(execution);
    assertEquals(OrchestrationStatusValidationDirective.SILENT_SUCCESS, execution.getVariable("orchestrationStatusValidationResult"));
    ArgumentCaptor<InfraActiveRequests> argument = ArgumentCaptor.forClass(InfraActiveRequests.class);
    Mockito.verify(requestsDbClient).patchInfraActiveRequests(argument.capture());
    assertEquals(vfModuleExistExpectedMessage, argument.getValue().getResourceStatusMessage());
}
Also used : ModelInfoGenericVnf(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) ModelInfoGenericVnf(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf) InfraActiveRequests(org.onap.so.db.request.beans.InfraActiveRequests) OrchestrationStatusStateTransitionDirective(org.onap.so.db.catalog.beans.OrchestrationStatusStateTransitionDirective) BuildingBlockDetail(org.onap.so.db.catalog.beans.BuildingBlockDetail) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Example 99 with InfraActiveRequests

use of org.onap.so.db.request.beans.InfraActiveRequests in project so by onap.

the class OrchestrationStatusValidatorTest method test_validateOrchestrationStatusSecondStageOfMultiStageWrongTargetActionVfModule.

@Test
public void test_validateOrchestrationStatusSecondStageOfMultiStageWrongTargetActionVfModule() throws Exception {
    String flowToBeCalled = "CreateVfModuleBB";
    execution.setVariable("orchestrationStatusValidationResult", OrchestrationStatusValidationDirective.SILENT_SUCCESS);
    execution.setVariable("aLaCarte", true);
    execution.setVariable("flowToBeCalled", flowToBeCalled);
    GenericVnf genericVnf = buildGenericVnf();
    ModelInfoGenericVnf modelInfoGenericVnf = genericVnf.getModelInfoGenericVnf();
    modelInfoGenericVnf.setMultiStageDesign("true");
    setGenericVnf().setModelInfoGenericVnf(modelInfoGenericVnf);
    setVfModule().setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION);
    BuildingBlockDetail buildingBlockDetail = getBuildingBlockDetail("CreateVfModuleBB", ResourceType.VF_MODULE, OrchestrationAction.ACTIVATE);
    doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled);
    org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule = new org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule();
    vfModule.setVfModuleId("vfModuleId");
    vfModule.setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION);
    when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
    OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = getOrchestrationStatusStateTransitionDirective(OrchestrationStatusValidationDirective.SILENT_SUCCESS, OrchestrationStatus.PENDING_ACTIVATION, ResourceType.VF_MODULE, OrchestrationAction.ACTIVATE);
    doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient).getOrchestrationStatusStateTransitionDirective(ResourceType.VF_MODULE, OrchestrationStatus.PENDING_ACTIVATION, OrchestrationAction.ACTIVATE);
    InfraActiveRequests request = new InfraActiveRequests();
    request.setRequestId("testVfModuleId1");
    request.setResourceStatusMessage(vfModuleExistExpectedMessage);
    Mockito.doNothing().when(requestsDbClient).patchInfraActiveRequests(request);
    orchestrationStatusValidator.validateOrchestrationStatus(execution);
    assertEquals(OrchestrationStatusValidationDirective.SILENT_SUCCESS, execution.getVariable("orchestrationStatusValidationResult"));
    ArgumentCaptor<InfraActiveRequests> argument = ArgumentCaptor.forClass(InfraActiveRequests.class);
    Mockito.verify(requestsDbClient).patchInfraActiveRequests(argument.capture());
    assertEquals(vfModuleExistExpectedMessage, argument.getValue().getResourceStatusMessage());
}
Also used : ModelInfoGenericVnf(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) ModelInfoGenericVnf(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf) InfraActiveRequests(org.onap.so.db.request.beans.InfraActiveRequests) OrchestrationStatusStateTransitionDirective(org.onap.so.db.catalog.beans.OrchestrationStatusStateTransitionDirective) BuildingBlockDetail(org.onap.so.db.catalog.beans.BuildingBlockDetail) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Example 100 with InfraActiveRequests

use of org.onap.so.db.request.beans.InfraActiveRequests in project so by onap.

the class ActivateVnfOperationalEnvironmentTest method processActivateSDCRequestTest_409.

@Test
public void processActivateSDCRequestTest_409() throws ApiException, JsonProcessingException {
    // ERROR in asdc
    JSONObject jsonMessages = new JSONObject();
    jsonMessages.put("message", "Failure");
    jsonMessages.put("messageId", "SVC4675");
    jsonMessages.put("text", "Error: Service state is invalid for this action.");
    JSONObject jsonServException = new JSONObject();
    jsonServException.put("policyException", jsonMessages);
    // jsonServException.put("serviceException", jsonMessages);
    JSONObject jsonErrorResponse = new JSONObject();
    jsonErrorResponse.put("requestError", jsonServException);
    // prepare request detail
    List<ServiceModelList> serviceModelVersionIdList = new ArrayList<>();
    ServiceModelList serviceModelList1 = new ServiceModelList();
    serviceModelList1.setRecoveryAction(RecoveryAction.retry);
    serviceModelList1.setServiceModelVersionId(serviceModelVersionId);
    serviceModelVersionIdList.add(serviceModelList1);
    InfraActiveRequests iar = new InfraActiveRequests();
    iar.setRequestId(requestId);
    iar.setRequestStatus("PENDING");
    wireMockServer.stubFor(get(urlPathEqualTo("/infraActiveRequests/" + requestId)).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withBody(mapper.writeValueAsString(iar)).withStatus(HttpStatus.SC_OK)));
    wireMockServer.stubFor(post(urlPathMatching("/sdc/v1/catalog/services/TEST_serviceModelVersionId/distr.*")).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(jsonErrorResponse.toString()).withStatus(HttpStatus.SC_CONFLICT)));
    wireMockServer.stubFor(post(urlPathEqualTo("/infraActiveRequests/")).withRequestBody(containing("operationalEnvId\":\"1dfe7154-eae0-44f2-8e7a-8e5e7882e55d\"")).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withStatus(HttpStatus.SC_OK)));
    thrown.expect(ValidateException.class);
    activateVnf.processActivateSDCRequest(requestId, operationalEnvironmentId, serviceModelVersionIdList, workloadContext, vnfOperationalEnvironmentId);
}
Also used : ServiceModelList(org.onap.so.apihandlerinfra.tenantisolationbeans.ServiceModelList) JSONObject(org.json.JSONObject) ArrayList(java.util.ArrayList) InfraActiveRequests(org.onap.so.db.request.beans.InfraActiveRequests) BaseTest(org.onap.so.apihandlerinfra.BaseTest) Test(org.junit.Test)

Aggregations

InfraActiveRequests (org.onap.so.db.request.beans.InfraActiveRequests)214 Test (org.junit.Test)119 BaseTaskTest (org.onap.so.bpmn.BaseTaskTest)29 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)26 Timestamp (java.sql.Timestamp)23 HttpEntity (org.springframework.http.HttpEntity)21 IOException (java.io.IOException)20 HashMap (java.util.HashMap)20 ApiException (org.onap.so.apihandlerinfra.exceptions.ApiException)20 ValidateException (org.onap.so.apihandlerinfra.exceptions.ValidateException)19 ServiceInstancesRequest (org.onap.so.serviceinstancebeans.ServiceInstancesRequest)19 BaseTest (org.onap.so.apihandlerinfra.BaseTest)18 ErrorLoggerInfo (org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo)18 ArrayList (java.util.ArrayList)16 ValidationException (org.onap.so.exceptions.ValidationException)15 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)13 Transactional (javax.transaction.Transactional)13 UriComponentsBuilder (org.springframework.web.util.UriComponentsBuilder)12 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)11 ResponseBuilder (org.onap.so.apihandler.common.ResponseBuilder)11