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);
}
}
}
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());
}
}
Aggregations