use of org.apache.syncope.common.lib.patch.AttrPatch in project syncope by apache.
the class AnyOperationsTest method mindiff.
@Test
public void mindiff() {
AnyObjectTO oldOne = new AnyObjectTO();
oldOne.setName("name");
oldOne.getPlainAttrs().add(new AttrTO.Builder().schema("plain").value("oldValue").build());
oldOne.getPlainAttrs().add(new AttrTO.Builder().schema("encrypted").value("oldValue").build());
AnyObjectTO newOne = new AnyObjectTO();
newOne.setName("name");
newOne.getPlainAttrs().add(new AttrTO.Builder().schema("plain").value("newValue").build());
newOne.getPlainAttrs().add(new AttrTO.Builder().schema("encrypted").value("oldValue").build());
AnyObjectPatch diff = AnyOperations.diff(newOne, oldOne, true);
assertEquals(1, diff.getPlainAttrs().size());
AttrPatch patch = diff.getPlainAttrs().iterator().next();
assertEquals(PatchOperation.ADD_REPLACE, patch.getOperation());
assertEquals("plain", patch.getAttrTO().getSchema());
}
Aggregations