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

added new component / REST endpoint

added a new page to view the current test priorization
parent e33f8a88
No related branches found
No related tags found
No related merge requests found
......@@ -2,16 +2,30 @@ package de.fhmuenster.masterthesis.Testgenerator.rest.service.config;
import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
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.RestController;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import de.fhmuenster.masterthesis.Testgenerator.rest.service.project.Project;
import de.fhmuenster.masterthesis.Testgenerator.rest.service.project.ProjectService;
import de.fhmuenster.masterthesis.Testgenerator.rest.service.test.TestService;
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 de.fhmuenster.masterthesis.testgeneratorDSL.Test;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator.Feature;
......@@ -19,6 +33,12 @@ import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator.Feature;
@RestController
@EnableWebMvc
public class ConfigController {
@Autowired
private ProjectService projectService;
@Autowired
private TestService testService;
@RequestMapping(path = "/project/{projectId}/config", method = RequestMethod.GET)
public String[] getConfig(@PathVariable(required = true) Long projectId) throws IOException {
......@@ -69,4 +89,26 @@ public class ConfigController {
System.out.println(e.getMessage());
}
}
@RequestMapping(path = "/project/{projectId}/priority", method = RequestMethod.GET)
public List<Test> getPriority(@PathVariable(required = true) Long projectId) throws IOException {
List<Test> tests = null;
try {
Project project = projectService.getProjectForId(projectId);
Path filePath = ProjectDirectoryUtils.getTestspecificationPath(project.getProjectDirectories());
Path dslFile = Paths.get(filePath.toString());
TestgeneratorDSLSerializer dsl = new TestgeneratorDSLSerializer(dslFile.toString());
tests = dsl.getTests();
Collections.sort(tests, (o1, o2) -> o1.getOrder() - o2.getOrder());
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
return tests;
}
}
......@@ -42,6 +42,7 @@ const routes: Routes = [
{ 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: 'project/:projectId/priority', component: PrioritizationOverviewComponent}, // new Project-Setting Component
{ path: 'impressum', component: ImprintComponent },
{ path: 'notfound', component: NotfoundComponent },
{ path: '**', redirectTo: 'notfound'} //has to be the last entry
......
......@@ -57,7 +57,7 @@
</div>
</div>
</div>
<div class="col-md-12">
<div class="col-md-6">
<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">
......@@ -65,6 +65,14 @@
</div>
</div>
</div>
<div class="col-md-6">
<div class="card text-white bg-light mb-3 clickable" [routerLink]="['priority']">
<div class="card-header">Test priority<i class="fas fa-sort-numeric-down"></i></div>
<div class="card-body">
<p class="card-text">View the actual test execution order ...</p>
</div>
</div>
</div>
</div>
</div>
\ No newline at end of file
.card {
margin-bottom: 10px;
}
\ No newline at end of file
<p>prioritization-overview works!</p>
<p>TODO: Priorisierung</p>
\ No newline at end of file
<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">Priority overview "{{actualProjectConfig.projectName}}"</p>
</div>
</div>
<div class="row justify-content-md-center ">
<div class="col-md-12">
<ng-container *ngIf="projectTests == 0; else tests">
<b>No tests found.</b>
</ng-container>
<ng-template #tests>
<ng-container *ngFor="let test of projectTests">
<div class="card">
<div class="card-header">
<b>{{ test.name }}</b>
</div>
<div class="card-body">
<h5 class="card-title">Execution order: <span class="badge badge-secondary">{{ test.order }}</span></h5>
<ul class="list-group list-group-flush">
<li class="list-group-item"><b>Priority: </b> {{ test.priority }} </li>
<li class="list-group-item"><b>Flag: </b> {{ test.flag }} </li>
</ul>
</div>
</div>
</ng-container>
</ng-template>
</div>
</div>
</div>
import { Component, OnInit } from '@angular/core';
import { ProjectService } from 'src/app/services/project.service';
import { Router, ActivatedRoute } from '@angular/router';
import { SingleProjectConfig } from 'src/app/models/single-project-config';
@Component({
selector: 'app-prioritization-overview',
......@@ -7,9 +10,36 @@ import { Component, OnInit } from '@angular/core';
})
export class PrioritizationOverviewComponent implements OnInit {
constructor() { }
actualProject: number;
actualProjectConfig: SingleProjectConfig;
isProjectLoading: boolean;
projectTests: any;
ngOnInit(): void {
constructor(private projectService: ProjectService, private router: Router, private route: ActivatedRoute) {
this.route.params.subscribe(params =>
this.actualProject = params['projectId']
)
}
async ngOnInit() {
await this.loadProject();
await this.loadPriority();
}
async loadProject() {
this.isProjectLoading = true;
try {
let result = await this.projectService.getProject(this.actualProject);
this.actualProjectConfig = result;
} finally {
this.isProjectLoading = false;
}
}
async loadPriority() {
let tests = await this.projectService.getTests(this.actualProject);
this.projectTests = tests;
console.log(this.projectTests);
}
}
......@@ -51,4 +51,9 @@ export class ProjectService {
const url = `${environment.apiBaseUrl}project/${projectId}/config`;
return await this.http.post<any>(url, config).toPromise();
}
public async getTests(projectId: number): Promise<any> {
const url = `${environment.apiBaseUrl}project/${projectId}/priority`;
return await this.http.get<any>(url).toPromise();
}
}
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