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());
}
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());
}
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());
}
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());
}
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);
}
Aggregations