summaryrefslogtreecommitdiffstats
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/pom.xml5
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResource.java10
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowProcessor.java18
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/CXFConfiguration.java10
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/MSOInfrastructureApplication.java6
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfCheckInputs.java57
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/SDNCAdapterCallbackRequestTest.java1
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/WorkflowTest.java22
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResourceExceptionHandlingTest.java78
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AaiConnectionTestImpl.java23
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AaiConnectionThrowingException.java39
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CancelDmaapSubscriptionTest.java49
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CheckAaiForCorrelationIdDelegateTest.java138
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateAaiEntryWithPnfIdDelegateTest.java50
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateAndActivatePnfResourceTest.java (renamed from bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/bpmn/CreateAndActivatePnfResourceTest.java)74
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/DmaapClientTestImpl.java1
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClientTest.java88
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfCheckInputsTest.java84
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClientTest.java197
19 files changed, 155 insertions, 795 deletions
diff --git a/bpmn/mso-infrastructure-bpmn/pom.xml b/bpmn/mso-infrastructure-bpmn/pom.xml
index 151ba2c3aa..77e2fa27d3 100644
--- a/bpmn/mso-infrastructure-bpmn/pom.xml
+++ b/bpmn/mso-infrastructure-bpmn/pom.xml
@@ -201,5 +201,10 @@
<artifactId>so-bpmn-tasks</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.onap.so</groupId>
+ <artifactId>cxf-logging</artifactId>
+ <version>${project.version}</version>
+ </dependency>
</dependencies>
</project>
diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResource.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResource.java
index cfd07d8c39..9ed36e5ba9 100644
--- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResource.java
+++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResource.java
@@ -36,10 +36,12 @@ import javax.ws.rs.ext.Provider;
import org.camunda.bpm.engine.ProcessEngineServices;
import org.camunda.bpm.engine.variable.impl.VariableMapImpl;
+import org.onap.logging.ref.slf4j.ONAPLogConstants;
import org.onap.so.bpmn.common.workflow.context.WorkflowContext;
import org.onap.so.bpmn.common.workflow.context.WorkflowContextHolder;
import org.onap.so.bpmn.common.workflow.context.WorkflowResponse;
import org.onap.so.logger.MsoLogger;
+import org.openecomp.mso.bpmn.common.workflow.service.WorkflowProcessorException;
import org.slf4j.MDC;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -92,7 +94,6 @@ public class WorkflowAsyncResource extends ProcessEngineAwareService {
/**
* Asynchronous JAX-RS method that starts a process instance.
- * @param asyncResponse an object that will receive the asynchronous response
* @param processKey the process key
* @param variableMap input variables to the process
* @return
@@ -110,11 +111,14 @@ public class WorkflowAsyncResource extends ProcessEngineAwareService {
@PathParam("processKey") String processKey, VariableMapImpl variableMap){
Map<String, Object> inputVariables = getInputVariables(variableMap);
try {
- MDC.put(MsoLogger.REQUEST_ID, getRequestId(inputVariables));
+ MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, getRequestId(inputVariables));
processor.startProcess(processKey, variableMap);
WorkflowResponse response = waitForResponse(getRequestId(inputVariables));
return Response.status(202).entity(response).build();
- } catch (Exception e) {
+ } catch (WorkflowProcessorException e) {
+ WorkflowResponse response = e.getWorkflowResponse();
+ return Response.status(500).entity(response).build();
+ }catch (Exception e) {
WorkflowResponse response = buildUnkownError(getRequestId(inputVariables),e.getMessage());
return Response.status(500).entity(response).build();
}
diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowProcessor.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowProcessor.java
index edc05afba2..da24ba14fd 100644
--- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowProcessor.java
+++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowProcessor.java
@@ -28,11 +28,10 @@ import java.util.UUID;
import org.camunda.bpm.engine.RuntimeService;
import org.camunda.bpm.engine.runtime.ProcessInstance;
import org.camunda.bpm.engine.variable.impl.VariableMapImpl;
-import org.onap.so.bpmn.common.workflow.context.WorkflowCallbackResponse;
-import org.onap.so.bpmn.common.workflow.context.WorkflowContextHolder;
+import org.onap.so.bpmn.common.workflow.context.WorkflowResponse;
import org.onap.so.logger.MsoLogger;
+import org.openecomp.mso.bpmn.common.workflow.service.WorkflowProcessorException;
import org.slf4j.MDC;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
@@ -79,13 +78,12 @@ public class WorkflowProcessor extends ProcessEngineAwareService {
msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError,
logMarker + "Error in starting the process: " + e.getMessage());
- WorkflowCallbackResponse callbackResponse = new WorkflowCallbackResponse();
- callbackResponse.setStatusCode(500);
- callbackResponse.setMessage("Fail");
- callbackResponse.setResponse("Error occurred while executing the process: " + e);
-
- WorkflowContextHolder.getInstance().processCallback(processKey, processInstanceId,
- getRequestId(inputVariables), callbackResponse);
+ WorkflowResponse workflowResponse = new WorkflowResponse();
+ workflowResponse.setResponse("Error occurred while executing the process: " + e);
+ workflowResponse.setProcessInstanceID(processInstanceId);
+ workflowResponse.setMessageCode(500);
+ workflowResponse.setMessage("Fail");
+ throw new WorkflowProcessorException(workflowResponse);
}
}
diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/CXFConfiguration.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/CXFConfiguration.java
index 8fe7ebe93a..62be1330b1 100644
--- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/CXFConfiguration.java
+++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/CXFConfiguration.java
@@ -37,7 +37,9 @@ import org.onap.so.bpmn.common.workflow.service.WorkflowAsyncResource;
import org.onap.so.bpmn.common.workflow.service.WorkflowMessageResource;
import org.onap.so.bpmn.common.workflow.service.WorkflowResource;
import org.onap.so.logger.MsoLogger;
-import org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging;
+import org.onap.so.logging.cxf.interceptor.SOAPLoggingInInterceptor;
+import org.onap.so.logging.cxf.interceptor.SOAPLoggingOutInterceptor;
+import org.onap.so.logging.jaxrs.filter.JaxRsFilterLogging;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
@@ -85,6 +87,9 @@ public class CXFConfiguration {
public Endpoint vnfAdapterCallback() {
EndpointImpl endpoint = new EndpointImpl(bus, vnfAdapterNotifyServiceImpl);
endpoint.publish("/VNFAdaptercallback");
+ endpoint.getInInterceptors().add(new SOAPLoggingInInterceptor());
+ endpoint.getOutInterceptors().add(new SOAPLoggingOutInterceptor());
+ endpoint.getOutFaultInterceptors().add(new SOAPLoggingOutInterceptor());
return endpoint;
}
@@ -92,6 +97,9 @@ public class CXFConfiguration {
public Endpoint sndcAdapterCallback() {
EndpointImpl endpoint = new EndpointImpl(bus, sdncAdapterCallbackServiceImpl);
endpoint.publish("/SDNCAdapterCallbackService");
+ endpoint.getInInterceptors().add(new SOAPLoggingInInterceptor());
+ endpoint.getOutInterceptors().add(new SOAPLoggingOutInterceptor());
+ endpoint.getOutFaultInterceptors().add(new SOAPLoggingOutInterceptor());
return endpoint;
}
diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/MSOInfrastructureApplication.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/MSOInfrastructureApplication.java
index c263fe636c..db2304d6b7 100644
--- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/MSOInfrastructureApplication.java
+++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/MSOInfrastructureApplication.java
@@ -29,9 +29,7 @@ import org.camunda.bpm.application.ProcessApplicationInfo;
import org.camunda.bpm.engine.ProcessEngine;
import org.camunda.bpm.spring.boot.starter.annotation.EnableProcessApplication;
import org.onap.so.bpmn.common.DefaultToShortClassNameBeanNameGenerator;
-import org.onap.so.db.request.data.repository.InfraActiveRequestsRepositoryImpl;
import org.onap.so.logger.MsoLogger;
-import org.onap.so.requestsdb.RequestsDBHelper;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@@ -52,9 +50,7 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
@EnableProcessApplication("MSO Infrastructure Application")
@EnableAsync
@ComponentScan(basePackages = { "org.onap" }, nameGenerator = DefaultToShortClassNameBeanNameGenerator.class, excludeFilters = {
- @Filter(type = FilterType.ANNOTATION, classes = SpringBootApplication.class),
- @Filter(type = FilterType.ASSIGNABLE_TYPE, classes = RequestsDBHelper.class),
- @Filter(type = FilterType.ASSIGNABLE_TYPE, classes = InfraActiveRequestsRepositoryImpl.class) })
+ @Filter(type = FilterType.ANNOTATION, classes = SpringBootApplication.class) })
public class MSOInfrastructureApplication {
private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL,
diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfCheckInputs.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfCheckInputs.java
deleted file mode 100644
index e4866f5334..0000000000
--- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfCheckInputs.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.infrastructure.pnf.delegate;
-
-import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.CORRELATION_ID;
-import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.TIMEOUT_FOR_NOTIFICATION;
-
-import org.camunda.bpm.engine.delegate.DelegateExecution;
-import org.camunda.bpm.engine.delegate.JavaDelegate;
-import org.onap.so.bpmn.common.scripts.ExceptionUtil;
-import org.onap.so.logger.MsoLogger;
-
-public class PnfCheckInputs implements JavaDelegate {
-
- private static MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.GENERAL, PnfCheckInputs.class);
-
- private String defaultTimeout;
-
- @Override
- public void execute(DelegateExecution execution) throws Exception {
- String correlationId = (String) execution.getVariable(CORRELATION_ID);
- if (correlationId == null) {
- new ExceptionUtil().buildAndThrowWorkflowException(execution, 9999, "correlationId variable not defined");
- }
- String timeout = (String) execution.getVariable(TIMEOUT_FOR_NOTIFICATION);
- if (timeout == null) {
- LOGGER.debug("timeoutForPnfEntryNotification variable not found, setting default");
- if (defaultTimeout == null) {
- new ExceptionUtil().buildAndThrowWorkflowException(execution, 9999,
- "default timeoutForPnfEntryNotification value not defined");
- }
- execution.setVariable(TIMEOUT_FOR_NOTIFICATION, defaultTimeout);
- }
- }
-
- public void setDefaultTimeout(String defaultTimeout) {
- this.defaultTimeout = defaultTimeout;
- }
-}
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/SDNCAdapterCallbackRequestTest.java b/bpmn/mso-infrastructure-bpmn/src/test/java/SDNCAdapterCallbackRequestTest.java
index 9843a95342..884c2ac9c6 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/SDNCAdapterCallbackRequestTest.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/SDNCAdapterCallbackRequestTest.java
@@ -23,7 +23,6 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import org.junit.Test;
-import org.onap.so.BaseTest;
import org.onap.so.bpmn.common.adapter.sdnc.CallbackHeader;
import org.onap.so.bpmn.common.adapter.sdnc.SDNCAdapterCallbackRequest;
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/WorkflowTest.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/WorkflowTest.java
index 8ebc80c4c2..041afe398b 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/WorkflowTest.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/WorkflowTest.java
@@ -141,7 +141,8 @@ public abstract class WorkflowTest {
*/
protected static final String JSON = "application/json; charset=UTF-8";
-
+ private static final int timeout = 2000;
+
/**
* Constructor.
*/
@@ -580,10 +581,27 @@ public abstract class WorkflowTest {
* reserve, assign, delete:ERR
* </pre>
* Errors are handled with junit assertions and will cause the test to fail.
+ * Uses the static/default timeout value for backward compatibility.
* @param callbacks an object containing callback data for the program
* @param program the program to execute
*/
protected void injectSDNCCallbacks(CallbackSet callbacks, String program) {
+ injectSDNCCallbacks(callbacks, program, timeout);
+ }
+
+ /**
+ * Runs a program to inject SDNC callback data into the test environment.
+ * A program is essentially just a list of keys that identify callback data
+ * to be injected, in sequence. An example program:
+ * <pre>
+ * reserve, assign, delete:ERR
+ * </pre>
+ * Errors are handled with junit assertions and will cause the test to fail.
+ * @param callbacks an object containing callback data for the program
+ * @param program the program to execute
+ * @param timeout a timeout value to wait for the callback
+ */
+ protected void injectSDNCCallbacks(CallbackSet callbacks, String program, int timeout) {
String[] cmds = program.replaceAll("\\s+", "").split(",");
@@ -1487,7 +1505,7 @@ public abstract class WorkflowTest {
for(Resource resource:resourceList){
resourceId = resource.getResourceId();
}
- String homingList = getJsonValue(content, "solutionInfo.placement");
+ String homingList = getJsonValue(content, "solutionInfo.placementInfo");
JSONArray placementArr = null;
try {
placementArr = new JSONArray(homingList);
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResourceExceptionHandlingTest.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResourceExceptionHandlingTest.java
new file mode 100644
index 0000000000..ff5e18c210
--- /dev/null
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResourceExceptionHandlingTest.java
@@ -0,0 +1,78 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+import javax.ws.rs.core.Response;
+
+import org.camunda.bpm.engine.test.Deployment;
+import org.camunda.bpm.engine.variable.impl.VariableMapImpl;
+import org.junit.Test;
+import org.onap.so.bpmn.common.workflow.context.WorkflowResponse;
+
+
+public class WorkflowAsyncResourceExceptionHandlingTest {
+
+ @Test
+ @Deployment(resources = { "testAsyncResource.bpmn" })
+ public void asyncRequestSuccess() throws InterruptedException {
+ VariableMapImpl variableMap = new VariableMapImpl();
+
+ Map<String, Object> variableValueType = new HashMap<>();
+
+ Map<String, Object> requestMsg = new HashMap<>();
+ requestMsg.put("value", "");
+ requestMsg.put("type", "String");
+
+ Map<String, Object> msorequestId = new HashMap<>();
+ msorequestId.put("type", "String");
+ msorequestId.put("value",UUID.randomUUID().toString());
+
+ Map<String, Object> timeout = new HashMap<>();
+ timeout.put("type", "String");
+ timeout.put("value","5");
+
+ variableValueType.put("testAsyncRequestMsg", requestMsg);
+ variableValueType.put("mso-request-id", msorequestId);
+ variableValueType.put("mso-service-request-timeout", timeout);
+
+ variableMap.put("variables", variableValueType);
+ WorkflowAsyncResource workflowAsyncResource = new WorkflowAsyncResource();
+ workflowAsyncResource.setProcessor(new WorkflowProcessor());
+ Response res = workflowAsyncResource.startProcessInstanceByKey("randomKey", variableMap);
+ assertEquals(500,res.getStatus());
+ WorkflowResponse workflowResponse = (WorkflowResponse)res.getEntity();
+ assertNotNull(workflowResponse);
+ assertEquals(500, workflowResponse.getMessageCode());
+ assertTrue(workflowResponse.getResponse().startsWith("Error occurred while executing the process:"));
+ assertEquals("Fail", workflowResponse.getMessage());
+
+
+ }
+
+}
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AaiConnectionTestImpl.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AaiConnectionTestImpl.java
index 7cb649d66e..201e791a24 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AaiConnectionTestImpl.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AaiConnectionTestImpl.java
@@ -20,38 +20,25 @@
package org.onap.so.bpmn.infrastructure.pnf.delegate;
+import org.onap.aai.domain.yang.Pnf;
+import org.onap.so.bpmn.infrastructure.pnf.implementation.AaiConnection;
+
import java.io.IOException;
import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
-import org.onap.aai.domain.yang.Pnf;
-import org.onap.so.bpmn.infrastructure.pnf.implementation.AaiConnection;
public class AaiConnectionTestImpl implements AaiConnection {
- public static final String ID_WITH_ENTRY_AND_IP = "idWithEntryAndIp";
- public static final String ID_WITH_IP_V6 = "idWithIpV6";
public static final String ID_WITHOUT_ENTRY = "IdWithoutEntry";
- public static final String ID_WITH_ENTRY_NO_IP = "idWithEntryNoIp";
- public static final String DEFAULT_IP = "1.2.3.4";
- public static final String DEFAULT_IP_V6 = "2001:db8::ff00:42:8329";
+ public static final String ID_WITH_ENTRY = "idWithEntryNoIp";
private Map<String, Pnf> created = new HashMap<>();
@Override
public Optional<Pnf> getEntryFor(String correlationId) throws IOException {
- if (Objects.equals(correlationId, ID_WITH_ENTRY_AND_IP)) {
- Pnf pnf = new Pnf();
- pnf.setIpaddressV4Oam(DEFAULT_IP);
- return Optional.of(pnf);
- } else if (Objects.equals(correlationId, ID_WITH_IP_V6)) {
- Pnf pnf = new Pnf();
- pnf.setIpaddressV6Oam(DEFAULT_IP_V6);
- return Optional.of(pnf);
- } else if (Objects.equals(correlationId, ID_WITH_ENTRY_NO_IP)) {
+ if (Objects.equals(correlationId, ID_WITH_ENTRY)) {
return Optional.of(new Pnf());
} else {
return Optional.empty();
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AaiConnectionThrowingException.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AaiConnectionThrowingException.java
deleted file mode 100644
index 7df6757817..0000000000
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AaiConnectionThrowingException.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.infrastructure.pnf.delegate;
-
-import java.io.IOException;
-import java.util.Optional;
-import org.onap.aai.domain.yang.Pnf;
-import org.onap.so.bpmn.infrastructure.pnf.implementation.AaiConnection;
-
-public class AaiConnectionThrowingException implements AaiConnection {
-
- @Override
- public Optional<Pnf> getEntryFor(String correlationId) throws IOException {
- throw new IOException();
- }
-
- @Override
- public void createEntry(String correlationId, Pnf entry) throws IOException {
- throw new IOException();
- }
-}
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CancelDmaapSubscriptionTest.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CancelDmaapSubscriptionTest.java
deleted file mode 100644
index 4282b0f2bb..0000000000
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CancelDmaapSubscriptionTest.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.infrastructure.pnf.delegate;
-
-import org.camunda.bpm.engine.delegate.DelegateExecution;
-import org.junit.Test;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-public class CancelDmaapSubscriptionTest {
-
- @Test
- public void shouldCancelSubscription() throws Exception {
- // given
- CancelDmaapSubscription delegate = new CancelDmaapSubscription();
- DmaapClientTestImpl dmaapClientTest = new DmaapClientTestImpl();
- delegate.setDmaapClient(dmaapClientTest);
- DelegateExecution delegateExecution = mock(DelegateExecution.class);
- when(delegateExecution.getVariable(eq(ExecutionVariableNames.CORRELATION_ID))).thenReturn("testCorrelationId");
- when(delegateExecution.getProcessBusinessKey()).thenReturn("testBusinessKey");
- dmaapClientTest.registerForUpdate("testCorrelationId", () -> {
- });
- // when
- delegate.execute(delegateExecution);
- // then
- assertThat(dmaapClientTest.haveRegisteredConsumer()).isFalse();
- }
-} \ No newline at end of file
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CheckAaiForCorrelationIdDelegateTest.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CheckAaiForCorrelationIdDelegateTest.java
deleted file mode 100644
index 627e57bfb8..0000000000
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CheckAaiForCorrelationIdDelegateTest.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.infrastructure.pnf.delegate;
-
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-import static org.onap.so.bpmn.infrastructure.pnf.delegate.AaiConnectionTestImpl.ID_WITHOUT_ENTRY;
-import static org.onap.so.bpmn.infrastructure.pnf.delegate.AaiConnectionTestImpl.ID_WITH_ENTRY_AND_IP;
-import static org.onap.so.bpmn.infrastructure.pnf.delegate.AaiConnectionTestImpl.ID_WITH_ENTRY_NO_IP;
-import static org.onap.so.bpmn.infrastructure.pnf.delegate.AaiConnectionTestImpl.ID_WITH_IP_V6;
-import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.AAI_CONTAINS_INFO_ABOUT_IP;
-import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.AAI_CONTAINS_INFO_ABOUT_PNF;
-import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.CORRELATION_ID;
-
-import org.camunda.bpm.engine.delegate.BpmnError;
-import org.camunda.bpm.engine.delegate.DelegateExecution;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.experimental.runners.Enclosed;
-import org.junit.runner.RunWith;
-import org.onap.so.bpmn.core.WorkflowException;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.junit4.SpringRunner;
-
-@RunWith(Enclosed.class)
-public class CheckAaiForCorrelationIdDelegateTest {
-
- public static class ConnectionOkTests {
-
- private CheckAaiForCorrelationIdDelegate delegate;
-
- @Before
- public void setUp() {
- delegate = new CheckAaiForCorrelationIdDelegate();
- delegate.setAaiConnection(new AaiConnectionTestImpl());
- }
-
- @Test
- public void shouldThrowExceptionWhenCorrelationIdIsNotSet() {
- // given
- DelegateExecution execution = mock(DelegateExecution.class);
- when(execution.getVariable(CORRELATION_ID)).thenReturn(null);
- when(execution.getVariable("testProcessKey")).thenReturn("testProcessKeyValue");
- // when, then
- assertThatThrownBy(() -> delegate.execute(execution)).isInstanceOf(BpmnError.class);
- verify(execution).setVariable(eq("WorkflowException"), any(WorkflowException.class));
- }
-
- @Test
- public void shouldSetCorrectVariablesWhenAaiDoesNotContainInfoAboutPnf() throws Exception {
- // given
- DelegateExecution execution = mock(DelegateExecution.class);
- when(execution.getVariable(CORRELATION_ID)).thenReturn(ID_WITHOUT_ENTRY);
- // when
- delegate.execute(execution);
- // then
- verify(execution).setVariableLocal(AAI_CONTAINS_INFO_ABOUT_PNF, false);
- }
-
- @Test
- public void shouldSetCorrectVariablesWhenAaiContainsInfoAboutPnf() throws Exception {
- shouldSetCorrectVariablesWhenAaiContainsInfoAboutPnf(ID_WITH_ENTRY_AND_IP);
- }
-
- @Test
- public void shouldSetCorrectVariablesWhenAaiContainsInfoAboutPnfWithIpV6() throws Exception {
- shouldSetCorrectVariablesWhenAaiContainsInfoAboutPnf(ID_WITH_IP_V6);
- }
-
- private void shouldSetCorrectVariablesWhenAaiContainsInfoAboutPnf(String id) throws Exception {
- // given
- DelegateExecution execution = mock(DelegateExecution.class);
- when(execution.getVariable(CORRELATION_ID)).thenReturn(id);
- // when
- delegate.execute(execution);
- // then
- verify(execution).setVariableLocal(AAI_CONTAINS_INFO_ABOUT_PNF, true);
- verify(execution).setVariableLocal(AAI_CONTAINS_INFO_ABOUT_IP, true);
- }
-
- @Test
- public void shouldSetCorrectVariablesWhenAaiContainsInfoAboutPnfWithoutIp() throws Exception {
- // given
- DelegateExecution execution = mock(DelegateExecution.class);
- when(execution.getVariable(CORRELATION_ID)).thenReturn(ID_WITH_ENTRY_NO_IP);
- // when
- delegate.execute(execution);
- // then
- verify(execution).setVariableLocal(AAI_CONTAINS_INFO_ABOUT_PNF, true);
- verify(execution).setVariableLocal(AAI_CONTAINS_INFO_ABOUT_IP, false);
- }
- }
-
- public static class NoConnectionTests {
-
- private CheckAaiForCorrelationIdDelegate delegate;
-
- @Before
- public void setUp() {
- delegate = new CheckAaiForCorrelationIdDelegate();
- delegate.setAaiConnection(new AaiConnectionThrowingException());
- }
-
- @Test
- public void shouldThrowExceptionWhenIoExceptionOnConnectionToAai() {
- // given
- DelegateExecution execution = mock(DelegateExecution.class);
- when(execution.getVariable(CORRELATION_ID)).thenReturn(ID_WITH_ENTRY_NO_IP);
- when(execution.getVariable("testProcessKey")).thenReturn("testProcessKey");
- // when, then
- assertThatThrownBy(() -> delegate.execute(execution)).isInstanceOf(BpmnError.class);
- verify(execution).setVariable(eq("WorkflowException"), any(WorkflowException.class));
- }
- }
-} \ No newline at end of file
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateAaiEntryWithPnfIdDelegateTest.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateAaiEntryWithPnfIdDelegateTest.java
deleted file mode 100644
index 465dc085fc..0000000000
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateAaiEntryWithPnfIdDelegateTest.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.infrastructure.pnf.delegate;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.CORRELATION_ID;
-
-import org.camunda.bpm.engine.delegate.DelegateExecution;
-import org.junit.Test;
-import org.onap.aai.domain.yang.Pnf;
-
-public class CreateAaiEntryWithPnfIdDelegateTest {
-
- @Test
- public void shouldSetPnfIdAndPnfName() throws Exception {
- // given
- CreateAaiEntryWithPnfIdDelegate delegate = new CreateAaiEntryWithPnfIdDelegate();
- AaiConnectionTestImpl aaiConnection = new AaiConnectionTestImpl();
- delegate.setAaiConnection(aaiConnection);
- DelegateExecution execution = mock(DelegateExecution.class);
- when(execution.getVariable(eq(CORRELATION_ID))).thenReturn("testCorrelationId");
- // when
- delegate.execute(execution);
- // then
- Pnf createdEntry = aaiConnection.getCreated().get("testCorrelationId");
- assertThat(createdEntry.getPnfId()).isEqualTo("testCorrelationId");
- assertThat(createdEntry.getPnfName()).isEqualTo("testCorrelationId");
- assertThat(createdEntry.isInMaint()).isTrue();
- }
-} \ No newline at end of file
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/bpmn/CreateAndActivatePnfResourceTest.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateAndActivatePnfResourceTest.java
index b514c38d47..2348af5dec 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/bpmn/CreateAndActivatePnfResourceTest.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateAndActivatePnfResourceTest.java
@@ -7,9 +7,9 @@
* 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.
@@ -18,33 +18,27 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.so.bpmn.infrastructure.pnf.delegate.bpmn;
+package org.onap.so.bpmn.infrastructure.pnf.delegate;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.camunda.bpm.engine.test.assertions.ProcessEngineAssertions.assertThat;
-import static org.onap.so.bpmn.infrastructure.pnf.delegate.AaiConnectionTestImpl.ID_WITHOUT_ENTRY;
-import static org.onap.so.bpmn.infrastructure.pnf.delegate.AaiConnectionTestImpl.ID_WITH_ENTRY_AND_IP;
-import static org.onap.so.bpmn.infrastructure.pnf.delegate.AaiConnectionTestImpl.ID_WITH_ENTRY_NO_IP;
-import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.CORRELATION_ID;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import org.assertj.core.api.Assertions;
import org.camunda.bpm.engine.RuntimeService;
-import org.camunda.bpm.engine.history.HistoricVariableInstance;
import org.camunda.bpm.engine.runtime.ProcessInstance;
import org.camunda.bpm.engine.test.Deployment;
import org.camunda.bpm.engine.test.ProcessEngineRule;
+import org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions;
import org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareTests;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.onap.so.bpmn.infrastructure.pnf.delegate.AaiConnectionTestImpl;
-import org.onap.so.bpmn.infrastructure.pnf.delegate.DmaapClientTestImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.CORRELATION_ID;
+
@RunWith(SpringRunner.class)
@ContextConfiguration(locations = "/applicationContext_forPnfTesting.xml")
public class CreateAndActivatePnfResourceTest {
@@ -65,47 +59,25 @@ public class CreateAndActivatePnfResourceTest {
@Test
@Deployment(resources = {"process/CreateAndActivatePnfResource.bpmn"})
- public void shouldSaveCurrentIpToVariableIfItAlreadyExistsInAai() throws Exception {
+ public void shouldWaitForMessageFromDmaapAndUpdateAaiEntryWhenAaiEntryExists() {
// given
aaiConnection.reset();
BpmnAwareTests.init(processEngineRule.getProcessEngine());
Map<String, Object> variables = new HashMap<>();
variables.put("timeoutForPnfEntryNotification", TIMEOUT_10_S);
- variables.put(CORRELATION_ID, ID_WITH_ENTRY_AND_IP);
- // when
- ProcessInstance instance = runtimeService
- .startProcessInstanceByKey("CreateAndActivatePnfResource", variables);
- // then
- assertThat(instance).isEnded().hasPassedInOrder(
- "CreateAndActivatePnf_StartEvent",
- "CheckAiiForCorrelationId",
- "DoesAaiContainInfoAboutPnf",
- "DoesAaiContainInfoAboutIp",
- "AaiEntryAlreadyUpToDate"
- );
- }
-
- @Test
- @Deployment(resources = {"process/CreateAndActivatePnfResource.bpmn"})
- public void shouldWaitForMessageFromDmaapAndUpdateAaiEntryWhenIpIsMissingInAaiEntry() throws Exception {
- // given
- aaiConnection.reset();
- BpmnAwareTests.init(processEngineRule.getProcessEngine());
- Map<String, Object> variables = new HashMap<>();
- variables.put("timeoutForPnfEntryNotification", TIMEOUT_10_S);
- variables.put(CORRELATION_ID, ID_WITH_ENTRY_NO_IP);
+ variables.put(CORRELATION_ID, AaiConnectionTestImpl.ID_WITH_ENTRY);
// when
ProcessInstance instance = runtimeService
.startProcessInstanceByKey("CreateAndActivatePnfResource", "businessKey", variables);
- assertThat(instance).isWaitingAt("WaitForDmaapPnfReadyNotification").isWaitingFor("WorkflowMessage");
+ BpmnAwareAssertions.assertThat(instance).isWaitingAt("WaitForDmaapPnfReadyNotification").isWaitingFor("WorkflowMessage");
dmaapClientTestImpl.sendMessage();
// then
- assertThat(instance).isEnded().hasPassedInOrder(
+ BpmnAwareAssertions.assertThat(instance).isEnded().hasPassedInOrder(
"CreateAndActivatePnf_StartEvent",
+ "CheckInputs",
"CheckAiiForCorrelationId",
"DoesAaiContainInfoAboutPnf",
- "DoesAaiContainInfoAboutIp",
"AaiEntryExists",
"InformDmaapClient",
"WaitForDmaapPnfReadyNotification",
@@ -115,22 +87,23 @@ public class CreateAndActivatePnfResourceTest {
@Test
@Deployment(resources = {"process/CreateAndActivatePnfResource.bpmn"})
- public void shouldCreateAaiEntryWaitForMessageFromDmaapAndUpdateAaiEntryWhenNoAaiEntry() throws Exception {
+ public void shouldCreateAaiEntryWaitForMessageFromDmaapAndUpdateAaiEntryWhenNoAaiEntryExists() {
// given
aaiConnection.reset();
BpmnAwareTests.init(processEngineRule.getProcessEngine());
Map<String, Object> variables = new HashMap<>();
variables.put("timeoutForPnfEntryNotification", TIMEOUT_10_S);
- variables.put(CORRELATION_ID, ID_WITHOUT_ENTRY);
+ variables.put(CORRELATION_ID, AaiConnectionTestImpl.ID_WITHOUT_ENTRY);
// when
ProcessInstance instance = runtimeService
.startProcessInstanceByKey("CreateAndActivatePnfResource", "businessKey", variables);
- assertThat(instance).isWaitingAt("WaitForDmaapPnfReadyNotification").isWaitingFor("WorkflowMessage");
+ BpmnAwareAssertions.assertThat(instance).isWaitingAt("WaitForDmaapPnfReadyNotification").isWaitingFor("WorkflowMessage");
dmaapClientTestImpl.sendMessage();
// then
- assertThat(instance).isEnded().hasPassedInOrder(
+ BpmnAwareAssertions.assertThat(instance).isEnded().hasPassedInOrder(
"CreateAndActivatePnf_StartEvent",
+ "CheckInputs",
"CheckAiiForCorrelationId",
"DoesAaiContainInfoAboutPnf",
"CreateAndActivatePnf_CreateAaiEntry",
@@ -139,11 +112,6 @@ public class CreateAndActivatePnfResourceTest {
"WaitForDmaapPnfReadyNotification",
"AaiEntryUpdated"
);
- assertThat(aaiConnection.getCreated()).containsOnlyKeys(ID_WITHOUT_ENTRY);
- }
-
- private List<HistoricVariableInstance> getVariables(ProcessInstance instance) {
- return processEngineRule.getHistoryService().createHistoricVariableInstanceQuery()
- .processInstanceId(instance.getProcessInstanceId()).taskIdIn().list();
+ Assertions.assertThat(aaiConnection.getCreated()).containsOnlyKeys(AaiConnectionTestImpl.ID_WITHOUT_ENTRY);
}
}
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/DmaapClientTestImpl.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/DmaapClientTestImpl.java
index f2a4205ebd..09fb2d4cd7 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/DmaapClientTestImpl.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/DmaapClientTestImpl.java
@@ -21,6 +21,7 @@
package org.onap.so.bpmn.infrastructure.pnf.delegate;
import org.onap.so.bpmn.infrastructure.pnf.dmaap.DmaapClient;
+
import java.util.Objects;
public class DmaapClientTestImpl implements DmaapClient {
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClientTest.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClientTest.java
deleted file mode 100644
index ddf33a1d77..0000000000
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClientTest.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.infrastructure.pnf.delegate;
-
-import org.camunda.bpm.engine.ProcessEngineServices;
-import org.camunda.bpm.engine.RuntimeService;
-import org.camunda.bpm.engine.delegate.DelegateExecution;
-import org.camunda.bpm.engine.runtime.MessageCorrelationBuilder;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.InOrder;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.*;
-
-public class InformDmaapClientTest {
- @Before
- public void setUp() throws Exception {
- informDmaapClient = new InformDmaapClient();
- dmaapClientTest = new DmaapClientTestImpl();
- informDmaapClient.setDmaapClient(dmaapClientTest);
- delegateExecution = mockDelegateExecution();
- }
-
- private InformDmaapClient informDmaapClient;
-
- private DmaapClientTestImpl dmaapClientTest;
-
- private DelegateExecution delegateExecution;
-
- private MessageCorrelationBuilder messageCorrelationBuilder;
-
- @Test
- public void shouldSendListenerToDmaapClient() throws Exception {
- // when
- informDmaapClient.execute(delegateExecution);
- // then
- assertThat(dmaapClientTest.getCorrelationId()).isEqualTo("testCorrelationId");
- assertThat(dmaapClientTest.getInformConsumer()).isNotNull();
- verifyZeroInteractions(messageCorrelationBuilder);
- }
-
- @Test
- public void shouldSendListenerToDmaapClientAndSendMessageToCamunda() throws Exception {
- // when
- informDmaapClient.execute(delegateExecution);
- dmaapClientTest.getInformConsumer().run();
- // then
- assertThat(dmaapClientTest.getCorrelationId()).isEqualTo("testCorrelationId");
- InOrder inOrder = inOrder(messageCorrelationBuilder);
- inOrder.verify(messageCorrelationBuilder).processInstanceBusinessKey("testBusinessKey");
- inOrder.verify(messageCorrelationBuilder).correlateWithResult();
- }
-
- private DelegateExecution mockDelegateExecution() {
- DelegateExecution delegateExecution = mock(DelegateExecution.class);
- when(delegateExecution.getVariable(eq(ExecutionVariableNames.CORRELATION_ID))).thenReturn("testCorrelationId");
- when(delegateExecution.getProcessBusinessKey()).thenReturn("testBusinessKey");
- ProcessEngineServices processEngineServices = mock(ProcessEngineServices.class);
- when(delegateExecution.getProcessEngineServices()).thenReturn(processEngineServices);
- RuntimeService runtimeService = mock(RuntimeService.class);
- when(processEngineServices.getRuntimeService()).thenReturn(runtimeService);
- messageCorrelationBuilder = mock(MessageCorrelationBuilder.class);
- when(runtimeService.createMessageCorrelation(any())).thenReturn(messageCorrelationBuilder);
- when(messageCorrelationBuilder.processInstanceBusinessKey(any())).thenReturn(messageCorrelationBuilder);
- return delegateExecution;
- }
-} \ No newline at end of file
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfCheckInputsTest.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfCheckInputsTest.java
deleted file mode 100644
index aab289fd90..0000000000
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfCheckInputsTest.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.infrastructure.pnf.delegate;
-
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.CORRELATION_ID;
-import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.TIMEOUT_FOR_NOTIFICATION;
-
-import org.camunda.bpm.engine.delegate.BpmnError;
-import org.camunda.bpm.engine.delegate.DelegateExecution;
-import org.junit.Before;
-import org.junit.Test;
-
-public class PnfCheckInputsTest {
-
- private PnfCheckInputs delegate;
-
- @Before
- public void setUp() throws Exception {
- delegate = new PnfCheckInputs();
- }
-
- private DelegateExecution mockDelegateExecution() {
- DelegateExecution delegateExecution = mock(DelegateExecution.class);
- when(delegateExecution.getVariable("testProcessKey")).thenReturn("testProcessKeyValue");
- return delegateExecution;
- }
-
- @Test
- public void shouldThrowException_whenPnfIdNotSet() throws Exception {
- // given
- DelegateExecution delegateExecution = mockDelegateExecution();
- // when, then
- assertThatThrownBy(() -> delegate.execute(delegateExecution)).isInstanceOf(BpmnError.class);
- }
-
- private DelegateExecution mockDelegateExecutionWithCorrelationId() {
- DelegateExecution delegateExecution = mockDelegateExecution();
- when(delegateExecution.getVariable(CORRELATION_ID)).thenReturn("testCorrelationId");
- return delegateExecution;
- }
-
- @Test
- public void shouldThrowException_whenTimeoutIsNotSetAndDefaultIsNotDefined() throws Exception {
- // given
- DelegateExecution delegateExecution = mockDelegateExecutionWithCorrelationId();
- // when, then
- assertThatThrownBy(() -> delegate.execute(delegateExecution)).isInstanceOf(BpmnError.class);
- }
-
- @Test
- public void shouldSetDefaultTimeout_whenTimeoutIsNotSet() throws Exception {
- // given
- String defaultTimeout = "T1D";
- delegate.setDefaultTimeout(defaultTimeout);
- DelegateExecution delegateExecution = mockDelegateExecutionWithCorrelationId();
- // when
- delegate.execute(delegateExecution);
- // then
- verify(delegateExecution).setVariable(eq(TIMEOUT_FOR_NOTIFICATION), eq(defaultTimeout));
- }
-} \ No newline at end of file
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClientTest.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClientTest.java
deleted file mode 100644
index 08ac9b6948..0000000000
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClientTest.java
+++ /dev/null
@@ -1,197 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.infrastructure.pnf.dmaap;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyZeroInteractions;
-import static org.mockito.Mockito.when;
-
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.lang.reflect.Field;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ScheduledExecutorService;
-
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpResponse;
-import org.apache.http.ProtocolVersion;
-import org.apache.http.client.HttpClient;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.message.BasicHttpResponse;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.ArgumentCaptor;
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
-import org.mockito.runners.MockitoJUnitRunner;
-import org.onap.so.bpmn.infrastructure.pnf.dmaap.PnfEventReadyDmaapClient.DmaapTopicListenerThread;
-import org.springframework.core.env.Environment;
-@RunWith(MockitoJUnitRunner.class)
-public class PnfEventReadyDmaapClientTest {
-
- private static final String CORRELATION_ID = "corrTestId";
- private static final String CORRELATION_ID_NOT_FOUND_IN_MAP = "otherCorrId";
- private static final String JSON_EXAMPLE_WITH_CORRELATION_ID = "[\n"
- + " {\n"
- + " \"pnfRegistrationFields\" : {\n"
- + " \"correlationId\" : \"%s\",\n"
- + " \"value\" : \"value1\"\n"
- + " }\n"
- + " },\n"
- + " {\n"
- + " \"pnfRegistrationFields\" : {\n"
- + " \"correlationId\" : \"corr\",\n"
- + " \"value\" : \"value2\"\n"
- + " }\n"
- + " }\n"
- + "]";
- private static final String JSON_EXAMPLE_WITH_NO_CORRELATION_ID =
- "{\"pnfRegistrationFields\":{\"field\":\"value\"}}";
-
- private static final String HOST = "hostTest";
- private static final int PORT = 1234;
- private static final String PROTOCOL = "http";
- private static final String URI_PATH_PREFIX = "eventsForTesting";
- private static final String EVENT_TOPIC_TEST = "eventTopicTest";
- private static final String CONSUMER_ID = "consumerTestId";
- private static final String CONSUMER_GROUP = "consumerGroupTest";
- @Mock
- private Environment env;
- @InjectMocks
- private PnfEventReadyDmaapClient testedObject = new PnfEventReadyDmaapClient();
-;
- private DmaapTopicListenerThread testedObjectInnerClassThread;
- private HttpClient httpClientMock;
- private Runnable threadMockToNotifyCamundaFlow;
- private ScheduledExecutorService executorMock;
-
- @Before
- public void init() throws NoSuchFieldException, IllegalAccessException {
- when(env.getProperty(eq("pnf.dmaap.port"), eq(Integer.class))).thenReturn(PORT);
- when(env.getProperty(eq("pnf.dmaap.host"))).thenReturn(HOST);
- testedObject.setDmaapProtocol(PROTOCOL);
- testedObject.setDmaapUriPathPrefix(URI_PATH_PREFIX);
- testedObject.setDmaapTopicName(EVENT_TOPIC_TEST);
- testedObject.setConsumerId(CONSUMER_ID);
- testedObject.setConsumerGroup(CONSUMER_GROUP);
- testedObject.setDmaapClientDelayInSeconds(1);
- testedObject.init();
- testedObjectInnerClassThread = testedObject.new DmaapTopicListenerThread();
- httpClientMock = mock(HttpClient.class);
- threadMockToNotifyCamundaFlow = mock(Runnable.class);
- executorMock = mock(ScheduledExecutorService.class);
- setPrivateField();
- }
-
- /**
- * Test run method, where the are following conditions:
- * <p> - DmaapThreadListener is running, flag is set to true
- * <p> - map is filled with one entry with the key that we get from response
- * <p> run method should invoke thread from map to notify camunda process, remove element from the map (map is
- * empty) and shutdown the executor because of empty map
- */
- @Test
- public void correlationIdIsFoundInHttpResponse_notifyAboutPnfReady()
- throws IOException {
- when(httpClientMock.execute(any(HttpGet.class))).
- thenReturn(createResponse(String.format(JSON_EXAMPLE_WITH_CORRELATION_ID, CORRELATION_ID)));
- testedObjectInnerClassThread.run();
- ArgumentCaptor<HttpGet> captor1 = ArgumentCaptor.forClass(HttpGet.class);
- verify(httpClientMock).execute(captor1.capture());
- assertThat(captor1.getValue().getURI()).hasHost(HOST).hasPort(PORT).hasScheme(PROTOCOL)
- .hasPath(
- "/" + URI_PATH_PREFIX + "/" + EVENT_TOPIC_TEST + "/" + CONSUMER_GROUP + "/" + CONSUMER_ID + "");
- verify(threadMockToNotifyCamundaFlow).run();
- verify(executorMock).shutdownNow();
- }
-
- /**
- * Test run method, where the are following conditions:
- * <p> - DmaapThreadListener is running, flag is set to true
- * <p> - map is filled with one entry with the correlationId that does not match to correlationId
- * taken from http response. run method should not do anything with the map not run any thread to notify camunda
- * process
- */
- @Test
- public void correlationIdIsFoundInHttpResponse_NotFoundInMap()
- throws IOException {
- when(httpClientMock.execute(any(HttpGet.class))).
- thenReturn(createResponse(
- String.format(JSON_EXAMPLE_WITH_CORRELATION_ID, CORRELATION_ID_NOT_FOUND_IN_MAP)));
- testedObjectInnerClassThread.run();
- verifyZeroInteractions(threadMockToNotifyCamundaFlow, executorMock);
- }
-
- /**
- * Test run method, where the are following conditions:
- * <p> - DmaapThreadListener is running, flag is set to true
- * <p> - map is filled with one entry with the correlationId but no correlation id is taken from HttpResponse
- * run method should not do anything with the map and not run any thread to notify camunda process
- */
- @Test
- public void correlationIdIsNotFoundInHttpResponse() throws IOException {
- when(httpClientMock.execute(any(HttpGet.class))).
- thenReturn(createResponse(JSON_EXAMPLE_WITH_NO_CORRELATION_ID));
- testedObjectInnerClassThread.run();
- verifyZeroInteractions(threadMockToNotifyCamundaFlow, executorMock);
- }
-
- private void setPrivateField() throws NoSuchFieldException, IllegalAccessException {
- Field httpClientField = testedObject.getClass().getDeclaredField("httpClient");
- httpClientField.setAccessible(true);
- httpClientField.set(testedObject, httpClientMock);
- httpClientField.setAccessible(false);
-
- Field executorField = testedObject.getClass().getDeclaredField("executor");
- executorField.setAccessible(true);
- executorField.set(testedObject, executorMock);
- executorField.setAccessible(false);
-
- Field pnfCorrelationToThreadMapField = testedObject.getClass()
- .getDeclaredField("pnfCorrelationIdToThreadMap");
- pnfCorrelationToThreadMapField.setAccessible(true);
- Map<String, Runnable> pnfCorrelationToThreadMap = new ConcurrentHashMap<>();
- pnfCorrelationToThreadMap.put(CORRELATION_ID, threadMockToNotifyCamundaFlow);
- pnfCorrelationToThreadMapField.set(testedObject, pnfCorrelationToThreadMap);
-
- Field threadRunFlag = testedObject.getClass().getDeclaredField("dmaapThreadListenerIsRunning");
- threadRunFlag.setAccessible(true);
- threadRunFlag.set(testedObject, true);
- threadRunFlag.setAccessible(false);
- }
-
- private HttpResponse createResponse(String json) throws UnsupportedEncodingException {
- HttpEntity entity = new StringEntity(json);
- ProtocolVersion protocolVersion = new ProtocolVersion("", 1, 1);
- HttpResponse response = new BasicHttpResponse(protocolVersion, 1, "");
- response.setEntity(entity);
- response.setStatusCode(200);
- return response;
- }
-
-}