summaryrefslogtreecommitdiffstats
path: root/bpmn
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn')
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/CDSPropertiesImpl.java6
-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/test/java/org/onap/so/bpmn/common/workflow/service/CallbackHandlerServiceTest.java103
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CloudSiteCatalogUtils.java15
4 files changed, 125 insertions, 9 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/CDSPropertiesImpl.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/CDSPropertiesImpl.java
index b8ab588a75..dfdef74886 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/CDSPropertiesImpl.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/CDSPropertiesImpl.java
@@ -24,6 +24,7 @@ public class CDSPropertiesImpl implements CDSProperties {
private static final String ENDPOINT = "cds.endpoint";
private static final String PORT = "cds.port";
+ private static final String AUTH = "cds.auth";
public CDSPropertiesImpl() {
// Needed for service loader
@@ -40,6 +41,11 @@ public class CDSPropertiesImpl implements CDSProperties {
}
@Override
+ public String getBasicAuth() {
+ return Objects.requireNonNull(UrnPropertiesReader.getVariable(AUTH));
+ }
+
+ @Override
public URL getEndpoint() {
return null;
}
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/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;
+ }
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CloudSiteCatalogUtils.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CloudSiteCatalogUtils.java
index bba883e727..752c39a0a6 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CloudSiteCatalogUtils.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CloudSiteCatalogUtils.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
@@ -25,14 +27,15 @@ import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.onap.so.client.exception.ExceptionBuilder;
import org.onap.so.db.catalog.client.CatalogDbClient;
import org.onap.so.db.catalog.beans.CloudSite;
-import org.onap.so.logger.MsoLogger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class CloudSiteCatalogUtils {
- private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, CloudSiteCatalogUtils.class);
+ private static final Logger logger = LoggerFactory.getLogger(CloudSiteCatalogUtils.class);
@Autowired
private ExceptionBuilder exceptionUtil;
@@ -46,17 +49,17 @@ public class CloudSiteCatalogUtils {
if (cloudRegionId != null) {
Optional<CloudSite> cloudSite = getCloudSite(cloudRegionId);
if (!cloudSite.isPresent()) {
- msoLogger.debug("Cloud Region with cloudRegionId " + cloudRegionId + " not found in Catalog DB");
+ logger.debug("Cloud Region with cloudRegionId {} not found in Catalog DB", cloudRegionId);
exceptionUtil.buildAndThrowWorkflowException(execution, 404, "Cloud Region with cloudRegionId " + cloudRegionId + " not found in Catalog DB");
}
if (cloudSite.get().getIdentityService() == null) {
- msoLogger.debug("No identityService found for Cloud Region with cloudRegionId " + cloudRegionId + " in Catalog DB");
+ logger.debug("No identityService found for Cloud Region with cloudRegionId {} in Catalog DB", cloudRegionId);
exceptionUtil.buildAndThrowWorkflowException(execution, 404, "No identityService found for Cloud Region with cloudRegionId " + cloudRegionId + " in Catalog DB");
}
String identityUrl = cloudSite.get().getIdentityService().getIdentityUrl();
- msoLogger.debug("identityUrl from Catalog DB is: " + identityUrl);
+ logger.debug("identityUrl from Catalog DB is: {}", identityUrl);
execution.setVariable("identityUrl", identityUrl);
}
}
@@ -73,4 +76,4 @@ public class CloudSiteCatalogUtils {
return(Optional.of(catalogDbClient.getCloudSiteByClliAndAicVersion(id,"2.5")));
}
}
-} \ No newline at end of file
+}