aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-tasks
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn/so-bpmn-tasks')
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/service/level/ServiceLevelTest.java66
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/VnfEBBLoaderTest.java85
2 files changed, 143 insertions, 8 deletions
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/service/level/ServiceLevelTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/service/level/ServiceLevelTest.java
index cfaa4040c7..fb15ffa2b3 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/service/level/ServiceLevelTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/service/level/ServiceLevelTest.java
@@ -21,35 +21,85 @@
package org.onap.so.bpmn.infrastructure.service.level;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
import java.util.ArrayList;
+import java.util.List;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
+import org.junit.Before;
import org.junit.Test;
-import java.util.List;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.so.bpmn.infrastructure.service.level.impl.ServiceLevelConstants;
+import org.onap.so.client.exception.ExceptionBuilder;
+@RunWith(MockitoJUnitRunner.class)
public class ServiceLevelTest {
private static final String EXECUTION_KEY_PNF_NAME_LIST = "pnfNameList";
private static final String EXECUTION_KEY_PNF_COUNTER = "pnfCounter";
+ private static final String PARAM_NAME = "param1";
+ private static final String SCOPE = "scope1";
+ private static final String PNF_NAME = "pnfName1";
+
+ @Mock
+ private ExceptionBuilder exceptionBuilderMock;
+ @InjectMocks
+ private ServiceLevel testedObject;
+
+ private DelegateExecution execution;
+
+ @Before
+ public void init() {
+ execution = new DelegateExecutionFake();
+ }
@Test
public void pnfCounterExecution_success() {
// given
- String pnfName = "pnfName1";
- DelegateExecution execution = new DelegateExecutionFake();
- execution.setVariable(EXECUTION_KEY_PNF_NAME_LIST, createPnfNameList(pnfName));
+ execution.setVariable(EXECUTION_KEY_PNF_NAME_LIST, createPnfNameList());
execution.setVariable(EXECUTION_KEY_PNF_COUNTER, 0);
// when
- new ServiceLevel().pnfCounterExecution(execution);
+ testedObject.pnfCounterExecution(execution);
// then
- assertThat(execution.getVariable(ServiceLevelConstants.PNF_NAME)).isEqualTo(pnfName);
+ assertThat(execution.getVariable(ServiceLevelConstants.PNF_NAME)).isEqualTo(PNF_NAME);
assertThat(execution.getVariable(EXECUTION_KEY_PNF_COUNTER)).isEqualTo(1);
}
- private List<String> createPnfNameList(String pnfName) {
+ @Test
+ public void validateParams_success_paramExistsInExecution() {
+ // given
+ execution.setVariable(PARAM_NAME, "anyValue");
+ // when
+ testedObject.validateParamsWithScope(execution, "anyScope", createParamList());
+ // then
+ verify(exceptionBuilderMock, times(0)).buildAndThrowWorkflowException(any(DelegateExecution.class),
+ eq(ServiceLevelConstants.ERROR_CODE), any(String.class));
+ }
+
+ @Test
+ public void validateParams_exceptionParamDoesNotExistInExecution() {
+ // when
+ testedObject.validateParamsWithScope(execution, SCOPE, createParamList());
+ // then
+ verify(exceptionBuilderMock).buildAndThrowWorkflowException(execution, ServiceLevelConstants.ERROR_CODE,
+ "Validation of health check workflow parameters failed for the scope: " + SCOPE);
+ }
+
+ private List<String> createParamList() {
+ List<String> params = new ArrayList<>();
+ params.add(PARAM_NAME);
+ return params;
+ }
+
+ private List<String> createPnfNameList() {
List<String> pnfNameList = new ArrayList<>();
- pnfNameList.add(pnfName);
+ pnfNameList.add(PNF_NAME);
return pnfNameList;
}
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/VnfEBBLoaderTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/VnfEBBLoaderTest.java
new file mode 100644
index 0000000000..a9bfde9bab
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/VnfEBBLoaderTest.java
@@ -0,0 +1,85 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2021 Nokia
+ * ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
+ * Modifications Copyright (c) 2021 Nokia
+ * ================================================================================
+ * Modifications Copyright (c) 2020 Tech Mahindra
+ * ================================================================================
+ * 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.workflow.tasks.ebb.loader;
+
+
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
+import org.javatuples.Pair;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
+import org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowType;
+import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetup;
+import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetupUtils;
+import org.onap.so.client.exception.ExceptionBuilder;
+import org.onap.so.bpmn.infrastructure.workflow.tasks.Resource;
+import java.util.ArrayList;
+import java.util.List;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+
+
+public class VnfEBBLoaderTest {
+
+ private String serviceId;
+ private String vnfId;
+ private BBInputSetupUtils bbInputSetupUtils;
+ private BBInputSetup bbInputSetup;
+ private WorkflowActionExtractResourcesAAI workflowActionUtils;
+ private ExceptionBuilder exceptionBuilder;
+ private DelegateExecution delegateExecution;
+ private VnfEBBLoader cut;
+
+ private org.onap.aai.domain.yang.ServiceInstance serviceInstanceAAI;
+ private ServiceInstance serviceInstanceMSO;
+
+ @Before
+ public void setup() {
+ serviceId = "service123";
+ vnfId = "vnf123";
+ serviceInstanceAAI = mock(org.onap.aai.domain.yang.ServiceInstance.class);
+ serviceInstanceMSO = mock(ServiceInstance.class);
+ bbInputSetupUtils = mock(BBInputSetupUtils.class);
+ bbInputSetup = mock(BBInputSetup.class);
+ workflowActionUtils = mock(WorkflowActionExtractResourcesAAI.class);
+ exceptionBuilder = mock(ExceptionBuilder.class);
+ delegateExecution = new DelegateExecutionFake();
+ }
+
+ @Test
+ public void traverseAAIVnf_shouldAddServiceToResourceList() throws Exception {
+ List<Resource> resourceList = new ArrayList<>();
+ List<Pair<WorkflowType, String>> aaiResourceIds = new ArrayList<>();
+ doReturn(serviceInstanceAAI).when(bbInputSetupUtils).getAAIServiceInstanceById(serviceId);
+ doReturn(serviceInstanceMSO).when(bbInputSetup).getExistingServiceInstance(serviceInstanceAAI);
+ cut = new VnfEBBLoader(bbInputSetupUtils, bbInputSetup, workflowActionUtils, exceptionBuilder);
+ cut.traverseAAIVnf(delegateExecution, resourceList, serviceId, vnfId, aaiResourceIds);
+ assertEquals(WorkflowType.SERVICE, resourceList.get(0).getResourceType());
+ }
+}