Search in sources :

Example 11 with Project

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

the class ProjectApiItTest method testGetProjects.

@Test
public void testGetProjects() {
    Map<Long, Project> createdProjects = new HashMap<>();
    try {
        int numProjects = 5;
        for (int i = 0; i < numProjects; i++) {
            Project project = createProject(PROJECT_NAME + i);
            createdProjects.put(project.getId(), project);
        }
        log.debug("GET /project");
        ResponseEntity<Project[]> response = httpClient.getForEntity("/api/project", Project[].class);
        Project[] projects = response.getBody();
        log.info("Projects Array size:" + projects.length);
        Map<Long, Project> retrievedProjects = new HashMap<>();
        for (Project project : projects) {
            retrievedProjects.put(project.getId(), project);
        }
        assertTrue(retrievedProjects.keySet().containsAll(createdProjects.keySet()));
    } finally {
        for (Long projectId : createdProjects.keySet()) {
            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 12 with Project

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

the class ProjectApiItTest method testCreateProject.

@Test
public void testCreateProject() throws JsonProcessingException, IOException {
    // Test data (input)
    String requestJson = "{ \"id\": 0,\"name\": \"" + PROJECT_NAME + "\"}";
    HttpHeaders headers = new HttpHeaders();
    headers.setContentType(MediaType.APPLICATION_JSON);
    HttpEntity<String> entity = new HttpEntity<>(requestJson, headers);
    // Exercise #1 (create project)
    log.debug("POST /project");
    ResponseEntity<Project> response = httpClient.postForEntity("/api/project", entity, Project.class);
    log.info("Project created:" + response.getBody());
    try {
        assertTrue(response.getBody().getName().equals(PROJECT_NAME));
        assertNotNull(response.getBody().getId());
    } finally {
        deleteProject(response.getBody().getId());
    }
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) Project(io.elastest.etm.model.Project) HttpEntity(org.springframework.http.HttpEntity) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

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