diff --git a/Testgenerator/src/main/java/de/fhmuenster/masterthesis/Testgenerator/bpmn/data/BPMNTestcase.java b/Testgenerator/src/main/java/de/fhmuenster/masterthesis/Testgenerator/bpmn/data/BPMNTestcase.java index 28506a0f0d8877245be72baeaf00d86a6cf7da85..6cb5f107c6bbf7f85e1146be93ba7b0738a054af 100644 --- a/Testgenerator/src/main/java/de/fhmuenster/masterthesis/Testgenerator/bpmn/data/BPMNTestcase.java +++ b/Testgenerator/src/main/java/de/fhmuenster/masterthesis/Testgenerator/bpmn/data/BPMNTestcase.java @@ -12,6 +12,7 @@ public class BPMNTestcase { private List<String> mocks; private int priority; private String flag; + private int order; public BPMNTestcase() { this.taskVariableList = new ArrayList<>(); @@ -72,6 +73,14 @@ public class BPMNTestcase { public void setPriority(int priority) { this.priority = priority; } + + public int getOrder() { + return order; + } + + public void setOrder(int order) { + this.order = order; + } public String getFlag() { return flag; 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 330bb6a35ee7b23d08b59b81cd3a9f783070361d..1744fac3648b60fb45796f033e6ba4f02dcae46f 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 @@ -1216,12 +1216,18 @@ public class MigrationService { int index = 0; for(FlowElement oe : cleanedOldFlow) { - if(cleanedNewFlow.get(index) != null) { - if(!cleanedNewFlow.get(index).getName().equals(oe.getName())) { - //Reihenfolge passt nicht mehr - result.add(this.prepareFlowChangeWrapper(flowNew, ActionType.ACTIVITY_CHANGE_ORDER, oe)); + try { + if(cleanedNewFlow.get(index) != null) { + if(!cleanedNewFlow.get(index).getName().equals(oe.getName())) { + //Reihenfolge passt nicht mehr + result.add(this.prepareFlowChangeWrapper(flowNew, ActionType.ACTIVITY_CHANGE_ORDER, oe)); + } } } + catch(IndexOutOfBoundsException e) { + + } + index++; } @@ -1419,47 +1425,53 @@ public class MigrationService { int index = 0; for(FlowElement oe : cleanedOldFlow) { - if((cleanedNewFlow.get(index) != null) && cleanedNewFlow.get(index).getName().equals(oe.getName())) { - //Fall: Änderung von X nach X - if(!(oe instanceof UserTaskFlowElement) && !(cleanedNewFlow.get(index) instanceof UserTaskFlowElement)) { - //ManualTaskFlowElement | ScriptTaskFlowElement | ServiceTaskFlowElement | BusinessRuleTaskFlowElement - boolean foundChangedType = false; - if((oe instanceof ManualTaskFlowElement && !(cleanedNewFlow.get(index) instanceof ManualTaskFlowElement)) || - (oe instanceof ScriptTaskFlowElement && !(cleanedNewFlow.get(index) instanceof ScriptTaskFlowElement)) || - (oe instanceof ServiceTaskFlowElement && !(cleanedNewFlow.get(index) instanceof ServiceTaskFlowElement)) || - (oe instanceof BusinessRuleTaskFlowElement && !(cleanedNewFlow.get(index) instanceof BusinessRuleTaskFlowElement))) { - foundChangedType = true; + try { + if((cleanedNewFlow.get(index) != null) && cleanedNewFlow.get(index).getName().equals(oe.getName())) { + //Fall: Änderung von X nach X + if(!(oe instanceof UserTaskFlowElement) && !(cleanedNewFlow.get(index) instanceof UserTaskFlowElement)) { + //ManualTaskFlowElement | ScriptTaskFlowElement | ServiceTaskFlowElement | BusinessRuleTaskFlowElement + boolean foundChangedType = false; + if((oe instanceof ManualTaskFlowElement && !(cleanedNewFlow.get(index) instanceof ManualTaskFlowElement)) || + (oe instanceof ScriptTaskFlowElement && !(cleanedNewFlow.get(index) instanceof ScriptTaskFlowElement)) || + (oe instanceof ServiceTaskFlowElement && !(cleanedNewFlow.get(index) instanceof ServiceTaskFlowElement)) || + (oe instanceof BusinessRuleTaskFlowElement && !(cleanedNewFlow.get(index) instanceof BusinessRuleTaskFlowElement))) { + foundChangedType = true; + } + + if(foundChangedType) { + result.add(this.prepareFlowChangeWrapper(flowNew, ActionType.ACTIVITY_CHANGE_TYPE_FROM_XTASK_TO_XTASK, + oe)); + } } - if(foundChangedType) { - result.add(this.prepareFlowChangeWrapper(flowNew, ActionType.ACTIVITY_CHANGE_TYPE_FROM_XTASK_TO_XTASK, + //Fall: Änderung von UserTask nach X + if(oe instanceof UserTaskFlowElement && !(cleanedNewFlow.get(index) instanceof UserTaskFlowElement)) { + result.add(this.prepareFlowChangeWrapper(flowNew, ActionType.ACTIVITY_CHANGE_TYPE_FROM_USERTASK_TO_XTASK, oe)); } - } - - //Fall: Änderung von UserTask nach X - if(oe instanceof UserTaskFlowElement && !(cleanedNewFlow.get(index) instanceof UserTaskFlowElement)) { - result.add(this.prepareFlowChangeWrapper(flowNew, ActionType.ACTIVITY_CHANGE_TYPE_FROM_USERTASK_TO_XTASK, - oe)); - } - - //Fall: Änderung von X nach UserTask - if(!(oe instanceof UserTaskFlowElement) && cleanedNewFlow.get(index) instanceof UserTaskFlowElement) { - FlowElement newElement = cleanedNewFlow.get(index); - boolean hasRequiredField = this.checkIfElementHasRequiredFields(newElement); - if(hasRequiredField) { - result.add(this.prepareFlowChangeWrapper(flowNew, - ActionType.ACTIVITY_CHANGE_TYPE_FROM_XTASK_TO_USERTASK_REQUIRED, - newElement)); - } - else { - result.add(this.prepareFlowChangeWrapper(flowNew, - ActionType.ACTIVITY_CHANGE_TYPE_FROM_XTASK_TO_USERTASK_NOT_REQUIRED, - newElement)); - } + + //Fall: Änderung von X nach UserTask + if(!(oe instanceof UserTaskFlowElement) && cleanedNewFlow.get(index) instanceof UserTaskFlowElement) { + FlowElement newElement = cleanedNewFlow.get(index); + boolean hasRequiredField = this.checkIfElementHasRequiredFields(newElement); + if(hasRequiredField) { + result.add(this.prepareFlowChangeWrapper(flowNew, + ActionType.ACTIVITY_CHANGE_TYPE_FROM_XTASK_TO_USERTASK_REQUIRED, + newElement)); + } + else { + result.add(this.prepareFlowChangeWrapper(flowNew, + ActionType.ACTIVITY_CHANGE_TYPE_FROM_XTASK_TO_USERTASK_NOT_REQUIRED, + newElement)); + } + } } } + catch(IndexOutOfBoundsException e) { + + } + index++; } diff --git a/Testgenerator/src/main/java/de/fhmuenster/masterthesis/Testgenerator/prioritization/PrioritizationService.java b/Testgenerator/src/main/java/de/fhmuenster/masterthesis/Testgenerator/prioritization/PrioritizationService.java index b91214a86dac1b26a6b38e4ba3df2cf055858df3..9b34bbceab9c1b8da683eed0794cb72470827421 100644 --- a/Testgenerator/src/main/java/de/fhmuenster/masterthesis/Testgenerator/prioritization/PrioritizationService.java +++ b/Testgenerator/src/main/java/de/fhmuenster/masterthesis/Testgenerator/prioritization/PrioritizationService.java @@ -77,13 +77,13 @@ public class PrioritizationService { this.sumDependencies(dependenciesRead, dependenciesWrite, dependenciesRemove); - this.newDSL.serialize(); + HashMap<String, Integer> testPriorities = this.sumTestPriorities(); this.setTestPriorities(testPriorities); this.setTestOrder(testPriorities); - + this.newDSL.serialize(); } /** @@ -93,14 +93,25 @@ public class PrioritizationService { private void setTestOrder(HashMap<String, Integer> testPriorities) { HashMap<String, Integer> sortedList = PrioritizationService.sortByValue(testPriorities); - + List<Test> testList = this.newDSL.getTests(); int i = 1; for (String key : sortedList.keySet()){ System.out.println("[TEST] " + key + " with priority " + sortedList.get(key) + " [JUNIT] Order: " + i); - i++; + // TODO: dem Test die Order hinzufügen - // test.setOrder(i); + for(Test test: testList) { + if(test.getName().equals(key)) { + test.setOrder(i); + try { + this.newDSL.serialize(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + i++; } } diff --git a/Testgenerator/src/main/java/de/fhmuenster/masterthesis/Testgenerator/rest/service/change/ChangeController.java b/Testgenerator/src/main/java/de/fhmuenster/masterthesis/Testgenerator/rest/service/change/ChangeController.java index c028f6822c16e1bc7a7ebb902a2616662f478389..272e737c6a5404a3ab9ce3e279063958cede26c3 100644 --- a/Testgenerator/src/main/java/de/fhmuenster/masterthesis/Testgenerator/rest/service/change/ChangeController.java +++ b/Testgenerator/src/main/java/de/fhmuenster/masterthesis/Testgenerator/rest/service/change/ChangeController.java @@ -234,26 +234,7 @@ public class ChangeController { } } - } -// for (int i=0; i<newFlows.size();i++) { -// System.out.println(matchingFlows[i][0].getName()+" "+matchingFlows[i][1].getName()); -// } -// for (int i=0; i<newFlows.size();i++) { -// System.out.print(matchingFlows[i][0].getName()+" ---"); -// try { -// System.out.print(matchingFlows[i][1].getName()+" ---"); -// } catch (Exception e) { -// System.out.print("kein passender Flow gefunden"); -// if(matchingFlows[i][1]==null){ -// System.out.println(i); -// } -// } -// System.out.println(""); -// -// -// } -// - + } //Alte DSL kopieren und neu generieren Path testFilePath = ProjectDirectoryUtils.getTestspecificationPath(project.getProjectDirectories()); @@ -338,8 +319,6 @@ public class ChangeController { } - - //Prüfen, ob ggf Tasks gelöscht wurden List<TaskVariables> variableListToSet = new ArrayList<>(); for(TaskVariables tv : bpmnTestcase.getTaskVariableList()) { @@ -374,8 +353,7 @@ public class ChangeController { typeChanged = true; } } - - + List<VariableValue> variableValuesToSet = new ArrayList<>(); if(!typeChanged) { List<String> deletedInputVariables = new ArrayList<>(); @@ -385,7 +363,6 @@ public class ChangeController { } } - for(VariableValue vv : tv.getVariableValues()) { if(!deletedInputVariables.contains(vv.getVariable())) { variableValuesToSet.add(vv); @@ -418,15 +395,10 @@ public class ChangeController { bpmnTestcase.getMocks().clear(); bpmnTestcase.getMocks().addAll(mocksToAdd); - - - testService.addTest(bpmnTestcase, project.getProjectDirectories()); } } - - newDSL = null; newDSL = new TestgeneratorDSLSerializer(newDSLFile.toString()); diff --git a/Testgenerator/src/main/java/de/fhmuenster/masterthesis/Testgenerator/rest/service/config/ConfigController.java b/Testgenerator/src/main/java/de/fhmuenster/masterthesis/Testgenerator/rest/service/config/ConfigController.java new file mode 100644 index 0000000000000000000000000000000000000000..3f24cd69d24efae66852ee4062818e9a74ac8c2d --- /dev/null +++ b/Testgenerator/src/main/java/de/fhmuenster/masterthesis/Testgenerator/rest/service/config/ConfigController.java @@ -0,0 +1,74 @@ +package de.fhmuenster.masterthesis.Testgenerator.rest.service.config; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; +import java.util.Enumeration; +import java.util.List; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; + +import org.apache.commons.io.FileUtils; +import org.apache.commons.io.IOUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.servlet.config.annotation.EnableWebMvc; + +import de.fhmuenster.masterthesis.Testgenerator.prioritization.PrioritizationService; +import de.fhmuenster.masterthesis.Testgenerator.rest.dto.BPMNFlowSetDTO; +import de.fhmuenster.masterthesis.Testgenerator.rest.service.project.Project; +import de.fhmuenster.masterthesis.Testgenerator.rest.service.project.ProjectService; +import de.fhmuenster.masterthesis.Testgenerator.utils.ProjectDirectoryUtils; +import de.fhmuenster.masterthesis.Testgenerator.yaml.MigrationYaml; +import de.fhmuenster.masterthesis.Testgenerator.yaml.YamlReader; +import de.fhmuenster.masterthesis.serialization.TestgeneratorDSLSerializer; + +@RestController +@EnableWebMvc +public class ConfigController { + + @Autowired + private ProjectService projectService; + + YamlReader yamlReader = new YamlReader(); + MigrationYaml yaml = yamlReader.loadMigrationYaml(); + + @RequestMapping(path = "/project/{projectId}/config", method = RequestMethod.GET) + public String[] getConfig(@PathVariable(required = true) Long projectId) throws IOException { + + String[] priorityFormula = { + yaml.getPriority().getFormularPart0(), + yaml.getPriority().getFormularPart1(), + yaml.getPriority().getFormularPart2(), + yaml.getPriority().getFormularPart3(), + yaml.getPriority().getFormularPart4(), + yaml.getPriority().getFormularPart5(), + yaml.getPriority().getFormularPart6() + }; + + return priorityFormula; + + } + + @RequestMapping(path = "/project/{projectId}/config", method = RequestMethod.POST) + public void saveConfig(@PathVariable(required = true) Long projectId, @RequestBody List<String> arrayParams) throws IOException { + yaml.getPriority().setFormularPart0(arrayParams.get(0)); + yaml.getPriority().setFormularPart1(arrayParams.get(1)); + yaml.getPriority().setFormularPart2(arrayParams.get(2)); + yaml.getPriority().setFormularPart3(arrayParams.get(3)); + yaml.getPriority().setFormularPart4(arrayParams.get(4)); + yaml.getPriority().setFormularPart5(arrayParams.get(5)); + yaml.getPriority().setFormularPart6(arrayParams.get(6)); + } +} diff --git a/Testgenerator/src/main/java/de/fhmuenster/masterthesis/Testgenerator/rest/service/converters/TestConverter.java b/Testgenerator/src/main/java/de/fhmuenster/masterthesis/Testgenerator/rest/service/converters/TestConverter.java index 9a6221f20c31422356477a804246322f2ffd75ee..243e7d30ce763bddc170f052eea7686972027366 100644 --- a/Testgenerator/src/main/java/de/fhmuenster/masterthesis/Testgenerator/rest/service/converters/TestConverter.java +++ b/Testgenerator/src/main/java/de/fhmuenster/masterthesis/Testgenerator/rest/service/converters/TestConverter.java @@ -68,11 +68,12 @@ public class TestConverter { // @Tim, @Henning Priorität hier hinzufügen int prio = testcase.getPriority(); + int order = testcase.getOrder(); //Flag Flag flag = Flag.get(testcase.getFlag()); - return TestgeneratorDSLObjectCreator.createTest(testcase.getName(), flow, variableDeclarationsList, endCheckDeclaration, mocks, prio, flag); + return TestgeneratorDSLObjectCreator.createTest(testcase.getName(), flow, variableDeclarationsList, endCheckDeclaration, mocks, prio, flag, order); } public static FlowElement getFlowElement(List<FlowElement> flowElements, String name) { @@ -115,6 +116,7 @@ public class TestConverter { bpmnTestcase.setEndChecks(endCheckList); bpmnTestcase.setMocks(mocks); bpmnTestcase.setPriority(testcase.getPriority()); + bpmnTestcase.setOrder(testcase.getOrder()); bpmnTestcase.setFlag(testcase.getFlag().name()); return bpmnTestcase; diff --git a/Testgenerator/src/main/java/de/fhmuenster/masterthesis/Testgenerator/yaml/MigrationYaml.java b/Testgenerator/src/main/java/de/fhmuenster/masterthesis/Testgenerator/yaml/MigrationYaml.java index 85e88b32f4da635ebefabcaeade3b6adb2b3edda..402e83f19441daeef36c117fe4e273bbd93355c9 100644 --- a/Testgenerator/src/main/java/de/fhmuenster/masterthesis/Testgenerator/yaml/MigrationYaml.java +++ b/Testgenerator/src/main/java/de/fhmuenster/masterthesis/Testgenerator/yaml/MigrationYaml.java @@ -5,6 +5,7 @@ public class MigrationYaml { private Gateway gateway; private Activity activity; private Event event; + private Priority priority; public MigrationYaml() { @@ -41,6 +42,14 @@ public class MigrationYaml { public void setEvent(Event event) { this.event = event; } + + public Priority getPriority() { + return priority; + } + + public void setPriority(Priority priority) { + this.priority = priority; + } diff --git a/Testgenerator/src/main/java/de/fhmuenster/masterthesis/Testgenerator/yaml/Priority.java b/Testgenerator/src/main/java/de/fhmuenster/masterthesis/Testgenerator/yaml/Priority.java new file mode 100644 index 0000000000000000000000000000000000000000..f86c50bffbcc571d059c4ccc1dc371c19ce6ffa5 --- /dev/null +++ b/Testgenerator/src/main/java/de/fhmuenster/masterthesis/Testgenerator/yaml/Priority.java @@ -0,0 +1,72 @@ +package de.fhmuenster.masterthesis.Testgenerator.yaml; + +public class Priority { + + private String formularPart0; + private String formularPart1; + private String formularPart2; + private String formularPart3; + private String formularPart4; + private String formularPart5; + private String formularPart6; + + public Priority() { + + } + + public String getFormularPart0() { + return formularPart0; + } + + public void setFormularPart0(String formularPart0) { + this.formularPart0 = formularPart0; + } + + public String getFormularPart1() { + return formularPart1; + } + + public void setFormularPart1(String formularPart1) { + this.formularPart1 = formularPart1; + } + + public String getFormularPart2() { + return formularPart2; + } + + public void setFormularPart2(String formularPart2) { + this.formularPart2 = formularPart2; + } + + public String getFormularPart3() { + return formularPart3; + } + + public void setFormularPart3(String formularPart3) { + this.formularPart3 = formularPart3; + } + + public String getFormularPart4() { + return formularPart4; + } + + public void setFormularPart4(String formularPart4) { + this.formularPart4 = formularPart4; + } + + public String getFormularPart5() { + return formularPart5; + } + + public void setFormularPart5(String formularPart5) { + this.formularPart5 = formularPart5; + } + + public String getFormularPart6() { + return formularPart6; + } + + public void setFormularPart6(String formularPart6) { + this.formularPart6 = formularPart6; + } +} \ No newline at end of file diff --git a/Testgenerator/src/main/resources/migration.yaml b/Testgenerator/src/main/resources/migration.yaml index abe09f67e353614f3d92e2ee30fd8879391b2c99..af593eb32e1ce0b45b442c4c5f147b0866e803ca 100644 --- a/Testgenerator/src/main/resources/migration.yaml +++ b/Testgenerator/src/main/resources/migration.yaml @@ -3,6 +3,14 @@ configuration: green: 100 yellow: 200 red: 500 +priority: + formularPart0: "Priority" + formularPart1: "=" + formularPart2: "Flow size" + formularPart3: "+" + formularPart4: "Flow score" + formularPart5: "-" + formularPart6: "Flow dependency" gateway: deleteTests: true add: diff --git a/testgenerator-web/testgenerator-web/src/app/app-routing.module.ts b/testgenerator-web/testgenerator-web/src/app/app-routing.module.ts index 9084447d2cefcdf6caee87c8500b180bc578ad9e..65d2d7a1c2d963c4fe753c268055044ee06e3860 100644 --- a/testgenerator-web/testgenerator-web/src/app/app-routing.module.ts +++ b/testgenerator-web/testgenerator-web/src/app/app-routing.module.ts @@ -19,7 +19,7 @@ import { UpdateProjectComponent } from './components/update-project/update-proje import { PrioritizationOverviewComponent } from './prioritization-overview/prioritization-overview.component'; import { MigrationOverviewComponent } from './components/migration-overview/migration-overview.component'; import { MatchingFlowsComponent } from './components/matching-flows/matching-flows.component'; - +import { ProjectConfigComponent } from './components/project-config/project-config.component'; const routes: Routes = [ { path: '', component: ProjectsComponent }, @@ -41,6 +41,7 @@ const routes: Routes = [ { path: 'project/:projectId/update/matchingFlows', component: MatchingFlowsComponent }, { path: 'project/:projectId/update/prio', component: PrioritizationOverviewComponent }, { path: 'project/:projectId/update', component: UpdateProjectComponent }, // new Update Component + { path: 'project/:projectId/config', component: ProjectConfigComponent}, // new Project-Setting Component { path: 'impressum', component: ImprintComponent }, { path: 'notfound', component: NotfoundComponent }, { path: '**', redirectTo: 'notfound'} //has to be the last entry diff --git a/testgenerator-web/testgenerator-web/src/app/app.module.ts b/testgenerator-web/testgenerator-web/src/app/app.module.ts index ff4f2803a2e7d547918db3b6927b7af64434c5a5..ddf231b8c55273148d59ea4bee4d2c1cc0837ef2 100644 --- a/testgenerator-web/testgenerator-web/src/app/app.module.ts +++ b/testgenerator-web/testgenerator-web/src/app/app.module.ts @@ -39,6 +39,7 @@ import { VariableConstraintsPipe } from './pipes/variable-constraints.pipe'; import {CdkAccordionModule} from '@angular/cdk/accordion'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import {MatExpansionModule} from '@angular/material/expansion'; +import { ProjectConfigComponent } from './components/project-config/project-config.component'; @NgModule({ declarations: [ @@ -71,7 +72,8 @@ import {MatExpansionModule} from '@angular/material/expansion'; MatchingFlowsComponent, FlagComponent, - VariableConstraintsPipe + VariableConstraintsPipe, + ProjectConfigComponent ], imports: [ BrowserModule, diff --git a/testgenerator-web/testgenerator-web/src/app/components/project-config/project-config.component.css b/testgenerator-web/testgenerator-web/src/app/components/project-config/project-config.component.css new file mode 100644 index 0000000000000000000000000000000000000000..ad815d7d7b2285412366671e40b280511a171d49 --- /dev/null +++ b/testgenerator-web/testgenerator-web/src/app/components/project-config/project-config.component.css @@ -0,0 +1,104 @@ +.padding-bottom { + padding-bottom: 20px; +} + +.config { + position: relative; + width: 98%; +} + +.config-header { + border: 10px solid #f7f7f9; + padding: 10px; +} + +.saveConfig { + margin-top: 10px; +} + +.dragItemBlocked { + font-size: 16px; + font-weight: 500; +} + +.dragItem { + font-size: 16px; +} + +.padding-last { + padding-bottom: 15px; +} + +.config-header span { + font-weight: 600; + vertical-align: middle; + text-transform: uppercase; + color: #838383; + font-size: 18px; +} + +.config-header i { + font-size: 16px; +} + +.config-body { + padding: 10px; + background-color: #f7f7f9; +} + +.alert { + margin-top: 20px; +} + +.example-list { + width: 100%; + max-width: 100%; + border: solid 1px #ccc; + min-height: 60px; + display: flex; + flex-direction: row; + background: white; + border-radius: 4px; + overflow: hidden; + } + + .example-box { + padding: 20px 10px; + border-right: solid 1px #ccc; + color: rgba(0, 0, 0, 0.87); + display: flex; + flex-direction: row; + align-items: center; + justify-content: space-between; + box-sizing: border-box; + cursor: move; + background: white; + font-size: 14px; + flex-grow: 1; + flex-basis: 0; + } + + .cdk-drag-preview { + box-sizing: border-box; + border-radius: 4px; + box-shadow: 0 5px 5px -3px rgba(0, 0, 0, 0.2), + 0 8px 10px 1px rgba(0, 0, 0, 0.14), + 0 3px 14px 2px rgba(0, 0, 0, 0.12); + } + + .cdk-drag-placeholder { + opacity: 0; + } + + .cdk-drag-animating { + transition: transform 250ms cubic-bezier(0, 0, 0.2, 1); + } + + .example-box:last-child { + border: none; + } + + .example-list.cdk-drop-list-dragging .example-box:not(.cdk-drag-placeholder) { + transition: transform 250ms cubic-bezier(0, 0, 0.2, 1); + } + \ No newline at end of file diff --git a/testgenerator-web/testgenerator-web/src/app/components/project-config/project-config.component.html b/testgenerator-web/testgenerator-web/src/app/components/project-config/project-config.component.html new file mode 100644 index 0000000000000000000000000000000000000000..d5689f37a5dc2a5919b9c78ce8fae2566b3eec30 --- /dev/null +++ b/testgenerator-web/testgenerator-web/src/app/components/project-config/project-config.component.html @@ -0,0 +1,65 @@ +<div class="container bg-body rounded shadow-sm" *ngIf="!isProjectLoading && actualProjectConfig"> + <div class="row"> + <div class="col-md-12"> + <h6 class="border-bottom pb-3 mb-0 headerTitle"> + <a [routerLink]="['../']" i18n="projects header"><i class="fas fa-angle-left"></i> Back to overview</a> + </h6> + <p class="title" *ngIf="!isProjectLoading && actualProjectConfig" i18n="project header">Configuration Project "{{actualProjectConfig.projectName}}"</p> + </div> + </div> + <div class="row justify-content-md-center padding-last"> + <div class="config"> + <div class="config-header"> + <span><i class="fas fa-cog"></i> Define the formula for calculating the test execution priority</span> + </div> + <div class="config-body"> + <ul> + <li><b>Flow size:</b> Number of elements within a flow</li> + <li><b>Flow score:</b> Sum of element-flags within a flow</li> + <li><b>Flow dependency:</b> Calculated dependencies within a flow</li> + </ul> + <div cdkDropList cdkDropListOrientation="horizontal" class="example-list" (cdkDropListDropped)="drop($event)"> + <ng-container *ngFor="let formulaPart of priorityFormula"> + <!-- Blocked elements--> + <ng-container *ngIf="formulaPart.edit == false && formulaPart.input == false; else formularParts"> + <div class="example-box" cdkDragDisabled cdkDrag > + <span class="dragItemBlocked">{{formulaPart.value}}</span> + </div> + </ng-container> + <ng-template #formularParts> + <ng-container *ngIf="formulaPart.edit == true && formulaPart.input == false; else formularOperators"> + <div class="example-box" cdkDrag> + <span class="dragItem">{{formulaPart.value}}</span> + </div> + </ng-container> + </ng-template> + <ng-template #formularOperators> + <ng-container *ngIf="formulaPart.edit == false && formulaPart.input == true"> + <div class="example-box" cdkDragDisabled cdkDrag> + <select class="form-select" aria-label="Default select example" (change)="onChange($event.target.value, formulaPart.name)"> + <option value="{{formulaPart.value}}" selected>{{formulaPart.value}}</option> + <option *ngIf="formulaPart.value != '+'"value="+">+</option> + <option *ngIf="formulaPart.value != '-'"value="-">-</option> + <option *ngIf="formulaPart.value != '*'"value="*">*</option> + <option *ngIf="formulaPart.value != '/'"value="/">/</option> + </select> + </div> + </ng-container> + </ng-template> + </ng-container> + </div> + <div class="row lastRow"> + <div class="col-md-12"> + <button type="button" class="btn btn-primary saveConfig float-right" type="submit" (click)="saveConfig()"> + Save configuration + <i *ngIf="configSaveSuccess == true" class="far fa-check-circle"></i> + <i *ngIf="configSaveSuccess == false" class="fas fa-times"></i> + </button> + </div> + </div> + </div> + </div> + </div> + +</div> + diff --git a/testgenerator-web/testgenerator-web/src/app/components/project-config/project-config.component.spec.ts b/testgenerator-web/testgenerator-web/src/app/components/project-config/project-config.component.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..c223f0ed2adc026286c82872c86b9f881666c4fb --- /dev/null +++ b/testgenerator-web/testgenerator-web/src/app/components/project-config/project-config.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { ProjectConfigComponent } from './project-config.component'; + +describe('ProjectConfigComponent', () => { + let component: ProjectConfigComponent; + let fixture: ComponentFixture<ProjectConfigComponent>; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ ProjectConfigComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(ProjectConfigComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/testgenerator-web/testgenerator-web/src/app/components/project-config/project-config.component.ts b/testgenerator-web/testgenerator-web/src/app/components/project-config/project-config.component.ts new file mode 100644 index 0000000000000000000000000000000000000000..a7caacfa5b4b507b08f377e6f12a0eb4dc5834a1 --- /dev/null +++ b/testgenerator-web/testgenerator-web/src/app/components/project-config/project-config.component.ts @@ -0,0 +1,96 @@ +import { Component, OnInit } from '@angular/core'; +import { FileService } from 'src/app/services/file.service'; +import { Router, ActivatedRoute } from '@angular/router'; +import { ProjectService } from 'src/app/services/project.service'; +import { SingleProjectConfig } from 'src/app/models/single-project-config'; +import { CdkDragDrop, moveItemInArray} from '@angular/cdk/drag-drop'; + +@Component({ + selector: 'app-project-config', + templateUrl: './project-config.component.html', + styleUrls: ['./project-config.component.css'] +}) + +export class ProjectConfigComponent implements OnInit { + + actualProject: number; + actualProjectConfig: SingleProjectConfig; + isProjectLoading: boolean; + configSaveSuccess: boolean; + + priorityFormula = []; + + constructor(private projectService: ProjectService, private fileService: FileService, private router: Router, private route: ActivatedRoute) { + this.route.params.subscribe(params => + this.actualProject = params['projectId'] + ) + } + + drop(event: CdkDragDrop<string[]>) { + moveItemInArray(this.priorityFormula, event.previousIndex, event.currentIndex); + } + + async ngOnInit() { + await this.loadProject(); + } + + async loadProject() { + this.isProjectLoading = true; + try { + let result = await this.projectService.getProject(this.actualProject); + let config = await this.projectService.getConfig(this.actualProject); + + + this.priorityFormula = [ + {name: "priority", edit: false, input: false, value: config[0], type: "static"}, + {name: "equals", edit: false, input: false, value: config[1], type: "static"}, + {name: "flowSize", edit: true, input: false, value: config[2], type: "flowCalc"}, + {name: "operator1", edit: false, input: true, value: config[3], type: "operator"}, + {name: "flowScore", edit: true, input: false, value: config[4], type: "flowCalc"}, + {name: "operator2", edit: false, input: true, value: config[5], type: "operator"}, + {name: "flowDependency", edit: true, input: false, value: config[6], type: "flowCalc"}, + ]; + + this.actualProjectConfig = result; + } finally { + this.isProjectLoading = false; + } + } + + async saveConfig() { + + if(this.checkFormularSyntax()) + { + let postArray = []; + this.priorityFormula.forEach(function (value) { + postArray.push(value.value); + }) + + this.projectService.saveConfig(this.actualProject, postArray); + this.configSaveSuccess = true; + } + else + { + this.configSaveSuccess = false; + return false; + } + } + + checkFormularSyntax() { + if( this.priorityFormula[0].type == "static" && + this.priorityFormula[1].type == "static" && + this.priorityFormula[2].type == "flowCalc" && + this.priorityFormula[3].type == "operator" && + this.priorityFormula[4].type == "flowCalc" && + this.priorityFormula[5].type == "operator" && + this.priorityFormula[6].type == "flowCalc") + return true; + else + return false; + } + + onChange(value, name) { + let index = this.priorityFormula.findIndex(( obj => obj.name == name)); + this.priorityFormula[index].value = value; + } +} diff --git a/testgenerator-web/testgenerator-web/src/app/components/project/project.component.html b/testgenerator-web/testgenerator-web/src/app/components/project/project.component.html index e7e7e0a377a47436daaa18bb0953e1db048fa266..4ca3dc9ba65048704a587fc4ad28fcfec6b5ee8c 100644 --- a/testgenerator-web/testgenerator-web/src/app/components/project/project.component.html +++ b/testgenerator-web/testgenerator-web/src/app/components/project/project.component.html @@ -54,6 +54,14 @@ </div> </div> </div> + <div class="col-md-12"> + <div class="card text-white bg-warning mb-3 clickable" [routerLink]="['config']"> + <div class="card-header">Project Settings<i class="fas fa-hammer"></i></div> + <div class="card-body"> + <p class="card-text">Set the project configuration ...</p> + </div> + </div> + </div> </div> </div> \ No newline at end of file diff --git a/testgenerator-web/testgenerator-web/src/app/services/project.service.ts b/testgenerator-web/testgenerator-web/src/app/services/project.service.ts index 7af154ae5212844dc8e98fbd17bb0a359085ed27..8facbbc858781ec8d6b460a33be1dcddda7237d6 100644 --- a/testgenerator-web/testgenerator-web/src/app/services/project.service.ts +++ b/testgenerator-web/testgenerator-web/src/app/services/project.service.ts @@ -41,4 +41,14 @@ export class ProjectService { const url = `${environment.apiBaseUrl}project/${projectId}`; return await this.http.delete<any>(url).toPromise(); } + + public async getConfig(projectId: number): Promise<any> { + const url = `${environment.apiBaseUrl}project/${projectId}/config`; + return await this.http.get<any>(url).toPromise(); + } + + public async saveConfig(projectId: number, config:Array<String>): Promise<any> { + const url = `${environment.apiBaseUrl}project/${projectId}/config`; + return await this.http.post<any>(url, config).toPromise(); + } }