aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn
diff options
context:
space:
mode:
authorSteve Smokowski <ss835w@att.com>2019-04-05 13:45:29 +0000
committerGerrit Code Review <gerrit@onap.org>2019-04-05 13:45:29 +0000
commit8dcb6c2cfe69e95e22601eb1b15b6cbaa6b8746a (patch)
tree03f0eac860c489f81c31158f9e34885ca79369fc /bpmn
parent7350292687c521002a4abbcc9f1d24cc37caf13f (diff)
parent608a077f8ea3b18dddbfeb4d8b486661e05561c7 (diff)
Merge "Fixed Sonar blocker issues"
Diffstat (limited to 'bpmn')
-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
3 files changed, 40 insertions, 11 deletions
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: "