You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by cs...@apache.org on 2013/01/30 16:29:52 UTC
svn commit: r1440464 - in
/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest:
AbstractTest.java AuthenticationTestITCase.java
DerivedSchemaTestITCase.java SchemaTestITCase.java
VirtualSchemaTestITCase.java
Author: cschneider
Date: Wed Jan 30 15:29:51 2013
New Revision: 1440464
URL: http://svn.apache.org/viewvc?rev=1440464&view=rev
Log:
SYNCOPE-231 Handling client side exceptions in SchemaService create
Modified:
syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java
syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AuthenticationTestITCase.java
syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/DerivedSchemaTestITCase.java
syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/SchemaTestITCase.java
syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/VirtualSchemaTestITCase.java
Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java?rev=1440464&r1=1440463&r2=1440464&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java Wed Jan 30 15:29:51 2013
@@ -25,6 +25,7 @@ import java.util.List;
import java.util.UUID;
import javax.sql.DataSource;
+import javax.ws.rs.PathParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
@@ -67,8 +68,11 @@ import org.apache.syncope.common.service
import org.apache.syncope.common.services.UserRequestService;
import org.apache.syncope.common.services.UserService;
import org.apache.syncope.common.services.WorkflowService;
+import org.apache.syncope.common.services.SchemaService.SchemaType;
+import org.apache.syncope.common.to.AbstractSchemaTO;
import org.apache.syncope.common.to.AttributeTO;
import org.apache.syncope.common.to.UserTO;
+import org.apache.syncope.common.types.AttributableType;
import org.apache.syncope.common.validation.SyncopeClientErrorHandler;
import org.junit.Before;
import org.junit.runner.RunWith;
@@ -341,4 +345,16 @@ public abstract class AbstractTest {
+ builder.toString());
}
}
+
+ <T extends AbstractSchemaTO> Response createSchema(@PathParam("kind") AttributableType kind,
+ @PathParam("type") SchemaType type, T schemaTO) {
+ Response response = schemaService.create(kind, type, schemaTO);
+ if (response.getStatus() != HttpStatus.SC_CREATED) {
+ Exception ex = clientExceptionMapper.fromResponse(response);
+ if (ex != null) {
+ throw (RuntimeException) ex;
+ }
+ }
+ return response;
+ }
}
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=1440464&r1=1440463&r2=1440464&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 Wed Jan 30 15:29:51 2013
@@ -88,7 +88,7 @@ public class AuthenticationTestITCase ex
schemaTO.setMandatoryCondition("false");
schemaTO.setType(SchemaType.String);
- response = schemaService.create(AttributableType.USER, SchemaService.SchemaType.NORMAL, schemaTO);
+ response = createSchema(AttributableType.USER, SchemaService.SchemaType.NORMAL, schemaTO);
SchemaTO newSchemaTO = getObject(response, SchemaTO.class, entitlementService);
assertEquals(schemaTO, newSchemaTO);
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=1440464&r1=1440463&r2=1440464&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 Wed Jan 30 15:29:51 2013
@@ -63,7 +63,7 @@ public class DerivedSchemaTestITCase ext
schema.setName("derived");
schema.setExpression("derived_sx + '_' + derived_dx");
- Response response = schemaService.create(AttributableType.USER, SchemaService.SchemaType.DERIVED, schema);
+ Response response = createSchema(AttributableType.USER, SchemaService.SchemaType.DERIVED, schema);
DerivedSchemaTO actual = getObject(response, DerivedSchemaTO.class, schemaService);
assertNotNull(actual);
@@ -89,7 +89,7 @@ public class DerivedSchemaTestITCase ext
assertNotNull(e.getException(SyncopeClientExceptionType.NotFound));
} finally {
// Recreate schema to make test re-runnable
- Response response = schemaService.create(AttributableType.ROLE, SchemaService.SchemaType.DERIVED, schema);
+ Response response = createSchema(AttributableType.ROLE, SchemaService.SchemaType.DERIVED, schema);
assertNotNull(response);
assertEquals(HttpStatus.SC_CREATED, response.getStatus());
}
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=1440464&r1=1440463&r2=1440464&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 Wed Jan 30 15:29:51 2013
@@ -55,11 +55,11 @@ public class SchemaTestITCase extends Ab
SchemaTO schemaTO = buildSchemaTO("testAttribute", SchemaType.String);
schemaTO.setMandatoryCondition("false");
- Response response = schemaService.create(AttributableType.USER, SchemaService.SchemaType.NORMAL, schemaTO);
+ Response response = createSchema(AttributableType.USER, SchemaService.SchemaType.NORMAL, schemaTO);
SchemaTO newSchemaTO = getObject(response, SchemaTO.class, schemaService);
assertEquals(schemaTO, newSchemaTO);
- response = schemaService.create(AttributableType.MEMBERSHIP, SchemaService.SchemaType.NORMAL, schemaTO);
+ response = createSchema(AttributableType.MEMBERSHIP, SchemaService.SchemaType.NORMAL, schemaTO);
newSchemaTO = getObject(response, SchemaTO.class, schemaService);
assertEquals(schemaTO, newSchemaTO);
}
@@ -71,7 +71,7 @@ public class SchemaTestITCase extends Ab
schemaTO.setType(SchemaType.String);
try {
- schemaService.create(AttributableType.USER, SchemaService.SchemaType.NORMAL, schemaTO);
+ createSchema(AttributableType.USER, SchemaService.SchemaType.NORMAL, schemaTO);
fail("This should not be reacheable");
} catch (SyncopeClientCompositeErrorException scce) {
SyncopeClientException sce = scce.getException(SyncopeClientExceptionType.InvalidUSchema);
@@ -89,7 +89,7 @@ public class SchemaTestITCase extends Ab
schemaTO.setType(SchemaType.Enum);
try {
- schemaService.create(AttributableType.ROLE, SchemaService.SchemaType.NORMAL, schemaTO);
+ createSchema(AttributableType.ROLE, SchemaService.SchemaType.NORMAL, schemaTO);
fail("This should not be reacheable");
} catch (SyncopeClientCompositeErrorException scce) {
SyncopeClientException sce = scce.getException(SyncopeClientExceptionType.InvalidRSchema);
@@ -108,7 +108,7 @@ public class SchemaTestITCase extends Ab
schemaTO.setType(SchemaType.Enum);
try {
- schemaService.create(AttributableType.USER, SchemaService.SchemaType.NORMAL, schemaTO);
+ createSchema(AttributableType.USER, SchemaService.SchemaType.NORMAL, schemaTO);
fail("This should not be reacheable");
} catch (SyncopeClientCompositeErrorException scce) {
SyncopeClientException sce = scce.getException(SyncopeClientExceptionType.InvalidUSchema);
@@ -124,7 +124,7 @@ public class SchemaTestITCase extends Ab
public void delete() {
SchemaTO schemaTO = buildSchemaTO("todelete", SchemaType.String);
schemaTO.setMandatoryCondition("false");
- schemaService.create(AttributableType.USER, SchemaService.SchemaType.NORMAL, schemaTO);
+ createSchema(AttributableType.USER, SchemaService.SchemaType.NORMAL, schemaTO);
schemaService.delete(AttributableType.USER, SchemaService.SchemaType.NORMAL, schemaTO.getName());
SchemaTO firstname = null;
@@ -185,7 +185,7 @@ public class SchemaTestITCase extends Ab
schemaTO.setName("schema_issue258");
schemaTO.setType(SchemaType.Double);
- Response response = schemaService.create(AttributableType.USER, SchemaService.SchemaType.NORMAL, schemaTO);
+ Response response = createSchema(AttributableType.USER, SchemaService.SchemaType.NORMAL, schemaTO);
schemaTO = getObject(response, SchemaTO.class, schemaService);
assertNotNull(schemaTO);
@@ -210,7 +210,7 @@ public class SchemaTestITCase extends Ab
SchemaTO schemaTO = buildSchemaTO("schema_issue259", SchemaType.Double);
schemaTO.setUniqueConstraint(true);
- Response response = schemaService.create(AttributableType.USER, SchemaService.SchemaType.NORMAL, schemaTO);
+ Response response = createSchema(AttributableType.USER, SchemaService.SchemaType.NORMAL, schemaTO);
schemaTO = getObject(response, SchemaTO.class, schemaService);
assertNotNull(schemaTO);
@@ -235,7 +235,7 @@ public class SchemaTestITCase extends Ab
SchemaTO schemaTO = buildSchemaTO("schema_issue260", SchemaType.Double);
schemaTO.setUniqueConstraint(true);
- Response response = schemaService.create(AttributableType.USER, SchemaService.SchemaType.NORMAL, schemaTO);
+ Response response = createSchema(AttributableType.USER, SchemaService.SchemaType.NORMAL, schemaTO);
schemaTO = getObject(response, SchemaTO.class, schemaService);
assertNotNull(schemaTO);
Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/VirtualSchemaTestITCase.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/VirtualSchemaTestITCase.java?rev=1440464&r1=1440463&r2=1440464&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/VirtualSchemaTestITCase.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/VirtualSchemaTestITCase.java Wed Jan 30 15:29:51 2013
@@ -59,7 +59,7 @@ public class VirtualSchemaTestITCase ext
VirtualSchemaTO schema = new VirtualSchemaTO();
schema.setName("virtual");
- Response response = schemaService.create(AttributableType.USER, SchemaService.SchemaType.VIRTUAL, schema);
+ Response response = createSchema(AttributableType.USER, SchemaService.SchemaType.VIRTUAL, schema);
VirtualSchemaTO actual = getObject(response, VirtualSchemaTO.class, schemaService);
assertNotNull(actual);