diff options
author | Smokowski, Steven <steve.smokowski@att.com> | 2020-07-14 15:55:24 -0400 |
---|---|---|
committer | Benjamin, Max (mb388a) <mb388a@att.com> | 2020-07-14 15:55:24 -0400 |
commit | c2289b86be119991c6fabf4ce9c6c69a4fcd4496 (patch) | |
tree | 8ccaff7f366845c2a1d67293b3984e0ccd942cdd /bpmn/mso-infrastructure-bpmn/src/test/java | |
parent | 32dc5fffcf9071eda394b7b501e632f49887c552 (diff) |
Add back auto process migration
Add back auto process migration
Issue-ID: SO-3069
Signed-off-by: Benjamin, Max (mb388a) <mb388a@att.com>
Change-Id: I50fc83484e9bd992e1419f980dcc54055ca40cb8
Diffstat (limited to 'bpmn/mso-infrastructure-bpmn/src/test/java')
-rw-r--r-- | bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/workflow/service/AutoProcessInstanceMigrationServiceTest.java | 124 |
1 files changed, 124 insertions, 0 deletions
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/workflow/service/AutoProcessInstanceMigrationServiceTest.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/workflow/service/AutoProcessInstanceMigrationServiceTest.java new file mode 100644 index 0000000000..36e828448d --- /dev/null +++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/workflow/service/AutoProcessInstanceMigrationServiceTest.java @@ -0,0 +1,124 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 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.mockito.Mockito.doReturn; +import java.util.ArrayList; +import java.util.List; +import org.camunda.bpm.engine.ProcessEngine; +import org.camunda.bpm.engine.RepositoryService; +import org.camunda.bpm.engine.repository.ProcessDefinition; +import org.camunda.bpm.engine.repository.ProcessDefinitionQuery; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Spy; +import org.mockito.junit.MockitoJUnitRunner; +import org.springframework.core.env.Environment; + +@RunWith(MockitoJUnitRunner.class) +public class AutoProcessInstanceMigrationServiceTest { + + @Mock + private ProcessEngine processEngine; + + @Mock + private ProcessDefinition outdated; + + @Mock + private ProcessDefinition newDef; + + @Mock + private ProcessDefinition key; + + @Mock + private ProcessDefinition testKey; + + @Mock + private ProcessDefinition suspendedDef; + + @Mock + private RepositoryService repositoryService; + + @Mock + private ProcessDefinitionQuery query; + + @Mock + private ProcessDefinitionQuery keyQuery; + + @Mock + private Environment env; + + @Spy + @InjectMocks + private AutoProcessInstanceMigrationService migrationService; + + + @Test + public void getOldProcessDefinitionsTest() { + List<ProcessDefinition> expectedList = new ArrayList<>(); + expectedList.add(outdated); + + List<ProcessDefinition> defList = new ArrayList<>(); + defList.add(outdated); + defList.add(newDef); + defList.add(suspendedDef); + + + doReturn(query).when(repositoryService).createProcessDefinitionQuery(); + doReturn(query).when(query).processDefinitionKey("test"); + doReturn(defList).when(query).list(); + doReturn(3).when(outdated).getVersion(); + doReturn(4).when(newDef).getVersion(); + doReturn(true).when(suspendedDef).isSuspended(); + List<ProcessDefinition> outdatedList = migrationService.getOldProcessDefinitions("test", 4); + + assertEquals(expectedList, outdatedList); + } + + @Test + public void getProcessDefinitionsTest() { + List<ProcessDefinition> expected = new ArrayList<ProcessDefinition>(); + expected.add(testKey); + expected.add(key); + + List<String> processDefinitionKeys = new ArrayList<String>(); + processDefinitionKeys.add("testKey"); + processDefinitionKeys.add("key"); + + doReturn(processDefinitionKeys).when(env).getProperty("migration.processDefinitionKeys", List.class, + new ArrayList<String>()); + + doReturn(query).when(repositoryService).createProcessDefinitionQuery(); + doReturn(query).when(query).processDefinitionKey("testKey"); + doReturn(query).when(query).latestVersion(); + doReturn(testKey).when(query).singleResult(); + + doReturn(keyQuery).when(query).processDefinitionKey("key"); + doReturn(keyQuery).when(keyQuery).latestVersion(); + doReturn(key).when(keyQuery).singleResult(); + + List<ProcessDefinition> actualProcessDefinitions = migrationService.getProcessDefinitions(); + + assertEquals(expected, actualProcessDefinitions); + } +} |