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 2013/10/28 11:24:49 UTC
svn commit: r1536304 [3/4] - in /syncope/trunk:
client/src/main/java/org/apache/syncope/client/rest/
common/src/main/java/org/apache/syncope/common/
common/src/main/java/org/apache/syncope/common/types/
common/src/main/java/org/apache/syncope/common/va...
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/TaskDataBinder.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/TaskDataBinder.java?rev=1536304&r1=1536303&r2=1536304&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/TaskDataBinder.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/TaskDataBinder.java Mon Oct 28 10:24:47 2013
@@ -18,7 +18,6 @@
*/
package org.apache.syncope.core.rest.data;
-import javax.ws.rs.core.Response;
import org.apache.commons.lang3.StringUtils;
import org.apache.syncope.common.to.AbstractAttributableTO;
import org.apache.syncope.common.to.PropagationTaskTO;
@@ -30,10 +29,9 @@ import org.apache.syncope.common.to.Sync
import org.apache.syncope.common.to.TaskExecTO;
import org.apache.syncope.common.to.AbstractTaskTO;
import org.apache.syncope.common.to.UserTO;
-import org.apache.syncope.common.types.SyncopeClientExceptionType;
+import org.apache.syncope.common.types.ClientExceptionType;
import org.apache.syncope.common.types.TaskType;
import org.apache.syncope.common.util.BeanUtils;
-import org.apache.syncope.common.validation.SyncopeClientCompositeException;
import org.apache.syncope.common.validation.SyncopeClientException;
import org.apache.syncope.core.init.JobInstanceLoader;
import org.apache.syncope.core.persistence.beans.ExternalResource;
@@ -85,28 +83,28 @@ public class TaskDataBinder {
private void checkJexl(final AbstractAttributableTO attributableTO, final SyncopeClientException sce) {
for (AttributeTO attrTO : attributableTO.getAttrs()) {
if (!attrTO.getValues().isEmpty() && !jexlUtil.isExpressionValid(attrTO.getValues().get(0))) {
- sce.addElement("Invalid JEXL: " + attrTO.getValues().get(0));
+ sce.getElements().add("Invalid JEXL: " + attrTO.getValues().get(0));
}
}
for (AttributeTO attrTO : attributableTO.getVirAttrs()) {
if (!attrTO.getValues().isEmpty() && !jexlUtil.isExpressionValid(attrTO.getValues().get(0))) {
- sce.addElement("Invalid JEXL: " + attrTO.getValues().get(0));
+ sce.getElements().add("Invalid JEXL: " + attrTO.getValues().get(0));
}
}
}
private void fill(final SyncTask task, final SyncTaskTO taskTO) {
- SyncopeClientException sce = new SyncopeClientException(SyncopeClientExceptionType.InvalidSyncTask);
+ SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidSyncTask);
// 1. validate JEXL expressions in user and role templates
if (taskTO.getUserTemplate() != null) {
UserTO template = taskTO.getUserTemplate();
if (StringUtils.isNotBlank(template.getUsername()) && !jexlUtil.isExpressionValid(template.getUsername())) {
- sce.addElement("Invalid JEXL: " + template.getUsername());
+ sce.getElements().add("Invalid JEXL: " + template.getUsername());
}
if (StringUtils.isNotBlank(template.getPassword()) && !jexlUtil.isExpressionValid(template.getPassword())) {
- sce.addElement("Invalid JEXL: " + template.getPassword());
+ sce.getElements().add("Invalid JEXL: " + template.getPassword());
}
checkJexl(template, sce);
@@ -119,16 +117,13 @@ public class TaskDataBinder {
RoleTO template = taskTO.getRoleTemplate();
if (StringUtils.isNotBlank(template.getName()) && !jexlUtil.isExpressionValid(template.getName())) {
- sce.addElement("Invalid JEXL: " + template.getName());
+ sce.getElements().add("Invalid JEXL: " + template.getName());
}
checkJexl(template, sce);
}
if (!sce.isEmpty()) {
- SyncopeClientCompositeException scce =
- new SyncopeClientCompositeException(Response.Status.BAD_REQUEST.getStatusCode());
- scce.addException(sce);
- throw scce;
+ throw sce;
}
// 2. all JEXL expressions are valid: accept user and role templates
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/UserDataBinder.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/UserDataBinder.java?rev=1536304&r1=1536303&r2=1536304&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/UserDataBinder.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/UserDataBinder.java Mon Oct 28 10:24:47 2013
@@ -22,7 +22,6 @@ import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import javax.annotation.Resource;
-import javax.ws.rs.core.Response;
import org.apache.commons.lang3.StringUtils;
import org.apache.syncope.common.mod.MembershipMod;
import org.apache.syncope.common.mod.UserMod;
@@ -33,7 +32,7 @@ import org.apache.syncope.common.types.C
import org.apache.syncope.common.types.IntMappingType;
import org.apache.syncope.common.types.PasswordPolicySpec;
import org.apache.syncope.common.types.ResourceOperation;
-import org.apache.syncope.common.types.SyncopeClientExceptionType;
+import org.apache.syncope.common.types.ClientExceptionType;
import org.apache.syncope.common.util.BeanUtils;
import org.apache.syncope.common.validation.SyncopeClientCompositeException;
import org.apache.syncope.common.validation.SyncopeClientException;
@@ -181,8 +180,8 @@ public class UserDataBinder extends Abst
user.setPassword(password, getPredefinedCipherAlgoritm(), passwordHistorySize);
} catch (NotFoundException e) {
final SyncopeClientException invalidCiperAlgorithm =
- new SyncopeClientException(SyncopeClientExceptionType.NotFound);
- invalidCiperAlgorithm.addElement(e.getMessage());
+ SyncopeClientException.build(ClientExceptionType.NotFound);
+ invalidCiperAlgorithm.getElements().add(e.getMessage());
scce.addException(invalidCiperAlgorithm);
throw scce;
@@ -190,8 +189,7 @@ public class UserDataBinder extends Abst
}
public void create(final SyncopeUser user, final UserTO userTO) {
- SyncopeClientCompositeException scce =
- new SyncopeClientCompositeException(Response.Status.BAD_REQUEST.getStatusCode());
+ SyncopeClientCompositeException scce = SyncopeClientException.buildComposite();
// memberships
SyncopeRole role;
@@ -246,8 +244,7 @@ public class UserDataBinder extends Abst
public PropagationByResource update(final SyncopeUser user, final UserMod userMod) {
PropagationByResource propByRes = new PropagationByResource();
- SyncopeClientCompositeException scce =
- new SyncopeClientCompositeException(Response.Status.BAD_REQUEST.getStatusCode());
+ SyncopeClientCompositeException scce = SyncopeClientException.buildComposite();
Set<String> currentResources = user.getResourceNames();
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/utils/RestServiceExceptionMapper.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/utils/RestServiceExceptionMapper.java?rev=1536304&r1=1536303&r2=1536304&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/utils/RestServiceExceptionMapper.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/utils/RestServiceExceptionMapper.java Mon Oct 28 10:24:47 2013
@@ -30,13 +30,15 @@ import javax.ws.rs.core.Response.Respons
import javax.ws.rs.ext.ExceptionMapper;
import javax.ws.rs.ext.Provider;
import org.apache.cxf.jaxrs.client.ResponseExceptionMapper;
+import org.apache.syncope.common.SyncopeConstants;
import org.apache.syncope.common.services.InvalidSearchConditionException;
import org.apache.syncope.common.types.EntityViolationType;
-import org.apache.syncope.common.types.SyncopeClientExceptionType;
+import org.apache.syncope.common.types.ClientExceptionType;
import org.apache.syncope.common.validation.SyncopeClientCompositeException;
import org.apache.syncope.common.validation.SyncopeClientException;
import org.apache.syncope.core.persistence.dao.MissingConfKeyException;
import org.apache.syncope.core.persistence.dao.NotFoundException;
+import org.apache.syncope.core.persistence.validation.attrvalue.ParsingValidationException;
import org.apache.syncope.core.persistence.validation.entity.InvalidEntityException;
import org.apache.syncope.core.rest.controller.UnauthorizedRoleException;
import org.apache.syncope.core.workflow.WorkflowException;
@@ -59,8 +61,11 @@ public class RestServiceExceptionMapper
public Response toResponse(final Exception ex) {
LOG.error("Exception thrown by REST method: " + ex.getMessage(), ex);
- if (ex instanceof SyncopeClientCompositeException) {
- return getCompositeExceptionResponse((SyncopeClientCompositeException) ex);
+ if (ex instanceof SyncopeClientException) {
+ SyncopeClientException sce = (SyncopeClientException) ex;
+ return (sce.isComposite()
+ ? getSyncopeClientCompositeExceptionResponse(sce.asComposite())
+ : getSyncopeClientExceptionResponse(sce));
}
if (ex instanceof AccessDeniedException) {
@@ -70,20 +75,20 @@ public class RestServiceExceptionMapper
}
if (ex instanceof UnauthorizedRoleException) {
- return buildResponse(Response.status(Response.Status.FORBIDDEN),
- SyncopeClientExceptionType.UnauthorizedRole,
+ return buildResponse(Response.status(Response.Status.UNAUTHORIZED),
+ ClientExceptionType.UnauthorizedRole,
getExMessage(ex));
}
if (ex instanceof EntityExistsException) {
return buildResponse(Response.status(Response.Status.CONFLICT),
- SyncopeClientExceptionType.EntityExists,
+ ClientExceptionType.EntityExists,
getExMessage(ex));
}
if (ex instanceof DataIntegrityViolationException) {
return buildResponse(Response.status(Response.Status.CONFLICT),
- SyncopeClientExceptionType.DataIntegrityViolation,
+ ClientExceptionType.DataIntegrityViolation,
getExMessage(ex));
}
@@ -104,7 +109,7 @@ public class RestServiceExceptionMapper
// Rest is interpreted as InternalServerError
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).
- header(SyncopeClientExceptionType.Unknown.getElementHeaderName(), getExMessage(ex)).
+ header(ClientExceptionType.Unknown.getElementHeaderName(), getExMessage(ex)).
build();
}
@@ -114,14 +119,30 @@ public class RestServiceExceptionMapper
"Call of fromResponse() method is not expected in RestServiceExceptionMapper");
}
- private Response getCompositeExceptionResponse(final SyncopeClientCompositeException ex) {
- ResponseBuilder responseBuilder = Response.status(ex.getStatusCode());
+ private Response getSyncopeClientExceptionResponse(final SyncopeClientException ex) {
+ ResponseBuilder responseBuilder = Response.status(ex.getType().getResponseStatus());
+ responseBuilder.header(
+ SyncopeConstants.REST_EXCEPTION_TYPE_HEADER, ex.getType().getHeaderValue());
+
+ for (Object element : ex.getElements()) {
+ responseBuilder.header(ex.getType().getElementHeaderName(), element);
+ }
+
+ return responseBuilder.build();
+ }
+
+ private Response getSyncopeClientCompositeExceptionResponse(final SyncopeClientCompositeException ex) {
+ if (ex.getExceptions().size() == 1) {
+ return getSyncopeClientExceptionResponse(ex.getExceptions().iterator().next());
+ }
+
+ ResponseBuilder responseBuilder = Response.status(Response.Status.BAD_REQUEST);
for (SyncopeClientException sce : ex.getExceptions()) {
responseBuilder.header(
- SyncopeClientCompositeException.EXCEPTION_TYPE_HEADER, sce.getType().getHeaderValue());
+ SyncopeConstants.REST_EXCEPTION_TYPE_HEADER, sce.getType().getHeaderValue());
- for (String attributeName : sce.getElements()) {
- responseBuilder.header(sce.getType().getElementHeaderName(), attributeName);
+ for (Object element : sce.getElements()) {
+ responseBuilder.header(sce.getType().getElementHeaderName(), element);
}
}
return responseBuilder.build();
@@ -130,16 +151,13 @@ public class RestServiceExceptionMapper
private Response processNotFoundExceptions(final Exception ex) {
ResponseBuilder responseBuilder = Response.status(Response.Status.NOT_FOUND);
- if (ex instanceof javax.ws.rs.NotFoundException) {
- return buildResponse(responseBuilder, SyncopeClientExceptionType.NotFound, getExMessage(ex));
-
- } else if (ex instanceof NotFoundException) {
- return buildResponse(responseBuilder, SyncopeClientExceptionType.NotFound, getExMessage(ex));
-
+ if (ex instanceof javax.ws.rs.NotFoundException || ex instanceof NotFoundException) {
+ return buildResponse(responseBuilder, ClientExceptionType.NotFound, getExMessage(ex));
} else if (ex instanceof MissingConfKeyException) {
- return buildResponse(responseBuilder, SyncopeClientExceptionType.NotFound, getMessage(ex,
- ((MissingConfKeyException) ex).getConfKey()));
+ return buildResponse(responseBuilder, ClientExceptionType.NotFound,
+ getMessage(ex, ((MissingConfKeyException) ex).getConfKey()));
}
+
return null;
}
@@ -158,10 +176,9 @@ public class RestServiceExceptionMapper
if (iee != null) {
ResponseBuilder builder = Response.status(Response.Status.BAD_REQUEST);
- SyncopeClientExceptionType exType =
- SyncopeClientExceptionType.valueOf("Invalid" + iee.getEntityClassSimpleName());
+ ClientExceptionType exType = ClientExceptionType.valueOf("Invalid" + iee.getEntityClassSimpleName());
- builder.header(SyncopeClientCompositeException.EXCEPTION_TYPE_HEADER, exType.getHeaderValue());
+ builder.header(SyncopeConstants.REST_EXCEPTION_TYPE_HEADER, exType.getHeaderValue());
for (Map.Entry<Class<?>, Set<EntityViolationType>> violation : iee.getViolations().entrySet()) {
for (EntityViolationType violationType : violation.getValue()) {
@@ -186,28 +203,30 @@ public class RestServiceExceptionMapper
return ((BadRequestException) ex).getResponse();
}
} else if (ex instanceof WorkflowException) {
- return buildResponse(responseBuilder, SyncopeClientExceptionType.Workflow, getExMessage(ex));
+ return buildResponse(responseBuilder, ClientExceptionType.Workflow, getExMessage(ex));
} else if (ex instanceof InvalidSearchConditionException) {
- return buildResponse(responseBuilder, SyncopeClientExceptionType.InvalidSearchCondition, getExMessage(ex));
+ return buildResponse(responseBuilder, ClientExceptionType.InvalidSearchCondition, getExMessage(ex));
} else if (ex instanceof PersistenceException) {
- return buildResponse(responseBuilder, SyncopeClientExceptionType.GenericPersistence, getExMessage(ex));
+ return buildResponse(responseBuilder, ClientExceptionType.GenericPersistence, getExMessage(ex));
} else if (ex instanceof org.apache.ibatis.exceptions.PersistenceException) {
- return buildResponse(responseBuilder, SyncopeClientExceptionType.Workflow, getMessage(ex,
+ return buildResponse(responseBuilder, ClientExceptionType.Workflow, getMessage(ex,
"Currently unavailable. Please try later."));
} else if (ex instanceof JpaSystemException) {
- return buildResponse(responseBuilder, SyncopeClientExceptionType.DataIntegrityViolation, getExMessage(ex));
+ return buildResponse(responseBuilder, ClientExceptionType.DataIntegrityViolation, getExMessage(ex));
} else if (ex instanceof ConfigurationException) {
- return buildResponse(responseBuilder, SyncopeClientExceptionType.InvalidConnIdConf, getExMessage(ex));
+ return buildResponse(responseBuilder, ClientExceptionType.InvalidConnIdConf, getExMessage(ex));
+ } else if (ex instanceof ParsingValidationException) {
+ return buildResponse(responseBuilder, ClientExceptionType.InvalidValues, getExMessage(ex));
}
return null;
}
- private Response buildResponse(final ResponseBuilder responseBuilder, final SyncopeClientExceptionType hType,
+ private Response buildResponse(final ResponseBuilder responseBuilder, final ClientExceptionType hType,
final String msg) {
return responseBuilder.header(
- SyncopeClientCompositeException.EXCEPTION_TYPE_HEADER, hType.getHeaderValue()).
+ SyncopeConstants.REST_EXCEPTION_TYPE_HEADER, hType.getHeaderValue()).
header(hType.getElementHeaderName(), msg).
build();
}
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ConfigurationServiceImpl.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ConfigurationServiceImpl.java?rev=1536304&r1=1536303&r2=1536304&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ConfigurationServiceImpl.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ConfigurationServiceImpl.java Mon Oct 28 10:24:47 2013
@@ -50,7 +50,7 @@ public class ConfigurationServiceImpl ex
ConfigurationTO created = controller.create(configurationTO);
URI location = uriInfo.getAbsolutePathBuilder().path(created.getKey()).build();
return Response.created(location).
- header(SyncopeConstants.REST_HEADER_ID, created.getKey()).
+ header(SyncopeConstants.REST_RESOURCE_ID_HEADER, created.getKey()).
build();
}
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ConnectorServiceImpl.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ConnectorServiceImpl.java?rev=1536304&r1=1536303&r2=1536304&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ConnectorServiceImpl.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ConnectorServiceImpl.java Mon Oct 28 10:24:47 2013
@@ -45,7 +45,7 @@ public class ConnectorServiceImpl extend
public Response create(final ConnInstanceTO connInstanceTO) {
ConnInstanceTO connInstance = controller.create(connInstanceTO);
URI location = uriInfo.getAbsolutePathBuilder().path(String.valueOf(connInstance.getId())).build();
- return Response.created(location).header(SyncopeConstants.REST_HEADER_ID, connInstance.getId()).build();
+ return Response.created(location).header(SyncopeConstants.REST_RESOURCE_ID_HEADER, connInstance.getId()).build();
}
@Override
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/services/NotificationServiceImpl.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/services/NotificationServiceImpl.java?rev=1536304&r1=1536303&r2=1536304&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/services/NotificationServiceImpl.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/services/NotificationServiceImpl.java Mon Oct 28 10:24:47 2013
@@ -41,7 +41,7 @@ public class NotificationServiceImpl ext
NotificationTO createdNotificationTO = controller.create(notificationTO);
URI location = uriInfo.getAbsolutePathBuilder().path(String.valueOf(createdNotificationTO.getId())).build();
return Response.created(location)
- .header(SyncopeConstants.REST_HEADER_ID, createdNotificationTO.getId())
+ .header(SyncopeConstants.REST_RESOURCE_ID_HEADER, createdNotificationTO.getId())
.build();
}
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/services/PolicyServiceImpl.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/services/PolicyServiceImpl.java?rev=1536304&r1=1536303&r2=1536304&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/services/PolicyServiceImpl.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/services/PolicyServiceImpl.java Mon Oct 28 10:24:47 2013
@@ -46,7 +46,7 @@ public class PolicyServiceImpl extends A
public <T extends AbstractPolicyTO> Response create(final T policyTO) {
AbstractPolicyTO policy = policyController.create(policyTO);
URI location = uriInfo.getAbsolutePathBuilder().path(String.valueOf(policy.getId())).build();
- return Response.created(location).header(SyncopeConstants.REST_HEADER_ID, policy.getId()).build();
+ return Response.created(location).header(SyncopeConstants.REST_RESOURCE_ID_HEADER, policy.getId()).build();
}
@Override
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ReportServiceImpl.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ReportServiceImpl.java?rev=1536304&r1=1536303&r2=1536304&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ReportServiceImpl.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ReportServiceImpl.java Mon Oct 28 10:24:47 2013
@@ -50,7 +50,7 @@ public class ReportServiceImpl extends A
ReportTO createdReportTO = controller.create(reportTO);
URI location = uriInfo.getAbsolutePathBuilder().path(String.valueOf(createdReportTO.getId())).build();
return Response.created(location)
- .header(SyncopeConstants.REST_HEADER_ID, createdReportTO.getId())
+ .header(SyncopeConstants.REST_RESOURCE_ID_HEADER, createdReportTO.getId())
.build();
}
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ResourceServiceImpl.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ResourceServiceImpl.java?rev=1536304&r1=1536303&r2=1536304&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ResourceServiceImpl.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ResourceServiceImpl.java Mon Oct 28 10:24:47 2013
@@ -49,7 +49,7 @@ public class ResourceServiceImpl extends
ResourceTO resource = controller.create(resourceTO);
URI location = uriInfo.getAbsolutePathBuilder().path(resource.getName()).build();
return Response.created(location)
- .header(SyncopeConstants.REST_HEADER_ID, resource.getName())
+ .header(SyncopeConstants.REST_RESOURCE_ID_HEADER, resource.getName())
.build();
}
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/services/RoleServiceImpl.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/services/RoleServiceImpl.java?rev=1536304&r1=1536303&r2=1536304&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/services/RoleServiceImpl.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/services/RoleServiceImpl.java Mon Oct 28 10:24:47 2013
@@ -56,7 +56,7 @@ public class RoleServiceImpl extends Abs
RoleTO created = controller.create(roleTO);
URI location = uriInfo.getAbsolutePathBuilder().path(String.valueOf(created.getId())).build();
return Response.created(location)
- .header(SyncopeConstants.REST_HEADER_ID, created.getId())
+ .header(SyncopeConstants.REST_RESOURCE_ID_HEADER, created.getId())
.entity(created)
.build();
}
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/services/SchemaServiceImpl.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/services/SchemaServiceImpl.java?rev=1536304&r1=1536303&r2=1536304&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/services/SchemaServiceImpl.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/services/SchemaServiceImpl.java Mon Oct 28 10:24:47 2013
@@ -46,7 +46,7 @@ public class SchemaServiceImpl extends A
URI location = uriInfo.getAbsolutePathBuilder().path(response.getName()).build();
return Response.created(location)
- .header(SyncopeConstants.REST_HEADER_ID, response.getName())
+ .header(SyncopeConstants.REST_RESOURCE_ID_HEADER, response.getName())
.build();
}
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/services/TaskServiceImpl.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/services/TaskServiceImpl.java?rev=1536304&r1=1536303&r2=1536304&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/services/TaskServiceImpl.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/services/TaskServiceImpl.java Mon Oct 28 10:24:47 2013
@@ -62,7 +62,7 @@ public class TaskServiceImpl extends Abs
}
URI location = uriInfo.getAbsolutePathBuilder().path(String.valueOf(createdTask.getId())).build();
- return Response.created(location).header(SyncopeConstants.REST_HEADER_ID, createdTask.getId()).build();
+ return Response.created(location).header(SyncopeConstants.REST_RESOURCE_ID_HEADER, createdTask.getId()).build();
}
@Override
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/services/UserRequestServiceImpl.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/services/UserRequestServiceImpl.java?rev=1536304&r1=1536303&r2=1536304&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/services/UserRequestServiceImpl.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/services/UserRequestServiceImpl.java Mon Oct 28 10:24:47 2013
@@ -70,7 +70,7 @@ public class UserRequestServiceImpl exte
URI location = uriInfo.getAbsolutePathBuilder().path(String.valueOf(outUserRequestTO.getId())).build();
return Response.created(location)
- .header(SyncopeConstants.REST_HEADER_ID, outUserRequestTO.getId())
+ .header(SyncopeConstants.REST_RESOURCE_ID_HEADER, outUserRequestTO.getId())
.build();
}
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/services/UserServiceImpl.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/services/UserServiceImpl.java?rev=1536304&r1=1536303&r2=1536304&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/services/UserServiceImpl.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/services/UserServiceImpl.java Mon Oct 28 10:24:47 2013
@@ -72,7 +72,7 @@ public class UserServiceImpl extends Abs
UserTO created = controller.create(userTO);
URI location = uriInfo.getAbsolutePathBuilder().path(String.valueOf(created.getId())).build();
return Response.created(location).
- header(SyncopeConstants.REST_HEADER_ID, created.getId()).
+ header(SyncopeConstants.REST_RESOURCE_ID_HEADER, created.getId()).
entity(created)
.build();
}
Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AuthenticationTestITCase.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AuthenticationTestITCase.java?rev=1536304&r1=1536303&r2=1536304&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AuthenticationTestITCase.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AuthenticationTestITCase.java Mon Oct 28 10:24:47 2013
@@ -46,8 +46,7 @@ import org.apache.syncope.common.to.User
import org.apache.syncope.common.types.AttributableType;
import org.apache.syncope.common.types.AttributeSchemaType;
import org.apache.syncope.common.types.SchemaType;
-import org.apache.syncope.common.types.SyncopeClientExceptionType;
-import org.apache.syncope.common.validation.SyncopeClientCompositeException;
+import org.apache.syncope.common.types.ClientExceptionType;
import org.apache.syncope.common.validation.SyncopeClientException;
import org.junit.FixMethodOrder;
import org.junit.Test;
@@ -110,8 +109,8 @@ public class AuthenticationTestITCase ex
assertNotNull(schemaTO);
// 4. read the schema created above (as user) - success
- SchemaService schemaService2 =
- clientFactory.create(userTO.getUsername(), "password123").getService(SchemaService.class);
+ SchemaService schemaService2 = clientFactory.create(userTO.getUsername(), "password123").getService(
+ SchemaService.class);
schemaTO = schemaService2.read(AttributableType.USER, SchemaType.NORMAL, schemaName);
assertNotNull(schemaTO);
@@ -120,9 +119,9 @@ public class AuthenticationTestITCase ex
try {
schemaService2.update(AttributableType.ROLE, SchemaType.NORMAL, schemaName, schemaTO);
fail("Schemaupdate as user schould not work");
- } catch (SyncopeClientCompositeException e) {
+ } catch (SyncopeClientException e) {
assertNotNull(e);
- assertEquals(HttpStatus.SC_FORBIDDEN, e.getStatusCode());
+ assertEquals(HttpStatus.SC_UNAUTHORIZED, e.getType().getResponseStatus().getStatusCode());
} catch (AccessControlException e) {
// CXF Service will throw this exception
assertNotNull(e);
@@ -146,23 +145,23 @@ public class AuthenticationTestITCase ex
userTO = createUser(userTO);
assertNotNull(userTO);
- UserService userService2 =
- clientFactory.create(userTO.getUsername(), "password123").getService(UserService.class);
+ UserService userService2 = clientFactory.create(userTO.getUsername(), "password123").
+ getService(UserService.class);
UserTO readUserTO = userService2.read(1L);
assertNotNull(readUserTO);
- UserService userService3 =
- clientFactory.create("verdi", ADMIN_PWD).getService(UserService.class);
+ UserService userService3 = clientFactory.create("verdi", ADMIN_PWD).getService(UserService.class);
SyncopeClientException exception = null;
try {
userService3.read(1L);
fail();
- } catch (SyncopeClientCompositeException e) {
- exception = e.getException(SyncopeClientExceptionType.UnauthorizedRole);
+ } catch (SyncopeClientException e) {
+ exception = e;
}
assertNotNull(exception);
+ assertEquals(ClientExceptionType.UnauthorizedRole, exception.getType());
}
@Test
@@ -180,8 +179,8 @@ public class AuthenticationTestITCase ex
userTO = createUser(userTO);
assertNotNull(userTO);
- UserService userService2 =
- clientFactory.create(userTO.getUsername(), "password123").getService(UserService.class);
+ UserService userService2 = clientFactory.create(userTO.getUsername(), "password123").
+ getService(UserService.class);
AttributeCond isNullCond = new AttributeCond(AttributeCond.Type.ISNOTNULL);
isNullCond.setSchema("loginDate");
@@ -196,8 +195,7 @@ public class AuthenticationTestITCase ex
}
assertTrue(userIds.contains(1L));
- UserService userService3 =
- clientFactory.create("verdi", "password").getService(UserService.class);
+ UserService userService3 = clientFactory.create("verdi", "password").getService(UserService.class);
matchedUsers = userService3.search(searchCondition);
@@ -227,20 +225,19 @@ public class AuthenticationTestITCase ex
assertNotNull(userTO);
long userId = userTO.getId();
- UserService userService2 =
- clientFactory.create(userTO.getUsername(), "password123").getService(UserService.class);
+ UserService userService2 = clientFactory.create(userTO.getUsername(), "password123").getService(
+ UserService.class);
assertEquals(0, getFailedLogins(userService2, userId));
// authentications failed ...
- UserService userService3 =
- clientFactory.create(userTO.getUsername(), "wrongpwd1").getService(UserService.class);
+ UserService userService3 = clientFactory.create(userTO.getUsername(), "wrongpwd1").getService(UserService.class);
assertReadFails(userService3, userId);
assertReadFails(userService3, userId);
assertEquals(2, getFailedLogins(userService, userId));
- UserService userService4 =
- clientFactory.create(userTO.getUsername(), "password123").getService(UserService.class);
+ UserService userService4 = clientFactory.create(userTO.getUsername(), "password123").getService(
+ UserService.class);
assertEquals(0, getFailedLogins(userService4, userId));
}
@@ -260,13 +257,12 @@ public class AuthenticationTestITCase ex
long userId = userTO.getId();
assertNotNull(userTO);
- UserService userService2 =
- clientFactory.create(userTO.getUsername(), "password123").getService(UserService.class);
+ UserService userService2 = clientFactory.create(userTO.getUsername(), "password123").getService(
+ UserService.class);
assertEquals(0, getFailedLogins(userService2, userId));
// authentications failed ...
- UserService userService3 =
- clientFactory.create(userTO.getUsername(), "wrongpwd1").getService(UserService.class);
+ UserService userService3 = clientFactory.create(userTO.getUsername(), "wrongpwd1").getService(UserService.class);
assertReadFails(userService3, userId);
assertReadFails(userService3, userId);
assertReadFails(userService3, userId);
@@ -274,8 +270,7 @@ public class AuthenticationTestITCase ex
assertEquals(3, getFailedLogins(userService, userId));
// last authentication before suspension
- userService3 =
- clientFactory.create(userTO.getUsername(), "wrongpwd1").getService(UserService.class);
+ userService3 = clientFactory.create(userTO.getUsername(), "wrongpwd1").getService(UserService.class);
assertReadFails(userService3, userId);
userTO = userService.read(userTO.getId());
@@ -286,16 +281,14 @@ public class AuthenticationTestITCase ex
assertEquals("suspended", userTO.getStatus());
// Access with correct credentials should fail as user is suspended
- userService2 =
- clientFactory.create(userTO.getUsername(), "password123").getService(UserService.class);
+ userService2 = clientFactory.create(userTO.getUsername(), "password123").getService(UserService.class);
assertReadFails(userService2, userId);
userTO = userService.reactivate(userTO.getId());
assertNotNull(userTO);
assertEquals("active", userTO.getStatus());
- userService2 =
- clientFactory.create(userTO.getUsername(), "password123").getService(UserService.class);
+ userService2 = clientFactory.create(userTO.getUsername(), "password123").getService(UserService.class);
assertEquals(0, getFailedLogins(userService2, userId));
}
@@ -329,8 +322,8 @@ public class AuthenticationTestITCase ex
role1Admin = createUser(role1Admin);
assertNotNull(role1Admin);
- UserService userService2 =
- clientFactory.create(role1Admin.getUsername(), "password").getService(UserService.class);
+ UserService userService2 = clientFactory.create(role1Admin.getUsername(), "password").getService(
+ UserService.class);
// User with role 1, created by user with child role created above
UserTO role1User = UserTestITCase.getUniqueSampleTO("syncope48user@apache.org");
Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ConfigurationTestITCase.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ConfigurationTestITCase.java?rev=1536304&r1=1536303&r2=1536304&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ConfigurationTestITCase.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ConfigurationTestITCase.java Mon Oct 28 10:24:47 2013
@@ -38,8 +38,7 @@ import org.apache.syncope.common.Syncope
import org.apache.syncope.common.services.ConfigurationService;
import org.apache.syncope.common.to.ConfigurationTO;
import org.apache.syncope.common.types.EntityViolationType;
-import org.apache.syncope.common.types.SyncopeClientExceptionType;
-import org.apache.syncope.common.validation.SyncopeClientCompositeException;
+import org.apache.syncope.common.types.ClientExceptionType;
import org.apache.syncope.common.validation.SyncopeClientException;
import org.junit.FixMethodOrder;
import org.junit.Test;
@@ -57,8 +56,8 @@ public class ConfigurationTestITCase ext
Response response = configurationService.create(configurationTO);
assertNotNull(response);
assertEquals(HttpStatus.SC_CREATED, response.getStatus());
- ConfigurationTO newConfigurationTO =
- adminClient.getObject(response.getLocation(), ConfigurationService.class, ConfigurationTO.class);
+ ConfigurationTO newConfigurationTO = adminClient.getObject(response.getLocation(), ConfigurationService.class,
+ ConfigurationTO.class);
assertEquals(configurationTO, newConfigurationTO);
}
@@ -66,8 +65,8 @@ public class ConfigurationTestITCase ext
public void delete() throws UnsupportedEncodingException {
try {
configurationService.delete("nonExistent");
- } catch (SyncopeClientCompositeException e) {
- assertEquals(HttpStatus.SC_NOT_FOUND, e.getStatusCode());
+ } catch (SyncopeClientException e) {
+ assertEquals(HttpStatus.SC_NOT_FOUND, e.getType().getResponseStatus().getStatusCode());
}
ConfigurationTO tokenLengthTO = configurationService.read("token.length");
@@ -75,15 +74,15 @@ public class ConfigurationTestITCase ext
configurationService.delete("token.length");
try {
configurationService.read("token.length");
- } catch (SyncopeClientCompositeException e) {
- assertEquals(HttpStatus.SC_NOT_FOUND, e.getStatusCode());
+ } catch (SyncopeClientException e) {
+ assertEquals(HttpStatus.SC_NOT_FOUND, e.getType().getResponseStatus().getStatusCode());
}
Response response = configurationService.create(tokenLengthTO);
assertNotNull(response);
assertEquals(HttpStatus.SC_CREATED, response.getStatus());
- ConfigurationTO newConfigurationTO =
- adminClient.getObject(response.getLocation(), ConfigurationService.class, ConfigurationTO.class);
+ ConfigurationTO newConfigurationTO = adminClient.getObject(response.getLocation(), ConfigurationService.class,
+ ConfigurationTO.class);
assertEquals(tokenLengthTO, newConfigurationTO);
}
@@ -143,12 +142,12 @@ public class ConfigurationTestITCase ext
try {
configurationService.create(configurationTO);
fail();
- } catch (SyncopeClientCompositeException scce) {
- SyncopeClientException sce = scce.getException(SyncopeClientExceptionType.InvalidSyncopeConf);
+ } catch (SyncopeClientException e) {
+ assertEquals(ClientExceptionType.InvalidSyncopeConf, e.getType());
- assertNotNull(sce.getElements());
- assertEquals(1, sce.getElements().size());
- assertTrue(sce.getElements().iterator().next().contains(EntityViolationType.InvalidName.name()));
+ assertNotNull(e.getElements());
+ assertEquals(1, e.getElements().size());
+ assertTrue(e.getElements().iterator().next().toString().contains(EntityViolationType.InvalidName.name()));
}
}
}
Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ConnInstanceTestITCase.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ConnInstanceTestITCase.java?rev=1536304&r1=1536303&r2=1536304&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ConnInstanceTestITCase.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ConnInstanceTestITCase.java Mon Oct 28 10:24:47 2013
@@ -51,7 +51,7 @@ import org.apache.syncope.common.types.C
import org.apache.syncope.common.types.ConnConfProperty;
import org.apache.syncope.common.types.ConnectorCapability;
import org.apache.syncope.common.types.IntMappingType;
-import org.apache.syncope.common.validation.SyncopeClientCompositeException;
+import org.apache.syncope.common.validation.SyncopeClientException;
import org.apache.syncope.core.util.ConnIdBundleManager;
import org.identityconnectors.common.security.GuardedString;
import org.junit.BeforeClass;
@@ -85,7 +85,7 @@ public class ConnInstanceTestITCase exte
assertNotNull(connidDbTableVersion);
}
- @Test(expected = SyncopeClientCompositeException.class)
+ @Test(expected = SyncopeClientException.class)
public void createWithException() {
ConnInstanceTO connectorTO = new ConnInstanceTO();
@@ -149,8 +149,8 @@ public class ConnInstanceTestITCase exte
throw (RuntimeException) clientFactory.getExceptionMapper().fromResponse(response);
}
- ConnInstanceTO actual =
- adminClient.getObject(response.getLocation(), ConnectorService.class, ConnInstanceTO.class);
+ ConnInstanceTO actual = adminClient.getObject(response.getLocation(), ConnectorService.class,
+ ConnInstanceTO.class);
assertNotNull(actual);
assertEquals(actual.getBundleName(), connectorTO.getBundleName());
@@ -170,7 +170,7 @@ public class ConnInstanceTestITCase exte
try {
connectorService.update(connectorTO.getId(), connectorTO);
actual = connectorService.read(connectorTO.getId());
- } catch (SyncopeClientCompositeException e) {
+ } catch (SyncopeClientException e) {
LOG.error("update failed", e);
t = e;
}
@@ -182,7 +182,7 @@ public class ConnInstanceTestITCase exte
// check also for the deletion of the created object
try {
connectorService.delete(actual.getId());
- } catch (SyncopeClientCompositeException e) {
+ } catch (SyncopeClientException e) {
LOG.error("delete failed", e);
t = e;
}
@@ -192,8 +192,8 @@ public class ConnInstanceTestITCase exte
// check the non existence
try {
connectorService.read(actual.getId());
- } catch (SyncopeClientCompositeException e) {
- assertEquals(HttpStatus.SC_NOT_FOUND, e.getStatusCode());
+ } catch (SyncopeClientException e) {
+ assertEquals(HttpStatus.SC_NOT_FOUND, e.getType().getResponseStatus().getStatusCode());
}
}
@@ -341,8 +341,8 @@ public class ConnInstanceTestITCase exte
public void deleteWithException() {
try {
connectorService.delete(0L);
- } catch (SyncopeClientCompositeException e) {
- assertEquals(HttpStatus.SC_NOT_FOUND, e.getStatusCode());
+ } catch (SyncopeClientException e) {
+ assertEquals(HttpStatus.SC_NOT_FOUND, e.getType().getResponseStatus().getStatusCode());
}
}
@@ -697,13 +697,13 @@ public class ConnInstanceTestITCase exte
try {
connectorService.read(Long.valueOf(iter.next()));
fail();
- } catch (SyncopeClientCompositeException e) {
+ } catch (SyncopeClientException e) {
}
try {
connectorService.read(Long.valueOf(iter.next()));
fail();
- } catch (SyncopeClientCompositeException e) {
+ } catch (SyncopeClientException e) {
}
}
}
Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/DerivedSchemaTestITCase.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/DerivedSchemaTestITCase.java?rev=1536304&r1=1536303&r2=1536304&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/DerivedSchemaTestITCase.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/DerivedSchemaTestITCase.java Mon Oct 28 10:24:47 2013
@@ -31,8 +31,7 @@ import org.apache.syncope.common.to.DerS
import org.apache.syncope.common.types.AttributableType;
import org.apache.syncope.common.types.EntityViolationType;
import org.apache.syncope.common.types.SchemaType;
-import org.apache.syncope.common.types.SyncopeClientExceptionType;
-import org.apache.syncope.common.validation.SyncopeClientCompositeException;
+import org.apache.syncope.common.types.ClientExceptionType;
import org.apache.syncope.common.validation.SyncopeClientException;
import org.junit.FixMethodOrder;
import org.junit.Test;
@@ -78,18 +77,16 @@ public class DerivedSchemaTestITCase ext
schemaService.delete(AttributableType.ROLE, SchemaType.DERIVED, schema.getName());
- Throwable t = null;
try {
schemaService.read(AttributableType.ROLE, SchemaType.DERIVED, "rderiveddata");
- } catch (SyncopeClientCompositeException e) {
- t = e;
- assertNotNull(e.getException(SyncopeClientExceptionType.NotFound));
+ fail();
+ } catch (SyncopeClientException e) {
+ assertEquals(ClientExceptionType.NotFound, e.getType());
} finally {
// Recreate schema to make test re-runnable
schema = createSchema(AttributableType.ROLE, SchemaType.DERIVED, schema);
assertNotNull(schema);
}
- assertNotNull(t);
}
@Test
@@ -123,18 +120,18 @@ public class DerivedSchemaTestITCase ext
try {
createSchema(AttributableType.ROLE, SchemaType.DERIVED, actual);
fail();
- } catch (SyncopeClientCompositeException scce) {
- assertEquals(HttpStatus.SC_CONFLICT, scce.getStatusCode());
- assertTrue(scce.hasException(SyncopeClientExceptionType.EntityExists));
+ } catch (SyncopeClientException e) {
+ assertEquals(HttpStatus.SC_CONFLICT, e.getType().getResponseStatus().getStatusCode());
+ assertEquals(ClientExceptionType.EntityExists, e.getType());
}
actual.setName(null);
try {
createSchema(AttributableType.ROLE, SchemaType.DERIVED, actual);
fail();
- } catch (SyncopeClientCompositeException scce) {
- assertEquals(HttpStatus.SC_BAD_REQUEST, scce.getStatusCode());
- assertTrue(scce.hasException(SyncopeClientExceptionType.RequiredValuesMissing));
+ } catch (SyncopeClientException e) {
+ assertEquals(HttpStatus.SC_BAD_REQUEST, e.getType().getResponseStatus().getStatusCode());
+ assertEquals(ClientExceptionType.RequiredValuesMissing, e.getType());
}
}
@@ -147,12 +144,10 @@ public class DerivedSchemaTestITCase ext
try {
createSchema(AttributableType.ROLE, SchemaType.DERIVED, schema);
fail();
- } catch (SyncopeClientCompositeException scce) {
- SyncopeClientException sce = scce.getException(SyncopeClientExceptionType.InvalidRDerSchema);
+ } catch (SyncopeClientException e) {
+ assertEquals(ClientExceptionType.InvalidRDerSchema, e.getType());
- assertNotNull(sce.getElements());
- assertEquals(1, sce.getElements().size());
- assertTrue(sce.getElements().iterator().next().contains(EntityViolationType.InvalidName.name()));
+ assertTrue(e.getElements().iterator().next().toString().contains(EntityViolationType.InvalidName.name()));
}
}
}
Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/NotificationTestITCase.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/NotificationTestITCase.java?rev=1536304&r1=1536303&r2=1536304&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/NotificationTestITCase.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/NotificationTestITCase.java Mon Oct 28 10:24:47 2013
@@ -21,7 +21,6 @@ package org.apache.syncope.core.rest;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
import static org.junit.Assert.fail;
import java.util.List;
@@ -34,9 +33,8 @@ import org.apache.syncope.common.search.
import org.apache.syncope.common.services.NotificationService;
import org.apache.syncope.common.to.NotificationTO;
import org.apache.syncope.common.types.IntMappingType;
-import org.apache.syncope.common.types.SyncopeClientExceptionType;
+import org.apache.syncope.common.types.ClientExceptionType;
import org.apache.syncope.common.types.TraceLevel;
-import org.apache.syncope.common.validation.SyncopeClientCompositeException;
import org.apache.syncope.common.validation.SyncopeClientException;
import org.junit.FixMethodOrder;
import org.junit.Test;
@@ -45,6 +43,31 @@ import org.junit.runners.MethodSorters;
@FixMethodOrder(MethodSorters.JVM)
public class NotificationTestITCase extends AbstractTest {
+ private NotificationTO buildNotificationTO() {
+ NotificationTO notificationTO = new NotificationTO();
+ notificationTO.setTraceLevel(TraceLevel.SUMMARY);
+ notificationTO.getEvents().add("create");
+
+ AttributeCond fullnameLeafCond1 = new AttributeCond(AttributeCond.Type.LIKE);
+ fullnameLeafCond1.setSchema("fullname");
+ fullnameLeafCond1.setExpression("%o%");
+ AttributeCond fullnameLeafCond2 = new AttributeCond(AttributeCond.Type.LIKE);
+ fullnameLeafCond2.setSchema("fullname");
+ fullnameLeafCond2.setExpression("%i%");
+ NodeCond about = NodeCond.getAndCond(NodeCond.getLeafCond(fullnameLeafCond1),
+ NodeCond.getLeafCond(fullnameLeafCond2));
+
+ notificationTO.setAbout(about);
+
+ notificationTO.setRecipientAttrName("email");
+ notificationTO.setRecipientAttrType(IntMappingType.UserSchema);
+
+ notificationTO.setSender("syncope@syncope.apache.org");
+ notificationTO.setSubject("Test notification");
+ notificationTO.setTemplate("test");
+ return notificationTO;
+ }
+
@Test
public void read() {
NotificationTO notificationTO = notificationService.read(100L);
@@ -71,8 +94,8 @@ public class NotificationTestITCase exte
notificationTO.setRecipients(recipients);
Response response = notificationService.create(notificationTO);
- NotificationTO actual =
- adminClient.getObject(response.getLocation(), NotificationService.class, NotificationTO.class);
+ NotificationTO actual = adminClient.getObject(response.getLocation(), NotificationService.class,
+ NotificationTO.class);
assertNotNull(actual);
assertNotNull(actual.getId());
@@ -91,10 +114,9 @@ public class NotificationTestITCase exte
try {
notificationService.update(notificationTO.getId(), notificationTO);
fail();
- } catch (SyncopeClientCompositeException e) {
- exception = e.getException(SyncopeClientExceptionType.InvalidNotification);
+ } catch (SyncopeClientException e) {
+ assertEquals(ClientExceptionType.InvalidNotification, e.getType());
}
- assertNotNull(exception);
MembershipCond membCond = new MembershipCond();
membCond.setRoleId(7L);
@@ -120,8 +142,8 @@ public class NotificationTestITCase exte
try {
notificationService.read(notification.getId());
fail();
- } catch (SyncopeClientCompositeException e) {
- assertNotNull(e.getException(SyncopeClientExceptionType.NotFound));
+ } catch (SyncopeClientException e) {
+ assertEquals(ClientExceptionType.NotFound, e.getType());
}
}
@@ -135,38 +157,13 @@ public class NotificationTestITCase exte
try {
Response response = notificationService.create(notificationTO);
actual = adminClient.getObject(response.getLocation(), NotificationService.class, NotificationTO.class);
- } catch (SyncopeClientCompositeException e) {
- exception = e.getException(SyncopeClientExceptionType.InvalidNotification);
+ } catch (SyncopeClientException e) {
+ assertEquals(ClientExceptionType.InvalidNotification, e.getType());
}
- assertNull(exception);
assertNotNull(actual);
assertNotNull(actual.getId());
notificationTO.setId(actual.getId());
assertEquals(actual, notificationTO);
}
- private NotificationTO buildNotificationTO() {
- NotificationTO notificationTO = new NotificationTO();
- notificationTO.setTraceLevel(TraceLevel.SUMMARY);
- notificationTO.getEvents().add("create");
-
- AttributeCond fullnameLeafCond1 = new AttributeCond(AttributeCond.Type.LIKE);
- fullnameLeafCond1.setSchema("fullname");
- fullnameLeafCond1.setExpression("%o%");
- AttributeCond fullnameLeafCond2 = new AttributeCond(AttributeCond.Type.LIKE);
- fullnameLeafCond2.setSchema("fullname");
- fullnameLeafCond2.setExpression("%i%");
- NodeCond about = NodeCond.getAndCond(NodeCond.getLeafCond(fullnameLeafCond1),
- NodeCond.getLeafCond(fullnameLeafCond2));
-
- notificationTO.setAbout(about);
-
- notificationTO.setRecipientAttrName("email");
- notificationTO.setRecipientAttrType(IntMappingType.UserSchema);
-
- notificationTO.setSender("syncope@syncope.apache.org");
- notificationTO.setSubject("Test notification");
- notificationTO.setTemplate("test");
- return notificationTO;
- }
}
Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/PolicyTestITCase.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/PolicyTestITCase.java?rev=1536304&r1=1536303&r2=1536304&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/PolicyTestITCase.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/PolicyTestITCase.java Mon Oct 28 10:24:47 2013
@@ -30,8 +30,8 @@ import org.apache.syncope.common.to.Sync
import org.apache.syncope.common.types.PasswordPolicySpec;
import org.apache.syncope.common.types.PolicyType;
import org.apache.syncope.common.types.SyncPolicySpec;
-import org.apache.syncope.common.types.SyncopeClientExceptionType;
-import org.apache.syncope.common.validation.SyncopeClientCompositeException;
+import org.apache.syncope.common.types.ClientExceptionType;
+import org.apache.syncope.common.validation.SyncopeClientException;
import org.apache.syncope.core.sync.TestSyncRule;
import org.junit.FixMethodOrder;
import org.junit.Test;
@@ -81,8 +81,8 @@ public class PolicyTestITCase extends Ab
try {
createPolicy(policy);
fail();
- } catch (SyncopeClientCompositeException sccee) {
- assertNotNull(sccee.getException(SyncopeClientExceptionType.InvalidPasswordPolicy));
+ } catch (SyncopeClientException e) {
+ assertEquals(ClientExceptionType.InvalidPasswordPolicy, e.getType());
}
}
@@ -94,8 +94,8 @@ public class PolicyTestITCase extends Ab
try {
createPolicy(policy);
fail();
- } catch (SyncopeClientCompositeException sccee) {
- assertNotNull(sccee.getException(SyncopeClientExceptionType.InvalidSyncPolicy));
+ } catch (SyncopeClientException e) {
+ assertEquals(ClientExceptionType.InvalidSyncPolicy, e.getType());
}
}
@@ -150,14 +150,12 @@ public class PolicyTestITCase extends Ab
policyService.delete(policyTO.getId());
- Throwable t = null;
try {
policyService.read(policyTO.getId());
- } catch (SyncopeClientCompositeException e) {
- t = e;
+ fail();
+ } catch (SyncopeClientException e) {
+ assertNotNull(e);
}
-
- assertNotNull(t);
}
@Test
Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ReportTestITCase.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ReportTestITCase.java?rev=1536304&r1=1536303&r2=1536304&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ReportTestITCase.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ReportTestITCase.java Mon Oct 28 10:24:47 2013
@@ -38,7 +38,7 @@ import org.apache.syncope.common.to.Repo
import org.apache.syncope.common.to.ReportTO;
import org.apache.syncope.common.types.ReportExecExportFormat;
import org.apache.syncope.common.types.ReportExecStatus;
-import org.apache.syncope.common.validation.SyncopeClientCompositeException;
+import org.apache.syncope.common.validation.SyncopeClientException;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;
@@ -141,8 +141,8 @@ public class ReportTestITCase extends Ab
try {
reportService.read(report.getId());
fail();
- } catch (SyncopeClientCompositeException e) {
- assertEquals(HttpStatus.SC_NOT_FOUND, e.getStatusCode());
+ } catch (SyncopeClientException e) {
+ assertEquals(HttpStatus.SC_NOT_FOUND, e.getType().getResponseStatus().getStatusCode());
}
}
Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ResourceTestITCase.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ResourceTestITCase.java?rev=1536304&r1=1536303&r2=1536304&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ResourceTestITCase.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ResourceTestITCase.java Mon Oct 28 10:24:47 2013
@@ -46,8 +46,7 @@ import org.apache.syncope.common.types.C
import org.apache.syncope.common.types.EntityViolationType;
import org.apache.syncope.common.types.IntMappingType;
import org.apache.syncope.common.types.MappingPurpose;
-import org.apache.syncope.common.types.SyncopeClientExceptionType;
-import org.apache.syncope.common.validation.SyncopeClientCompositeException;
+import org.apache.syncope.common.types.ClientExceptionType;
import org.apache.syncope.common.validation.SyncopeClientException;
import org.junit.FixMethodOrder;
import org.junit.Test;
@@ -230,17 +229,13 @@ public class ResourceTestITCase extends
try {
createResource(resourceTO);
fail("Create should not have worked");
- } catch (SyncopeClientCompositeException e) {
- SyncopeClientException requiredValueMissing = e
- .getException(SyncopeClientExceptionType.RequiredValuesMissing);
- assertNotNull(requiredValueMissing);
- assertNotNull(requiredValueMissing.getElements());
- assertEquals(1, requiredValueMissing.getElements().size());
- assertEquals("intAttrName", requiredValueMissing.getElements().iterator().next());
+ } catch (SyncopeClientException e) {
+ assertEquals(ClientExceptionType.RequiredValuesMissing, e.getType());
+ assertEquals("intAttrName", e.getElements().iterator().next());
}
}
- @Test(expected = SyncopeClientCompositeException.class)
+ @Test(expected = SyncopeClientException.class)
public void createWithoutExtAttr() {
String resourceName = "ws-target-resource-create-wrong";
ResourceTO resourceTO = new ResourceTO();
@@ -303,8 +298,8 @@ public class ResourceTestITCase extends
resourceTO.setName("resourcenotfound");
resourceService.update(resourceTO.getName(), resourceTO);
- } catch (SyncopeClientCompositeException e) {
- assertEquals(HttpStatus.SC_NOT_FOUND, e.getStatusCode());
+ } catch (SyncopeClientException e) {
+ assertEquals(HttpStatus.SC_NOT_FOUND, e.getType().getResponseStatus().getStatusCode());
}
}
@@ -359,8 +354,8 @@ public class ResourceTestITCase extends
public void deleteWithException() {
try {
resourceService.delete("resourcenotfound");
- } catch (SyncopeClientCompositeException e) {
- assertEquals(HttpStatus.SC_NOT_FOUND, e.getStatusCode());
+ } catch (SyncopeClientException e) {
+ assertEquals(HttpStatus.SC_NOT_FOUND, e.getType().getResponseStatus().getStatusCode());
}
}
@@ -392,8 +387,8 @@ public class ResourceTestITCase extends
try {
resourceService.read(resourceName);
- } catch (SyncopeClientCompositeException e) {
- assertEquals(HttpStatus.SC_NOT_FOUND, e.getStatusCode());
+ } catch (SyncopeClientException e) {
+ assertEquals(HttpStatus.SC_NOT_FOUND, e.getType().getResponseStatus().getStatusCode());
}
}
@@ -432,18 +427,18 @@ public class ResourceTestITCase extends
try {
createResource(actual);
fail();
- } catch (SyncopeClientCompositeException scce) {
- assertEquals(HttpStatus.SC_CONFLICT, scce.getStatusCode());
- assertTrue(scce.hasException(SyncopeClientExceptionType.EntityExists));
+ } catch (SyncopeClientException e) {
+ assertEquals(HttpStatus.SC_CONFLICT, e.getType().getResponseStatus().getStatusCode());
+ assertEquals(ClientExceptionType.EntityExists, e.getType());
}
actual.setName(null);
try {
createResource(actual);
fail();
- } catch (SyncopeClientCompositeException scce) {
- assertEquals(HttpStatus.SC_BAD_REQUEST, scce.getStatusCode());
- assertTrue(scce.hasException(SyncopeClientExceptionType.RequiredValuesMissing));
+ } catch (SyncopeClientException e) {
+ assertEquals(HttpStatus.SC_BAD_REQUEST, e.getType().getResponseStatus().getStatusCode());
+ assertEquals(ClientExceptionType.RequiredValuesMissing, e.getType());
}
}
@@ -466,13 +461,13 @@ public class ResourceTestITCase extends
try {
resourceService.read("forBulk1");
fail();
- } catch (SyncopeClientCompositeException e) {
+ } catch (SyncopeClientException e) {
}
try {
resourceService.read("forBulk2");
fail();
- } catch (SyncopeClientCompositeException e) {
+ } catch (SyncopeClientException e) {
}
}
@@ -528,12 +523,10 @@ public class ResourceTestITCase extends
resourceService.create(
buildResourceTO("http://schemas.examples.org/security/authorization/organizationUnit"));
fail();
- } catch (SyncopeClientCompositeException scce) {
- SyncopeClientException sce = scce.getException(SyncopeClientExceptionType.InvalidExternalResource);
+ } catch (SyncopeClientException e) {
+ assertEquals(ClientExceptionType.InvalidExternalResource, e.getType());
- assertNotNull(sce.getElements());
- assertEquals(1, sce.getElements().size());
- assertTrue(sce.getElements().iterator().next().contains(EntityViolationType.InvalidName.name()));
+ assertTrue(e.getElements().iterator().next().toString().contains(EntityViolationType.InvalidName.name()));
}
}
Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/RoleTestITCase.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/RoleTestITCase.java?rev=1536304&r1=1536303&r2=1536304&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/RoleTestITCase.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/RoleTestITCase.java Mon Oct 28 10:24:47 2013
@@ -38,8 +38,7 @@ import org.apache.syncope.common.to.Sche
import org.apache.syncope.common.to.UserTO;
import org.apache.syncope.common.types.AttributableType;
import org.apache.syncope.common.types.SchemaType;
-import org.apache.syncope.common.types.SyncopeClientExceptionType;
-import org.apache.syncope.common.validation.SyncopeClientCompositeException;
+import org.apache.syncope.common.types.ClientExceptionType;
import org.apache.syncope.common.validation.SyncopeClientException;
import org.junit.FixMethodOrder;
import org.junit.Test;
@@ -86,8 +85,8 @@ public class RoleTestITCase extends Abst
try {
createRole(roleService, newRoleTO);
fail();
- } catch (SyncopeClientCompositeException sccee) {
- assertNotNull(sccee.getException(SyncopeClientExceptionType.InvalidSyncopeRole));
+ } catch (SyncopeClientException e) {
+ assertEquals(ClientExceptionType.InvalidSyncopeRole, e.getType());
}
}
@@ -139,8 +138,8 @@ public class RoleTestITCase extends Abst
public void delete() {
try {
roleService.delete(0L);
- } catch (SyncopeClientCompositeException e) {
- assertEquals(HttpStatus.SC_NOT_FOUND, e.getStatusCode());
+ } catch (SyncopeClientException e) {
+ assertEquals(HttpStatus.SC_NOT_FOUND, e.getType().getResponseStatus().getStatusCode());
}
RoleTO roleTO = new RoleTO();
@@ -157,8 +156,8 @@ public class RoleTestITCase extends Abst
try {
roleService.read(deletedRole.getId());
- } catch (SyncopeClientCompositeException e) {
- assertEquals(HttpStatus.SC_NOT_FOUND, e.getStatusCode());
+ } catch (SyncopeClientException e) {
+ assertEquals(HttpStatus.SC_NOT_FOUND, e.getType().getResponseStatus().getStatusCode());
}
}
@@ -197,17 +196,14 @@ public class RoleTestITCase extends Abst
assertTrue(userTO.getMembershipMap().containsKey(1L));
assertFalse(userTO.getMembershipMap().containsKey(3L));
- RoleService roleService2 =
- clientFactory.create("rossini", ADMIN_PWD).getService(RoleService.class);
+ RoleService roleService2 = clientFactory.create("rossini", ADMIN_PWD).getService(RoleService.class);
- SyncopeClientException exception = null;
try {
roleService2.selfRead(3L);
fail();
- } catch (SyncopeClientCompositeException e) {
- exception = e.getException(SyncopeClientExceptionType.UnauthorizedRole);
+ } catch (SyncopeClientException e) {
+ assertEquals(ClientExceptionType.UnauthorizedRole, e.getType());
}
- assertNotNull(exception);
RoleTO roleTO = roleService2.selfRead(1L);
assertNotNull(roleTO);
@@ -310,21 +306,19 @@ public class RoleTestITCase extends Abst
roleMod.setName("Managing Director");
// 3. try to update as verdi, not owner of role 7 - fail
- RoleService roleService2 =
- clientFactory.create("verdi", ADMIN_PWD).getService(RoleService.class);
+ RoleService roleService2 = clientFactory.create("verdi", ADMIN_PWD).getService(RoleService.class);
try {
roleService2.update(roleMod.getId(), roleMod);
fail();
- } catch (SyncopeClientCompositeException e) {
- assertEquals(HttpStatus.SC_FORBIDDEN, e.getStatusCode());
+ } catch (SyncopeClientException e) {
+ assertEquals(HttpStatus.SC_UNAUTHORIZED, e.getType().getResponseStatus().getStatusCode());
} catch (AccessControlException e) {
assertNotNull(e);
}
// 4. update as puccini, owner of role 7 because owner of role 6 with inheritance - success
- RoleService roleService3 =
- clientFactory.create("puccini", ADMIN_PWD).getService(RoleService.class);
+ RoleService roleService3 = clientFactory.create("puccini", ADMIN_PWD).getService(RoleService.class);
roleTO = roleService3.update(roleMod.getId(), roleMod);
assertEquals("Managing Director", roleTO.getName());
@@ -496,8 +490,8 @@ public class RoleTestITCase extends Abst
try {
roleService.update(roleMod.getId(), roleMod);
fail();
- } catch (SyncopeClientCompositeException e) {
- assertNotNull(e.getException(SyncopeClientExceptionType.RequiredValuesMissing));
+ } catch (SyncopeClientException e) {
+ assertEquals(ClientExceptionType.RequiredValuesMissing, e.getType());
}
// 4. also add an actual attribute for badge - it will work
Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/SchemaTestITCase.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/SchemaTestITCase.java?rev=1536304&r1=1536303&r2=1536304&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/SchemaTestITCase.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/SchemaTestITCase.java Mon Oct 28 10:24:47 2013
@@ -38,9 +38,8 @@ import org.apache.syncope.common.types.A
import org.apache.syncope.common.types.EntityViolationType;
import org.apache.syncope.common.types.AttributeSchemaType;
import org.apache.syncope.common.types.SchemaType;
-import org.apache.syncope.common.types.SyncopeClientExceptionType;
+import org.apache.syncope.common.types.ClientExceptionType;
import org.apache.syncope.common.util.AttributableOperations;
-import org.apache.syncope.common.validation.SyncopeClientCompositeException;
import org.apache.syncope.common.validation.SyncopeClientException;
import org.junit.FixMethodOrder;
import org.junit.Test;
@@ -77,12 +76,11 @@ public class SchemaTestITCase extends Ab
try {
createSchema(AttributableType.USER, SchemaType.NORMAL, schemaTO);
fail("This should not be reacheable");
- } catch (SyncopeClientCompositeException scce) {
- SyncopeClientException sce = scce.getException(SyncopeClientExceptionType.InvalidUSchema);
+ } catch (SyncopeClientException e) {
+ assertEquals(ClientExceptionType.InvalidUSchema, e.getType());
- assertNotNull(sce.getElements());
- assertEquals(1, sce.getElements().size());
- assertTrue(sce.getElements().iterator().next().contains(EntityViolationType.InvalidName.name()));
+ assertTrue(e.getElements().iterator().next().toString().
+ contains(EntityViolationType.InvalidName.name()));
}
}
@@ -95,13 +93,11 @@ public class SchemaTestITCase extends Ab
try {
createSchema(AttributableType.ROLE, SchemaType.NORMAL, schemaTO);
fail("This should not be reacheable");
- } catch (SyncopeClientCompositeException scce) {
- SyncopeClientException sce = scce.getException(SyncopeClientExceptionType.InvalidRSchema);
+ } catch (SyncopeClientException e) {
+ assertEquals(ClientExceptionType.InvalidRSchema, e.getType());
- assertNotNull(sce.getElements());
- assertEquals(1, sce.getElements().size());
- assertTrue(sce.getElements().iterator().next()
- .contains(EntityViolationType.InvalidSchemaEnum.name()));
+ assertTrue(e.getElements().iterator().next().toString().
+ contains(EntityViolationType.InvalidSchemaEnum.name()));
}
}
@@ -114,13 +110,11 @@ public class SchemaTestITCase extends Ab
try {
createSchema(AttributableType.USER, SchemaType.NORMAL, schemaTO);
fail("This should not be reacheable");
- } catch (SyncopeClientCompositeException scce) {
- SyncopeClientException sce = scce.getException(SyncopeClientExceptionType.InvalidUSchema);
+ } catch (SyncopeClientException e) {
+ assertEquals(ClientExceptionType.InvalidUSchema, e.getType());
- assertNotNull(sce.getElements());
- assertEquals(1, sce.getElements().size());
- assertTrue(sce.getElements().iterator().next()
- .contains(EntityViolationType.InvalidSchemaEnum.name()));
+ assertTrue(e.getElements().iterator().next().toString().
+ contains(EntityViolationType.InvalidSchemaEnum.name()));
}
}
@@ -134,8 +128,8 @@ public class SchemaTestITCase extends Ab
SchemaTO firstname = null;
try {
firstname = schemaService.read(AttributableType.USER, SchemaType.NORMAL, schemaTO.getName());
- } catch (SyncopeClientCompositeException e) {
- assertEquals(HttpStatus.SC_NOT_FOUND, e.getStatusCode());
+ } catch (SyncopeClientException e) {
+ assertEquals(HttpStatus.SC_NOT_FOUND, e.getType().getResponseStatus().getStatusCode());
}
assertNull(firstname);
}
@@ -174,9 +168,8 @@ public class SchemaTestITCase extends Ab
try {
schemaService.update(AttributableType.ROLE, SchemaType.NORMAL, schemaTO.getName(), updatedTO);
fail("This should not be reacheable");
- } catch (SyncopeClientCompositeException scce) {
- SyncopeClientException sce = scce.getException(SyncopeClientExceptionType.InvalidRSchema);
- assertNotNull(sce);
+ } catch (SyncopeClientException e) {
+ assertEquals(ClientExceptionType.InvalidRSchema, e.getType());
}
}
@@ -199,9 +192,8 @@ public class SchemaTestITCase extends Ab
try {
schemaService.update(AttributableType.USER, SchemaType.NORMAL, schemaTO.getName(), schemaTO);
fail("This should not be reacheable");
- } catch (SyncopeClientCompositeException scce) {
- SyncopeClientException sce = scce.getException(SyncopeClientExceptionType.InvalidUSchema);
- assertNotNull(sce);
+ } catch (SyncopeClientException e) {
+ assertEquals(ClientExceptionType.InvalidUSchema, e.getType());
}
}
@@ -246,9 +238,8 @@ public class SchemaTestITCase extends Ab
try {
schemaService.update(AttributableType.USER, SchemaType.NORMAL, schemaTO.getName(), schemaTO);
fail("This should not be reacheable");
- } catch (SyncopeClientCompositeException scce) {
- SyncopeClientException sce = scce.getException(SyncopeClientExceptionType.InvalidUSchema);
- assertNotNull(sce);
+ } catch (SyncopeClientException e) {
+ assertEquals(ClientExceptionType.InvalidUSchema, e.getType());
}
}
@@ -260,18 +251,18 @@ public class SchemaTestITCase extends Ab
try {
createSchema(AttributableType.ROLE, SchemaType.NORMAL, actual);
fail();
- } catch (SyncopeClientCompositeException scce) {
- assertEquals(HttpStatus.SC_CONFLICT, scce.getStatusCode());
- assertTrue(scce.hasException(SyncopeClientExceptionType.EntityExists));
+ } catch (SyncopeClientException e) {
+ assertEquals(HttpStatus.SC_CONFLICT, e.getType().getResponseStatus().getStatusCode());
+ assertEquals(ClientExceptionType.EntityExists, e.getType());
}
actual.setName(null);
try {
createSchema(AttributableType.ROLE, SchemaType.NORMAL, actual);
fail();
- } catch (SyncopeClientCompositeException scce) {
- assertEquals(HttpStatus.SC_BAD_REQUEST, scce.getStatusCode());
- assertTrue(scce.hasException(SyncopeClientExceptionType.RequiredValuesMissing));
+ } catch (SyncopeClientException e) {
+ assertEquals(HttpStatus.SC_BAD_REQUEST, e.getType().getResponseStatus().getStatusCode());
+ assertEquals(ClientExceptionType.RequiredValuesMissing, e.getType());
}
}
@@ -283,12 +274,11 @@ public class SchemaTestITCase extends Ab
try {
createSchema(AttributableType.ROLE, SchemaType.NORMAL, schema);
fail();
- } catch (SyncopeClientCompositeException scce) {
- SyncopeClientException sce = scce.getException(SyncopeClientExceptionType.InvalidRSchema);
+ } catch (SyncopeClientException e) {
+ assertEquals(ClientExceptionType.InvalidRSchema, e.getType());
- assertNotNull(sce.getElements());
- assertEquals(1, sce.getElements().size());
- assertTrue(sce.getElements().iterator().next().contains(EntityViolationType.InvalidName.name()));
+ assertTrue(e.getElements().iterator().next().toString().
+ contains(EntityViolationType.InvalidName.name()));
}
}
Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/TaskTestITCase.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/TaskTestITCase.java?rev=1536304&r1=1536303&r2=1536304&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/TaskTestITCase.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/TaskTestITCase.java Mon Oct 28 10:24:47 2013
@@ -58,7 +58,7 @@ import org.apache.syncope.common.types.I
import org.apache.syncope.common.types.PropagationTaskExecStatus;
import org.apache.syncope.common.types.TaskType;
import org.apache.syncope.common.types.TraceLevel;
-import org.apache.syncope.common.validation.SyncopeClientCompositeException;
+import org.apache.syncope.common.validation.SyncopeClientException;
import org.apache.syncope.core.sync.TestSyncActions;
import org.apache.syncope.core.sync.TestSyncRule;
import org.apache.syncope.core.sync.impl.SyncJob;
@@ -201,8 +201,8 @@ public class TaskTestITCase extends Abst
public void deal() {
try {
taskService.delete(0L);
- } catch (SyncopeClientCompositeException e) {
- assertEquals(HttpStatus.SC_NOT_FOUND, e.getStatusCode());
+ } catch (SyncopeClientException e) {
+ assertEquals(HttpStatus.SC_NOT_FOUND, e.getType().getResponseStatus().getStatusCode());
}
TaskExecTO exec = taskService.execute(1L, false);
assertEquals(PropagationTaskExecStatus.SUBMITTED.name(), exec.getStatus());
@@ -218,8 +218,8 @@ public class TaskTestITCase extends Abst
taskService.delete(1L);
try {
taskService.readExecution(exec.getId());
- } catch (SyncopeClientCompositeException e) {
- assertEquals(HttpStatus.SC_NOT_FOUND, e.getStatusCode());
+ } catch (SyncopeClientException e) {
+ assertEquals(HttpStatus.SC_NOT_FOUND, e.getType().getResponseStatus().getStatusCode());
}
}
Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/UserRequestTestITCase.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/UserRequestTestITCase.java?rev=1536304&r1=1536303&r2=1536304&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/UserRequestTestITCase.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/UserRequestTestITCase.java Mon Oct 28 10:24:47 2013
@@ -41,9 +41,10 @@ import org.apache.syncope.common.service
import org.apache.syncope.common.to.ConfigurationTO;
import org.apache.syncope.common.to.UserRequestTO;
import org.apache.syncope.common.to.UserTO;
-import org.apache.syncope.common.types.SyncopeClientExceptionType;
+import org.apache.syncope.common.types.ClientExceptionType;
import org.apache.syncope.common.types.UserRequestType;
-import org.apache.syncope.common.validation.SyncopeClientCompositeException;
+import org.apache.syncope.common.validation.SyncopeClientException;
+import org.apache.syncope.common.validation.SyncopeClientException;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;
@@ -81,8 +82,8 @@ public class UserRequestTestITCase exten
try {
createUserRequest(anonymousUserRequestService, new UserRequestTO(userTO));
fail();
- } catch (SyncopeClientCompositeException e) {
- assertNotNull(e.getException(SyncopeClientExceptionType.UnauthorizedRole));
+ } catch (SyncopeClientException e) {
+ assertEquals(ClientExceptionType.UnauthorizedRole, e.getType());
}
// 3. set create request allowed
@@ -128,8 +129,8 @@ public class UserRequestTestITCase exten
try {
createUserRequest(userRequestService, new UserRequestTO(userMod));
fail();
- } catch (SyncopeClientCompositeException e) {
- assertNotNull(e.getException(SyncopeClientExceptionType.UnauthorizedRole));
+ } catch (SyncopeClientException e) {
+ assertEquals(ClientExceptionType.UnauthorizedRole, e.getType());
}
// 3. auth as user just created
@@ -140,8 +141,8 @@ public class UserRequestTestITCase exten
try {
createUserRequest(userRequestService2, new UserRequestTO(userMod));
fail();
- } catch (SyncopeClientCompositeException scce) {
- assertNotNull(scce.getException(SyncopeClientExceptionType.InvalidSyncopeUser));
+ } catch (SyncopeClientException e) {
+ assertEquals(ClientExceptionType.InvalidSyncopeUser, e.getType());
}
// 5. now request user update works
@@ -186,8 +187,8 @@ public class UserRequestTestITCase exten
try {
createUserRequest(userRequestService, new UserRequestTO(userTO.getId()));
fail();
- } catch (SyncopeClientCompositeException e) {
- assertNotNull(e.getException(SyncopeClientExceptionType.UnauthorizedRole));
+ } catch (SyncopeClientException e) {
+ assertEquals(ClientExceptionType.UnauthorizedRole, e.getType());
}
// 3. auth as user just created
@@ -208,8 +209,8 @@ public class UserRequestTestITCase exten
try {
userService.read(userTO.getId());
fail();
- } catch (SyncopeClientCompositeException e) {
- assertEquals(HttpStatus.SC_NOT_FOUND, e.getStatusCode());
+ } catch (SyncopeClientException e) {
+ assertEquals(HttpStatus.SC_NOT_FOUND, e.getType().getResponseStatus().getStatusCode());
}
}
@@ -333,7 +334,7 @@ public class UserRequestTestITCase exten
assertEquals(3, userRequestService.listByUsername(userTO.getUsername()).size());
}
- @Test(expected = SyncopeClientCompositeException.class)
+ @Test(expected = SyncopeClientException.class)
public void executeNoClaim() {
UserTO userTO = UserTestITCase.getUniqueSampleTO("reqnoclaim@syncope.apache.org");