Skip to content
Snippets Groups Projects
Commit 474b8021 authored by Henning's avatar Henning
Browse files

added config (factor, score for a new/edit test), added YAML Writer to ConfigController

parent 7ec80525
No related branches found
No related tags found
No related merge requests found
......@@ -55,6 +55,12 @@
<artifactId>jackson-core</artifactId>
<version>2.13.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.yaml/snakeyaml -->
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>1.30</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
......
......@@ -16,6 +16,8 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import de.fhmuenster.masterthesis.Testgenerator.yaml.MigrationYaml;
import de.fhmuenster.masterthesis.Testgenerator.yaml.YamlReader;
import de.fhmuenster.masterthesis.serialization.TestgeneratorDSLSerializer;
import de.fhmuenster.masterthesis.testgeneratorDSL.BusinessRuleTaskFlowElement;
import de.fhmuenster.masterthesis.testgeneratorDSL.DelegateServiceTaskFlowElement;
......@@ -181,6 +183,13 @@ public class PrioritizationService {
return testPriorities;
}
private void sumTestPrioritiesByYAML(int size, int score, int dependency) {
YamlReader yamlReader = new YamlReader();
MigrationYaml yaml = yamlReader.loadMigrationYaml();
}
/**
* Here, the changes of the variables are compared to the flowelements
* @param differentVariables
......
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.ArrayList;
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;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator.Feature;
@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()
};
YamlReader yamlReader = new YamlReader();
MigrationYaml yaml = yamlReader.loadMigrationYaml();
List<String> configs = new ArrayList<String>();
configs.add(yaml.getPriority().getFormularPart0());
configs.add(yaml.getPriority().getFormularPart1());
configs.add(yaml.getPriority().getFormularPart2());
configs.add(yaml.getPriority().getFormularPart3());
configs.add(yaml.getPriority().getFormularPart4());
configs.add(yaml.getPriority().getFormularPart5());
configs.add(yaml.getPriority().getFormularPart6());
int factor = yaml.getPriority().getFactor();
int updateCreateScore = yaml.getPriority().getUpdateCreateScore();
configs.add(Integer.toString(factor));
configs.add(Integer.toString(updateCreateScore));
String[] returnArr = new String[configs.size()];
returnArr = configs.toArray(returnArr);
return priorityFormula;
return returnArr;
}
@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));
public void saveConfig(@PathVariable(required = true) Long projectId, @RequestBody List<String> arrayParams) throws IOException {
try {
ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
mapper.findAndRegisterModules();
MigrationYaml yaml = mapper.readValue(new File("src/main/resources/migration.yaml"), MigrationYaml.class);
mapper = new ObjectMapper(new YAMLFactory().disable(Feature.WRITE_DOC_START_MARKER));
yaml.getPriority().setFormularPart0(arrayParams.get(0)); // Formular parts 0-6
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));
yaml.getPriority().setFactor(Integer.parseInt(arrayParams.get(7))); // factor
yaml.getPriority().setUpdateCreateScore(Integer.parseInt(arrayParams.get(8))); // updateCreateScore
mapper.writeValue(new File("src/main/resources/migration.yaml"), yaml);
}
catch(Exception e) {
System.out.println(e.getMessage());
}
}
}
......@@ -9,6 +9,8 @@ public class Priority {
private String formularPart4;
private String formularPart5;
private String formularPart6;
private Integer factor;
private Integer updateCreateScore;
public Priority() {
......@@ -69,4 +71,20 @@ public class Priority {
public void setFormularPart6(String formularPart6) {
this.formularPart6 = formularPart6;
}
public Integer getUpdateCreateScore() {
return updateCreateScore;
}
public void setUpdateCreateScore(Integer updateCreateScore) {
this.updateCreateScore = updateCreateScore;
}
public Integer getFactor() {
return factor;
}
public void setFactor(Integer factor) {
this.factor = factor;
}
}
\ No newline at end of file
# globale Konfiguration für Status, kann dann spezieller überschrieben werden
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:
xor:
status: RED
status: "RED"
priority: null
or:
status: RED
status: "RED"
priority: null
parallel:
status: YELLOW
status: "YELLOW"
priority: null
delete:
xor:
status: RED
status: "RED"
priority: null
or:
status: RED
status: "RED"
priority: null
parallel:
status: YELLOW
status: "YELLOW"
priority: null
rename:
status: GREEN
status: "GREEN"
priority: null
deleteTests: true
activity:
add:
userTask:
required:
status: RED
status: "RED"
priority: null
notRequired:
status: GREEN
status: "GREEN"
priority: null
manualTask:
status: GREEN
status: "GREEN"
priority: null
businessRuleTask:
status: GREEN
status: "GREEN"
priority: null
serviceTask:
status: GREEN
status: "GREEN"
priority: null
scriptTask:
status: GREEN
status: "GREEN"
priority: null
delete:
userTask:
status: YELLOW
status: "YELLOW"
priority: null
manualTask:
status: GREEN
status: "GREEN"
priority: null
businessRuleTask:
status: GREEN
status: "GREEN"
priority: null
serviceTask:
status: GREEN
status: "GREEN"
priority: null
scriptTask:
status: GREEN
status: "GREEN"
priority: null
addProcessVariable:
required:
status: RED
status: "RED"
priority: null
notRequired:
status: GREEN
status: "GREEN"
priority: null
deleteProcessVariable:
status: YELLOW
status: "YELLOW"
priority: null
changeConstraint:
fromNotRequiredToRequired:
status: "RED"
priority: null
higherThanMin:
status: GREEN
status: "GREEN"
priority: null
lowerThanMax:
status: GREEN
status: "GREEN"
priority: null
lowerThanMin:
status: RED
status: "RED"
priority: null
higherThanMax:
status: RED
status: "RED"
priority: null
longerThanMinlength:
status: GREEN
status: "GREEN"
priority: null
shorterThanMaxlength:
status: GREEN
status: "GREEN"
priority: null
shorterThanMinlength:
status: RED
status: "RED"
priority: null
longerThanMaxlength:
status: RED
fromNotRequiredToRequired:
status: RED
status: "RED"
priority: null
changeOrder:
status: GREEN
status: "GREEN"
priority: null
changeType:
fromXTaskToUserTask:
required:
status: RED
status: "RED"
priority: null
notRequired:
status: GREEN
status: "GREEN"
priority: null
fromXTaskToXTask:
status: GREEN
status: "GREEN"
priority: null
fromUserTaskToXTask:
status: YELLOW
status: "YELLOW"
priority: null
event:
addProcessVariable:
required:
status: RED
status: "RED"
priority: null
notRequired:
status: GREEN
status: "GREEN"
priority: null
deleteProcessVariable:
status: YELLOW
status: "YELLOW"
priority: null
changeConstraint:
fromNotRequiredToRequired:
status: "RED"
priority: null
higherThanMin:
status: GREEN
status: "GREEN"
priority: null
lowerThanMax:
status: GREEN
status: "GREEN"
priority: null
lowerThanMin:
status: RED
status: "RED"
priority: null
higherThanMax:
status: RED
status: "RED"
priority: null
longerThanMinlength:
status: GREEN
status: "GREEN"
priority: null
shorterThanMaxlength:
status: GREEN
status: "GREEN"
priority: null
shorterThanMinlength:
status: RED
status: "RED"
priority: null
longerThanMaxlength:
status: RED
fromNotRequiredToRequired:
status: RED
status: "RED"
priority: null
priority:
formularPart0: "Priority"
formularPart1: "="
formularPart2: "FlowSize"
formularPart3: "+"
formularPart4: "FlowScore"
formularPart5: "/"
formularPart6: "FlowDependency"
factor: 2
updateCreateScore: 200
......@@ -17,6 +17,8 @@
<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>
<li style="list-style: none"> </li>
<li><b>Total test priority =</b> update/create score (<b>{{updateCreateScore}}</b>) + manual test score + (defined factor (<b>{{factor}}</b>) * <b>priority)</b></li>
</ul>
<div cdkDropList cdkDropListOrientation="horizontal" class="example-list" (cdkDropListDropped)="drop($event)">
<ng-container *ngFor="let formulaPart of priorityFormula">
......@@ -48,15 +50,50 @@
</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 class="config">
<div class="config-header">
<span><i class="fas fa-cog"></i> Define the factor for the priority formula</span>
</div>
<div class="config-body">
<ng-container>
<p>
This value is multiplied by the priority formula
</p>
<form>
<div class="form-group">
<input type="number" class="form-control" id="factor" placeholder="Enter factor" name="factor" [(ngModel)]="factor" value="{{ factor }}">
</div>
</form>
</ng-container>
</div>
</div>
<div class="config">
<div class="config-header">
<span><i class="fas fa-cog"></i> Define the score for editing a test</span>
</div>
<div class="config-body">
<ng-container>
<p>
This value will be added if you edit a test. This score can be used to prioritize tests that have recently been edited.
</p>
<form>
<div class="form-group">
<input type="number" class="form-control" id="updateCreateScore" placeholder="Enter edit test score" name="udpateCreateScore" [(ngModel)]="updateCreateScore" value="{{ updateCreateScore }}">
</div>
</form>
</ng-container>
</div>
</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="configLoading == true" class="fas fa-times"></i>
<i *ngIf="configSaveSuccess == false" class="fas fa-times"></i>
</button>
</div>
</div>
</div>
......
......@@ -4,6 +4,7 @@ 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';
import * as internal from 'stream';
@Component({
selector: 'app-project-config',
......@@ -17,7 +18,9 @@ export class ProjectConfigComponent implements OnInit {
actualProjectConfig: SingleProjectConfig;
isProjectLoading: boolean;
configSaveSuccess: boolean;
configLoading: boolean = false;
factor: number;
updateCreateScore: number;
priorityFormula = [];
constructor(private projectService: ProjectService, private fileService: FileService, private router: Router, private route: ActivatedRoute) {
......@@ -51,6 +54,9 @@ export class ProjectConfigComponent implements OnInit {
{name: "flowDependency", edit: true, input: false, value: config[6], type: "flowCalc"},
];
this.factor = config[7];
this.updateCreateScore = config[8];
this.actualProjectConfig = result;
} finally {
this.isProjectLoading = false;
......@@ -58,20 +64,23 @@ export class ProjectConfigComponent implements OnInit {
}
async saveConfig() {
this.configLoading = true;
if(this.checkFormularSyntax())
{
let postArray = [];
this.priorityFormula.forEach(function (value) {
postArray.push(value.value);
})
postArray.push(this.factor.toString());
postArray.push(this.updateCreateScore.toString());
this.projectService.saveConfig(this.actualProject, postArray);
this.configSaveSuccess = true;
this.configLoading = false;
}
else
{
this.configSaveSuccess = false;
this.configLoading = false;
return false;
}
}
......
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