aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/mso-infrastructure-bpmn
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn/mso-infrastructure-bpmn')
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/CallbackHandlerService.java10
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/SDNCAdapterCallbackServiceImpl.java5
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/VnfAdapterNotifyServiceImpl.java8
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowMessageResource.java1
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowResource.java1
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/LoggingAndURNMappingPlugin.java1
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/workflow/service/CallbackHandlerServiceTest.java103
7 files changed, 116 insertions, 13 deletions
diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/CallbackHandlerService.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/CallbackHandlerService.java
index 920cb11e4c..f4617f9978 100644
--- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/CallbackHandlerService.java
+++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/CallbackHandlerService.java
@@ -50,12 +50,16 @@ public class CallbackHandlerService {
public static final long FAST_POLL_DUR_SECONDS = 5;
public static final long FAST_POLL_INT_MS = 100;
public static final long SLOW_POLL_INT_MS = 1000;
-
+
private static final Logger logger = LoggerFactory.getLogger(CallbackHandlerService.class);
+ private RuntimeService runtimeService;
+
@Autowired
- RuntimeService runtimeService;
-
+ public CallbackHandlerService(RuntimeService runtimeService) {
+ this.runtimeService = runtimeService;
+ }
+
/**
* Parameterized callback handler.
*/
diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/SDNCAdapterCallbackServiceImpl.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/SDNCAdapterCallbackServiceImpl.java
index 710144dbb9..267e24fec4 100644
--- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/SDNCAdapterCallbackServiceImpl.java
+++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/SDNCAdapterCallbackServiceImpl.java
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 AT&T 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
@@ -63,7 +65,6 @@ public class SDNCAdapterCallbackServiceImpl extends ProcessEngineAwareService im
String correlationVariable = "SDNCA_requestId";
String correlationValue = sdncAdapterCallbackRequest.getCallbackHeader().getRequestId();
- MsoLogger.setServiceName("MSO." + method);
MsoLogger.setLogContext(correlationValue, "N/A");
CallbackResult result = callback.handleCallback(method, message, messageEventName,
@@ -88,4 +89,4 @@ public class SDNCAdapterCallbackServiceImpl extends ProcessEngineAwareService im
return error;
}
}
-} \ No newline at end of file
+}
diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/VnfAdapterNotifyServiceImpl.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/VnfAdapterNotifyServiceImpl.java
index 96a11d21a7..65cc70d5f4 100644
--- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/VnfAdapterNotifyServiceImpl.java
+++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/VnfAdapterNotifyServiceImpl.java
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 AT&T 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
@@ -116,7 +118,6 @@ public class VnfAdapterNotifyServiceImpl extends ProcessEngineAwareService imple
String correlationVariable = "VNFQ_messageId";
String correlationValue = messageId;
- MsoLogger.setServiceName("MSO." + method);
MsoLogger.setLogContext(correlationValue, "N/A");
QueryVnfNotification message = new QueryVnfNotification();
@@ -160,7 +161,6 @@ public class VnfAdapterNotifyServiceImpl extends ProcessEngineAwareService imple
String correlationVariable = "VNFC_messageId";
String correlationValue = messageId;
- MsoLogger.setServiceName("MSO." + method);
MsoLogger.setLogContext(correlationValue, "N/A");
CreateVnfNotification message = new CreateVnfNotification();
@@ -201,7 +201,6 @@ public class VnfAdapterNotifyServiceImpl extends ProcessEngineAwareService imple
String correlationVariable = "VNFU_messageId";
String correlationValue = messageId;
- MsoLogger.setServiceName("MSO." + method);
MsoLogger.setLogContext(correlationValue, "N/A");
UpdateVnfNotification message = new UpdateVnfNotification();
@@ -237,7 +236,6 @@ public class VnfAdapterNotifyServiceImpl extends ProcessEngineAwareService imple
String correlationVariable = "VNFDEL_uuid";
String correlationValue = messageId;
- MsoLogger.setServiceName("MSO." + method);
MsoLogger.setLogContext(correlationValue, "N/A");
DeleteVnfNotification message = new DeleteVnfNotification();
@@ -250,4 +248,4 @@ public class VnfAdapterNotifyServiceImpl extends ProcessEngineAwareService imple
callback.handleCallback(method, message, messageEventName, messageVariable,
correlationVariable, correlationValue, logMarker);
}
-} \ No newline at end of file
+}
diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowMessageResource.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowMessageResource.java
index 8b35f0e6d6..072dec28c6 100644
--- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowMessageResource.java
+++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowMessageResource.java
@@ -79,7 +79,6 @@ public class WorkflowMessageResource{
String message) {
String method = "receiveWorkflowMessage";
- MsoLogger.setServiceName("MSO." + method);
MsoLogger.setLogContext(correlator, "N/A");
logger.debug(LOGMARKER + " Received workflow message"
diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowResource.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowResource.java
index 92f1b7a816..d10ecd1ce2 100644
--- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowResource.java
+++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowResource.java
@@ -237,7 +237,6 @@ public class WorkflowResource extends ProcessEngineAwareService {
}
private void setLogContext(String processKey, Map<String, Object> inputVariables) {
- MsoLogger.setServiceName("MSO." + processKey);
if (inputVariables != null) {
MsoLogger.setLogContext(getValueFromInputVariables(inputVariables, "mso-request-id"),
getValueFromInputVariables(inputVariables, "mso-service-instance-id"));
diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/LoggingAndURNMappingPlugin.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/LoggingAndURNMappingPlugin.java
index 62aad7e345..04059557ae 100644
--- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/LoggingAndURNMappingPlugin.java
+++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/LoggingAndURNMappingPlugin.java
@@ -314,7 +314,6 @@ public class LoggingAndURNMappingPlugin extends AbstractProcessEnginePlugin {
.getName();
- MsoLogger.setServiceName(processName);
String requestId = (String) execution.getVariable("mso-request-id");
String svcid = (String) execution.getVariable("mso-service-instance-id");
MsoLogger.setLogContext(requestId, svcid);
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/workflow/service/CallbackHandlerServiceTest.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/workflow/service/CallbackHandlerServiceTest.java
new file mode 100644
index 0000000000..051107bb13
--- /dev/null
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/workflow/service/CallbackHandlerServiceTest.java
@@ -0,0 +1,103 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 Nokia.
+ * ================================================================================
+ * 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.common.workflow.service;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import org.camunda.bpm.engine.RuntimeService;
+import org.camunda.bpm.engine.impl.ExecutionQueryImpl;
+import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity;
+import org.camunda.bpm.engine.runtime.Execution;
+import org.camunda.bpm.engine.runtime.ExecutionQuery;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.so.bpmn.common.workflow.service.CallbackHandlerService.CallbackError;
+import org.onap.so.bpmn.common.workflow.service.CallbackHandlerService.CallbackResult;
+import org.onap.so.bpmn.common.workflow.service.CallbackHandlerService.CallbackSuccess;
+import org.onap.so.bpmn.core.UrnPropertiesReader;
+import org.springframework.core.env.Environment;
+
+public class CallbackHandlerServiceTest {
+
+ private static final String METHOD_NAME = "testMethod";
+ private static final String MESSAGE = "testMessage";
+ private static final String EVENT_NAME = "eventNameTest";
+ private static final String MESSAGE_VARIABLE = "messageVarTest";
+ private static final String CORRELATION_VARIABLE = "corrVarTest";
+ private static final String CORRELATION_VALUE = "corrValueTest";
+ private static final String LOG_MARKER = "markerTest";
+
+ private RuntimeService runtimeServiceMock;
+ private CallbackHandlerService testedObject;
+
+ @Before
+ public void setup() {
+ runtimeServiceMock = mock(RuntimeService.class);
+ testedObject = new CallbackHandlerService(runtimeServiceMock);
+ mockEnvironment();
+ }
+
+ @Test
+ public void callbackSuccessful() {
+ // given
+ mockRuntimeService(new ArrayList<>(Arrays.asList(new ExecutionEntity())));
+ // when
+ CallbackResult callbackResult = testedObject.handleCallback(METHOD_NAME, MESSAGE, EVENT_NAME, MESSAGE_VARIABLE,
+ CORRELATION_VARIABLE, CORRELATION_VALUE, LOG_MARKER, new HashMap<>());
+ // then
+ assertThat(callbackResult).isExactlyInstanceOf(CallbackSuccess.class);
+ }
+
+ @Test
+ public void callbackNotSuccessful_noWaitingProcesses() {
+ // given
+ mockRuntimeService(Collections.emptyList());
+ // when
+ CallbackResult callbackResult = testedObject.handleCallback(METHOD_NAME, MESSAGE, EVENT_NAME, MESSAGE_VARIABLE,
+ CORRELATION_VARIABLE, CORRELATION_VALUE, LOG_MARKER, new HashMap<>());
+ // then
+ assertThat(callbackResult).isExactlyInstanceOf(CallbackError.class);
+ }
+
+ private void mockRuntimeService(List<Execution> waitingProcesses) {
+ ExecutionQuery executionQueryMock = mock(ExecutionQueryImpl.class);
+ when(runtimeServiceMock.createExecutionQuery()).thenReturn(executionQueryMock);
+ when(executionQueryMock.messageEventSubscriptionName("eventNameTest")).thenReturn(executionQueryMock);
+ when(executionQueryMock.processVariableValueEquals("corrVarTest", "corrValueTest"))
+ .thenReturn(executionQueryMock);
+ when(executionQueryMock.list()).thenReturn(waitingProcesses);
+ }
+
+ private Environment mockEnvironment() {
+ Environment mockEnvironment = mock(Environment.class);
+ UrnPropertiesReader urnPropertiesReader = new UrnPropertiesReader();
+ urnPropertiesReader.setEnvironment(mockEnvironment);
+ when(mockEnvironment.getProperty("mso.correlation.timeout")).thenReturn("1");
+ return mockEnvironment;
+ }
+}