Author: jbernhardt
Date: Fri Jan 4 14:53:42 2013
New Revision: 1428905
URL: http://svn.apache.org/viewvc?rev=1428905&view=rev
Log:
[SYNCOPE-259]
Introduces ResourceService and loggerService.
Minor updates to other REST Services.
Added:
syncope/trunk/client/src/main/java/org/apache/syncope/services/ReportService.java
syncope/trunk/client/src/main/java/org/apache/syncope/services/ReportServiceProxy.java
syncope/trunk/client/src/main/java/org/apache/syncope/services/ResourceService.java
syncope/trunk/client/src/main/java/org/apache/syncope/services/ResourceServiceProxy.java
Modified:
syncope/trunk/client/src/main/java/org/apache/syncope/services/ConfigurationService.java
syncope/trunk/client/src/main/java/org/apache/syncope/services/ConfigurationServiceProxy.java
syncope/trunk/client/src/main/java/org/apache/syncope/services/RoleService.java
syncope/trunk/client/src/main/java/org/apache/syncope/services/UserService.java
syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java
syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ConfigurationTestITCase.java
syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ConnInstanceTestITCase.java
syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ReportTestITCase.java
syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ResourceTestITCase.java
syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/RoleTestITCase.java
syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java
Modified:
syncope/trunk/client/src/main/java/org/apache/syncope/services/ConfigurationService.java
URL:
http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/services/ConfigurationService.java?rev=1428905&r1=1428904&r2=1428905&view=diff
==============================================================================
---
syncope/trunk/client/src/main/java/org/apache/syncope/services/ConfigurationService.java
(original)
+++
syncope/trunk/client/src/main/java/org/apache/syncope/services/ConfigurationService.java
Fri Jan 4 14:53:42 2013
@@ -33,7 +33,7 @@ import javax.ws.rs.core.Response;
import org.apache.syncope.client.to.ConfigurationTO;
-@Path("configuration")
+@Path("configurations")
public interface ConfigurationService {
@POST
@@ -52,7 +52,7 @@ public interface ConfigurationService {
@PUT
@Path("{key}")
- ConfigurationTO update(final ConfigurationTO configurationTO);
+ ConfigurationTO update(@PathParam("key") final String key, final
ConfigurationTO configurationTO);
@GET
@Path("validators")
Modified:
syncope/trunk/client/src/main/java/org/apache/syncope/services/ConfigurationServiceProxy.java
URL:
http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/services/ConfigurationServiceProxy.java?rev=1428905&r1=1428904&r2=1428905&view=diff
==============================================================================
---
syncope/trunk/client/src/main/java/org/apache/syncope/services/ConfigurationServiceProxy.java
(original)
+++
syncope/trunk/client/src/main/java/org/apache/syncope/services/ConfigurationServiceProxy.java
Fri Jan 4 14:53:42 2013
@@ -60,7 +60,7 @@ public class ConfigurationServiceProxy e
}
@Override
- public ConfigurationTO update(ConfigurationTO configurationTO) {
+ public ConfigurationTO update(String key, ConfigurationTO
configurationTO) {
return restTemplate.postForObject(BASE_URL +
"configuration/update",
configurationTO, ConfigurationTO.class);
}
Added:
syncope/trunk/client/src/main/java/org/apache/syncope/services/ReportService.java
URL:
http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/services/ReportService.java?rev=1428905&view=auto
==============================================================================
---
syncope/trunk/client/src/main/java/org/apache/syncope/services/ReportService.java
(added)
+++
syncope/trunk/client/src/main/java/org/apache/syncope/services/ReportService.java
Fri Jan 4 14:53:42 2013
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.services;
+
+import java.util.List;
+import java.util.Set;
+
+import javax.ws.rs.DELETE;
+import javax.ws.rs.DefaultValue;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+
+import org.apache.syncope.client.to.ReportExecTO;
+import org.apache.syncope.client.to.ReportTO;
+import org.apache.syncope.types.ReportExecExportFormat;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+@Path("reports")
+public interface ReportService {
+
+ @POST
+ ReportTO create(final ReportTO reportTO);
+
+ @PUT
+ @Path("{reportId}")
+ ReportTO update(@PathParam("reportId") final Long reportId, final ReportTO
reportTO);
+
+ @GET
+ @Path("count")
+ int count();
+
+ @GET
+ List<ReportTO> list();
+
+ @GET
+ List<ReportTO> list(@QueryParam("page") final int page,
+ @QueryParam("size") @DefaultValue("25") final int size);
+
+ @GET
+ @Path("executions")
+ List<ReportExecTO> listExecutions();
+
+ @GET
+ @Path("reportletConfClasses")
+ List<String> getReportletConfClasses();
+
+ @GET
+ @Path("{reportId}")
+ ReportTO read(@PathParam("reportId") final Long reportId);
+
+ @GET
+ @Path("executions/{executionId}")
+ ReportExecTO readExecution(@PathParam("executionId") final Long
executionId);
+
+ @GET
+ @Path("executions/{executionId}")
+ @Produces(MediaType.APPLICATION_OCTET_STREAM)
+ void exportExecutionResult(@PathParam("executionId") final Long
executionId,
+ @QueryParam("format") final ReportExecExportFormat fmt);
+
+ @POST
+ @Path("{reportId}/execute")
+ ReportExecTO execute(@PathParam("reportId") final Long reportId);
+
+ @DELETE
+ @Path("{reportId}")
+ @RequestMapping(method = RequestMethod.GET, value = "/delete/{reportId}")
+ ReportTO delete(@PathParam("reportId") final Long reportId);
+
+ @DELETE
+ @Path("executions/{executionId}")
+ @RequestMapping(method = RequestMethod.GET, value =
"/execution/delete/{executionId}")
+ ReportExecTO deleteExecution(@PathParam("executionId") final Long
executionId);
+
+}
\ No newline at end of file
Added:
syncope/trunk/client/src/main/java/org/apache/syncope/services/ReportServiceProxy.java
URL:
http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/services/ReportServiceProxy.java?rev=1428905&view=auto
==============================================================================
---
syncope/trunk/client/src/main/java/org/apache/syncope/services/ReportServiceProxy.java
(added)
+++
syncope/trunk/client/src/main/java/org/apache/syncope/services/ReportServiceProxy.java
Fri Jan 4 14:53:42 2013
@@ -0,0 +1,108 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.services;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.syncope.client.to.ReportExecTO;
+import org.apache.syncope.client.to.ReportTO;
+import org.apache.syncope.types.ReportExecExportFormat;
+import org.springframework.web.client.RestTemplate;
+
+public class ReportServiceProxy extends SpringServiceProxy implements
ReportService {
+
+ public ReportServiceProxy(String baseUrl, RestTemplate restTemplate) {
+ super(baseUrl, restTemplate);
+ }
+
+ @Override
+ public ReportTO create(ReportTO reportTO) {
+ return restTemplate.postForObject(BASE_URL + "report/create",
reportTO, ReportTO.class);
+ }
+
+ @Override
+ public ReportTO update(Long reportId, ReportTO reportTO) {
+ return restTemplate.postForObject(BASE_URL + "report/update",
reportTO, ReportTO.class);
+ }
+
+ @Override
+ public int count() {
+ return restTemplate.getForObject(BASE_URL + "report/count.json",
Integer.class);
+ }
+
+ @Override
+ public List<ReportTO> list() {
+ return Arrays.asList(restTemplate.getForObject(BASE_URL +
"report/list", ReportTO[].class));
+ }
+
+ @Override
+ public List<ReportTO> list(int page, int size) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public List<ReportExecTO> listExecutions() {
+ return Arrays.asList(restTemplate.getForObject(BASE_URL +
"report/execution/list",
+ ReportExecTO[].class));
+ }
+
+ @Override
+ public List<String> getReportletConfClasses() {
+ return Arrays.asList(restTemplate.getForObject(BASE_URL +
"report/reportletConfClasses.json",
+ String[].class));
+ }
+
+ @Override
+ public ReportTO read(Long reportId) {
+ return restTemplate.getForObject(BASE_URL + "report/read/{reportId}",
ReportTO.class, reportId);
+ }
+
+ @Override
+ public ReportExecTO readExecution(Long executionId) {
+ return restTemplate.getForObject(BASE_URL +
"report/execution/read/{reportId}",
+ ReportExecTO.class, executionId);
+ }
+
+ @Override
+ public void exportExecutionResult(Long executionId, ReportExecExportFormat
fmt) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public ReportExecTO execute(Long reportId) {
+ return restTemplate.postForObject(BASE_URL +
"report/execute/{reportId}", null,
+ ReportExecTO.class, reportId);
+ }
+
+ @Override
+ public ReportTO delete(Long reportId) {
+ return restTemplate.getForObject(BASE_URL + "report/delete/{reportId}",
+ ReportTO.class, reportId);
+ }
+
+ @Override
+ public ReportExecTO deleteExecution(Long executionId) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
Added:
syncope/trunk/client/src/main/java/org/apache/syncope/services/ResourceService.java
URL:
http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/services/ResourceService.java?rev=1428905&view=auto
==============================================================================
---
syncope/trunk/client/src/main/java/org/apache/syncope/services/ResourceService.java
(added)
+++
syncope/trunk/client/src/main/java/org/apache/syncope/services/ResourceService.java
Fri Jan 4 14:53:42 2013
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.services;
+
+import java.util.List;
+import java.util.Set;
+
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.MatrixParam;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+
+import org.apache.syncope.client.to.ConnObjectTO;
+import org.apache.syncope.client.to.ResourceTO;
+import org.apache.syncope.types.AttributableType;
+
+@Path("resources")
+public interface ResourceService {
+
+ @POST
+ ResourceTO create(final ResourceTO resourceTO);
+
+ @PUT
+ @Path("{resourceName}")
+ ResourceTO update(@PathParam("resourceName") final String resourceName,
final ResourceTO resourceTO);
+
+ @DELETE
+ @Path("{resourceName}")
+ ResourceTO delete(@PathParam("resourceName") final String resourceName);
+
+ @GET
+ @Path("{resourceName}")
+ ResourceTO read(@PathParam("resourceName") final String resourceName);
+
+ // TODO: is it resource method?
+ @GET
+ @Path("propagationActionsClasses")
+ Set<String> getPropagationActionsClasses();
+
+ @GET
+ List<ResourceTO> list(@MatrixParam("connInstanceId") final Long
connInstanceId);
+
+ @GET
+ @Path("{resourceName}/{type}/{objectId}")
+ ConnObjectTO getConnector(@PathParam("resourceName") final String
resourceName,
+ @PathParam("type") final AttributableType type,
@PathParam("objectId") final String objectId);
+
+ @POST
+ @Path("validate")
+ boolean check(final ResourceTO resourceTO);
+}
Added:
syncope/trunk/client/src/main/java/org/apache/syncope/services/ResourceServiceProxy.java
URL:
http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/services/ResourceServiceProxy.java?rev=1428905&view=auto
==============================================================================
---
syncope/trunk/client/src/main/java/org/apache/syncope/services/ResourceServiceProxy.java
(added)
+++
syncope/trunk/client/src/main/java/org/apache/syncope/services/ResourceServiceProxy.java
Fri Jan 4 14:53:42 2013
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.syncope.services;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.syncope.client.to.ConnObjectTO;
+import org.apache.syncope.client.to.ResourceTO;
+import org.apache.syncope.types.AttributableType;
+import org.springframework.web.client.RestTemplate;
+
+public class ResourceServiceProxy extends SpringServiceProxy implements
ResourceService {
+
+ public ResourceServiceProxy(String baseUrl, RestTemplate restTemplate) {
+ super(baseUrl, restTemplate);
+ }
+
+ @Override
+ public ResourceTO create(ResourceTO resourceTO) {
+ return restTemplate.postForObject(BASE_URL + "resource/create.json",
resourceTO, ResourceTO.class);
+ }
+
+ @Override
+ public ResourceTO update(String resourceName, ResourceTO resourceTO) {
+ return restTemplate.postForObject(BASE_URL + "resource/update.json",
resourceTO, ResourceTO.class);
+ }
+
+ @Override
+ public ResourceTO delete(String resourceName) {
+ return restTemplate.getForObject(BASE_URL +
"resource/delete/{resourceName}.json", ResourceTO.class,
+ resourceName);
+ }
+
+ @Override
+ public ResourceTO read(String resourceName) {
+ return restTemplate.getForObject(BASE_URL +
"resource/read/{resourceName}.json", ResourceTO.class,
+ resourceName);
+ }
+
+ @Override
+ public Set<String> getPropagationActionsClasses() {
+ return new
HashSet<String>(Arrays.asList(restTemplate.getForObject(BASE_URL
+ + "resource/propagationActionsClasses.json", String[].class)));
+ }
+
+ @Override
+ public List<ResourceTO> list(Long connInstanceId) {
+ String query = (connInstanceId != null)
+ ? query = "?connInstanceId=" + connInstanceId.toString()
+ : "";
+
+ return Arrays.asList(restTemplate.getForObject(BASE_URL +
"resource/list.json" + query,
+ ResourceTO[].class, connInstanceId));
+ }
+
+ @Override
+ public ConnObjectTO getConnector(String resourceName, AttributableType
type, String objectId) {
+ return restTemplate.getForObject(BASE_URL +
"resource/{resourceName}/read/{type}/{objectId}.json",
+ ConnObjectTO.class, resourceName, type, objectId);
+ }
+
+ @Override
+ public boolean check(ResourceTO resourceTO) {
+ return restTemplate.postForObject(BASE_URL + "resource/check.json",
resourceTO, Boolean.class)
+ .booleanValue();
+ }
+
+}
Modified:
syncope/trunk/client/src/main/java/org/apache/syncope/services/RoleService.java
URL:
http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/services/RoleService.java?rev=1428905&r1=1428904&r2=1428905&view=diff
==============================================================================
---
syncope/trunk/client/src/main/java/org/apache/syncope/services/RoleService.java
(original)
+++
syncope/trunk/client/src/main/java/org/apache/syncope/services/RoleService.java
Fri Jan 4 14:53:42 2013
@@ -32,7 +32,7 @@ import org.apache.syncope.client.mod.Rol
import org.apache.syncope.client.search.NodeCond;
import org.apache.syncope.client.to.RoleTO;
-@Path("role")
+@Path("roles")
public interface RoleService {
@GET
@@ -40,7 +40,6 @@ public interface RoleService {
List<RoleTO> children(@PathParam("roleId") final Long roleId);
@POST
- @Path("")
RoleTO create(final RoleTO roleTO);
@DELETE
Modified:
syncope/trunk/client/src/main/java/org/apache/syncope/services/UserService.java
URL:
http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/services/UserService.java?rev=1428905&r1=1428904&r2=1428905&view=diff
==============================================================================
---
syncope/trunk/client/src/main/java/org/apache/syncope/services/UserService.java
(original)
+++
syncope/trunk/client/src/main/java/org/apache/syncope/services/UserService.java
Fri Jan 4 14:53:42 2013
@@ -35,7 +35,7 @@ import org.apache.syncope.client.search.
import org.apache.syncope.client.to.UserTO;
import org.apache.syncope.client.to.WorkflowFormTO;
-@Path("user")
+@Path("users")
public interface UserService {
/**
@@ -65,7 +65,6 @@ public interface UserService {
int count();
@POST
- @Path("")
UserTO create(final UserTO userTO);
@DELETE
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=1428905&r1=1428904&r2=1428905&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
Fri Jan 4 14:53:42 2013
@@ -29,6 +29,8 @@ import org.apache.syncope.services.Confi
import org.apache.syncope.services.ConnectorServiceProxy;
import org.apache.syncope.services.EntitlementServiceProxy;
import org.apache.syncope.services.LoggerServiceProxy;
+import org.apache.syncope.services.ReportServiceProxy;
+import org.apache.syncope.services.ResourceServiceProxy;
import org.apache.syncope.services.RoleServiceProxy;
import org.apache.syncope.services.UserServiceProxy;
import org.junit.Before;
@@ -80,6 +82,8 @@ public abstract class AbstractTest {
protected RoleServiceProxy roleService;
+ protected ResourceServiceProxy resourceService;
+
protected EntitlementServiceProxy entitlementService;
protected ConfigurationServiceProxy configurationService;
@@ -88,6 +92,8 @@ public abstract class AbstractTest {
protected LoggerServiceProxy loggerService;
+ protected ReportServiceProxy reportService;
+
@Autowired
protected DataSource testDataSource;
@@ -110,9 +116,11 @@ public abstract class AbstractTest {
setupRestTemplate(ADMIN_UID, ADMIN_PWD);
userService = new UserServiceProxy(BASE_URL, restTemplate);
roleService = new RoleServiceProxy(BASE_URL, restTemplate);
+ resourceService = new ResourceServiceProxy(BASE_URL,
restTemplate);
entitlementService = new EntitlementServiceProxy(BASE_URL,
restTemplate);
configurationService = new ConfigurationServiceProxy(BASE_URL,
restTemplate);
connectorService = new ConnectorServiceProxy(BASE_URL,
restTemplate);
loggerService = new LoggerServiceProxy(BASE_URL, restTemplate);
+ reportService = new ReportServiceProxy(BASE_URL, restTemplate);
}
}
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=1428905&r1=1428904&r2=1428905&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
Fri Jan 4 14:53:42 2013
@@ -95,9 +95,9 @@ public class ConfigurationTestITCase ext
value++;
configurationTO.setValue(value + "");
- ConfigurationTO newConfigurationTO =
configurationService.update(configurationTO);
+ ConfigurationTO newConfigurationTO =
configurationService.update(configurationTO.getKey(), configurationTO);
assertEquals(configurationTO, newConfigurationTO);
-
+
newConfigurationTO =
configurationService.read("token.expireTime");
assertEquals(configurationTO, newConfigurationTO);
}
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=1428905&r1=1428904&r2=1428905&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
Fri Jan 4 14:53:42 2013
@@ -18,22 +18,21 @@
*/
package org.apache.syncope.core.rest;
-import static org.junit.Assert.*;
+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.assertTrue;
import java.io.IOException;
import java.io.InputStream;
-import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
-import org.identityconnectors.common.security.GuardedString;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.springframework.http.HttpStatus;
-import org.springframework.web.client.HttpStatusCodeException;
+
import org.apache.syncope.client.to.ConnBundleTO;
import org.apache.syncope.client.to.ConnInstanceTO;
import org.apache.syncope.client.to.MappingItemTO;
@@ -44,8 +43,13 @@ import org.apache.syncope.types.ConnConf
import org.apache.syncope.types.ConnConfProperty;
import org.apache.syncope.types.ConnectorCapability;
import org.apache.syncope.types.IntMappingType;
+import org.identityconnectors.common.security.GuardedString;
+import org.junit.BeforeClass;
import org.junit.FixMethodOrder;
+import org.junit.Test;
import org.junit.runners.MethodSorters;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.client.HttpStatusCodeException;
@FixMethodOrder(MethodSorters.JVM)
public class ConnInstanceTestITCase extends AbstractTest {
@@ -240,8 +244,7 @@ public class ConnInstanceTestITCase exte
assertNotNull(connInstanceTO);
// check for resource
- List<ResourceTO> resources =
Arrays.asList(restTemplate.getForObject(BASE_URL
- + "resource/list.json?connInstanceId=103",
ResourceTO[].class));
+ List<ResourceTO> resources = resourceService.list(Long.valueOf(103));
assertEquals(4, resources.size());
@@ -273,13 +276,11 @@ public class ConnInstanceTestITCase exte
// ----------------------------------
// Check for connector instance update after resource creation.
// ----------------------------------
- resourceTO = restTemplate.postForObject(BASE_URL +
"resource/create.json", resourceTO,
- ResourceTO.class);
+ resourceTO = resourceService.create(resourceTO);
assertNotNull(resourceTO);
- resources = Arrays.asList(restTemplate.getForObject(BASE_URL +
"resource/list.json?connInstanceId="
- + connId, ResourceTO[].class));
+ resources = resourceService.list(connId);
assertEquals(1, resources.size());
// ----------------------------------
@@ -598,7 +599,7 @@ public class ConnInstanceTestITCase exte
// ----------------------------------------
// Check connection without saving the resource ....
// ----------------------------------------
- assertTrue(restTemplate.postForObject(BASE_URL +
"resource/check.json", resourceTO, Boolean.class));
+ assertTrue(resourceService.check(resourceTO));
// ----------------------------------------
}
}
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=1428905&r1=1428904&r2=1428905&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
Fri Jan 4 14:53:42 2013
@@ -18,48 +18,49 @@
*/
package org.apache.syncope.core.rest;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import java.io.IOException;
import java.io.StringWriter;
import java.net.HttpURLConnection;
import java.net.URL;
-import java.util.Arrays;
import java.util.List;
-import java.util.Set;
+
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.io.IOUtils;
-import org.junit.Test;
-import org.springframework.http.HttpStatus;
-import org.springframework.web.client.HttpStatusCodeException;
import org.apache.syncope.client.report.UserReportletConf;
import org.apache.syncope.client.to.ReportExecTO;
import org.apache.syncope.client.to.ReportTO;
-import org.apache.syncope.client.to.UserTO;
import org.junit.FixMethodOrder;
+import org.junit.Test;
import org.junit.runners.MethodSorters;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.client.HttpStatusCodeException;
@FixMethodOrder(MethodSorters.JVM)
public class ReportTestITCase extends AbstractTest {
@Test
public void getReportletClasses() {
- List<String> reportletClasses =
Arrays.asList(restTemplate.getForObject(
- BASE_URL + "report/reportletConfClasses.json",
String[].class));
+ List<String> reportletClasses =
reportService.getReportletConfClasses();
assertNotNull(reportletClasses);
assertFalse(reportletClasses.isEmpty());
}
@Test
public void count() {
- Integer count = restTemplate.getForObject(BASE_URL +
"report/count.json", Integer.class);
+ Integer count = reportService.count();
assertNotNull(count);
assertTrue(count > 0);
}
@Test
public void list() {
- List<ReportTO> reports =
Arrays.asList(restTemplate.getForObject(BASE_URL + "report/list",
ReportTO[].class));
+ List<ReportTO> reports = reportService.list();
assertNotNull(reports);
assertFalse(reports.isEmpty());
for (ReportTO report : reports) {
@@ -69,8 +70,7 @@ public class ReportTestITCase extends Ab
@Test
public void listExecutions() {
- List<ReportExecTO> executions =
Arrays.asList(restTemplate.getForObject(BASE_URL + "report/execution/list",
- ReportExecTO[].class));
+ List<ReportExecTO> executions = reportService.listExecutions();
assertNotNull(executions);
assertFalse(executions.isEmpty());
for (ReportExecTO execution : executions) {
@@ -80,7 +80,7 @@ public class ReportTestITCase extends Ab
@Test
public void read() {
- ReportTO reportTO = restTemplate.getForObject(BASE_URL +
"report/read/{reportId}", ReportTO.class, 1);
+ ReportTO reportTO = reportService.read(1L);
assertNotNull(reportTO);
assertNotNull(reportTO.getExecutions());
@@ -89,8 +89,7 @@ public class ReportTestITCase extends Ab
@Test
public void readExecution() {
- ReportExecTO reportExecTO = restTemplate.getForObject(BASE_URL +
"report/execution/read/{reportId}",
- ReportExecTO.class, 1);
+ ReportExecTO reportExecTO = reportService.readExecution(1L);
assertNotNull(reportExecTO);
}
@@ -101,11 +100,10 @@ public class ReportTestITCase extends Ab
report.addReportletConf(new UserReportletConf("first"));
report.addReportletConf(new UserReportletConf("second"));
- report = restTemplate.postForObject(BASE_URL + "report/create",
report, ReportTO.class);
+ report = reportService.create(report);
assertNotNull(report);
- ReportTO actual = restTemplate.getForObject(BASE_URL +
"report/read/{reportId}", ReportTO.class,
- report.getId());
+ ReportTO actual = reportService.read(report.getId());
assertNotNull(actual);
assertEquals(actual, report);
@@ -118,13 +116,13 @@ public class ReportTestITCase extends Ab
report.addReportletConf(new UserReportletConf("first"));
report.addReportletConf(new UserReportletConf("second"));
- report = restTemplate.postForObject(BASE_URL + "report/create",
report, ReportTO.class);
+ report = reportService.create(report);
assertNotNull(report);
assertEquals(2, report.getReportletConfs().size());
report.addReportletConf(new UserReportletConf("last"));
- ReportTO updated = restTemplate.postForObject(BASE_URL +
"report/update", report, ReportTO.class);
+ ReportTO updated = reportService.update(report.getId(), report);
assertNotNull(updated);
assertEquals(3, updated.getReportletConfs().size());
}
@@ -136,22 +134,22 @@ public class ReportTestITCase extends Ab
report.addReportletConf(new UserReportletConf("first"));
report.addReportletConf(new UserReportletConf("second"));
- report = restTemplate.postForObject(BASE_URL + "report/create",
report, ReportTO.class);
+ report = reportService.create(report);
assertNotNull(report);
- ReportTO deletedReport =
- restTemplate.getForObject(BASE_URL +
"report/delete/{reportId}", ReportTO.class, report.getId());
+ ReportTO deletedReport = reportService.delete(report.getId());
assertNotNull(deletedReport);
try {
- restTemplate.getForObject(BASE_URL + "report/read/{reportId}",
UserTO.class, report.getId());
+ reportService.read(report.getId());
fail();
} catch (HttpStatusCodeException e) {
assertEquals(HttpStatus.NOT_FOUND, e.getStatusCode());
}
}
- private void checkExport(final long execId, final String fmt, final String
encodedAuth) throws IOException {
+ private void checkExport(final long execId, final String fmt, final String
encodedAuth)
+ throws IOException {
URL url = new URL(BASE_URL + "report/execution/export/" + execId +
"?fmt=" + fmt);
int responseCode = 0;
String export = null;
@@ -178,17 +176,15 @@ public class ReportTestITCase extends Ab
}
@Test
- public void executeAndExport()
- throws IOException {
+ public void executeAndExport() throws IOException {
- ReportTO reportTO = restTemplate.getForObject(BASE_URL +
"report/read/{reportId}", ReportTO.class, 1);
+ ReportTO reportTO = reportService.read(1L);
reportTO.setId(0);
reportTO.setName("executeAndExport");
- reportTO = restTemplate.postForObject(BASE_URL + "report/create",
reportTO, ReportTO.class);
+ reportTO = reportService.create(reportTO);
assertNotNull(reportTO);
- ReportExecTO execution = restTemplate.postForObject(BASE_URL +
"report/execute/{reportId}", null,
- ReportExecTO.class, reportTO.getId());
+ ReportExecTO execution = reportService.execute(reportTO.getId());
assertNotNull(execution);
int maxit = 50;
@@ -198,7 +194,7 @@ public class ReportTestITCase extends Ab
} catch (InterruptedException e) {
}
- reportTO = restTemplate.getForObject(BASE_URL +
"report/read/{reportId}", ReportTO.class, reportTO.getId());
+ reportTO = reportService.read(reportTO.getId());
maxit--;
} while (reportTO.getExecutions().isEmpty() && maxit > 0);
@@ -257,11 +253,10 @@ public class ReportTestITCase extends Ab
public void issueSYNCOPE43() {
ReportTO reportTO = new ReportTO();
reportTO.setName("issueSYNCOPE43");
- reportTO = restTemplate.postForObject(BASE_URL + "report/create",
reportTO, ReportTO.class);
+ reportTO = reportService.create(reportTO);
assertNotNull(reportTO);
- ReportExecTO execution = restTemplate.postForObject(BASE_URL +
"report/execute/{reportId}", null,
- ReportExecTO.class, reportTO.getId());
+ ReportExecTO execution = reportService.execute(reportTO.getId());
assertNotNull(execution);
int maxit = 50;
@@ -271,7 +266,7 @@ public class ReportTestITCase extends Ab
} catch (InterruptedException e) {
}
- reportTO = restTemplate.getForObject(BASE_URL +
"report/read/{reportId}", ReportTO.class, reportTO.getId());
+ reportTO = reportService.read(reportTO.getId());
maxit--;
} while (reportTO.getExecutions().isEmpty() && maxit > 0);
@@ -282,16 +277,15 @@ public class ReportTestITCase extends Ab
@Test
public void issueSYNCOPE102() throws IOException {
// Create
- ReportTO reportTO = restTemplate.getForObject(BASE_URL +
"report/read/{reportId}", ReportTO.class, 1);
+ ReportTO reportTO = reportService.read(1L);
reportTO.setId(0);
reportTO.setName("issueSYNCOPE102");
- reportTO = restTemplate.postForObject(BASE_URL + "report/create",
reportTO, ReportTO.class);
+ reportTO = reportService.create(reportTO);
assertNotNull(reportTO);
// Execute (multiple requests)
for (int i = 0; i < 10; i++) {
- ReportExecTO execution = restTemplate.postForObject(BASE_URL +
"report/execute/{reportId}", null,
- ReportExecTO.class, reportTO.getId());
+ ReportExecTO execution = reportService.execute(reportTO.getId());
assertNotNull(execution);
}
@@ -303,7 +297,7 @@ public class ReportTestITCase extends Ab
} catch (InterruptedException e) {
}
- reportTO = restTemplate.getForObject(BASE_URL +
"report/read/{reportId}", ReportTO.class, reportTO.getId());
+ reportTO = reportService.read(reportTO.getId());
maxit--;
} while (reportTO.getExecutions().isEmpty() && maxit > 0);
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=1428905&r1=1428904&r2=1428905&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
Fri Jan 4 14:53:42 2013
@@ -46,8 +46,7 @@ public class ResourceTestITCase extends
@Test
public void getPropagationActionsClasses() {
- Set<String> actions = restTemplate.getForObject(
- BASE_URL + "resource/propagationActionsClasses.json",
Set.class);
+ Set<String> actions = resourceService.getPropagationActionsClasses();
assertNotNull(actions);
assertFalse(actions.isEmpty());
}
@@ -84,12 +83,11 @@ public class ResourceTestITCase extends
resourceTO.setUmapping(mapping);
- ResourceTO actual = restTemplate.postForObject(BASE_URL +
"resource/create.json", resourceTO, ResourceTO.class);
+ ResourceTO actual = resourceService.create(resourceTO);
assertNotNull(actual);
// check for existence
- actual = restTemplate.getForObject(BASE_URL +
"resource/read/{resourceName}.json", ResourceTO.class,
- resourceName);
+ actual = resourceService.read(resourceName);
assertNotNull(actual);
}
@@ -136,13 +134,12 @@ public class ResourceTestITCase extends
Set<ConnConfProperty> connectorConfigurationProperties = new
HashSet<ConnConfProperty>(Arrays.asList(p));
resourceTO.setConnectorConfigurationProperties(connectorConfigurationProperties);
- ResourceTO actual = restTemplate.postForObject(BASE_URL +
"resource/create.json", resourceTO, ResourceTO.class);
+ ResourceTO actual = resourceService.create(resourceTO);
assertNotNull(actual);
// check the existence
- actual = restTemplate.getForObject(BASE_URL +
"resource/read/{resourceName}.json", ResourceTO.class,
- resourceName);
+ actual = resourceService.read(resourceName);
assertNotNull(actual);
}
@@ -171,7 +168,7 @@ public class ResourceTestITCase extends
resourceTO.setRmapping(rmapping);
- ResourceTO actual = restTemplate.postForObject(BASE_URL +
"resource/create.json", resourceTO, ResourceTO.class);
+ ResourceTO actual = resourceService.create(resourceTO);
assertNotNull(actual);
assertNotNull(actual.getUmapping());
assertNotNull(actual.getUmapping().getItems());
@@ -203,7 +200,7 @@ public class ResourceTestITCase extends
Throwable t = null;
try {
- restTemplate.postForObject(BASE_URL + "resource/create.json",
resourceTO, ResourceTO.class);
+ resourceService.create(resourceTO);
} catch (SyncopeClientCompositeErrorException e) {
t = e;
@@ -239,7 +236,7 @@ public class ResourceTestITCase extends
resourceTO.setUmapping(mapping);
- restTemplate.postForObject(BASE_URL + "resource/create.json",
resourceTO, ResourceTO.class);
+ resourceService.create(resourceTO);
}
@Test
@@ -261,13 +258,12 @@ public class ResourceTestITCase extends
resourceTO.setUmapping(mapping);
- ResourceTO actual = restTemplate.postForObject(BASE_URL +
"resource/create.json", resourceTO, ResourceTO.class);
+ ResourceTO actual = resourceService.create(resourceTO);
assertNotNull(actual);
// check the existence
- actual = restTemplate.getForObject(BASE_URL +
"resource/read/{resourceName}.json", ResourceTO.class,
- resourceName);
+ actual = resourceService.read(resourceName);
assertNotNull(actual);
assertNotNull(actual.getPasswordPolicy());
assertEquals(4L, (long) actual.getPasswordPolicy());
@@ -279,7 +275,7 @@ public class ResourceTestITCase extends
ResourceTO resourceTO = new ResourceTO();
resourceTO.setName("resourcenotfound");
- restTemplate.postForObject(BASE_URL + "resource/update.json",
resourceTO, ResourceTO.class);
+ resourceService.update(resourceTO.getName(), resourceTO);
} catch (HttpStatusCodeException e) {
assertEquals(HttpStatus.NOT_FOUND, e.getStatusCode());
}
@@ -319,7 +315,7 @@ public class ResourceTestITCase extends
resourceTO.setUmapping(mapping);
- ResourceTO actual = restTemplate.postForObject(BASE_URL +
"resource/update.json", resourceTO, ResourceTO.class);
+ ResourceTO actual = resourceService.update(resourceTO.getName(),
resourceTO);
assertNotNull(actual);
// check for existence
@@ -331,8 +327,7 @@ public class ResourceTestITCase extends
@Test
public void deleteWithException() {
try {
- restTemplate.getForObject(
- BASE_URL + "resource/delete/{resourceName}.json",
ResourceTO.class, "resourcenotfound");
+ resourceService.delete("resourcenotfound");
} catch (HttpStatusCodeException e) {
assertEquals(HttpStatus.NOT_FOUND, e.getStatusCode());
}
@@ -342,13 +337,12 @@ public class ResourceTestITCase extends
public void updateResetSyncToken() {
// pre condition: sync token is set
String resourceName = "ws-target-resource-update-resetsynctoken";
- ResourceTO pre = restTemplate.getForObject(BASE_URL +
"/resource/read/{resourceName}.json", ResourceTO.class,
- resourceName);
+ ResourceTO pre = resourceService.read(resourceName);
assertNotNull(pre.getUsyncToken());
pre.setUsyncToken(null);
- ResourceTO actual = restTemplate.postForObject(BASE_URL +
"resource/update.json", pre, ResourceTO.class);
+ ResourceTO actual = resourceService.update(pre.getName(), pre);
// check that the synctoken has been reset
assertNull(actual.getUsyncToken());
@@ -358,13 +352,11 @@ public class ResourceTestITCase extends
public void delete() {
final String resourceName = "ws-target-resource-delete";
- ResourceTO deletedResource =
- restTemplate.getForObject(BASE_URL +
"resource/delete/{resourceName}.json", ResourceTO.class,
- resourceName);
+ ResourceTO deletedResource = resourceService.delete(resourceName);
assertNotNull(deletedResource);
try {
- restTemplate.getForObject(BASE_URL +
"resource/read/{resourceName}.json", ResourceTO.class, resourceName);
+ resourceService.read(resourceName);
} catch (HttpStatusCodeException e) {
assertEquals(HttpStatus.NOT_FOUND, e.getStatusCode());
}
@@ -372,8 +364,7 @@ public class ResourceTestITCase extends
@Test
public void list() {
- List<ResourceTO> actuals =
Arrays.asList(restTemplate.getForObject(BASE_URL + "resource/list.json",
- ResourceTO[].class));
+ List<ResourceTO> actuals = resourceService.list(null);
assertNotNull(actuals);
assertFalse(actuals.isEmpty());
for (ResourceTO resourceTO : actuals) {
@@ -383,8 +374,7 @@ public class ResourceTestITCase extends
@Test
public void listByType() {
- List<ResourceTO> actuals =
Arrays.asList(restTemplate.getForObject(BASE_URL
- + "resource/list.json?connInstanceId=105",
ResourceTO[].class));
+ List<ResourceTO> actuals = resourceService.list(Long.valueOf(105));
assertNotNull(actuals);
assertEquals(1, actuals.size());
@@ -393,9 +383,8 @@ public class ResourceTestITCase extends
@Test
public void read() {
- ResourceTO actual = restTemplate.getForObject(BASE_URL +
"/resource/read/{resourceName}.json",
- ResourceTO.class, "resource-testdb");
-
+ ResourceTO actual = resourceService.read("resource-testdb");
+
assertNotNull(actual);
}
}
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=1428905&r1=1428904&r2=1428905&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
Fri Jan 4 14:53:42 2013
@@ -37,6 +37,7 @@ import org.apache.syncope.client.to.Role
import org.apache.syncope.client.to.UserTO;
import
org.apache.syncope.client.validation.SyncopeClientCompositeErrorException;
import org.apache.syncope.client.validation.SyncopeClientException;
+import org.apache.syncope.types.AttributableType;
import org.apache.syncope.types.SyncopeClientExceptionType;
import org.junit.FixMethodOrder;
import org.junit.Test;
@@ -108,9 +109,7 @@ public class RoleTestITCase extends Abst
assertTrue(roleTO.getResources().contains("resource-ldap"));
- ConnObjectTO connObjectTO = restTemplate.getForObject(BASE_URL
- +
"/resource/resource-ldap/read/ROLE/lastRole.json",
- ConnObjectTO.class);
+ ConnObjectTO connObjectTO =
resourceService.getConnector("resource-ldap", AttributableType.ROLE,
"lastRole");
assertNotNull(connObjectTO);
assertNotNull(connObjectTO.getAttributeMap().get("owner"));
}
Modified:
syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java
URL:
http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java?rev=1428905&r1=1428904&r2=1428905&view=diff
==============================================================================
---
syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java
(original)
+++
syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java
Fri Jan 4 14:53:42 2013
@@ -50,6 +50,7 @@ import org.apache.syncope.client.validat
import org.apache.syncope.client.validation.SyncopeClientException;
import org.apache.syncope.core.init.SpringContextInitializer;
import org.apache.syncope.core.persistence.beans.user.SyncopeUser;
+import org.apache.syncope.types.AttributableType;
import org.apache.syncope.types.CipherAlgorithm;
import org.apache.syncope.types.PropagationTaskExecStatus;
import org.apache.syncope.types.SyncopeClientExceptionType;
@@ -69,9 +70,7 @@ import org.springframework.web.client.Ht
public class UserTestITCase extends AbstractTest {
private ConnObjectTO readUserConnObj(String resourceName, String userId) {
- return restTemplate.getForObject(BASE_URL
- + "/resource/{resourceName}/read/USER/{objectId}.json",
ConnObjectTO.class,
- resourceName, userId);
+ return resourceService.getConnector(resourceName,
AttributableType.USER, userId);
}
public static UserTO getSampleTO(final String email) {