Search in sources :

Example 11 with TodoRepository

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));
}
Also used : Todo(org.springframework.sync.Todo) List(java.util.List) TodoRepository(org.springframework.sync.TodoRepository) MockMvc(org.springframework.test.web.servlet.MockMvc) Test(org.junit.Test)

Example 12 with TodoRepository

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));
}
Also used : Todo(org.springframework.sync.Todo) List(java.util.List) TodoRepository(org.springframework.sync.TodoRepository) MockMvc(org.springframework.test.web.servlet.MockMvc) Test(org.junit.Test)

Example 13 with TodoRepository

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));
}
Also used : Todo(org.springframework.sync.Todo) List(java.util.List) TodoRepository(org.springframework.sync.TodoRepository) MockMvc(org.springframework.test.web.servlet.MockMvc) Test(org.junit.Test)

Example 14 with TodoRepository

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));
}
Also used : Todo(org.springframework.sync.Todo) List(java.util.List) TodoRepository(org.springframework.sync.TodoRepository) MockMvc(org.springframework.test.web.servlet.MockMvc) Test(org.junit.Test)

Example 15 with TodoRepository

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));
}
Also used : Todo(org.springframework.sync.Todo) List(java.util.List) TodoRepository(org.springframework.sync.TodoRepository) MockMvc(org.springframework.test.web.servlet.MockMvc) Test(org.junit.Test)

Aggregations

List (java.util.List)15 Test (org.junit.Test)15 Todo (org.springframework.sync.Todo)15 TodoRepository (org.springframework.sync.TodoRepository)15 MockMvc (org.springframework.test.web.servlet.MockMvc)15 Ignore (org.junit.Ignore)3