Search in sources :

Example 6 with AttrPatch

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());
}
Also used : AnyObjectTO(org.apache.syncope.common.lib.to.AnyObjectTO) AnyObjectPatch(org.apache.syncope.common.lib.patch.AnyObjectPatch) AttrPatch(org.apache.syncope.common.lib.patch.AttrPatch) Test(org.junit.jupiter.api.Test)

Aggregations

AttrPatch (org.apache.syncope.common.lib.patch.AttrPatch)6 HashMap (java.util.HashMap)3 List (java.util.List)3 Collection (java.util.Collection)2 Collections (java.util.Collections)2 HashSet (java.util.HashSet)2 Map (java.util.Map)2 Optional (java.util.Optional)2 Set (java.util.Set)2 Collectors (java.util.stream.Collectors)2 StringUtils (org.apache.commons.lang3.StringUtils)2 Pair (org.apache.commons.lang3.tuple.Pair)2 SyncopeClientCompositeException (org.apache.syncope.common.lib.SyncopeClientCompositeException)2 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)2 AnyObjectPatch (org.apache.syncope.common.lib.patch.AnyObjectPatch)2 AttrTO (org.apache.syncope.common.lib.to.AttrTO)2 MembershipTO (org.apache.syncope.common.lib.to.MembershipTO)2 AnyTypeKind (org.apache.syncope.common.lib.types.AnyTypeKind)2 ClientExceptionType (org.apache.syncope.common.lib.types.ClientExceptionType)2 PatchOperation (org.apache.syncope.common.lib.types.PatchOperation)2