diff options
author | Lukasz Muszkieta <lukasz.muszkieta@nokia.com> | 2021-06-23 17:01:42 +0200 |
---|---|---|
committer | Lukasz Muszkieta <lukasz.muszkieta@nokia.com> | 2021-06-23 17:01:42 +0200 |
commit | 04bccb9bb1fe83ed8bc197eb55618c596257e612 (patch) | |
tree | c26765fad08c0161ae61f6d118d4a2338b30b1b1 | |
parent | 3c9bc7d08acb18d76af794bfe936fed7c917b284 (diff) |
add junit coverage
Issue-ID: SO-3433
Signed-off-by: Lukasz Muszkieta <lukasz.muszkieta@nokia.com>
Change-Id: I600dc68c6f38597fedfd0e8d962fe879a6abb976
-rw-r--r-- | bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/service/level/ServiceLevelTest.java | 35 |
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()); |