Skip to content
Snippets Groups Projects
Commit deea77dd authored by Florian Lambers's avatar Florian Lambers
Browse files

added activity-add detection

parent 245a6999
No related branches found
No related tags found
No related merge requests found
Showing
with 392 additions and 83 deletions
......@@ -651,7 +651,12 @@ public class MatchingTestcollectionOld {
@Deployment(resources = {"retoure.bpmn", "\\schuh_vernichtung_spende.dmn"})
public void casetill1() {
ProcessInstance processInstance = runtimeService() //
.startProcessInstanceByKey("Retoure", withVariables(VAR_BESCHAEDIGT, true, VAR_ERSTATTUNG, true, VAR_KUNDENNUMMER, "123")); //
assertThat(processInstance) //
.isStarted() //
.hasPassed(Events.RETOURE_START) //
.hasPassed(Gateways.GATEWAY_PARALLEL_LAGER_NEUSENDUNG) //
.hasPassed(Gateways.GATEWAY_BESCHAEDIGT) //
.hasPassed(ManualTasks.WARE_EINSORTIEREN) //
......@@ -691,6 +696,7 @@ public class MatchingTestcollectionOld {
complete(getLockedTask(lockedTasks0, ServiceTasks.KUNDENDATEN_ERMITTELN), ExternalServiceMockProvider.customerProvider(variableSnapshot0));
assertThat(processInstance) //
.hasPassed(Events.RETOURE_START) //
.hasPassed(Gateways.GATEWAY_PARALLEL_LAGER_NEUSENDUNG) //
.hasPassed(Gateways.GATEWAY_BESCHAEDIGT) //
.hasPassed(ManualTasks.WARE_EINSORTIEREN) //
......@@ -727,6 +733,7 @@ public class MatchingTestcollectionOld {
complete(task(UserTasks.MANUELLE_PRUEFUNG));
assertThat(processInstance) //
.hasPassed(Events.RETOURE_START) //
.hasPassed(Gateways.GATEWAY_PARALLEL_LAGER_NEUSENDUNG) //
.hasPassed(Gateways.GATEWAY_BESCHAEDIGT) //
.hasPassed(ManualTasks.WARE_EINSORTIEREN) //
......@@ -763,6 +770,7 @@ public class MatchingTestcollectionOld {
complete(task(UserTasks.PAKET_PACKEN));
assertThat(processInstance) //
.hasPassed(Events.RETOURE_START) //
.hasPassed(Gateways.GATEWAY_PARALLEL_LAGER_NEUSENDUNG) //
.hasPassed(Gateways.GATEWAY_BESCHAEDIGT) //
.hasPassed(ManualTasks.WARE_EINSORTIEREN) //
......@@ -799,6 +807,7 @@ public class MatchingTestcollectionOld {
complete(task(UserTasks.PAKET_PRUEFEN));
assertThat(processInstance) //
.hasPassed(Events.RETOURE_START) //
.hasPassed(Gateways.GATEWAY_PARALLEL_LAGER_NEUSENDUNG) //
.hasPassed(Gateways.GATEWAY_BESCHAEDIGT) //
.hasPassed(ManualTasks.WARE_EINSORTIEREN) //
......@@ -835,6 +844,7 @@ public class MatchingTestcollectionOld {
complete(task(UserTasks.PAKET_SENDEN));
assertThat(processInstance) //
.hasPassed(Events.RETOURE_START) //
.hasPassed(Gateways.GATEWAY_PARALLEL_LAGER_NEUSENDUNG) //
.hasPassed(Gateways.GATEWAY_BESCHAEDIGT) //
.hasPassed(ManualTasks.WARE_EINSORTIEREN) //
......
package de.sample.onlineschuhdemo;
import static org.camunda.bpm.engine.test.assertions.ProcessEngineTests.*;
import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareTests.complete;
import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareTests.runtimeService;
import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareTests.task;
import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareTests.withVariables;
import static org.assertj.core.api.Assertions.entry;
import static de.sample.onlineschuhdemo.TestUtils.*;
import org.apache.ibatis.logging.LogFactory;
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.externaltask.LockedExternalTask;
import org.camunda.bpm.extension.process_test_coverage.junit.rules.TestCoverageProcessEngineRuleBuilder;
import org.junit.Before;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
import java.util.List;
import java.util.Map;
public class Testcollection {
@ClassRule
@Rule
public static ProcessEngineRule rule = TestCoverageProcessEngineRuleBuilder.create().build();
static {
LogFactory.useSlf4jLogging();
}
@Before
public void setup() {
init(rule.getProcessEngine());
}
}
package de.fhmuenster.masterthesis.Testgenerator.migration;
public enum ActionType {
ACTIVITY_ADD_MANUAL_TASK, ACTIVITY_ADD_USER_TASK, ACTIVITY_ADD_SCRIPT_TASK, ACTIVITY_ADD_SERVICE_TASK
ACTIVITY_ADD_MANUAL_TASK, ACTIVITY_ADD_USER_TASK, ACTIVITY_ADD_BUSINESS_RULE_TASK,
ACTIVITY_ADD_SCRIPT_TASK, ACTIVITY_ADD_SERVICE_TASK
}
......@@ -18,8 +18,10 @@ import de.fhmuenster.masterthesis.serialization.TestgeneratorDSLSerializer;
import de.fhmuenster.masterthesis.testgeneratorDSL.Flow;
import de.fhmuenster.masterthesis.testgeneratorDSL.FlowElementReference;
import de.fhmuenster.masterthesis.testgeneratorDSL.ManualTaskFlowElement;
import de.fhmuenster.masterthesis.testgeneratorDSL.ScriptTaskFlowElement;
import de.fhmuenster.masterthesis.testgeneratorDSL.UserTaskFlowElement;
import de.fhmuenster.masterthesis.testgeneratorDSL.SequenceFlowElement;
import de.fhmuenster.masterthesis.testgeneratorDSL.ServiceTaskFlowElement;
import de.fhmuenster.masterthesis.testgeneratorDSL.BusinessRuleTaskFlowElement;
import de.fhmuenster.masterthesis.testgeneratorDSL.Flag;
import de.fhmuenster.masterthesis.utils.TestgeneratorDSLUtils;
......@@ -46,7 +48,11 @@ public class MigrationService {
// 1. Schritt: Prüfen, ob in einem Flow neue Elemente hinzugekommen sind
List<FlowChangeWrapper> activityAddActionResults = detectActivityAddActions(oldDSL.getFlows(), newDSL.getFlows());
transferResultsToCorrespondingCategory(migrationResultWrapper, activityAddActionResults);
// 2. Schritt: Prüfen, ob in einem Flow Elemente gelöscht wurden
List<FlowChangeWrapper> activityDeleteActionResults = detectActivityDeleteActions(oldDSL.getFlows(), newDSL.getFlows());
transferResultsToCorrespondingCategory(migrationResultWrapper, activityDeleteActionResults);
System.out.println("Ergebnis addAction");
for(FlowChangeWrapper fcw : activityAddActionResults) {
System.out.println("+++ Neu: " + fcw.getFlowElement().getName() + " [" + fcw.getActionType() + "] in Flow " + fcw.getFlow().getName()
......@@ -63,7 +69,12 @@ public class MigrationService {
}
}
newDSL.getFlow(fcw.getFlow().getName()).setFlag(maxFlag);
//Alte Flow-Flag überprüfen (könnte z.B. sein, dass activityAdd YELLOW ist und bei activityDelete kommt GREEN dazu)
//würde sonst einfach überschreiben
Flow flow = newDSL.getFlow(fcw.getFlow().getName());
Flag flowFlag = this.calcMaxFlag(flow.getFlag(), maxFlag);
flow.setFlag(flowFlag);
newDSL.serialize();
} catch (IOException e) {
......@@ -84,12 +95,18 @@ public class MigrationService {
result.addAll(compareFlowsForAddAction(matchingFlows[i][1], matchingFlows[i][0]));
}
//Flows miteinander vergleichen
/*
for(int i=0; i < oldFlows.size(); i++) {
result.addAll(compareFlowsForAddAction(oldFlows.get(i), newFlows.get(i)));
return result;
}
private List<FlowChangeWrapper> detectActivityDeleteActions(List<Flow> oldFlows, List<Flow> newFlows) {
List<FlowChangeWrapper> result = new ArrayList<>();
//Flow Matching
Flow [][] matchingFlows = this.changeService.compareFlows(newFlows, oldFlows);
for(int i=0; i < matchingFlows.length; i++) {
result.addAll(compareFlowsForDeleteAction(matchingFlows[i][1], matchingFlows[i][0]));
}
*/
return result;
}
......@@ -136,11 +153,100 @@ public class MigrationService {
}
if(e.getRef() instanceof BusinessRuleTaskFlowElement) {
BusinessRuleTaskFlowElement element = (BusinessRuleTaskFlowElement) e.getRef();
//element.get
//element.get
result.add(new FlowChangeWrapper(newFlow, ActionType.ACTIVITY_ADD_USER_TASK,
e.getRef(), yaml.getActivity().getAdd().getManualTask()));
FlowChangeWrapper fcw = null;
if(element.getResultVariable() != "") {
fcw = new FlowChangeWrapper(newFlow, ActionType.ACTIVITY_ADD_BUSINESS_RULE_TASK,
e.getRef(), yaml.getActivity().getAdd().getBusinessRuleTask().getWithOutput());
}
else {
fcw = new FlowChangeWrapper(newFlow, ActionType.ACTIVITY_ADD_BUSINESS_RULE_TASK,
e.getRef(), yaml.getActivity().getAdd().getBusinessRuleTask().getWithoutOutput());
}
if(fcw.getMigrationResult().getPriority() == null) {
fcw.getMigrationResult().setPriority(this.loadGlobalPriority(fcw.getMigrationResult().getStatus(), yaml));
}
result.add(fcw);
}
if(e.getRef() instanceof ServiceTaskFlowElement) {
ServiceTaskFlowElement element = (ServiceTaskFlowElement) e.getRef();
FlowChangeWrapper fcw = null;
//erstmal als todo gelassen
/*
if(element.get != "") {
fcw = new FlowChangeWrapper(newFlow, ActionType.ACTIVITY_ADD_BUSINESS_RULE_TASK,
e.getRef(), yaml.getActivity().getAdd().getBusinessRuleTask().getWithOutput());
}
else {
fcw = new FlowChangeWrapper(newFlow, ActionType.ACTIVITY_ADD_BUSINESS_RULE_TASK,
e.getRef(), yaml.getActivity().getAdd().getBusinessRuleTask().getWithoutOutput());
}
*/
fcw = new FlowChangeWrapper(newFlow, ActionType.ACTIVITY_ADD_SERVICE_TASK,
e.getRef(), yaml.getActivity().getAdd().getServiceTask().getWithoutOutput());
if(fcw.getMigrationResult().getPriority() == null) {
fcw.getMigrationResult().setPriority(this.loadGlobalPriority(fcw.getMigrationResult().getStatus(), yaml));
}
result.add(fcw);
}
if(e.getRef() instanceof ScriptTaskFlowElement) {
ScriptTaskFlowElement element = (ScriptTaskFlowElement) e.getRef();
FlowChangeWrapper fcw = null;
//erstmal als todo gelassen
/*
if(element.get != "") {
fcw = new FlowChangeWrapper(newFlow, ActionType.ACTIVITY_ADD_BUSINESS_RULE_TASK,
e.getRef(), yaml.getActivity().getAdd().getBusinessRuleTask().getWithOutput());
}
else {
fcw = new FlowChangeWrapper(newFlow, ActionType.ACTIVITY_ADD_BUSINESS_RULE_TASK,
e.getRef(), yaml.getActivity().getAdd().getBusinessRuleTask().getWithoutOutput());
}
*/
fcw = new FlowChangeWrapper(newFlow, ActionType.ACTIVITY_ADD_SCRIPT_TASK,
e.getRef(), yaml.getActivity().getAdd().getScriptTask().getWithoutOutput());
if(fcw.getMigrationResult().getPriority() == null) {
fcw.getMigrationResult().setPriority(this.loadGlobalPriority(fcw.getMigrationResult().getStatus(), yaml));
}
result.add(fcw);
}
}
return result;
}
private List<FlowChangeWrapper> compareFlowsForDeleteAction(Flow oldFlow, Flow newFlow) {
List<FlowElementReference> deletedFlowElements = new ArrayList<>();
List<FlowElementReference> oldElements = TestgeneratorDSLUtils.getInclElements(oldFlow);
List<FlowElementReference> newElements = TestgeneratorDSLUtils.getInclElements(newFlow);
List<FlowChangeWrapper> result = new ArrayList<>();
for(FlowElementReference fer : oldElements) {
if (fer.getRef() instanceof SequenceFlowElement) continue;
if(!checkIfElementExistsInFlowElements(fer, newElements)) {
deletedFlowElements.add(fer);
}
}
if(deletedFlowElements.size() == 0) return result;
//Yaml laden
YamlReader yamlReader = new YamlReader();
MigrationYaml yaml = yamlReader.loadMigrationYaml();
for(FlowElementReference e : deletedFlowElements) {
}
return result;
......
......@@ -3,6 +3,7 @@ package de.fhmuenster.masterthesis.Testgenerator.yaml;
public class Activity {
private ActivityAdd add;
private ActivityDelete delete;
public Activity() {
......@@ -15,6 +16,12 @@ public class Activity {
public void setAdd(ActivityAdd add) {
this.add = add;
}
public ActivityDelete getDelete() {
return delete;
}
public void setDelete(ActivityDelete delete) {
this.delete = delete;
}
}
......@@ -4,7 +4,9 @@ public class ActivityAdd {
private MigrationResult userTask;
private MigrationResult manualTask;
//private MigrationResult businessRuleTask;
private OutputType businessRuleTask;
private OutputType serviceTask;
private OutputType scriptTask;
public ActivityAdd() {
......@@ -25,4 +27,28 @@ public class ActivityAdd {
public void setManualTask(MigrationResult manualTask) {
this.manualTask = manualTask;
}
public OutputType getBusinessRuleTask() {
return businessRuleTask;
}
public void setBusinessRuleTask(OutputType businessRuleTask) {
this.businessRuleTask = businessRuleTask;
}
public OutputType getServiceTask() {
return serviceTask;
}
public void setServiceTask(OutputType serviceTask) {
this.serviceTask = serviceTask;
}
public OutputType getScriptTask() {
return scriptTask;
}
public void setScriptTask(OutputType scriptTask) {
this.scriptTask = scriptTask;
}
}
package de.fhmuenster.masterthesis.Testgenerator.yaml;
public class ActivityDelete {
private MigrationResult userTask;
private MigrationResult manualTask;
private OutputType businessRuleTask;
private OutputType serviceTask;
private OutputType scriptTask;
public ActivityDelete() {
}
public MigrationResult getUserTask() {
return userTask;
}
public void setUserTask(MigrationResult userTask) {
this.userTask = userTask;
}
public MigrationResult getManualTask() {
return manualTask;
}
public void setManualTask(MigrationResult manualTask) {
this.manualTask = manualTask;
}
public OutputType getBusinessRuleTask() {
return businessRuleTask;
}
public void setBusinessRuleTask(OutputType businessRuleTask) {
this.businessRuleTask = businessRuleTask;
}
public OutputType getServiceTask() {
return serviceTask;
}
public void setServiceTask(OutputType serviceTask) {
this.serviceTask = serviceTask;
}
public OutputType getScriptTask() {
return scriptTask;
}
public void setScriptTask(OutputType scriptTask) {
this.scriptTask = scriptTask;
}
}
package de.fhmuenster.masterthesis.Testgenerator.yaml;
public class OutputType {
private MigrationResult withOutput;
private MigrationResult withoutOutput;
public OutputType() {
}
public MigrationResult getWithOutput() {
return withOutput;
}
public void setWithOutput(MigrationResult withOutput) {
this.withOutput = withOutput;
}
public MigrationResult getWithoutOutput() {
return withoutOutput;
}
public void setWithoutOutput(MigrationResult withoutOutput) {
this.withoutOutput = withoutOutput;
}
}
......@@ -7,23 +7,52 @@ gateway:
add:
xor:
status: RED
priority: 0
or:
status: RED
priority: 0
parallel:
status: NONE
priority: 0
delete:
status: NONE
priority: 0
rename:
status: GREEN
priority: 0
activity:
add:
userTask:
status: RED
priority: 0
manualTask:
status: GREEN
\ No newline at end of file
status: GREEN
businessRuleTask:
withOutput:
status: RED
withoutOutput:
status: GREEN
serviceTask:
withOutput:
status: RED
withoutOutput:
status: GREEN
scriptTask:
withOutput:
status: RED
withoutOutput:
status: GREEN
delete:
userTask:
status: YELLOW
manualTask:
status: GREEN
businessRuleTask:
withOutput:
status: YELLOW
withoutOutput:
status: GREEN
serviceTask:
withOutput:
status: YELLOW
withoutOutput:
status: GREEN
scriptTask:
withOutput:
status: YELLOW
withoutOutput:
status: GREEN
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment