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