use of org.springframework.sync.PatchOperation in project spring-sync by spring-projects.
the class DiffSyncTest method patchEntity_moveProperty_duplicate.
@Test
public void patchEntity_moveProperty_duplicate() throws Exception {
DiffSync<Person> sync = new DiffSync<Person>(new MapBasedShadowStore("x"), Person.class);
List<PatchOperation> ops = new ArrayList<PatchOperation>();
ops.add(new MoveOperation("/firstName", "/lastName"));
VersionedPatch vPatch1 = new VersionedPatch(ops, 0, 0);
VersionedPatch vPatch2 = new VersionedPatch(ops, 0, 0);
Person person = new Person("Edmund", "Blackadder");
Person patched = sync.apply(person, vPatch1, vPatch2);
VersionedPatch diff = sync.diff(patched);
// the server is acknowledge client version 1 (the client should be at that version by this time)
assertEquals(1, diff.getClientVersion());
// the server created the patch against server version 0 (but it will be 1 after the patch is created)
assertEquals(0, diff.getServerVersion());
assertEquals("Blackadder", patched.getFirstName());
assertNull(patched.getLastName());
}
use of org.springframework.sync.PatchOperation in project spring-sync by spring-projects.
the class DiffSyncTest method patchEntity_moveProperty_normal.
@Test
public void patchEntity_moveProperty_normal() throws Exception {
DiffSync<Person> sync = new DiffSync<Person>(new MapBasedShadowStore("x"), Person.class);
List<PatchOperation> ops = new ArrayList<PatchOperation>();
ops.add(new MoveOperation("/firstName", "/lastName"));
VersionedPatch vPatch1 = new VersionedPatch(ops, 0, 0);
Person person = new Person("Edmund", "Blackadder");
Person patched = sync.apply(person, vPatch1);
VersionedPatch diff = sync.diff(patched);
// the server is acknowledge client version 1 (the client should be at that version by this time)
assertEquals(1, diff.getClientVersion());
// the server created the patch against server version 0 (but it will be 1 after the patch is created)
assertEquals(0, diff.getServerVersion());
assertEquals("Blackadder", patched.getFirstName());
assertNull(patched.getLastName());
}
Aggregations