use of org.springframework.sync.TodoRepository in project spring-sync by spring-projects.
the class DiffSyncControllerTest method patchSendsAStatusChangeAndADescriptionChangeForSameItem.
@Test
public void patchSendsAStatusChangeAndADescriptionChangeForSameItem() throws Exception {
TodoRepository todoRepository = todoRepository();
MockMvc mvc = mockMvc(todoRepository);
mvc.perform(patch(RESOURCE_PATH).content(resource("patch-change-single-status-and-desc")).accept(JSON_PATCH).contentType(JSON_PATCH)).andExpect(status().isOk()).andExpect(content().string("[]")).andExpect(content().contentType(JSON_PATCH));
List<Todo> all = (List<Todo>) repository.findAll();
assertEquals(3, all.size());
assertEquals(all.get(0), new Todo(1L, "A", false));
assertEquals(all.get(1), new Todo(2L, "BBB", true));
assertEquals(all.get(2), new Todo(3L, "C", false));
}
use of org.springframework.sync.TodoRepository in project spring-sync by spring-projects.
the class DiffSyncControllerTest method patchRemovesAnItem.
@Test
public void patchRemovesAnItem() throws Exception {
TodoRepository todoRepository = todoRepository();
MockMvc mvc = mockMvc(todoRepository);
mvc.perform(patch(RESOURCE_PATH).content(resource("patch-remove-item")).accept(JSON_PATCH).contentType(JSON_PATCH)).andExpect(status().isOk()).andExpect(content().string("[]")).andExpect(content().contentType(JSON_PATCH));
List<Todo> all = (List<Todo>) repository.findAll();
assertEquals(2, all.size());
assertEquals(all.get(0), new Todo(1L, "A", false));
assertEquals(all.get(1), new Todo(3L, "C", false));
}
use of org.springframework.sync.TodoRepository in project spring-sync by spring-projects.
the class DiffSyncControllerTest method patchUpdatesStatusOnOneItemAndRemovesTwoOtherItems.
@Test
public void patchUpdatesStatusOnOneItemAndRemovesTwoOtherItems() throws Exception {
TodoRepository todoRepository = todoRepository();
MockMvc mvc = mockMvc(todoRepository);
mvc.perform(patch(RESOURCE_PATH).content(resource("patch-change-status-and-delete-two-items")).accept(JSON_PATCH).contentType(JSON_PATCH)).andExpect(status().isOk()).andExpect(content().string("[]")).andExpect(content().contentType(JSON_PATCH));
List<Todo> all = (List<Todo>) repository.findAll();
assertEquals(1, all.size());
assertEquals(all.get(0), new Todo(1L, "A", true));
}
use of org.springframework.sync.TodoRepository in project spring-sync by spring-projects.
the class DiffSyncControllerTest method patchSendsEntityDescriptionChange.
@Test
public void patchSendsEntityDescriptionChange() throws Exception {
TodoRepository todoRepository = todoRepository();
MockMvc mvc = mockMvc(todoRepository);
mvc.perform(patch(RESOURCE_PATH + "/2").content(resource("patch-change-entity-description")).accept(JSON_PATCH).contentType(JSON_PATCH)).andExpect(status().isOk()).andExpect(content().string("[]")).andExpect(content().contentType(JSON_PATCH));
List<Todo> all = (List<Todo>) repository.findAll();
assertEquals(3, all.size());
assertEquals(new Todo(1L, "A", false), all.get(0));
assertEquals(new Todo(2L, "BBB", false), all.get(1));
assertEquals(new Todo(3L, "C", false), all.get(2));
}
use of org.springframework.sync.TodoRepository in project spring-sync by spring-projects.
the class DiffSyncControllerTest method patchRemovesTwoItems.
@Test
public void patchRemovesTwoItems() throws Exception {
TodoRepository todoRepository = todoRepository();
MockMvc mvc = mockMvc(todoRepository);
mvc.perform(patch(RESOURCE_PATH).content(resource("patch-remove-two-items")).accept(JSON_PATCH).contentType(JSON_PATCH)).andExpect(status().isOk()).andExpect(content().string("[]")).andExpect(content().contentType(JSON_PATCH));
List<Todo> all = (List<Todo>) repository.findAll();
assertEquals(1, all.size());
assertEquals(all.get(0), new Todo(1L, "A", false));
}