use of org.springframework.sync.diffsync.shadowstore.MapBasedShadowStore in project spring-sync by spring-projects.
the class DiffSyncTest method patchEntity_numericProperty.
@Test
public void patchEntity_numericProperty() throws Exception {
DiffSync<Todo> sync = new DiffSync<Todo>(new MapBasedShadowStore("x"), Todo.class);
Patch patch = readJsonPatchFromResource("single-change-id");
Todo todo = new Todo(1L, "A", false);
Todo patched = sync.apply(todo, patch);
assertEquals(123L, patched.getId().longValue());
assertEquals("A", patched.getDescription());
assertFalse(patched.isComplete());
// original remains unchanged
assertEquals(1L, todo.getId().longValue());
assertEquals("A", todo.getDescription());
assertFalse(todo.isComplete());
}
use of org.springframework.sync.diffsync.shadowstore.MapBasedShadowStore in project spring-sync by spring-projects.
the class DiffSyncTest method patchList_changeSingleEntityStatus.
@Test
public void patchList_changeSingleEntityStatus() throws Exception {
DiffSync<Todo> sync = new DiffSync<Todo>(new MapBasedShadowStore("x"), Todo.class);
Patch patch = readJsonPatchFromResource("patch-change-single-status");
List<Todo> todos = getTodoList();
List<Todo> patched = sync.apply(todos, patch);
// original should remain unchanged
assertEquals(todos, getTodoList());
assertNotEquals(patched, todos);
assertEquals(3, patched.size());
assertEquals(todos.get(0), patched.get(0));
assertEquals(new Todo(2L, "B", true), patched.get(1));
assertEquals(todos.get(2), patched.get(2));
}
use of org.springframework.sync.diffsync.shadowstore.MapBasedShadowStore in project spring-sync by spring-projects.
the class DiffSyncTest method patchList_modifyThenRemoveItem.
@Test
public void patchList_modifyThenRemoveItem() throws Exception {
DiffSync<Todo> sync = new DiffSync<Todo>(new MapBasedShadowStore("x"), Todo.class);
Patch patch = readJsonPatchFromResource("patch-modify-then-remove-item");
List<Todo> todos = getTodoList();
List<Todo> patched = sync.apply(todos, patch);
// original should remain unchanged
assertEquals(todos, getTodoList());
assertNotEquals(patched, todos);
assertEquals(2, patched.size());
assertEquals(new Todo(1L, "A", false), patched.get(0));
assertEquals(new Todo(3L, "C", false), patched.get(1));
}
use of org.springframework.sync.diffsync.shadowstore.MapBasedShadowStore in project spring-sync by spring-projects.
the class DiffSyncTest method patchList_deleteTwoItemsAndChangeStatusOnAnother.
@Test
public void patchList_deleteTwoItemsAndChangeStatusOnAnother() throws Exception {
DiffSync<Todo> sync = new DiffSync<Todo>(new MapBasedShadowStore("x"), Todo.class);
Patch patch = readJsonPatchFromResource("patch-delete-twoitems-and-change-status-on-another");
List<Todo> todos = getTodoList();
List<Todo> patched = sync.apply(todos, patch);
// original should remain unchanged
assertEquals(todos, getTodoList());
assertNotEquals(patched, todos);
assertEquals(1, patched.size());
assertEquals(new Todo(3L, "C", true), patched.get(0));
}
use of org.springframework.sync.diffsync.shadowstore.MapBasedShadowStore in project spring-sync by spring-projects.
the class DiffSyncTest method patchList_removeItem.
@Test
public void patchList_removeItem() throws Exception {
DiffSync<Todo> sync = new DiffSync<Todo>(new MapBasedShadowStore("x"), Todo.class);
Patch patch = readJsonPatchFromResource("patch-remove-item");
List<Todo> todos = getTodoList();
List<Todo> patched = sync.apply(todos, patch);
// original should remain unchanged
assertEquals(todos, getTodoList());
assertNotEquals(patched, todos);
assertEquals(2, patched.size());
assertEquals(new Todo(1L, "A", false), patched.get(0));
assertEquals(new Todo(3L, "C", false), patched.get(1));
}
Aggregations