aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java20
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoMulticloudUtilsTest.java15
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java10
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtilsTest.java36
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmCreateJobTask.java5
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/CustomWorkflowValidation.java52
6 files changed, 87 insertions, 51 deletions
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java
index ccdcf92953..1fabcb279c 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java
@@ -71,6 +71,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{
public static final String VNF_ID = "vnf_id";
public static final String VF_MODULE_ID = "vf_module_id";
public static final String TEMPLATE_TYPE = "template_type";
+ public static final String MULTICLOUD_QUERY_BODY_NULL = "multicloudQueryBody is null";
public static final List<String> MULTICLOUD_INPUTS =
Arrays.asList(OOF_DIRECTIVES, SDNC_DIRECTIVES, USER_DIRECTIVES, TEMPLATE_TYPE);
@@ -302,11 +303,16 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{
returnInfo.setStatusMessage(response.getStatusInfo().getReasonPhrase());
} else if (response.getStatus() == Response.Status.OK.getStatusCode() && response.hasEntity()) {
multicloudQueryBody = getQueryBody((java.io.InputStream)response.getEntity());
- returnInfo.setCanonicalName(stackName + "/" + multicloudQueryBody.getWorkloadId());
- returnInfo.setStatus(getHeatStatus(multicloudQueryBody.getWorkloadStatus()));
- returnInfo.setStatusMessage(multicloudQueryBody.getWorkloadStatus());
- if (logger.isDebugEnabled()) {
- logger.debug("Multicloud Create Response Body: " + multicloudQueryBody.toString());
+ if (multicloudQueryBody != null) {
+ returnInfo.setCanonicalName(stackName + "/" + multicloudQueryBody.getWorkloadId());
+ returnInfo.setStatus(getHeatStatus(multicloudQueryBody.getWorkloadStatus()));
+ returnInfo.setStatusMessage(multicloudQueryBody.getWorkloadStatus());
+ if (logger.isDebugEnabled()) {
+ logger.debug("Multicloud Create Response Body: " + multicloudQueryBody.toString());
+ }
+ } else {
+ returnInfo.setStatus(HeatStatus.FAILED);
+ returnInfo.setStatusMessage(MULTICLOUD_QUERY_BODY_NULL);
}
} else {
returnInfo.setStatus(HeatStatus.FAILED);
@@ -624,7 +630,9 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{
}
private HeatStatus mapResponseToHeatStatus(Response response) {
- if (response.getStatusInfo().getStatusCode() == Response.Status.OK.getStatusCode()) {
+ if (response == null) {
+ return HeatStatus.FAILED;
+ } else if (response.getStatusInfo().getStatusCode() == Response.Status.OK.getStatusCode()) {
return HeatStatus.CREATED;
} else if (response.getStatusInfo().getStatusCode() == Response.Status.CREATED.getStatusCode()) {
return HeatStatus.CREATED;
diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoMulticloudUtilsTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoMulticloudUtilsTest.java
index 669e47f94d..e066c4eec6 100644
--- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoMulticloudUtilsTest.java
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoMulticloudUtilsTest.java
@@ -4,8 +4,6 @@
* ================================================================================
* Copyright (C) 2019 Samsung Intellectual Property. All rights reserved.
* ================================================================================
- * Modifications Copyright (c) 2019 Samsung
- * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -31,6 +29,7 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.when;
+import static org.onap.so.openstack.utils.MsoMulticloudUtils.MULTICLOUD_QUERY_BODY_NULL;
import java.io.IOException;
import java.util.HashMap;
@@ -123,6 +122,18 @@ public class MsoMulticloudUtilsTest extends BaseTest {
assertTrue(HeatStatus.NOTFOUND == result.getStatus());
}
+ @Test
+ public void queryStackWithNullMulticloudQueryBody() throws MsoException {
+ wireMockServer.stubFor(get(urlPathEqualTo("/api/multicloud/v1/CloudOwner/MTN13/infra_workload/instanceId"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBody(CREATE_STACK_RESPONSE)
+ .withStatus(HttpStatus.SC_OK)));
+
+ StackInfo result = multicloudUtils.queryStack("MTN13", "CloudOwner", "TEST-tenant", "instanceId");
+ assertTrue(HeatStatus.FAILED == result.getStatus());
+ assertEquals(MULTICLOUD_QUERY_BODY_NULL, result.getStatusMessage());
+ }
+
@Test(expected = VduException.class)
public void updateVdu() throws MsoException {
multicloudUtils.updateVdu(new CloudInfo(), "instanceId", new HashMap<>(), new VduModelInfo(),
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java
index 7a967d3159..750b7ace35 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2019 TechMahindra
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -130,13 +132,15 @@ public class AbstractCDSProcessingBBUtils implements CDSProcessingListener {
//CDSProcessingListener cdsProcessingListener = new AbstractCDSProcessingBBUtils();
- CDSProcessingClient cdsClient = new CDSProcessingClient(this);
- CountDownLatch countDownLatch = cdsClient.sendRequest(executionServiceInput);
-
+ CDSProcessingClient cdsClient = null;
+ CountDownLatch countDownLatch;
try {
+ cdsClient = new CDSProcessingClient(this);
+ countDownLatch = cdsClient.sendRequest(executionServiceInput);
countDownLatch.await(props.getTimeout(), TimeUnit.SECONDS);
} catch (InterruptedException ex) {
logger.error("Caught exception in sendRequestToCDSClient in AbstractCDSProcessingBBUtils : ", ex);
+ Thread.currentThread().interrupt();
} finally {
cdsClient.close();
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtilsTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtilsTest.java
index b2812d9bfb..161f879716 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtilsTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtilsTest.java
@@ -20,28 +20,36 @@
package org.onap.so.client.cds;
-import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.util.UUID;
import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.so.client.cds.beans.AbstractCDSPropertiesBean;
+import org.onap.so.client.exception.ExceptionBuilder;
-@RunWith(JUnit4.class)
+@RunWith(MockitoJUnitRunner.class)
public class AbstractCDSProcessingBBUtilsTest {
@InjectMocks
private AbstractCDSProcessingBBUtils abstractCDSProcessingBBUtils = new AbstractCDSProcessingBBUtils();
@InjectMocks
AbstractCDSPropertiesBean abstractCDSPropertiesBean = new AbstractCDSPropertiesBean();
+ @Mock
+ ExceptionBuilder exceptionUtil;
- @Test
- public void preProcessRequestTest() throws Exception {
+ @Before
+ public void init(){
String requestObject = "{\"config-assign-request\":{\"resolution-key\":\"resolutionKey\", \"config-assign-properties\":{\"service-instance-id\":\"serviceInstanceId\", \"vnf-id\":\"vnfId\", \"vnf-name\":\"vnfName\", \"service-model-uuid\":\"serviceModelUuid\", \"vnf-customization-uuid\":\"vnfCustomizationUuid\",\"Instance1\":\"Instance1Value\",\"Instance2\":\"Instance2Value\",\"Param3\":\"Param3Value\"}}}";
String blueprintName = "blueprintName";
String blueprintVersion = "blueprintVersion";
@@ -59,12 +67,28 @@ public class AbstractCDSProcessingBBUtilsTest {
abstractCDSPropertiesBean.setRequestId(requestId);
abstractCDSPropertiesBean.setRequestObject(requestObject);
abstractCDSPropertiesBean.setSubRequestId(subRequestId);
+ }
+
+ @Test
+ public void preProcessRequestTest() throws Exception {
DelegateExecution execution = mock(DelegateExecution.class);
when(execution.getVariable("executionObject")).thenReturn(abstractCDSPropertiesBean);
abstractCDSProcessingBBUtils.constructExecutionServiceInputObject(execution);
- assertTrue(true);
+ verify(exceptionUtil, times(0))
+ .buildAndThrowWorkflowException(any(DelegateExecution.class), anyInt(), any(Exception.class));
+ }
+
+ @Test
+ public void sendRequestToCDSClientTest() {
+
+ DelegateExecution execution = mock(DelegateExecution.class);
+ when(execution.getVariable("executionServiceInput")).thenReturn(abstractCDSPropertiesBean);
+ abstractCDSProcessingBBUtils.sendRequestToCDSClient(execution);
+ verify(exceptionUtil, times(1))
+ .buildAndThrowWorkflowException(any(DelegateExecution.class), anyInt(), any(Exception.class));
+
}
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmCreateJobTask.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmCreateJobTask.java
index 59ff71ab0c..9e0c26ba20 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmCreateJobTask.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmCreateJobTask.java
@@ -2,6 +2,8 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Ericsson. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -85,8 +87,7 @@ public class MonitorVnfmCreateJobTask extends MonitorVnfmJobTask{
+ "Unable to retrieve OperationStatus";
LOGGER.error(message);
exceptionUtil.buildAndThrowWorkflowException(execution, 1206, message);
- }
- if (operationStatusOption.isPresent()) {
+ } else if (operationStatusOption != null && operationStatusOption.isPresent()) {
final OperationStateEnum operationStatus = operationStatusOption.get();
if (operationStatus != OperationStateEnum.COMPLETED) {
final String message = "Unable to instantiate jobId: "
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/CustomWorkflowValidation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/CustomWorkflowValidation.java
index 695213bf20..0602f09796 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/CustomWorkflowValidation.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/CustomWorkflowValidation.java
@@ -4,6 +4,7 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
+ * Modifications Copyright (c) 2019 Samsung
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,44 +22,31 @@
package org.onap.so.apihandlerinfra.validation;
-import java.util.List;
-import java.util.Map;
-
import org.onap.so.exceptions.ValidationException;
import org.onap.so.serviceinstancebeans.CloudConfiguration;
import org.onap.so.serviceinstancebeans.RequestParameters;
import com.google.common.base.Strings;
-public class CustomWorkflowValidation implements ValidationRule{
-
+public class CustomWorkflowValidation implements ValidationRule {
+
@Override
- public ValidationInformation validate(ValidationInformation info) throws ValidationException{
- RequestParameters requestParameters = info.getSir().getRequestDetails().getRequestParameters();
- CloudConfiguration cloudConfiguration = info.getSir().getRequestDetails ().getCloudConfiguration();
- String workflowUuid = info.getInstanceIdMap().get("workflowUuid");
-
+ public ValidationInformation validate(ValidationInformation info) throws ValidationException {
+ RequestParameters requestParameters = info.getSir().getRequestDetails().getRequestParameters();
+ CloudConfiguration cloudConfiguration = info.getSir().getRequestDetails().getCloudConfiguration();
+
if (cloudConfiguration == null) {
- throw new ValidationException ("cloudConfiguration");
- }else if (Strings.isNullOrEmpty((cloudConfiguration.getCloudOwner ()))) {
- throw new ValidationException ("cloudOwner");
- }else if (Strings.isNullOrEmpty((cloudConfiguration.getLcpCloudRegionId ()))) {
- throw new ValidationException ("lcpCloudRegionId");
- }else if (Strings.isNullOrEmpty((cloudConfiguration.getTenantId ()))) {
- throw new ValidationException ("tenantId");
- }
- if(requestParameters == null){
- throw new ValidationException("requestParameters");
- }
-
- List<Map<String, Object>> userParams = requestParameters.getUserParams();
- if (!validateCustomUserParams(userParams, workflowUuid)) {
- throw new ValidationException("userParams");
- }
- return info;
- }
-
- private boolean validateCustomUserParams(List<Map<String, Object>> userParams, String workflowUuid) {
- return true;
+ throw new ValidationException("cloudConfiguration");
+ } else if (Strings.isNullOrEmpty((cloudConfiguration.getCloudOwner()))) {
+ throw new ValidationException("cloudOwner");
+ } else if (Strings.isNullOrEmpty((cloudConfiguration.getLcpCloudRegionId()))) {
+ throw new ValidationException("lcpCloudRegionId");
+ } else if (Strings.isNullOrEmpty((cloudConfiguration.getTenantId()))) {
+ throw new ValidationException("tenantId");
+ }
+ if (requestParameters == null) {
+ throw new ValidationException("requestParameters");
+ }
+ return info;
}
-} \ No newline at end of file
+}