Search in sources :

Example 1 with Project

use of io.elastest.etm.model.Project in project elastest-torm by elastest.

the class ExternalService method createElasTestEntitiesForExtJob.

private TJob createElasTestEntitiesForExtJob(ExternalJob externalJob) throws Exception {
    logger.info("Creating external job entities.");
    try {
        logger.debug("Creating Project.");
        Project project = projectService.getProjectByName(externalJob.getJobName());
        if (project == null) {
            project = new Project();
            project.setId(0L);
            project.setName(externalJob.getJobName());
            project = projectService.createProject(project);
        }
        logger.debug("Creating TJob.");
        TJob tJob = tJobService.getTJobByName(externalJob.getJobName());
        if (tJob == null) {
            tJob = new TJob();
            tJob.setName(externalJob.getJobName());
            tJob.setProject(project);
            tJob.setExternal(true);
            tJob = tJobService.createTJob(tJob);
        }
        if (externalJob.getTSServices() != null && externalJob.getTSServices().size() > 0) {
            tJob.setSelectedServices("[");
            for (TestSupportServices tSService : externalJob.getTSServices()) {
                tJob.setSelectedServices(tJob.getSelectedServices() + tSService.toJsonString());
            }
            tJob.setSelectedServices(tJob.getSelectedServices() + "]");
        }
        return tJob;
    } catch (Exception e) {
        e.printStackTrace();
        logger.error("Error message: " + e.getMessage());
        throw e;
    }
}
Also used : ExternalProject(io.elastest.etm.model.external.ExternalProject) Project(io.elastest.etm.model.Project) TestSupportServices(io.elastest.etm.api.model.TestSupportServices) TJob(io.elastest.etm.model.TJob) ExternalTJob(io.elastest.etm.model.external.ExternalTJob) HTTPException(javax.xml.ws.http.HTTPException)

Example 2 with Project

use of io.elastest.etm.model.Project in project elastest-torm by elastest.

the class EtmApiItTest method createProject.

protected Project createProject(String projectName) {
    String requestJson = "{ \"id\": 0,\"name\": \"" + projectName + "\"}";
    HttpHeaders headers = new HttpHeaders();
    headers.setContentType(MediaType.APPLICATION_JSON);
    HttpEntity<String> entity = new HttpEntity<String>(requestJson, headers);
    log.info("POST /project");
    ResponseEntity<Project> response = httpClient.postForEntity("/api/project", entity, Project.class);
    return response.getBody();
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) Project(io.elastest.etm.model.Project) HttpEntity(org.springframework.http.HttpEntity)

Example 3 with Project

use of io.elastest.etm.model.Project in project elastest-torm by elastest.

the class ProjectApiItTest method testDeleteProject.

@Test
public void testDeleteProject() {
    Project project = createProject(PROJECT_NAME);
    Map<String, Long> urlParams = new HashMap<>();
    urlParams.put("id", project.getId());
    log.info("DELETE /project");
    ResponseEntity<Long> response = httpClient.exchange("/api/project/{id}", HttpMethod.DELETE, null, Long.class, urlParams);
    log.info("Deleted project:" + response.getBody());
    assertTrue(response.getBody().longValue() == project.getId());
}
Also used : Project(io.elastest.etm.model.Project) HashMap(java.util.HashMap) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 4 with Project

use of io.elastest.etm.model.Project in project elastest-torm by elastest.

the class ProjectApiItTest method testGetProjectById.

@Test
public void testGetProjectById() {
    long projectId = -1;
    try {
        Project project = createProject(PROJECT_NAME);
        projectId = project.getId();
        Map<String, Long> urlParams = new HashMap<>();
        urlParams.put("id", projectId);
        log.info("GET /project/{id}");
        ResponseEntity<Project> response = httpClient.getForEntity("/api/project/{id}", Project.class, urlParams);
        assertNotNull(response.getBody());
        assertTrue(response.getBody().getName().equals(PROJECT_NAME));
    } finally {
        if (projectId != -1) {
            deleteProject(projectId);
        }
    }
}
Also used : Project(io.elastest.etm.model.Project) HashMap(java.util.HashMap) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 5 with Project

use of io.elastest.etm.model.Project in project elastest-torm by elastest.

the class ProjectApiItTest method createProject.

private Project createProject(String projectName) {
    String requestJson = "{ \"id\": 0,\"name\": \"" + projectName + "\"}";
    HttpHeaders headers = new HttpHeaders();
    headers.setContentType(MediaType.APPLICATION_JSON);
    HttpEntity<String> entity = new HttpEntity<String>(requestJson, headers);
    log.info("POST /project");
    ResponseEntity<Project> response = httpClient.postForEntity("/api/project", entity, Project.class);
    return response.getBody();
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) Project(io.elastest.etm.model.Project) HttpEntity(org.springframework.http.HttpEntity)

Aggregations

Project (io.elastest.etm.model.Project)12 Test (org.junit.jupiter.api.Test)6 TJob (io.elastest.etm.model.TJob)5 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)4 HashMap (java.util.HashMap)3 HttpEntity (org.springframework.http.HttpEntity)3 HttpHeaders (org.springframework.http.HttpHeaders)3 SutSpecification (io.elastest.etm.model.SutSpecification)2 TestSupportServices (io.elastest.etm.api.model.TestSupportServices)1 Parameter (io.elastest.etm.model.Parameter)1 SutExecution (io.elastest.etm.model.SutExecution)1 TJobExecution (io.elastest.etm.model.TJobExecution)1 ExternalProject (io.elastest.etm.model.external.ExternalProject)1 ExternalTJob (io.elastest.etm.model.external.ExternalTJob)1 ArrayList (java.util.ArrayList)1 PostConstruct (javax.annotation.PostConstruct)1 HTTPException (javax.xml.ws.http.HTTPException)1 Bean (org.springframework.context.annotation.Bean)1