use of org.springframework.sync.TodoRepository in project spring-sync by spring-projects.
the class DiffSyncControllerTest method statusChangedOnClient_itemDeletedFromServer.
@Test
@Ignore
public void statusChangedOnClient_itemDeletedFromServer() throws Exception {
TodoRepository todoRepository = todoRepository();
MockMvc mvc = mockMvc(todoRepository);
performNoOpRequestToSetupShadow(mvc);
repository.delete(2L);
mvc.perform(patch(RESOURCE_PATH).content(resource("patch-change-single-status")).accept(JSON_PATCH).contentType(JSON_PATCH)).andExpect(content().string(resource("patch-remove-completed-item"))).andExpect(content().contentType(JSON_PATCH)).andExpect(status().isOk());
List<Todo> all = (List<Todo>) repository.findAll();
assertEquals(2, all.size());
assertEquals(new Todo(1L, "A", false), all.get(0));
assertEquals(new Todo(3L, "C", false), all.get(1));
}
use of org.springframework.sync.TodoRepository in project spring-sync by spring-projects.
the class DiffSyncControllerTest method patchChangesItemStatusAndThenRemovesThatSameItem.
@Test
public void patchChangesItemStatusAndThenRemovesThatSameItem() throws Exception {
TodoRepository todoRepository = todoRepository();
MockMvc mvc = mockMvc(todoRepository);
mvc.perform(patch(RESOURCE_PATH).content(resource("patch-modify-then-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 patchSendsSingleStatusChange.
@Test
public void patchSendsSingleStatusChange() throws Exception {
TodoRepository todoRepository = todoRepository();
MockMvc mvc = mockMvc(todoRepository);
mvc.perform(patch(RESOURCE_PATH).content(resource("patch-change-single-status")).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, "B", 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 patchRemovesTwoOtherItemsAndUpdatesStatusOnAnother.
@Test
public void patchRemovesTwoOtherItemsAndUpdatesStatusOnAnother() throws Exception {
TodoRepository todoRepository = todoRepository();
MockMvc mvc = mockMvc(todoRepository);
mvc.perform(patch(RESOURCE_PATH).content(resource("patch-delete-twoitems-and-change-status-on-another")).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(3L, "C", true));
}
use of org.springframework.sync.TodoRepository in project spring-sync by spring-projects.
the class DiffSyncControllerTest method patchAddsAnItem.
@Test
@Ignore
public void patchAddsAnItem() throws Exception {
TodoRepository todoRepository = todoRepository();
MockMvc mvc = mockMvc(todoRepository);
mvc.perform(patch(RESOURCE_PATH).content(resource("patch-add-new-item")).accept(JSON_PATCH).contentType(JSON_PATCH)).andExpect(status().isOk()).andExpect(content().string("[{\"op\":\"test\",\"path\":\"/3/id\"},{\"op\":\"add\",\"path\":\"/3/id\",\"value\":4}]")).andExpect(content().contentType(JSON_PATCH));
List<Todo> all = (List<Todo>) repository.findAll();
assertEquals(4, all.size());
assertEquals(all.get(0), new Todo(1L, "A", false));
assertEquals(all.get(1), new Todo(2L, "B", false));
assertEquals(all.get(2), new Todo(3L, "C", false));
assertEquals(all.get(2), new Todo(4L, "D", false));
}