aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-tasks/src/test/java/org/onap
diff options
context:
space:
mode:
authorSeshu Kumar M <seshu.kumar.m@huawei.com>2021-07-31 02:59:20 +0000
committerGerrit Code Review <gerrit@onap.org>2021-07-31 02:59:20 +0000
commite32fa2efac9f9b9e5a01a86f494664714042c352 (patch)
tree48898f3dcee289dc24e6b4bf0dd946a2d5d6d89e /bpmn/so-bpmn-tasks/src/test/java/org/onap
parent3d8768d468510462c85008ded35dddc272a1b060 (diff)
parent04bccb9bb1fe83ed8bc197eb55618c596257e612 (diff)
Merge "add junit coverage"
Diffstat (limited to 'bpmn/so-bpmn-tasks/src/test/java/org/onap')
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/service/level/ServiceLevelTest.java35
1 files changed, 34 insertions, 1 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 fb15ffa2b3..f22932b988 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
@@ -25,7 +25,9 @@ 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 static org.mockito.Mockito.when;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
@@ -37,6 +39,8 @@ 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;
+import org.onap.so.db.catalog.beans.Workflow;
+import org.onap.so.db.catalog.client.CatalogDbClient;
@RunWith(MockitoJUnitRunner.class)
public class ServiceLevelTest {
@@ -44,11 +48,15 @@ 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";
+ private static final String OPERATION_NAME = ServiceLevelConstants.HEALTH_CHECK_OPERATION;
+ private static final String SCOPE = ServiceLevelConstants.PNF;
+ private static final String WORKFLOW_NAME = "workflowTestName";
@Mock
private ExceptionBuilder exceptionBuilderMock;
+ @Mock
+ private CatalogDbClient catalogDbClientMock;
@InjectMocks
private ServiceLevel testedObject;
@@ -60,6 +68,31 @@ public class ServiceLevelTest {
}
@Test
+ public void fetchWorkflowUsingScope_catalogDBReturnsEmpty() {
+ // given
+ when(catalogDbClientMock.findWorkflowByOperationName(OPERATION_NAME)).thenReturn(Collections.emptyList());
+ // when
+ String workflowResult = testedObject.fetchWorkflowUsingScope(SCOPE, OPERATION_NAME);
+ // then
+ assertThat(workflowResult).isEqualTo("GenericPnfHealthCheck");
+ }
+
+ @Test
+ public void fetchWorkflowUsingScope_catalogDBReturnsNotEmpty() {
+ // given
+ Workflow workflow = new Workflow();
+ workflow.setResourceTarget(SCOPE);
+ workflow.setName(WORKFLOW_NAME);
+ List<Workflow> workflowList = new ArrayList<>();
+ workflowList.add(workflow);
+ when(catalogDbClientMock.findWorkflowByOperationName(OPERATION_NAME)).thenReturn(workflowList);
+ // when
+ String workflowResult = testedObject.fetchWorkflowUsingScope(SCOPE, OPERATION_NAME);
+ // then
+ assertThat(workflowResult).isEqualTo(WORKFLOW_NAME);
+ }
+
+ @Test
public void pnfCounterExecution_success() {
// given
execution.setVariable(EXECUTION_KEY_PNF_NAME_LIST, createPnfNameList());