use of lunigorn.task_book_service.persistence.domain.Task in project task-book by Lunigorn.
the class TaskRepositoryTests method taskDeleteSuccess.
@Test
public void taskDeleteSuccess() {
// arrange
Task task = new Task();
String randomName = RandomStringUtils.randomAlphabetic(10);
String randomDescription = RandomStringUtils.randomAlphabetic(1000);
task.setName(randomName);
task.setDescription(randomDescription);
tasks.save(task);
Task toDelete = tasks.findOneByName(randomName);
// act
tasks.delete(toDelete);
// assert
assertNotNull(toDelete);
assertNull(tasks.findOneByName(randomName));
}
use of lunigorn.task_book_service.persistence.domain.Task in project task-book by Lunigorn.
the class TaskRepositoryTests method taskSaveSucces.
@Test
public void taskSaveSucces() {
// arrange
Task task = new Task();
String randomName = RandomStringUtils.randomAlphabetic(10);
String randomDescription = RandomStringUtils.randomAlphabetic(1000);
task.setName(randomName);
task.setDescription(randomDescription);
// act
tasks.save(task);
// assert
Task found = tasks.findOneByName(randomName);
assertEquals(task, found);
}
use of lunigorn.task_book_service.persistence.domain.Task in project task-book by Lunigorn.
the class TaskController method deleteById.
@RequestMapping(path = "/tasks/{id}", method = RequestMethod.DELETE)
public Task deleteById(@PathVariable Long id) {
Task found = tasks.findOne(id);
if (found.equals(null))
return null;
tasks.delete(id);
return found;
}
use of lunigorn.task_book_service.persistence.domain.Task in project task-book by Lunigorn.
the class TaskControllerTests method taskUpdateSucces.
@Test
@SneakyThrows({ Exception.class })
public void taskUpdateSucces() {
// arrange
Task task = new Task();
String randomName = RandomStringUtils.randomAlphabetic(10);
String randomDescription = RandomStringUtils.randomAlphabetic(1000);
task.setName(randomName);
task.setDescription(randomDescription);
tasks.save(task);
String newRandomName = RandomStringUtils.randomAlphabetic(10);
String newRandomDescription = RandomStringUtils.randomAlphabetic(1000);
// assert name saved in database is correct
assertEquals(tasks.findOne(task.getId()).getName(), randomName);
assertEquals(tasks.findOne(task.getId()).getDescription(), randomDescription);
// act
mockMvc.perform(put("/tasks/").content("{\"id\":\"" + task.getId() + "\",\"name\":\"" + newRandomName + "\",\"description\":\"" + newRandomDescription + "\"}").contentType(contentType)).andDo(print()).andExpect(status().is2xxSuccessful()).andExpect(jsonPath("$.id", anything())).andExpect(jsonPath("$.name", is(newRandomName))).andExpect(jsonPath("$.description", is(newRandomDescription)));
// assert name saved in database is changed
assertEquals(tasks.findOne(task.getId()).getName(), newRandomName);
assertEquals(tasks.findOne(task.getId()).getDescription(), newRandomDescription);
assertNotEquals(tasks.findOne(task.getId()).getName(), randomName);
assertNotEquals(tasks.findOne(task.getId()).getDescription(), randomDescription);
}
Aggregations