diff --git a/Testgenerator/src/main/java/de/fhmuenster/masterthesis/Testgenerator/migration/MigrationService.java b/Testgenerator/src/main/java/de/fhmuenster/masterthesis/Testgenerator/migration/MigrationService.java index dbcae627fbd472108b9521f34096b6ec5493fa9f..7832cafc01517263158e01a5406e8b72fdb10e33 100644 --- a/Testgenerator/src/main/java/de/fhmuenster/masterthesis/Testgenerator/migration/MigrationService.java +++ b/Testgenerator/src/main/java/de/fhmuenster/masterthesis/Testgenerator/migration/MigrationService.java @@ -81,7 +81,7 @@ public class MigrationService { } - private void setFlagsForStandardFlowChangeWrapper(List<FlowChangeWrapper> flowChangeWrapper, TestgeneratorDSLSerializer newDSL) { + private void setFlagsForStandardFlowChangeWrapper(List<FlowChangeWrapper> flowChangeWrapper, TestgeneratorDSLSerializer newDSL, TestgeneratorDSLSerializer oldDSL) { for(FlowChangeWrapper fcw : flowChangeWrapper) { if(!flowHasTests(fcw.getFlow(), newDSL)) continue; @@ -90,11 +90,26 @@ public class MigrationService { try { Flag maxFlag = Flag.NONE; List<FlowElementReference> fers = newDSL.getFlow(fcw.getFlow().getName()).getInclElements(); + List<FlowElementReference> fersOld = oldDSL.getFlow(fcw.getFlow().getName()).getInclElements(); + Flow flow = newDSL.getFlow(fcw.getFlow().getName()); + Flow oldFlow = oldDSL.getFlow(fcw.getFlow().getName()); + Boolean setScore = false; for(FlowElementReference fer : fers) { if(fer.getRef().getName().equals(fcw.getFlowElement().getName())) { Flag newFlag = this.convertMigrationResultToFlag(fcw.getMigrationResult().getStatus()); + int score = this.calcScore(newFlag, flow); + flow.setScore(score); + setScore = true; fer.setFlag(this.calcMaxFlag(fer.getFlag(), newFlag)); maxFlag = this.calcMaxFlag(maxFlag, newFlag); + } + } + + for(FlowElementReference oldFer: fersOld) { + if(fcw.getActionType().name().contains("DELETE") && oldFer.getRef().getName().equals(fcw.getFlowElement().getName())) { + Flag newFlag = this.convertMigrationResultToFlag(fcw.getMigrationResult().getStatus()); + int score = this.calcScore(newFlag, flow); + flow.setScore(score); } } @@ -104,11 +119,9 @@ public class MigrationService { //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); - int score = this.calcScore(flow.getFlag(), flow); - flow.setScore(score); + //Anhand der neuen Flows das Flag auch für die zugehörigen Tests setzen //Test-Flags setzen @@ -191,7 +204,7 @@ public class MigrationService { allStandardFlowChangeWrapper.addAll(sequenceFlowChangeExpressionActionResults); - this.setFlagsForStandardFlowChangeWrapper(allStandardFlowChangeWrapper, newDSL); + this.setFlagsForStandardFlowChangeWrapper(allStandardFlowChangeWrapper, newDSL, oldDSL); for(FlowChangeWrapper fcw : processVariableChangeConstraintActionResults) { @@ -200,21 +213,22 @@ public class MigrationService { try { Flag maxFlag = Flag.NONE; List<FlowElementReference> fers = newDSL.getFlow(fcw.getFlow().getName()).getInclElements(); + Flow flow = newDSL.getFlow(fcw.getFlow().getName()); + for(FlowElementReference fer : fers) { if(fer.getRef().getName().equals(fcw.getFlowElement().getName())) { Flag newFlag = this.convertMigrationResultToFlag(fcw.getMigrationResult().getStatus()); + int score = this.calcScore(newFlag, flow); + flow.setScore(score); fer.setFlag(this.calcMaxFlag(fer.getFlag(), newFlag)); maxFlag = this.calcMaxFlag(maxFlag, newFlag); } } //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); - int score = this.calcScore(flow.getFlag(), flow); - flow.setScore(score); - + //Anhand der neuen Flows das Flag auch für die zugehörigen Tests setzen //Test-Flags setzen List<Flow> newFlows = newDSL.getFlows(); @@ -241,23 +255,21 @@ public class MigrationService { try { Flag maxFlag = Flag.NONE; List<FlowElementReference> fers = newDSL.getFlow(fcw.getFlow().getName()).getInclElements(); + Flow flow = newDSL.getFlow(fcw.getFlow().getName()); for(FlowElementReference fer : fers) { if(fer.getRef().getName().equals(fcw.getFlowElement().getName())) { Flag newFlag = this.convertMigrationResultToFlag(fcw.getMigrationResult().getStatus()); + int score = this.calcScore(newFlag, flow); + flow.setScore(score); fer.setFlag(this.calcMaxFlag(fer.getFlag(), newFlag)); maxFlag = this.calcMaxFlag(maxFlag, newFlag); } } //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); - - - int score = this.calcScore(flow.getFlag(), flow); - flow.setScore(score); - + //Anhand der neuen Flows das Flag auch für die zugehörigen Tests setzen //Test-Flags setzen List<Flow> newFlows = newDSL.getFlows(); @@ -293,21 +305,20 @@ public class MigrationService { try { Flag maxFlag = Flag.NONE; List<FlowElementReference> fers = newDSL.getFlow(fcw.getFlow().getName()).getInclElements(); + Flow flow = newDSL.getFlow(fcw.getFlow().getName()); for(FlowElementReference fer : fers) { if(fer.getRef().getName().equals(fcw.getFlowElement().getName())) { Flag newFlag = this.convertMigrationResultToFlag(fcw.getMigrationResult().getStatus()); + int score = this.calcScore(newFlag, flow); + flow.setScore(score); fer.setFlag(this.calcMaxFlag(fer.getFlag(), newFlag)); maxFlag = this.calcMaxFlag(maxFlag, newFlag); } } //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); - int score = this.calcScore(flow.getFlag(), flow); - flow.setScore(score); - + //Die vorhandenen Tests müssen gelöscht werden, wenn ein XOR hinzugefügt wurde if(yaml.getGateway().getDeleteTests()) { if(!fcw.getAffectedTests().isEmpty()) { @@ -343,22 +354,23 @@ public class MigrationService { System.out.println(fcw.getActionType() + " on Flow element " + fcw.getFlowElement().getName()); try { Flag maxFlag = Flag.NONE; + Flow flow = newDSL.getFlow(fcw.getFlow().getName()); List<FlowElementReference> fers = newDSL.getFlow(fcw.getFlow().getName()).getInclElements(); for(FlowElementReference fer : fers) { if(fer.getRef().getName().equals(fcw.getFlowElement().getName())) { Flag newFlag = this.convertMigrationResultToFlag(fcw.getMigrationResult().getStatus()); + int score = this.calcScore(newFlag, flow); + flow.setScore(score); fer.setFlag(this.calcMaxFlag(fer.getFlag(), newFlag)); maxFlag = this.calcMaxFlag(maxFlag, newFlag); } } //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); - int score = this.calcScore(flow.getFlag(), flow); - flow.setScore(score); + //Die vorhandenen Tests müssen gelöscht werden, wenn ein XOR hinzugefügt wurde if(yaml.getGateway().getDeleteTests()) { if(!fcw.getAffectedTests().isEmpty()) {