You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by il...@apache.org on 2017/10/04 10:49:34 UTC
[1/2] syncope git commit: Adding some utility Builders
Repository: syncope
Updated Branches:
refs/heads/2_0_X cf5f1c9e1 -> 85d0a2603
refs/heads/master 8b61a2244 -> d41b96a58
Adding some utility Builders
Project: http://git-wip-us.apache.org/repos/asf/syncope/repo
Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/85d0a260
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/85d0a260
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/85d0a260
Branch: refs/heads/2_0_X
Commit: 85d0a2603fc61c1662b15811968252e7e4c54072
Parents: cf5f1c9
Author: Francesco Chicchiriccò <il...@apache.org>
Authored: Wed Oct 4 12:45:27 2017 +0200
Committer: Francesco Chicchiriccò <il...@apache.org>
Committed: Wed Oct 4 12:45:27 2017 +0200
----------------------------------------------------------------------
.../console/commons/status/StatusUtils.java | 9 +-
.../console/rest/AbstractAnyRestClient.java | 48 ++++-----
.../common/lib/patch/AssociationPatch.java | 54 ++++++++++
.../common/lib/patch/DeassociationPatch.java | 44 ++++++++
.../syncope/common/lib/patch/PasswordPatch.java | 4 +-
.../syncope/common/lib/patch/StatusPatch.java | 54 ++++++++++
.../apache/syncope/common/lib/to/AttrTO.java | 4 +-
.../rest/cxf/service/AbstractAnyService.java | 16 +--
.../syncope/fit/core/AbstractTaskITCase.java | 14 +--
.../syncope/fit/core/AuthenticationITCase.java | 11 +-
.../apache/syncope/fit/core/GroupITCase.java | 42 +++-----
.../apache/syncope/fit/core/PullTaskITCase.java | 10 +-
.../org/apache/syncope/fit/core/UserITCase.java | 101 +++++++------------
.../apache/syncope/fit/core/VirAttrITCase.java | 10 +-
14 files changed, 256 insertions(+), 165 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/syncope/blob/85d0a260/client/console/src/main/java/org/apache/syncope/client/console/commons/status/StatusUtils.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/commons/status/StatusUtils.java b/client/console/src/main/java/org/apache/syncope/client/console/commons/status/StatusUtils.java
index 8a9aa09..1e6f513 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/commons/status/StatusUtils.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/commons/status/StatusUtils.java
@@ -169,23 +169,22 @@ public class StatusUtils implements Serializable {
}
public static StatusPatch buildStatusPatch(final Collection<StatusBean> statuses, final Boolean enable) {
- StatusPatch statusPatch = new StatusPatch();
- statusPatch.setOnSyncope(false);
+ StatusPatch.Builder builder = new StatusPatch.Builder();
for (StatusBean status : statuses) {
if (enable == null
|| (enable && !status.getStatus().isActive()) || (!enable && status.getStatus().isActive())) {
if ("syncope".equalsIgnoreCase(status.getResource())) {
- statusPatch.setOnSyncope(true);
+ builder.onSyncope(true);
} else {
- statusPatch.getResources().add(status.getResource());
+ builder.resource(status.getResource());
}
}
}
- return statusPatch;
+ return builder.build();
}
public static Panel getStatusImagePanel(final String componentId, final Status status) {
http://git-wip-us.apache.org/repos/asf/syncope/blob/85d0a260/client/console/src/main/java/org/apache/syncope/client/console/rest/AbstractAnyRestClient.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/rest/AbstractAnyRestClient.java b/client/console/src/main/java/org/apache/syncope/client/console/rest/AbstractAnyRestClient.java
index 9d7d1d7..4796ddb 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/rest/AbstractAnyRestClient.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/rest/AbstractAnyRestClient.java
@@ -83,10 +83,9 @@ public abstract class AbstractAnyRestClient<TO extends AnyTO, P extends AnyPatch
synchronized (this) {
AnyService<?, ?> service = getService(etag, getAnyServiceClass());
- DeassociationPatch deassociationPatch = new DeassociationPatch();
- deassociationPatch.setKey(key);
- deassociationPatch.setAction(ResourceDeassociationAction.UNLINK);
- deassociationPatch.getResources().addAll(StatusUtils.buildStatusPatch(statuses).getResources());
+ DeassociationPatch deassociationPatch = new DeassociationPatch.Builder().key(key).
+ action(ResourceDeassociationAction.UNLINK).
+ resources(StatusUtils.buildStatusPatch(statuses).getResources()).build();
result = service.deassociate(deassociationPatch).readEntity(BulkActionResult.class);
@@ -102,11 +101,10 @@ public abstract class AbstractAnyRestClient<TO extends AnyTO, P extends AnyPatch
StatusPatch statusPatch = StatusUtils.buildStatusPatch(statuses);
- AssociationPatch associationPatch = new AssociationPatch();
- associationPatch.setKey(key);
- associationPatch.setAction(ResourceAssociationAction.LINK);
- associationPatch.setOnSyncope(statusPatch.isOnSyncope());
- associationPatch.getResources().addAll(statusPatch.getResources());
+ AssociationPatch associationPatch = new AssociationPatch.Builder().key(key).
+ action(ResourceAssociationAction.LINK).
+ onSyncope(statusPatch.isOnSyncope()).
+ resources(statusPatch.getResources()).build();
result = service.associate(associationPatch).readEntity(BulkActionResult.class);
@@ -120,10 +118,9 @@ public abstract class AbstractAnyRestClient<TO extends AnyTO, P extends AnyPatch
synchronized (this) {
AnyService<?, ?> service = getService(etag, getAnyServiceClass());
- DeassociationPatch deassociationPatch = new DeassociationPatch();
- deassociationPatch.setKey(key);
- deassociationPatch.setAction(ResourceDeassociationAction.DEPROVISION);
- deassociationPatch.getResources().addAll(StatusUtils.buildStatusPatch(statuses).getResources());
+ DeassociationPatch deassociationPatch = new DeassociationPatch.Builder().key(key).
+ action(ResourceDeassociationAction.DEPROVISION).
+ resources(StatusUtils.buildStatusPatch(statuses).getResources()).build();
result = service.deassociate(deassociationPatch).readEntity(BulkActionResult.class);
@@ -139,11 +136,10 @@ public abstract class AbstractAnyRestClient<TO extends AnyTO, P extends AnyPatch
StatusPatch statusPatch = StatusUtils.buildStatusPatch(statuses);
- AssociationPatch associationPatch = new AssociationPatch();
- associationPatch.setKey(key);
- associationPatch.setAction(ResourceAssociationAction.PROVISION);
- associationPatch.setOnSyncope(statusPatch.isOnSyncope());
- associationPatch.getResources().addAll(statusPatch.getResources());
+ AssociationPatch associationPatch = new AssociationPatch.Builder().key(key).
+ action(ResourceAssociationAction.PROVISION).
+ onSyncope(statusPatch.isOnSyncope()).
+ resources(statusPatch.getResources()).build();
result = service.associate(associationPatch).readEntity(BulkActionResult.class);
@@ -157,10 +153,9 @@ public abstract class AbstractAnyRestClient<TO extends AnyTO, P extends AnyPatch
synchronized (this) {
AnyService<?, ?> service = getService(etag, getAnyServiceClass());
- DeassociationPatch deassociationPatch = new DeassociationPatch();
- deassociationPatch.setKey(key);
- deassociationPatch.setAction(ResourceDeassociationAction.UNASSIGN);
- deassociationPatch.getResources().addAll(StatusUtils.buildStatusPatch(statuses).getResources());
+ DeassociationPatch deassociationPatch = new DeassociationPatch.Builder().key(key).
+ action(ResourceDeassociationAction.UNASSIGN).
+ resources(StatusUtils.buildStatusPatch(statuses).getResources()).build();
result = service.deassociate(deassociationPatch).readEntity(BulkActionResult.class);
@@ -176,11 +171,10 @@ public abstract class AbstractAnyRestClient<TO extends AnyTO, P extends AnyPatch
StatusPatch statusPatch = StatusUtils.buildStatusPatch(statuses);
- AssociationPatch associationPatch = new AssociationPatch();
- associationPatch.setKey(key);
- associationPatch.setAction(ResourceAssociationAction.ASSIGN);
- associationPatch.setOnSyncope(statusPatch.isOnSyncope());
- associationPatch.getResources().addAll(statusPatch.getResources());
+ AssociationPatch associationPatch = new AssociationPatch.Builder().key(key).
+ action(ResourceAssociationAction.ASSIGN).
+ onSyncope(statusPatch.isOnSyncope()).
+ resources(statusPatch.getResources()).build();
result = service.associate(associationPatch).readEntity(BulkActionResult.class);
http://git-wip-us.apache.org/repos/asf/syncope/blob/85d0a260/common/lib/src/main/java/org/apache/syncope/common/lib/patch/AssociationPatch.java
----------------------------------------------------------------------
diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/patch/AssociationPatch.java b/common/lib/src/main/java/org/apache/syncope/common/lib/patch/AssociationPatch.java
index 56efe7e..e445aac 100644
--- a/common/lib/src/main/java/org/apache/syncope/common/lib/patch/AssociationPatch.java
+++ b/common/lib/src/main/java/org/apache/syncope/common/lib/patch/AssociationPatch.java
@@ -18,6 +18,7 @@
*/
package org.apache.syncope.common.lib.patch;
+import java.util.Collection;
import javax.ws.rs.PathParam;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
@@ -29,6 +30,59 @@ public class AssociationPatch extends PasswordPatch {
private static final long serialVersionUID = 6295778399633883767L;
+ public static class Builder extends PasswordPatch.Builder {
+
+ @Override
+ protected AssociationPatch newInstance() {
+ return new AssociationPatch();
+ }
+
+ @Override
+ protected AssociationPatch getInstance() {
+ return (AssociationPatch) super.getInstance();
+ }
+
+ @Override
+ public AssociationPatch build() {
+ return (AssociationPatch) super.build();
+ }
+
+ @Override
+ public Builder onSyncope(final boolean onSyncope) {
+ return (Builder) super.onSyncope(onSyncope);
+ }
+
+ @Override
+ public Builder resource(final String resource) {
+ return (Builder) super.resource(resource);
+ }
+
+ @Override
+ public Builder resources(final Collection<String> resources) {
+ return (Builder) super.resources(resources);
+ }
+
+ @Override
+ public Builder resources(final String... resources) {
+ return (Builder) super.resources(resources);
+ }
+
+ @Override
+ public Builder value(final String value) {
+ return (Builder) super.value(value);
+ }
+
+ public Builder key(final String key) {
+ getInstance().setKey(key);
+ return this;
+ }
+
+ public Builder action(final ResourceAssociationAction action) {
+ getInstance().setAction(action);
+ return this;
+ }
+ }
+
private String key;
private ResourceAssociationAction action;
http://git-wip-us.apache.org/repos/asf/syncope/blob/85d0a260/common/lib/src/main/java/org/apache/syncope/common/lib/patch/DeassociationPatch.java
----------------------------------------------------------------------
diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/patch/DeassociationPatch.java b/common/lib/src/main/java/org/apache/syncope/common/lib/patch/DeassociationPatch.java
index e5271e0..3c6cc60 100644
--- a/common/lib/src/main/java/org/apache/syncope/common/lib/patch/DeassociationPatch.java
+++ b/common/lib/src/main/java/org/apache/syncope/common/lib/patch/DeassociationPatch.java
@@ -20,6 +20,8 @@ package org.apache.syncope.common.lib.patch;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
import java.util.List;
import javax.ws.rs.PathParam;
import javax.xml.bind.annotation.XmlElement;
@@ -35,6 +37,48 @@ public class DeassociationPatch extends AbstractBaseBean {
private static final long serialVersionUID = 6295778399633883767L;
+ public static class Builder {
+
+ private final DeassociationPatch instance;
+
+ public Builder() {
+ this.instance = new DeassociationPatch();
+ }
+
+ public Builder key(final String key) {
+ instance.setKey(key);
+ return this;
+ }
+
+ public Builder action(final ResourceDeassociationAction action) {
+ instance.setAction(action);
+ return this;
+ }
+
+ public Builder resource(final String resource) {
+ if (resource != null) {
+ instance.getResources().add(resource);
+ }
+ return this;
+ }
+
+ public Builder resources(final String... resources) {
+ instance.getResources().addAll(Arrays.asList(resources));
+ return this;
+ }
+
+ public Builder resources(final Collection<String> resources) {
+ if (resources != null) {
+ instance.getResources().addAll(resources);
+ }
+ return this;
+ }
+
+ public DeassociationPatch build() {
+ return instance;
+ }
+ }
+
private String key;
private ResourceDeassociationAction action;
http://git-wip-us.apache.org/repos/asf/syncope/blob/85d0a260/common/lib/src/main/java/org/apache/syncope/common/lib/patch/PasswordPatch.java
----------------------------------------------------------------------
diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/patch/PasswordPatch.java b/common/lib/src/main/java/org/apache/syncope/common/lib/patch/PasswordPatch.java
index 93e6b9e..af989e4 100644
--- a/common/lib/src/main/java/org/apache/syncope/common/lib/patch/PasswordPatch.java
+++ b/common/lib/src/main/java/org/apache/syncope/common/lib/patch/PasswordPatch.java
@@ -20,6 +20,7 @@ package org.apache.syncope.common.lib.patch;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
@@ -27,7 +28,6 @@ import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.bind.annotation.XmlType;
-import org.apache.commons.collections4.CollectionUtils;
@XmlRootElement(name = "passwordPatch")
@XmlType
@@ -56,7 +56,7 @@ public class PasswordPatch extends StringReplacePatchItem {
}
public Builder resources(final String... resources) {
- CollectionUtils.addAll(getInstance().getResources(), resources);
+ getInstance().getResources().addAll(Arrays.asList(resources));
return this;
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/85d0a260/common/lib/src/main/java/org/apache/syncope/common/lib/patch/StatusPatch.java
----------------------------------------------------------------------
diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/patch/StatusPatch.java b/common/lib/src/main/java/org/apache/syncope/common/lib/patch/StatusPatch.java
index b7d9c1e..9c94dc7 100644
--- a/common/lib/src/main/java/org/apache/syncope/common/lib/patch/StatusPatch.java
+++ b/common/lib/src/main/java/org/apache/syncope/common/lib/patch/StatusPatch.java
@@ -18,6 +18,7 @@
*/
package org.apache.syncope.common.lib.patch;
+import java.util.Collection;
import javax.ws.rs.PathParam;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
@@ -29,6 +30,59 @@ public class StatusPatch extends PasswordPatch {
private static final long serialVersionUID = 99309988426922612L;
+ public static class Builder extends PasswordPatch.Builder {
+
+ @Override
+ protected StatusPatch newInstance() {
+ return new StatusPatch();
+ }
+
+ @Override
+ protected StatusPatch getInstance() {
+ return (StatusPatch) super.getInstance();
+ }
+
+ @Override
+ public StatusPatch build() {
+ return (StatusPatch) super.build();
+ }
+
+ @Override
+ public Builder onSyncope(final boolean onSyncope) {
+ return (Builder) super.onSyncope(onSyncope);
+ }
+
+ @Override
+ public Builder resource(final String resource) {
+ return (Builder) super.resource(resource);
+ }
+
+ @Override
+ public Builder resources(final Collection<String> resources) {
+ return (Builder) super.resources(resources);
+ }
+
+ @Override
+ public Builder resources(final String... resources) {
+ return (Builder) super.resources(resources);
+ }
+
+ public Builder key(final String key) {
+ getInstance().setKey(key);
+ return this;
+ }
+
+ public Builder type(final StatusPatchType type) {
+ getInstance().setType(type);
+ return this;
+ }
+
+ public Builder token(final String token) {
+ getInstance().setToken(token);
+ return this;
+ }
+ }
+
/**
* Key of user to for which status update is requested.
*/
http://git-wip-us.apache.org/repos/asf/syncope/blob/85d0a260/common/lib/src/main/java/org/apache/syncope/common/lib/to/AttrTO.java
----------------------------------------------------------------------
diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/to/AttrTO.java b/common/lib/src/main/java/org/apache/syncope/common/lib/to/AttrTO.java
index 7822a6b..bd63527 100644
--- a/common/lib/src/main/java/org/apache/syncope/common/lib/to/AttrTO.java
+++ b/common/lib/src/main/java/org/apache/syncope/common/lib/to/AttrTO.java
@@ -21,6 +21,7 @@ package org.apache.syncope.common.lib.to;
import org.apache.syncope.common.lib.AbstractBaseBean;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import javax.ws.rs.PathParam;
@@ -28,7 +29,6 @@ import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
-import org.apache.commons.collections4.CollectionUtils;
@XmlRootElement(name = "attribute")
@XmlType
@@ -56,7 +56,7 @@ public class AttrTO extends AbstractBaseBean {
}
public Builder values(final String... values) {
- CollectionUtils.addAll(instance.getValues(), values);
+ instance.getValues().addAll(Arrays.asList(values));
return this;
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/85d0a260/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/AbstractAnyService.java
----------------------------------------------------------------------
diff --git a/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/AbstractAnyService.java b/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/AbstractAnyService.java
index 1b7e7f2..ba315c7 100644
--- a/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/AbstractAnyService.java
+++ b/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/AbstractAnyService.java
@@ -383,10 +383,10 @@ public abstract class AbstractAnyService<TO extends AnyTO, P extends AnyPatch>
case SUSPEND:
if (logic instanceof UserLogic) {
for (String key : bulkAction.getTargets()) {
- StatusPatch statusPatch = new StatusPatch();
- statusPatch.setKey(key);
- statusPatch.setType(StatusPatchType.SUSPEND);
- statusPatch.setOnSyncope(true);
+ StatusPatch statusPatch = new StatusPatch.Builder().key(key).
+ type(StatusPatchType.SUSPEND).
+ onSyncope(true).
+ build();
try {
result.getResults().put(
@@ -406,10 +406,10 @@ public abstract class AbstractAnyService<TO extends AnyTO, P extends AnyPatch>
case REACTIVATE:
if (logic instanceof UserLogic) {
for (String key : bulkAction.getTargets()) {
- StatusPatch statusPatch = new StatusPatch();
- statusPatch.setKey(key);
- statusPatch.setType(StatusPatchType.REACTIVATE);
- statusPatch.setOnSyncope(true);
+ StatusPatch statusPatch = new StatusPatch.Builder().key(key).
+ type(StatusPatchType.REACTIVATE).
+ onSyncope(true).
+ build();
try {
result.getResults().put(
http://git-wip-us.apache.org/repos/asf/syncope/blob/85d0a260/fit/core-reference/src/test/java/org/apache/syncope/fit/core/AbstractTaskITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/AbstractTaskITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/AbstractTaskITCase.java
index 94dafbd..9f882d3 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/AbstractTaskITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/AbstractTaskITCase.java
@@ -104,11 +104,8 @@ public abstract class AbstractTaskITCase extends AbstractITCase {
build());
if (matchingGroups.getSize() > 0) {
for (GroupTO group : matchingGroups.getResult()) {
- DeassociationPatch deassociationPatch = new DeassociationPatch();
- deassociationPatch.setKey(group.getKey());
- deassociationPatch.setAction(ResourceDeassociationAction.UNLINK);
- deassociationPatch.getResources().add(RESOURCE_NAME_LDAP);
- groupService.deassociate(deassociationPatch);
+ groupService.deassociate(new DeassociationPatch.Builder().key(group.getKey()).
+ action(ResourceDeassociationAction.UNLINK).resource(RESOURCE_NAME_LDAP).build());
groupService.delete(group.getKey());
}
}
@@ -119,11 +116,8 @@ public abstract class AbstractTaskITCase extends AbstractITCase {
build());
if (matchingUsers.getSize() > 0) {
for (UserTO user : matchingUsers.getResult()) {
- DeassociationPatch deassociationPatch = new DeassociationPatch();
- deassociationPatch.setKey(user.getKey());
- deassociationPatch.setAction(ResourceDeassociationAction.UNLINK);
- deassociationPatch.getResources().add(RESOURCE_NAME_LDAP);
- userService.deassociate(deassociationPatch);
+ userService.deassociate(new DeassociationPatch.Builder().key(user.getKey()).
+ action(ResourceDeassociationAction.UNLINK).resource(RESOURCE_NAME_LDAP).build());
userService.delete(user.getKey());
}
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/85d0a260/fit/core-reference/src/test/java/org/apache/syncope/fit/core/AuthenticationITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/AuthenticationITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/AuthenticationITCase.java
index 82ef773..45c8096 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/AuthenticationITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/AuthenticationITCase.java
@@ -409,9 +409,8 @@ public class AuthenticationITCase extends AbstractITCase {
assertNotNull(e);
}
- StatusPatch reactivate = new StatusPatch();
- reactivate.setKey(userTO.getKey());
- reactivate.setType(StatusPatchType.REACTIVATE);
+ StatusPatch reactivate = new StatusPatch.Builder().key(userTO.getKey()).
+ type(StatusPatchType.REACTIVATE).build();
userTO = userService.status(reactivate).readEntity(new GenericType<ProvisioningResult<UserTO>>() {
}).getEntity();
assertNotNull(userTO);
@@ -546,10 +545,8 @@ public class AuthenticationITCase extends AbstractITCase {
assertNotNull(user);
// 2. unlink the resource from the created user
- DeassociationPatch deassociationPatch = new DeassociationPatch();
- deassociationPatch.setKey(user.getKey());
- deassociationPatch.setAction(ResourceDeassociationAction.UNLINK);
- deassociationPatch.getResources().add(RESOURCE_NAME_TESTDB);
+ DeassociationPatch deassociationPatch = new DeassociationPatch.Builder().key(user.getKey()).
+ action(ResourceDeassociationAction.UNLINK).resource(RESOURCE_NAME_TESTDB).build();
assertNotNull(userService.deassociate(deassociationPatch).readEntity(BulkActionResult.class));
// 3. change password on Syncope
http://git-wip-us.apache.org/repos/asf/syncope/blob/85d0a260/fit/core-reference/src/test/java/org/apache/syncope/fit/core/GroupITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/GroupITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/GroupITCase.java
index 13f6dd9..be975b7 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/GroupITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/GroupITCase.java
@@ -328,10 +328,8 @@ public class GroupITCase extends AbstractITCase {
assertNotNull(resourceService.readConnObject(RESOURCE_NAME_LDAP, AnyTypeKind.GROUP.name(), actual.getKey()));
- DeassociationPatch deassociationPatch = new DeassociationPatch();
- deassociationPatch.setKey(actual.getKey());
- deassociationPatch.setAction(ResourceDeassociationAction.UNLINK);
- deassociationPatch.getResources().add(RESOURCE_NAME_LDAP);
+ DeassociationPatch deassociationPatch = new DeassociationPatch.Builder().key(actual.getKey()).
+ action(ResourceDeassociationAction.UNLINK).resource(RESOURCE_NAME_LDAP).build();
assertNotNull(groupService.deassociate(deassociationPatch).readEntity(BulkActionResult.class));
@@ -357,10 +355,8 @@ public class GroupITCase extends AbstractITCase {
assertNotNull(e);
}
- AssociationPatch associationPatch = new AssociationPatch();
- associationPatch.setKey(actual.getKey());
- associationPatch.setAction(ResourceAssociationAction.LINK);
- associationPatch.getResources().add(RESOURCE_NAME_LDAP);
+ AssociationPatch associationPatch = new AssociationPatch.Builder().key(actual.getKey()).
+ action(ResourceAssociationAction.LINK).resource(RESOURCE_NAME_LDAP).build();
assertNotNull(groupService.associate(associationPatch).readEntity(BulkActionResult.class));
@@ -426,10 +422,8 @@ public class GroupITCase extends AbstractITCase {
assertNotNull(e);
}
- AssociationPatch associationPatch = new AssociationPatch();
- associationPatch.setKey(groupTO.getKey());
- associationPatch.setAction(ResourceAssociationAction.ASSIGN);
- associationPatch.getResources().add(RESOURCE_NAME_LDAP);
+ AssociationPatch associationPatch = new AssociationPatch.Builder().key(groupTO.getKey()).
+ action(ResourceAssociationAction.ASSIGN).resource(RESOURCE_NAME_LDAP).build();
assertNotNull(groupService.associate(associationPatch).readEntity(BulkActionResult.class));
@@ -455,10 +449,8 @@ public class GroupITCase extends AbstractITCase {
assertNotNull(resourceService.readConnObject(RESOURCE_NAME_LDAP, AnyTypeKind.GROUP.name(), groupTO.getKey()));
- DeassociationPatch deassociationPatch = new DeassociationPatch();
- deassociationPatch.setKey(groupTO.getKey());
- deassociationPatch.setAction(ResourceDeassociationAction.DEPROVISION);
- deassociationPatch.getResources().add(RESOURCE_NAME_LDAP);
+ DeassociationPatch deassociationPatch = new DeassociationPatch.Builder().key(groupTO.getKey()).
+ action(ResourceDeassociationAction.DEPROVISION).resource(RESOURCE_NAME_LDAP).build();
assertNotNull(groupService.deassociate(deassociationPatch).readEntity(BulkActionResult.class));
@@ -495,10 +487,8 @@ public class GroupITCase extends AbstractITCase {
assertNotNull(e);
}
- AssociationPatch associationPatch = new AssociationPatch();
- associationPatch.setKey(groupTO.getKey());
- associationPatch.setAction(ResourceAssociationAction.PROVISION);
- associationPatch.getResources().add(RESOURCE_NAME_LDAP);
+ AssociationPatch associationPatch = new AssociationPatch.Builder().key(groupTO.getKey()).
+ action(ResourceAssociationAction.PROVISION).resource(RESOURCE_NAME_LDAP).build();
assertNotNull(groupService.associate(associationPatch).readEntity(BulkActionResult.class));
@@ -530,10 +520,8 @@ public class GroupITCase extends AbstractITCase {
assertNotNull(e);
}
- AssociationPatch associationPatch = new AssociationPatch();
- associationPatch.setKey(groupTO.getKey());
- associationPatch.setAction(ResourceAssociationAction.PROVISION);
- associationPatch.getResources().add(RESOURCE_NAME_LDAP);
+ AssociationPatch associationPatch = new AssociationPatch.Builder().key(groupTO.getKey()).
+ action(ResourceAssociationAction.PROVISION).resource(RESOURCE_NAME_LDAP).build();
assertNotNull(groupService.associate(associationPatch).readEntity(BulkActionResult.class));
@@ -543,10 +531,8 @@ public class GroupITCase extends AbstractITCase {
assertNotNull(resourceService.readConnObject(
RESOURCE_NAME_LDAP, AnyTypeKind.GROUP.name(), groupTO.getKey()));
- DeassociationPatch deassociationPatch = new DeassociationPatch();
- deassociationPatch.setKey(groupTO.getKey());
- deassociationPatch.setAction(ResourceDeassociationAction.DEPROVISION);
- deassociationPatch.getResources().add(RESOURCE_NAME_LDAP);
+ DeassociationPatch deassociationPatch = new DeassociationPatch.Builder().key(groupTO.getKey()).
+ action(ResourceDeassociationAction.DEPROVISION).resource(RESOURCE_NAME_LDAP).build();
assertNotNull(groupService.deassociate(deassociationPatch).readEntity(BulkActionResult.class));
http://git-wip-us.apache.org/repos/asf/syncope/blob/85d0a260/fit/core-reference/src/test/java/org/apache/syncope/fit/core/PullTaskITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/PullTaskITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/PullTaskITCase.java
index 43e860c..40bebc4 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/PullTaskITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/PullTaskITCase.java
@@ -411,9 +411,6 @@ public class PullTaskITCase extends AbstractTaskITCase {
@Test
public void reconcileFromScriptedSQL() {
- System.out.println("QUAAAAAAAAAAAAAAAAAAAAA");
- LOG.info("QUAAAAAAAAAAAAAAAa");
-
// 0. reset sync token and set MappingItemTransformer
ResourceTO resource = resourceService.read(RESOURCE_NAME_DBSCRIPTED);
ResourceTO originalResource = SerializationUtils.clone(resource);
@@ -466,11 +463,8 @@ public class PullTaskITCase extends AbstractTaskITCase {
is("location").equalTo("pull*").query()).build());
assertTrue(matchingPrinters.getSize() > 0);
for (AnyObjectTO printer : matchingPrinters.getResult()) {
- DeassociationPatch deassociationPatch = new DeassociationPatch();
- deassociationPatch.setKey(printer.getKey());
- deassociationPatch.setAction(ResourceDeassociationAction.UNLINK);
- deassociationPatch.getResources().add(RESOURCE_NAME_DBSCRIPTED);
- anyObjectService.deassociate(deassociationPatch);
+ anyObjectService.deassociate(new DeassociationPatch.Builder().key(printer.getKey()).
+ action(ResourceDeassociationAction.UNLINK).resource(RESOURCE_NAME_DBSCRIPTED).build());
anyObjectService.delete(printer.getKey());
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/85d0a260/fit/core-reference/src/test/java/org/apache/syncope/fit/core/UserITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/UserITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/UserITCase.java
index 3b2aa3b..0fb88f1 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/UserITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/UserITCase.java
@@ -700,10 +700,9 @@ public class UserITCase extends AbstractITCase {
assertEquals("created", userTO.getStatus());
- StatusPatch statusPatch = new StatusPatch();
- statusPatch.setKey(userTO.getKey());
- statusPatch.setType(StatusPatchType.ACTIVATE);
- statusPatch.setToken(userTO.getToken());
+ StatusPatch statusPatch = new StatusPatch.Builder().key(userTO.getKey()).
+ type(StatusPatchType.ACTIVATE).token(userTO.getToken()).build();
+
userTO = userService.status(statusPatch).readEntity(new GenericType<ProvisioningResult<UserTO>>() {
}).getEntity();
@@ -727,17 +726,16 @@ public class UserITCase extends AbstractITCase {
? "active"
: "created", userTO.getStatus());
- StatusPatch statusPatch = new StatusPatch();
- statusPatch.setKey(userTO.getKey());
- statusPatch.setType(StatusPatchType.SUSPEND);
+ StatusPatch statusPatch = new StatusPatch.Builder().key(userTO.getKey()).
+ type(StatusPatchType.SUSPEND).token(userTO.getToken()).build();
+
userTO = userService.status(statusPatch).readEntity(new GenericType<ProvisioningResult<UserTO>>() {
}).getEntity();
assertNotNull(userTO);
assertEquals("suspended", userTO.getStatus());
- statusPatch = new StatusPatch();
- statusPatch.setKey(userTO.getKey());
- statusPatch.setType(StatusPatchType.REACTIVATE);
+ statusPatch = new StatusPatch.Builder().key(userTO.getKey()).type(StatusPatchType.REACTIVATE).build();
+
userTO = userService.status(statusPatch).readEntity(new GenericType<ProvisioningResult<UserTO>>() {
}).getEntity();
assertNotNull(userTO);
@@ -766,12 +764,11 @@ public class UserITCase extends AbstractITCase {
String userKey = userTO.getKey();
// Suspend with effect on syncope, ldap and db => user should be suspended in syncope and all resources
- StatusPatch statusPatch = new StatusPatch();
- statusPatch.setKey(userKey);
- statusPatch.setType(StatusPatchType.SUSPEND);
- statusPatch.setOnSyncope(true);
- statusPatch.getResources().add(RESOURCE_NAME_TESTDB);
- statusPatch.getResources().add(RESOURCE_NAME_LDAP);
+ StatusPatch statusPatch = new StatusPatch.Builder().key(userKey).
+ type(StatusPatchType.SUSPEND).
+ onSyncope(true).
+ resources(RESOURCE_NAME_TESTDB, RESOURCE_NAME_LDAP).
+ build();
userTO = userService.status(statusPatch).readEntity(new GenericType<ProvisioningResult<UserTO>>() {
}).getEntity();
assertNotNull(userTO);
@@ -785,11 +782,11 @@ public class UserITCase extends AbstractITCase {
assertNotNull(connObjectTO);
// Suspend and reactivate only on ldap => db and syncope should still show suspended
- statusPatch = new StatusPatch();
- statusPatch.setKey(userKey);
- statusPatch.setType(StatusPatchType.SUSPEND);
- statusPatch.setOnSyncope(false);
- statusPatch.getResources().add(RESOURCE_NAME_LDAP);
+ statusPatch = new StatusPatch.Builder().key(userKey).
+ type(StatusPatchType.SUSPEND).
+ onSyncope(false).
+ resources(RESOURCE_NAME_LDAP).
+ build();
userService.status(statusPatch);
statusPatch.setType(StatusPatchType.REACTIVATE);
userTO = userService.status(statusPatch).readEntity(new GenericType<ProvisioningResult<UserTO>>() {
@@ -801,12 +798,11 @@ public class UserITCase extends AbstractITCase {
assertFalse(getBooleanAttribute(connObjectTO, OperationalAttributes.ENABLE_NAME));
// Reactivate on syncope and db => syncope and db should show the user as active
- statusPatch = new StatusPatch();
- statusPatch.setKey(userKey);
- statusPatch.setType(StatusPatchType.REACTIVATE);
- statusPatch.setOnSyncope(true);
- statusPatch.getResources().add(RESOURCE_NAME_TESTDB);
-
+ statusPatch = new StatusPatch.Builder().key(userKey).
+ type(StatusPatchType.REACTIVATE).
+ onSyncope(true).
+ resources(RESOURCE_NAME_TESTDB).
+ build();
userTO = userService.status(statusPatch).readEntity(new GenericType<ProvisioningResult<UserTO>>() {
}).getEntity();
assertNotNull(userTO);
@@ -1042,10 +1038,8 @@ public class UserITCase extends AbstractITCase {
assertNotNull(actual);
assertNotNull(resourceService.readConnObject(RESOURCE_NAME_CSV, AnyTypeKind.USER.name(), actual.getKey()));
- DeassociationPatch deassociationPatch = new DeassociationPatch();
- deassociationPatch.setKey(actual.getKey());
- deassociationPatch.setAction(ResourceDeassociationAction.UNLINK);
- deassociationPatch.getResources().add(RESOURCE_NAME_CSV);
+ DeassociationPatch deassociationPatch = new DeassociationPatch.Builder().key(actual.getKey()).
+ action(ResourceDeassociationAction.UNLINK).resource(RESOURCE_NAME_CSV).build();
assertNotNull(userService.deassociate(deassociationPatch).readEntity(BulkActionResult.class));
@@ -1075,10 +1069,8 @@ public class UserITCase extends AbstractITCase {
assertNotNull(e);
}
- AssociationPatch associationPatch = new AssociationPatch();
- associationPatch.setKey(actual.getKey());
- associationPatch.setAction(ResourceAssociationAction.LINK);
- associationPatch.getResources().add(RESOURCE_NAME_CSV);
+ AssociationPatch associationPatch = new AssociationPatch.Builder().key(actual.getKey()).
+ action(ResourceAssociationAction.LINK).resource(RESOURCE_NAME_CSV).build();
assertNotNull(userService.associate(associationPatch).readEntity(BulkActionResult.class));
@@ -1107,10 +1099,8 @@ public class UserITCase extends AbstractITCase {
assertNotNull(actual);
assertNotNull(resourceService.readConnObject(RESOURCE_NAME_CSV, AnyTypeKind.USER.name(), actual.getKey()));
- DeassociationPatch deassociationPatch = new DeassociationPatch();
- deassociationPatch.setKey(actual.getKey());
- deassociationPatch.setAction(ResourceDeassociationAction.UNASSIGN);
- deassociationPatch.getResources().add(RESOURCE_NAME_CSV);
+ DeassociationPatch deassociationPatch = new DeassociationPatch.Builder().key(actual.getKey()).
+ action(ResourceDeassociationAction.UNASSIGN).resource(RESOURCE_NAME_CSV).build();
assertNotNull(userService.deassociate(deassociationPatch).readEntity(BulkActionResult.class));
@@ -1145,11 +1135,8 @@ public class UserITCase extends AbstractITCase {
assertNotNull(e);
}
- AssociationPatch associationPatch = new AssociationPatch();
- associationPatch.setKey(actual.getKey());
- associationPatch.setValue("password");
- associationPatch.setAction(ResourceAssociationAction.ASSIGN);
- associationPatch.getResources().add(RESOURCE_NAME_CSV);
+ AssociationPatch associationPatch = new AssociationPatch.Builder().key(actual.getKey()).
+ value("password").action(ResourceAssociationAction.ASSIGN).resource(RESOURCE_NAME_CSV).build();
assertNotNull(userService.associate(associationPatch).readEntity(BulkActionResult.class));
@@ -1172,10 +1159,8 @@ public class UserITCase extends AbstractITCase {
assertNotNull(actual);
assertNotNull(resourceService.readConnObject(RESOURCE_NAME_CSV, AnyTypeKind.USER.name(), actual.getKey()));
- DeassociationPatch deassociationPatch = new DeassociationPatch();
- deassociationPatch.setKey(actual.getKey());
- deassociationPatch.setAction(ResourceDeassociationAction.DEPROVISION);
- deassociationPatch.getResources().add(RESOURCE_NAME_CSV);
+ DeassociationPatch deassociationPatch = new DeassociationPatch.Builder().key(actual.getKey()).
+ action(ResourceDeassociationAction.DEPROVISION).resource(RESOURCE_NAME_CSV).build();
assertNotNull(userService.deassociate(deassociationPatch).readEntity(BulkActionResult.class));
@@ -1210,11 +1195,8 @@ public class UserITCase extends AbstractITCase {
assertNotNull(e);
}
- AssociationPatch associationPatch = new AssociationPatch();
- associationPatch.setKey(actual.getKey());
- associationPatch.setValue("password");
- associationPatch.setAction(ResourceAssociationAction.PROVISION);
- associationPatch.getResources().add(RESOURCE_NAME_CSV);
+ AssociationPatch associationPatch = new AssociationPatch.Builder().key(actual.getKey()).
+ value("password").action(ResourceAssociationAction.PROVISION).resource(RESOURCE_NAME_CSV).build();
assertNotNull(userService.associate(associationPatch).readEntity(BulkActionResult.class));
@@ -1243,11 +1225,8 @@ public class UserITCase extends AbstractITCase {
assertNotNull(e);
}
- AssociationPatch associationPatch = new AssociationPatch();
- associationPatch.setKey(actual.getKey());
- associationPatch.setValue("password");
- associationPatch.setAction(ResourceAssociationAction.PROVISION);
- associationPatch.getResources().add(RESOURCE_NAME_CSV);
+ AssociationPatch associationPatch = new AssociationPatch.Builder().key(actual.getKey()).
+ value("password").action(ResourceAssociationAction.PROVISION).resource(RESOURCE_NAME_CSV).build();
assertNotNull(userService.associate(associationPatch).readEntity(BulkActionResult.class));
@@ -1256,10 +1235,8 @@ public class UserITCase extends AbstractITCase {
assertTrue(actual.getResources().isEmpty());
assertNotNull(resourceService.readConnObject(RESOURCE_NAME_CSV, AnyTypeKind.USER.name(), actual.getKey()));
- DeassociationPatch deassociationPatch = new DeassociationPatch();
- deassociationPatch.setKey(actual.getKey());
- deassociationPatch.setAction(ResourceDeassociationAction.DEPROVISION);
- deassociationPatch.getResources().add(RESOURCE_NAME_CSV);
+ DeassociationPatch deassociationPatch = new DeassociationPatch.Builder().key(actual.getKey()).
+ action(ResourceDeassociationAction.DEPROVISION).resource(RESOURCE_NAME_CSV).build();
assertNotNull(userService.deassociate(deassociationPatch).readEntity(BulkActionResult.class));
http://git-wip-us.apache.org/repos/asf/syncope/blob/85d0a260/fit/core-reference/src/test/java/org/apache/syncope/fit/core/VirAttrITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/VirAttrITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/VirAttrITCase.java
index 5297257..0efb6ae 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/VirAttrITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/VirAttrITCase.java
@@ -168,9 +168,8 @@ public class VirAttrITCase extends AbstractITCase {
// ----------------------------------
// suspend/reactivate user and check virtual attribute value (unchanged)
// ----------------------------------
- StatusPatch statusPatch = new StatusPatch();
- statusPatch.setKey(userTO.getKey());
- statusPatch.setType(StatusPatchType.SUSPEND);
+ StatusPatch statusPatch = new StatusPatch.Builder().key(userTO.getKey()).
+ type(StatusPatchType.SUSPEND).build();
userTO = userService.status(statusPatch).readEntity(new GenericType<ProvisioningResult<UserTO>>() {
}).getEntity();
assertEquals("suspended", userTO.getStatus());
@@ -178,9 +177,8 @@ public class VirAttrITCase extends AbstractITCase {
connObjectTO = resourceService.readConnObject(RESOURCE_NAME_WS2, AnyTypeKind.USER.name(), userTO.getKey());
assertEquals("virtualvalue2", connObjectTO.getAttr("COMPANYNAME").getValues().get(0));
- statusPatch = new StatusPatch();
- statusPatch.setKey(userTO.getKey());
- statusPatch.setType(StatusPatchType.REACTIVATE);
+ statusPatch = new StatusPatch.Builder().key(userTO.getKey()).
+ type(StatusPatchType.REACTIVATE).build();
userTO = userService.status(statusPatch).readEntity(new GenericType<ProvisioningResult<UserTO>>() {
}).getEntity();
assertEquals("active", userTO.getStatus());
[2/2] syncope git commit: Adding some utility Builders
Posted by il...@apache.org.
Adding some utility Builders
Project: http://git-wip-us.apache.org/repos/asf/syncope/repo
Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/d41b96a5
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/d41b96a5
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/d41b96a5
Branch: refs/heads/master
Commit: d41b96a58fe960026c2bd8588ca823cc967fc110
Parents: 8b61a22
Author: Francesco Chicchiriccò <il...@apache.org>
Authored: Wed Oct 4 12:45:27 2017 +0200
Committer: Francesco Chicchiriccò <il...@apache.org>
Committed: Wed Oct 4 12:49:25 2017 +0200
----------------------------------------------------------------------
.../console/commons/status/StatusUtils.java | 9 +-
.../console/rest/AbstractAnyRestClient.java | 48 ++++-----
.../common/lib/patch/AssociationPatch.java | 54 ++++++++++
.../common/lib/patch/DeassociationPatch.java | 44 ++++++++
.../syncope/common/lib/patch/PasswordPatch.java | 5 +-
.../syncope/common/lib/patch/StatusPatch.java | 54 ++++++++++
.../apache/syncope/common/lib/to/AttrTO.java | 5 +-
.../rest/cxf/service/AbstractAnyService.java | 16 +--
.../syncope/fit/core/AbstractTaskITCase.java | 14 +--
.../syncope/fit/core/AuthenticationITCase.java | 11 +-
.../apache/syncope/fit/core/GroupITCase.java | 42 +++-----
.../apache/syncope/fit/core/PullTaskITCase.java | 7 +-
.../org/apache/syncope/fit/core/UserITCase.java | 101 +++++++------------
.../apache/syncope/fit/core/VirAttrITCase.java | 10 +-
14 files changed, 256 insertions(+), 164 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/syncope/blob/d41b96a5/client/console/src/main/java/org/apache/syncope/client/console/commons/status/StatusUtils.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/commons/status/StatusUtils.java b/client/console/src/main/java/org/apache/syncope/client/console/commons/status/StatusUtils.java
index 38fbb6e..601cd0f 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/commons/status/StatusUtils.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/commons/status/StatusUtils.java
@@ -170,23 +170,22 @@ public class StatusUtils implements Serializable {
}
public static StatusPatch buildStatusPatch(final Collection<StatusBean> statuses, final Boolean enable) {
- StatusPatch statusPatch = new StatusPatch();
- statusPatch.setOnSyncope(false);
+ StatusPatch.Builder builder = new StatusPatch.Builder();
for (StatusBean status : statuses) {
if (enable == null
|| (enable && !status.getStatus().isActive()) || (!enable && status.getStatus().isActive())) {
if ("syncope".equalsIgnoreCase(status.getResource())) {
- statusPatch.setOnSyncope(true);
+ builder.onSyncope(true);
} else {
- statusPatch.getResources().add(status.getResource());
+ builder.resource(status.getResource());
}
}
}
- return statusPatch;
+ return builder.build();
}
public static Panel getStatusImagePanel(final String componentId, final Status status) {
http://git-wip-us.apache.org/repos/asf/syncope/blob/d41b96a5/client/console/src/main/java/org/apache/syncope/client/console/rest/AbstractAnyRestClient.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/rest/AbstractAnyRestClient.java b/client/console/src/main/java/org/apache/syncope/client/console/rest/AbstractAnyRestClient.java
index 9d7d1d7..4796ddb 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/rest/AbstractAnyRestClient.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/rest/AbstractAnyRestClient.java
@@ -83,10 +83,9 @@ public abstract class AbstractAnyRestClient<TO extends AnyTO, P extends AnyPatch
synchronized (this) {
AnyService<?, ?> service = getService(etag, getAnyServiceClass());
- DeassociationPatch deassociationPatch = new DeassociationPatch();
- deassociationPatch.setKey(key);
- deassociationPatch.setAction(ResourceDeassociationAction.UNLINK);
- deassociationPatch.getResources().addAll(StatusUtils.buildStatusPatch(statuses).getResources());
+ DeassociationPatch deassociationPatch = new DeassociationPatch.Builder().key(key).
+ action(ResourceDeassociationAction.UNLINK).
+ resources(StatusUtils.buildStatusPatch(statuses).getResources()).build();
result = service.deassociate(deassociationPatch).readEntity(BulkActionResult.class);
@@ -102,11 +101,10 @@ public abstract class AbstractAnyRestClient<TO extends AnyTO, P extends AnyPatch
StatusPatch statusPatch = StatusUtils.buildStatusPatch(statuses);
- AssociationPatch associationPatch = new AssociationPatch();
- associationPatch.setKey(key);
- associationPatch.setAction(ResourceAssociationAction.LINK);
- associationPatch.setOnSyncope(statusPatch.isOnSyncope());
- associationPatch.getResources().addAll(statusPatch.getResources());
+ AssociationPatch associationPatch = new AssociationPatch.Builder().key(key).
+ action(ResourceAssociationAction.LINK).
+ onSyncope(statusPatch.isOnSyncope()).
+ resources(statusPatch.getResources()).build();
result = service.associate(associationPatch).readEntity(BulkActionResult.class);
@@ -120,10 +118,9 @@ public abstract class AbstractAnyRestClient<TO extends AnyTO, P extends AnyPatch
synchronized (this) {
AnyService<?, ?> service = getService(etag, getAnyServiceClass());
- DeassociationPatch deassociationPatch = new DeassociationPatch();
- deassociationPatch.setKey(key);
- deassociationPatch.setAction(ResourceDeassociationAction.DEPROVISION);
- deassociationPatch.getResources().addAll(StatusUtils.buildStatusPatch(statuses).getResources());
+ DeassociationPatch deassociationPatch = new DeassociationPatch.Builder().key(key).
+ action(ResourceDeassociationAction.DEPROVISION).
+ resources(StatusUtils.buildStatusPatch(statuses).getResources()).build();
result = service.deassociate(deassociationPatch).readEntity(BulkActionResult.class);
@@ -139,11 +136,10 @@ public abstract class AbstractAnyRestClient<TO extends AnyTO, P extends AnyPatch
StatusPatch statusPatch = StatusUtils.buildStatusPatch(statuses);
- AssociationPatch associationPatch = new AssociationPatch();
- associationPatch.setKey(key);
- associationPatch.setAction(ResourceAssociationAction.PROVISION);
- associationPatch.setOnSyncope(statusPatch.isOnSyncope());
- associationPatch.getResources().addAll(statusPatch.getResources());
+ AssociationPatch associationPatch = new AssociationPatch.Builder().key(key).
+ action(ResourceAssociationAction.PROVISION).
+ onSyncope(statusPatch.isOnSyncope()).
+ resources(statusPatch.getResources()).build();
result = service.associate(associationPatch).readEntity(BulkActionResult.class);
@@ -157,10 +153,9 @@ public abstract class AbstractAnyRestClient<TO extends AnyTO, P extends AnyPatch
synchronized (this) {
AnyService<?, ?> service = getService(etag, getAnyServiceClass());
- DeassociationPatch deassociationPatch = new DeassociationPatch();
- deassociationPatch.setKey(key);
- deassociationPatch.setAction(ResourceDeassociationAction.UNASSIGN);
- deassociationPatch.getResources().addAll(StatusUtils.buildStatusPatch(statuses).getResources());
+ DeassociationPatch deassociationPatch = new DeassociationPatch.Builder().key(key).
+ action(ResourceDeassociationAction.UNASSIGN).
+ resources(StatusUtils.buildStatusPatch(statuses).getResources()).build();
result = service.deassociate(deassociationPatch).readEntity(BulkActionResult.class);
@@ -176,11 +171,10 @@ public abstract class AbstractAnyRestClient<TO extends AnyTO, P extends AnyPatch
StatusPatch statusPatch = StatusUtils.buildStatusPatch(statuses);
- AssociationPatch associationPatch = new AssociationPatch();
- associationPatch.setKey(key);
- associationPatch.setAction(ResourceAssociationAction.ASSIGN);
- associationPatch.setOnSyncope(statusPatch.isOnSyncope());
- associationPatch.getResources().addAll(statusPatch.getResources());
+ AssociationPatch associationPatch = new AssociationPatch.Builder().key(key).
+ action(ResourceAssociationAction.ASSIGN).
+ onSyncope(statusPatch.isOnSyncope()).
+ resources(statusPatch.getResources()).build();
result = service.associate(associationPatch).readEntity(BulkActionResult.class);
http://git-wip-us.apache.org/repos/asf/syncope/blob/d41b96a5/common/lib/src/main/java/org/apache/syncope/common/lib/patch/AssociationPatch.java
----------------------------------------------------------------------
diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/patch/AssociationPatch.java b/common/lib/src/main/java/org/apache/syncope/common/lib/patch/AssociationPatch.java
index 56efe7e..e445aac 100644
--- a/common/lib/src/main/java/org/apache/syncope/common/lib/patch/AssociationPatch.java
+++ b/common/lib/src/main/java/org/apache/syncope/common/lib/patch/AssociationPatch.java
@@ -18,6 +18,7 @@
*/
package org.apache.syncope.common.lib.patch;
+import java.util.Collection;
import javax.ws.rs.PathParam;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
@@ -29,6 +30,59 @@ public class AssociationPatch extends PasswordPatch {
private static final long serialVersionUID = 6295778399633883767L;
+ public static class Builder extends PasswordPatch.Builder {
+
+ @Override
+ protected AssociationPatch newInstance() {
+ return new AssociationPatch();
+ }
+
+ @Override
+ protected AssociationPatch getInstance() {
+ return (AssociationPatch) super.getInstance();
+ }
+
+ @Override
+ public AssociationPatch build() {
+ return (AssociationPatch) super.build();
+ }
+
+ @Override
+ public Builder onSyncope(final boolean onSyncope) {
+ return (Builder) super.onSyncope(onSyncope);
+ }
+
+ @Override
+ public Builder resource(final String resource) {
+ return (Builder) super.resource(resource);
+ }
+
+ @Override
+ public Builder resources(final Collection<String> resources) {
+ return (Builder) super.resources(resources);
+ }
+
+ @Override
+ public Builder resources(final String... resources) {
+ return (Builder) super.resources(resources);
+ }
+
+ @Override
+ public Builder value(final String value) {
+ return (Builder) super.value(value);
+ }
+
+ public Builder key(final String key) {
+ getInstance().setKey(key);
+ return this;
+ }
+
+ public Builder action(final ResourceAssociationAction action) {
+ getInstance().setAction(action);
+ return this;
+ }
+ }
+
private String key;
private ResourceAssociationAction action;
http://git-wip-us.apache.org/repos/asf/syncope/blob/d41b96a5/common/lib/src/main/java/org/apache/syncope/common/lib/patch/DeassociationPatch.java
----------------------------------------------------------------------
diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/patch/DeassociationPatch.java b/common/lib/src/main/java/org/apache/syncope/common/lib/patch/DeassociationPatch.java
index e5271e0..3c6cc60 100644
--- a/common/lib/src/main/java/org/apache/syncope/common/lib/patch/DeassociationPatch.java
+++ b/common/lib/src/main/java/org/apache/syncope/common/lib/patch/DeassociationPatch.java
@@ -20,6 +20,8 @@ package org.apache.syncope.common.lib.patch;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
import java.util.List;
import javax.ws.rs.PathParam;
import javax.xml.bind.annotation.XmlElement;
@@ -35,6 +37,48 @@ public class DeassociationPatch extends AbstractBaseBean {
private static final long serialVersionUID = 6295778399633883767L;
+ public static class Builder {
+
+ private final DeassociationPatch instance;
+
+ public Builder() {
+ this.instance = new DeassociationPatch();
+ }
+
+ public Builder key(final String key) {
+ instance.setKey(key);
+ return this;
+ }
+
+ public Builder action(final ResourceDeassociationAction action) {
+ instance.setAction(action);
+ return this;
+ }
+
+ public Builder resource(final String resource) {
+ if (resource != null) {
+ instance.getResources().add(resource);
+ }
+ return this;
+ }
+
+ public Builder resources(final String... resources) {
+ instance.getResources().addAll(Arrays.asList(resources));
+ return this;
+ }
+
+ public Builder resources(final Collection<String> resources) {
+ if (resources != null) {
+ instance.getResources().addAll(resources);
+ }
+ return this;
+ }
+
+ public DeassociationPatch build() {
+ return instance;
+ }
+ }
+
private String key;
private ResourceDeassociationAction action;
http://git-wip-us.apache.org/repos/asf/syncope/blob/d41b96a5/common/lib/src/main/java/org/apache/syncope/common/lib/patch/PasswordPatch.java
----------------------------------------------------------------------
diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/patch/PasswordPatch.java b/common/lib/src/main/java/org/apache/syncope/common/lib/patch/PasswordPatch.java
index b02e52e..af989e4 100644
--- a/common/lib/src/main/java/org/apache/syncope/common/lib/patch/PasswordPatch.java
+++ b/common/lib/src/main/java/org/apache/syncope/common/lib/patch/PasswordPatch.java
@@ -20,6 +20,7 @@ package org.apache.syncope.common.lib.patch;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
@@ -55,9 +56,7 @@ public class PasswordPatch extends StringReplacePatchItem {
}
public Builder resources(final String... resources) {
- for (String resource : resources) {
- getInstance().getResources().add(resource);
- }
+ getInstance().getResources().addAll(Arrays.asList(resources));
return this;
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/d41b96a5/common/lib/src/main/java/org/apache/syncope/common/lib/patch/StatusPatch.java
----------------------------------------------------------------------
diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/patch/StatusPatch.java b/common/lib/src/main/java/org/apache/syncope/common/lib/patch/StatusPatch.java
index b7d9c1e..9c94dc7 100644
--- a/common/lib/src/main/java/org/apache/syncope/common/lib/patch/StatusPatch.java
+++ b/common/lib/src/main/java/org/apache/syncope/common/lib/patch/StatusPatch.java
@@ -18,6 +18,7 @@
*/
package org.apache.syncope.common.lib.patch;
+import java.util.Collection;
import javax.ws.rs.PathParam;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
@@ -29,6 +30,59 @@ public class StatusPatch extends PasswordPatch {
private static final long serialVersionUID = 99309988426922612L;
+ public static class Builder extends PasswordPatch.Builder {
+
+ @Override
+ protected StatusPatch newInstance() {
+ return new StatusPatch();
+ }
+
+ @Override
+ protected StatusPatch getInstance() {
+ return (StatusPatch) super.getInstance();
+ }
+
+ @Override
+ public StatusPatch build() {
+ return (StatusPatch) super.build();
+ }
+
+ @Override
+ public Builder onSyncope(final boolean onSyncope) {
+ return (Builder) super.onSyncope(onSyncope);
+ }
+
+ @Override
+ public Builder resource(final String resource) {
+ return (Builder) super.resource(resource);
+ }
+
+ @Override
+ public Builder resources(final Collection<String> resources) {
+ return (Builder) super.resources(resources);
+ }
+
+ @Override
+ public Builder resources(final String... resources) {
+ return (Builder) super.resources(resources);
+ }
+
+ public Builder key(final String key) {
+ getInstance().setKey(key);
+ return this;
+ }
+
+ public Builder type(final StatusPatchType type) {
+ getInstance().setType(type);
+ return this;
+ }
+
+ public Builder token(final String token) {
+ getInstance().setToken(token);
+ return this;
+ }
+ }
+
/**
* Key of user to for which status update is requested.
*/
http://git-wip-us.apache.org/repos/asf/syncope/blob/d41b96a5/common/lib/src/main/java/org/apache/syncope/common/lib/to/AttrTO.java
----------------------------------------------------------------------
diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/to/AttrTO.java b/common/lib/src/main/java/org/apache/syncope/common/lib/to/AttrTO.java
index 0c71ca6..bd63527 100644
--- a/common/lib/src/main/java/org/apache/syncope/common/lib/to/AttrTO.java
+++ b/common/lib/src/main/java/org/apache/syncope/common/lib/to/AttrTO.java
@@ -21,6 +21,7 @@ package org.apache.syncope.common.lib.to;
import org.apache.syncope.common.lib.AbstractBaseBean;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import javax.ws.rs.PathParam;
@@ -55,9 +56,7 @@ public class AttrTO extends AbstractBaseBean {
}
public Builder values(final String... values) {
- for (String value : values) {
- instance.getValues().add(value);
- }
+ instance.getValues().addAll(Arrays.asList(values));
return this;
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/d41b96a5/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/AbstractAnyService.java
----------------------------------------------------------------------
diff --git a/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/AbstractAnyService.java b/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/AbstractAnyService.java
index ed0f2dd..ee8489c 100644
--- a/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/AbstractAnyService.java
+++ b/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/AbstractAnyService.java
@@ -385,10 +385,10 @@ public abstract class AbstractAnyService<TO extends AnyTO, P extends AnyPatch>
case SUSPEND:
if (logic instanceof UserLogic) {
bulkAction.getTargets().forEach(key -> {
- StatusPatch statusPatch = new StatusPatch();
- statusPatch.setKey(key);
- statusPatch.setType(StatusPatchType.SUSPEND);
- statusPatch.setOnSyncope(true);
+ StatusPatch statusPatch = new StatusPatch.Builder().key(key).
+ type(StatusPatchType.SUSPEND).
+ onSyncope(true).
+ build();
try {
result.getResults().put(
@@ -408,10 +408,10 @@ public abstract class AbstractAnyService<TO extends AnyTO, P extends AnyPatch>
case REACTIVATE:
if (logic instanceof UserLogic) {
bulkAction.getTargets().forEach(key -> {
- StatusPatch statusPatch = new StatusPatch();
- statusPatch.setKey(key);
- statusPatch.setType(StatusPatchType.REACTIVATE);
- statusPatch.setOnSyncope(true);
+ StatusPatch statusPatch = new StatusPatch.Builder().key(key).
+ type(StatusPatchType.REACTIVATE).
+ onSyncope(true).
+ build();
try {
result.getResults().put(
http://git-wip-us.apache.org/repos/asf/syncope/blob/d41b96a5/fit/core-reference/src/test/java/org/apache/syncope/fit/core/AbstractTaskITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/AbstractTaskITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/AbstractTaskITCase.java
index 92aa4b2..49cc8f4 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/AbstractTaskITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/AbstractTaskITCase.java
@@ -104,11 +104,8 @@ public abstract class AbstractTaskITCase extends AbstractITCase {
build());
if (matchingGroups.getSize() > 0) {
for (GroupTO group : matchingGroups.getResult()) {
- DeassociationPatch deassociationPatch = new DeassociationPatch();
- deassociationPatch.setKey(group.getKey());
- deassociationPatch.setAction(ResourceDeassociationAction.UNLINK);
- deassociationPatch.getResources().add(RESOURCE_NAME_LDAP);
- groupService.deassociate(deassociationPatch);
+ groupService.deassociate(new DeassociationPatch.Builder().key(group.getKey()).
+ action(ResourceDeassociationAction.UNLINK).resource(RESOURCE_NAME_LDAP).build());
groupService.delete(group.getKey());
}
}
@@ -119,11 +116,8 @@ public abstract class AbstractTaskITCase extends AbstractITCase {
build());
if (matchingUsers.getSize() > 0) {
for (UserTO user : matchingUsers.getResult()) {
- DeassociationPatch deassociationPatch = new DeassociationPatch();
- deassociationPatch.setKey(user.getKey());
- deassociationPatch.setAction(ResourceDeassociationAction.UNLINK);
- deassociationPatch.getResources().add(RESOURCE_NAME_LDAP);
- userService.deassociate(deassociationPatch);
+ userService.deassociate(new DeassociationPatch.Builder().key(user.getKey()).
+ action(ResourceDeassociationAction.UNLINK).resource(RESOURCE_NAME_LDAP).build());
userService.delete(user.getKey());
}
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/d41b96a5/fit/core-reference/src/test/java/org/apache/syncope/fit/core/AuthenticationITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/AuthenticationITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/AuthenticationITCase.java
index 946d97d..58dca0d 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/AuthenticationITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/AuthenticationITCase.java
@@ -396,9 +396,8 @@ public class AuthenticationITCase extends AbstractITCase {
assertNotNull(e);
}
- StatusPatch reactivate = new StatusPatch();
- reactivate.setKey(userTO.getKey());
- reactivate.setType(StatusPatchType.REACTIVATE);
+ StatusPatch reactivate = new StatusPatch.Builder().key(userTO.getKey()).
+ type(StatusPatchType.REACTIVATE).build();
userTO = userService.status(reactivate).readEntity(new GenericType<ProvisioningResult<UserTO>>() {
}).getEntity();
assertNotNull(userTO);
@@ -523,10 +522,8 @@ public class AuthenticationITCase extends AbstractITCase {
assertNotNull(user);
// 2. unlink the resource from the created user
- DeassociationPatch deassociationPatch = new DeassociationPatch();
- deassociationPatch.setKey(user.getKey());
- deassociationPatch.setAction(ResourceDeassociationAction.UNLINK);
- deassociationPatch.getResources().add(RESOURCE_NAME_TESTDB);
+ DeassociationPatch deassociationPatch = new DeassociationPatch.Builder().key(user.getKey()).
+ action(ResourceDeassociationAction.UNLINK).resource(RESOURCE_NAME_TESTDB).build();
assertNotNull(userService.deassociate(deassociationPatch).readEntity(BulkActionResult.class));
// 3. change password on Syncope
http://git-wip-us.apache.org/repos/asf/syncope/blob/d41b96a5/fit/core-reference/src/test/java/org/apache/syncope/fit/core/GroupITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/GroupITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/GroupITCase.java
index 3b8db05..a1337d2 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/GroupITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/GroupITCase.java
@@ -316,10 +316,8 @@ public class GroupITCase extends AbstractITCase {
assertNotNull(resourceService.readConnObject(RESOURCE_NAME_LDAP, AnyTypeKind.GROUP.name(), actual.getKey()));
- DeassociationPatch deassociationPatch = new DeassociationPatch();
- deassociationPatch.setKey(actual.getKey());
- deassociationPatch.setAction(ResourceDeassociationAction.UNLINK);
- deassociationPatch.getResources().add(RESOURCE_NAME_LDAP);
+ DeassociationPatch deassociationPatch = new DeassociationPatch.Builder().key(actual.getKey()).
+ action(ResourceDeassociationAction.UNLINK).resource(RESOURCE_NAME_LDAP).build();
assertNotNull(groupService.deassociate(deassociationPatch).readEntity(BulkActionResult.class));
@@ -345,10 +343,8 @@ public class GroupITCase extends AbstractITCase {
assertNotNull(e);
}
- AssociationPatch associationPatch = new AssociationPatch();
- associationPatch.setKey(actual.getKey());
- associationPatch.setAction(ResourceAssociationAction.LINK);
- associationPatch.getResources().add(RESOURCE_NAME_LDAP);
+ AssociationPatch associationPatch = new AssociationPatch.Builder().key(actual.getKey()).
+ action(ResourceAssociationAction.LINK).resource(RESOURCE_NAME_LDAP).build();
assertNotNull(groupService.associate(associationPatch).readEntity(BulkActionResult.class));
@@ -414,10 +410,8 @@ public class GroupITCase extends AbstractITCase {
assertNotNull(e);
}
- AssociationPatch associationPatch = new AssociationPatch();
- associationPatch.setKey(groupTO.getKey());
- associationPatch.setAction(ResourceAssociationAction.ASSIGN);
- associationPatch.getResources().add(RESOURCE_NAME_LDAP);
+ AssociationPatch associationPatch = new AssociationPatch.Builder().key(groupTO.getKey()).
+ action(ResourceAssociationAction.ASSIGN).resource(RESOURCE_NAME_LDAP).build();
assertNotNull(groupService.associate(associationPatch).readEntity(BulkActionResult.class));
@@ -443,10 +437,8 @@ public class GroupITCase extends AbstractITCase {
assertNotNull(resourceService.readConnObject(RESOURCE_NAME_LDAP, AnyTypeKind.GROUP.name(), groupTO.getKey()));
- DeassociationPatch deassociationPatch = new DeassociationPatch();
- deassociationPatch.setKey(groupTO.getKey());
- deassociationPatch.setAction(ResourceDeassociationAction.DEPROVISION);
- deassociationPatch.getResources().add(RESOURCE_NAME_LDAP);
+ DeassociationPatch deassociationPatch = new DeassociationPatch.Builder().key(groupTO.getKey()).
+ action(ResourceDeassociationAction.DEPROVISION).resource(RESOURCE_NAME_LDAP).build();
assertNotNull(groupService.deassociate(deassociationPatch).readEntity(BulkActionResult.class));
@@ -483,10 +475,8 @@ public class GroupITCase extends AbstractITCase {
assertNotNull(e);
}
- AssociationPatch associationPatch = new AssociationPatch();
- associationPatch.setKey(groupTO.getKey());
- associationPatch.setAction(ResourceAssociationAction.PROVISION);
- associationPatch.getResources().add(RESOURCE_NAME_LDAP);
+ AssociationPatch associationPatch = new AssociationPatch.Builder().key(groupTO.getKey()).
+ action(ResourceAssociationAction.PROVISION).resource(RESOURCE_NAME_LDAP).build();
assertNotNull(groupService.associate(associationPatch).readEntity(BulkActionResult.class));
@@ -518,10 +508,8 @@ public class GroupITCase extends AbstractITCase {
assertNotNull(e);
}
- AssociationPatch associationPatch = new AssociationPatch();
- associationPatch.setKey(groupTO.getKey());
- associationPatch.setAction(ResourceAssociationAction.PROVISION);
- associationPatch.getResources().add(RESOURCE_NAME_LDAP);
+ AssociationPatch associationPatch = new AssociationPatch.Builder().key(groupTO.getKey()).
+ action(ResourceAssociationAction.PROVISION).resource(RESOURCE_NAME_LDAP).build();
assertNotNull(groupService.associate(associationPatch).readEntity(BulkActionResult.class));
@@ -531,10 +519,8 @@ public class GroupITCase extends AbstractITCase {
assertNotNull(resourceService.readConnObject(
RESOURCE_NAME_LDAP, AnyTypeKind.GROUP.name(), groupTO.getKey()));
- DeassociationPatch deassociationPatch = new DeassociationPatch();
- deassociationPatch.setKey(groupTO.getKey());
- deassociationPatch.setAction(ResourceDeassociationAction.DEPROVISION);
- deassociationPatch.getResources().add(RESOURCE_NAME_LDAP);
+ DeassociationPatch deassociationPatch = new DeassociationPatch.Builder().key(groupTO.getKey()).
+ action(ResourceDeassociationAction.DEPROVISION).resource(RESOURCE_NAME_LDAP).build();
assertNotNull(groupService.deassociate(deassociationPatch).readEntity(BulkActionResult.class));
http://git-wip-us.apache.org/repos/asf/syncope/blob/d41b96a5/fit/core-reference/src/test/java/org/apache/syncope/fit/core/PullTaskITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/PullTaskITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/PullTaskITCase.java
index 699d317..391289a 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/PullTaskITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/PullTaskITCase.java
@@ -444,11 +444,8 @@ public class PullTaskITCase extends AbstractTaskITCase {
is("location").equalTo("pull*").query()).build());
assertTrue(matchingPrinters.getSize() > 0);
for (AnyObjectTO printer : matchingPrinters.getResult()) {
- DeassociationPatch deassociationPatch = new DeassociationPatch();
- deassociationPatch.setKey(printer.getKey());
- deassociationPatch.setAction(ResourceDeassociationAction.UNLINK);
- deassociationPatch.getResources().add(RESOURCE_NAME_DBSCRIPTED);
- anyObjectService.deassociate(deassociationPatch);
+ anyObjectService.deassociate(new DeassociationPatch.Builder().key(printer.getKey()).
+ action(ResourceDeassociationAction.UNLINK).resource(RESOURCE_NAME_DBSCRIPTED).build());
anyObjectService.delete(printer.getKey());
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/d41b96a5/fit/core-reference/src/test/java/org/apache/syncope/fit/core/UserITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/UserITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/UserITCase.java
index f406c0e..7dee2f1 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/UserITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/UserITCase.java
@@ -713,10 +713,9 @@ public class UserITCase extends AbstractITCase {
assertEquals("created", userTO.getStatus());
- StatusPatch statusPatch = new StatusPatch();
- statusPatch.setKey(userTO.getKey());
- statusPatch.setType(StatusPatchType.ACTIVATE);
- statusPatch.setToken(userTO.getToken());
+ StatusPatch statusPatch = new StatusPatch.Builder().key(userTO.getKey()).
+ type(StatusPatchType.ACTIVATE).token(userTO.getToken()).build();
+
userTO = userService.status(statusPatch).readEntity(new GenericType<ProvisioningResult<UserTO>>() {
}).getEntity();
@@ -740,17 +739,16 @@ public class UserITCase extends AbstractITCase {
? "active"
: "created", userTO.getStatus());
- StatusPatch statusPatch = new StatusPatch();
- statusPatch.setKey(userTO.getKey());
- statusPatch.setType(StatusPatchType.SUSPEND);
+ StatusPatch statusPatch = new StatusPatch.Builder().key(userTO.getKey()).
+ type(StatusPatchType.SUSPEND).token(userTO.getToken()).build();
+
userTO = userService.status(statusPatch).readEntity(new GenericType<ProvisioningResult<UserTO>>() {
}).getEntity();
assertNotNull(userTO);
assertEquals("suspended", userTO.getStatus());
- statusPatch = new StatusPatch();
- statusPatch.setKey(userTO.getKey());
- statusPatch.setType(StatusPatchType.REACTIVATE);
+ statusPatch = new StatusPatch.Builder().key(userTO.getKey()).type(StatusPatchType.REACTIVATE).build();
+
userTO = userService.status(statusPatch).readEntity(new GenericType<ProvisioningResult<UserTO>>() {
}).getEntity();
assertNotNull(userTO);
@@ -779,12 +777,11 @@ public class UserITCase extends AbstractITCase {
String userKey = userTO.getKey();
// Suspend with effect on syncope, ldap and db => user should be suspended in syncope and all resources
- StatusPatch statusPatch = new StatusPatch();
- statusPatch.setKey(userKey);
- statusPatch.setType(StatusPatchType.SUSPEND);
- statusPatch.setOnSyncope(true);
- statusPatch.getResources().add(RESOURCE_NAME_TESTDB);
- statusPatch.getResources().add(RESOURCE_NAME_LDAP);
+ StatusPatch statusPatch = new StatusPatch.Builder().key(userKey).
+ type(StatusPatchType.SUSPEND).
+ onSyncope(true).
+ resources(RESOURCE_NAME_TESTDB, RESOURCE_NAME_LDAP).
+ build();
userTO = userService.status(statusPatch).readEntity(new GenericType<ProvisioningResult<UserTO>>() {
}).getEntity();
assertNotNull(userTO);
@@ -798,11 +795,11 @@ public class UserITCase extends AbstractITCase {
assertNotNull(connObjectTO);
// Suspend and reactivate only on ldap => db and syncope should still show suspended
- statusPatch = new StatusPatch();
- statusPatch.setKey(userKey);
- statusPatch.setType(StatusPatchType.SUSPEND);
- statusPatch.setOnSyncope(false);
- statusPatch.getResources().add(RESOURCE_NAME_LDAP);
+ statusPatch = new StatusPatch.Builder().key(userKey).
+ type(StatusPatchType.SUSPEND).
+ onSyncope(false).
+ resources(RESOURCE_NAME_LDAP).
+ build();
userService.status(statusPatch);
statusPatch.setType(StatusPatchType.REACTIVATE);
userTO = userService.status(statusPatch).readEntity(new GenericType<ProvisioningResult<UserTO>>() {
@@ -814,12 +811,11 @@ public class UserITCase extends AbstractITCase {
assertFalse(getBooleanAttribute(connObjectTO, OperationalAttributes.ENABLE_NAME));
// Reactivate on syncope and db => syncope and db should show the user as active
- statusPatch = new StatusPatch();
- statusPatch.setKey(userKey);
- statusPatch.setType(StatusPatchType.REACTIVATE);
- statusPatch.setOnSyncope(true);
- statusPatch.getResources().add(RESOURCE_NAME_TESTDB);
-
+ statusPatch = new StatusPatch.Builder().key(userKey).
+ type(StatusPatchType.REACTIVATE).
+ onSyncope(true).
+ resources(RESOURCE_NAME_TESTDB).
+ build();
userTO = userService.status(statusPatch).readEntity(new GenericType<ProvisioningResult<UserTO>>() {
}).getEntity();
assertNotNull(userTO);
@@ -1051,10 +1047,8 @@ public class UserITCase extends AbstractITCase {
assertNotNull(actual);
assertNotNull(resourceService.readConnObject(RESOURCE_NAME_CSV, AnyTypeKind.USER.name(), actual.getKey()));
- DeassociationPatch deassociationPatch = new DeassociationPatch();
- deassociationPatch.setKey(actual.getKey());
- deassociationPatch.setAction(ResourceDeassociationAction.UNLINK);
- deassociationPatch.getResources().add(RESOURCE_NAME_CSV);
+ DeassociationPatch deassociationPatch = new DeassociationPatch.Builder().key(actual.getKey()).
+ action(ResourceDeassociationAction.UNLINK).resource(RESOURCE_NAME_CSV).build();
assertNotNull(userService.deassociate(deassociationPatch).readEntity(BulkActionResult.class));
@@ -1084,10 +1078,8 @@ public class UserITCase extends AbstractITCase {
assertNotNull(e);
}
- AssociationPatch associationPatch = new AssociationPatch();
- associationPatch.setKey(actual.getKey());
- associationPatch.setAction(ResourceAssociationAction.LINK);
- associationPatch.getResources().add(RESOURCE_NAME_CSV);
+ AssociationPatch associationPatch = new AssociationPatch.Builder().key(actual.getKey()).
+ action(ResourceAssociationAction.LINK).resource(RESOURCE_NAME_CSV).build();
assertNotNull(userService.associate(associationPatch).readEntity(BulkActionResult.class));
@@ -1116,10 +1108,8 @@ public class UserITCase extends AbstractITCase {
assertNotNull(actual);
assertNotNull(resourceService.readConnObject(RESOURCE_NAME_CSV, AnyTypeKind.USER.name(), actual.getKey()));
- DeassociationPatch deassociationPatch = new DeassociationPatch();
- deassociationPatch.setKey(actual.getKey());
- deassociationPatch.setAction(ResourceDeassociationAction.UNASSIGN);
- deassociationPatch.getResources().add(RESOURCE_NAME_CSV);
+ DeassociationPatch deassociationPatch = new DeassociationPatch.Builder().key(actual.getKey()).
+ action(ResourceDeassociationAction.UNASSIGN).resource(RESOURCE_NAME_CSV).build();
assertNotNull(userService.deassociate(deassociationPatch).readEntity(BulkActionResult.class));
@@ -1154,11 +1144,8 @@ public class UserITCase extends AbstractITCase {
assertNotNull(e);
}
- AssociationPatch associationPatch = new AssociationPatch();
- associationPatch.setKey(actual.getKey());
- associationPatch.setValue("password");
- associationPatch.setAction(ResourceAssociationAction.ASSIGN);
- associationPatch.getResources().add(RESOURCE_NAME_CSV);
+ AssociationPatch associationPatch = new AssociationPatch.Builder().key(actual.getKey()).
+ value("password").action(ResourceAssociationAction.ASSIGN).resource(RESOURCE_NAME_CSV).build();
assertNotNull(userService.associate(associationPatch).readEntity(BulkActionResult.class));
@@ -1181,10 +1168,8 @@ public class UserITCase extends AbstractITCase {
assertNotNull(actual);
assertNotNull(resourceService.readConnObject(RESOURCE_NAME_CSV, AnyTypeKind.USER.name(), actual.getKey()));
- DeassociationPatch deassociationPatch = new DeassociationPatch();
- deassociationPatch.setKey(actual.getKey());
- deassociationPatch.setAction(ResourceDeassociationAction.DEPROVISION);
- deassociationPatch.getResources().add(RESOURCE_NAME_CSV);
+ DeassociationPatch deassociationPatch = new DeassociationPatch.Builder().key(actual.getKey()).
+ action(ResourceDeassociationAction.DEPROVISION).resource(RESOURCE_NAME_CSV).build();
assertNotNull(userService.deassociate(deassociationPatch).readEntity(BulkActionResult.class));
@@ -1219,11 +1204,8 @@ public class UserITCase extends AbstractITCase {
assertNotNull(e);
}
- AssociationPatch associationPatch = new AssociationPatch();
- associationPatch.setKey(actual.getKey());
- associationPatch.setValue("password");
- associationPatch.setAction(ResourceAssociationAction.PROVISION);
- associationPatch.getResources().add(RESOURCE_NAME_CSV);
+ AssociationPatch associationPatch = new AssociationPatch.Builder().key(actual.getKey()).
+ value("password").action(ResourceAssociationAction.PROVISION).resource(RESOURCE_NAME_CSV).build();
assertNotNull(userService.associate(associationPatch).readEntity(BulkActionResult.class));
@@ -1252,11 +1234,8 @@ public class UserITCase extends AbstractITCase {
assertNotNull(e);
}
- AssociationPatch associationPatch = new AssociationPatch();
- associationPatch.setKey(actual.getKey());
- associationPatch.setValue("password");
- associationPatch.setAction(ResourceAssociationAction.PROVISION);
- associationPatch.getResources().add(RESOURCE_NAME_CSV);
+ AssociationPatch associationPatch = new AssociationPatch.Builder().key(actual.getKey()).
+ value("password").action(ResourceAssociationAction.PROVISION).resource(RESOURCE_NAME_CSV).build();
assertNotNull(userService.associate(associationPatch).readEntity(BulkActionResult.class));
@@ -1265,10 +1244,8 @@ public class UserITCase extends AbstractITCase {
assertTrue(actual.getResources().isEmpty());
assertNotNull(resourceService.readConnObject(RESOURCE_NAME_CSV, AnyTypeKind.USER.name(), actual.getKey()));
- DeassociationPatch deassociationPatch = new DeassociationPatch();
- deassociationPatch.setKey(actual.getKey());
- deassociationPatch.setAction(ResourceDeassociationAction.DEPROVISION);
- deassociationPatch.getResources().add(RESOURCE_NAME_CSV);
+ DeassociationPatch deassociationPatch = new DeassociationPatch.Builder().key(actual.getKey()).
+ action(ResourceDeassociationAction.DEPROVISION).resource(RESOURCE_NAME_CSV).build();
assertNotNull(userService.deassociate(deassociationPatch).readEntity(BulkActionResult.class));
http://git-wip-us.apache.org/repos/asf/syncope/blob/d41b96a5/fit/core-reference/src/test/java/org/apache/syncope/fit/core/VirAttrITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/VirAttrITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/VirAttrITCase.java
index d7161f7..43f9120 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/VirAttrITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/VirAttrITCase.java
@@ -166,9 +166,8 @@ public class VirAttrITCase extends AbstractITCase {
// ----------------------------------
// suspend/reactivate user and check virtual attribute value (unchanged)
// ----------------------------------
- StatusPatch statusPatch = new StatusPatch();
- statusPatch.setKey(userTO.getKey());
- statusPatch.setType(StatusPatchType.SUSPEND);
+ StatusPatch statusPatch = new StatusPatch.Builder().key(userTO.getKey()).
+ type(StatusPatchType.SUSPEND).build();
userTO = userService.status(statusPatch).readEntity(new GenericType<ProvisioningResult<UserTO>>() {
}).getEntity();
assertEquals("suspended", userTO.getStatus());
@@ -176,9 +175,8 @@ public class VirAttrITCase extends AbstractITCase {
connObjectTO = resourceService.readConnObject(RESOURCE_NAME_WS2, AnyTypeKind.USER.name(), userTO.getKey());
assertEquals("virtualvalue2", connObjectTO.getAttr("COMPANYNAME").get().getValues().get(0));
- statusPatch = new StatusPatch();
- statusPatch.setKey(userTO.getKey());
- statusPatch.setType(StatusPatchType.REACTIVATE);
+ statusPatch = new StatusPatch.Builder().key(userTO.getKey()).
+ type(StatusPatchType.REACTIVATE).build();
userTO = userService.status(statusPatch).readEntity(new GenericType<ProvisioningResult<UserTO>>() {
}).getEntity();
assertEquals("active", userTO.getStatus());