syncope-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbernha...@apache.org
Subject svn commit: r1427826 - in /syncope/trunk: client/src/main/java/org/apache/syncope/client/mod/ client/src/main/java/org/apache/syncope/services/ core/src/test/java/org/apache/syncope/core/rest/
Date Wed, 02 Jan 2013 15:37:38 GMT
Author: jbernhardt
Date: Wed Jan  2 15:37:37 2013
New Revision: 1427826

URL: http://svn.apache.org/viewvc?rev=1427826&view=rev
Log:
[SYNCOPE-259]
Introduces RoleService Interface and RoleServiceProxy which is used for Integration-Tests

Added:
    syncope/trunk/client/src/main/java/org/apache/syncope/client/mod/StatusMod.java
    syncope/trunk/client/src/main/java/org/apache/syncope/services/RoleService.java
    syncope/trunk/client/src/main/java/org/apache/syncope/services/RoleServiceProxy.java
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/RoleTestITCase.java
    syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/SearchTestITCase.java

Added: syncope/trunk/client/src/main/java/org/apache/syncope/client/mod/StatusMod.java
URL: http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/client/mod/StatusMod.java?rev=1427826&view=auto
==============================================================================
--- syncope/trunk/client/src/main/java/org/apache/syncope/client/mod/StatusMod.java (added)
+++ syncope/trunk/client/src/main/java/org/apache/syncope/client/mod/StatusMod.java Wed Jan
 2 15:37:37 2013
@@ -0,0 +1,121 @@
+/*
+ * 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.client.mod;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElementWrapper;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+import org.apache.syncope.client.AbstractBaseBean;
+
+@XmlType
+@XmlRootElement
+public class StatusMod extends AbstractBaseBean {
+
+    public enum Status {
+        ACTIVATE, REACTIVATE, SUSPEND;
+    }
+
+    public StatusMod(long id, Status status) {
+        this.id = id;
+        this.status = status;
+    }
+
+    public StatusMod() {
+    }
+
+    private Status status;
+
+    private String token;
+
+    private static final long serialVersionUID = 1338094801957616986L;
+
+    private long id;
+
+    private boolean updateInternal = true;
+
+    private boolean updateRemote = true;
+
+    private final Set<String> excludeResources = new HashSet<String>();
+
+    public long getId() {
+        return id;
+    }
+
+    public void setId(long id) {
+        this.id = id;
+    }
+
+    public boolean isUpdateInternal() {
+        return updateInternal;
+    }
+
+    public void setUpdateInternal(boolean updateInternal) {
+        this.updateInternal = updateInternal;
+    }
+
+    public boolean isUpdateRemote() {
+        return updateRemote;
+    }
+
+    public void setUpdateRemote(boolean updateRemote) {
+        this.updateRemote = updateRemote;
+    }
+
+    @XmlElementWrapper(name = "excludeResources")
+    @XmlElement(name = "resource")
+    public Set<String> getExcludeResources() {
+        return excludeResources;
+    }
+
+    /**
+     * @return the status
+     */
+    public Status getStatus() {
+        return status;
+    }
+
+    /**
+     * @param status
+     *            the status to set
+     */
+    public void setStatus(Status status) {
+        this.status = status;
+    }
+
+    /**
+     * @return the token
+     */
+    public String getToken() {
+        return token;
+    }
+
+    /**
+     * @param token
+     *            the token to set
+     */
+    public void setToken(String token) {
+        this.token = token;
+    }
+
+}

Added: 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=1427826&view=auto
==============================================================================
--- syncope/trunk/client/src/main/java/org/apache/syncope/services/RoleService.java (added)
+++ syncope/trunk/client/src/main/java/org/apache/syncope/services/RoleService.java Wed Jan
 2 15:37:37 2013
@@ -0,0 +1,93 @@
+/*
+ * 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 javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+
+import org.apache.syncope.client.mod.RoleMod;
+import org.apache.syncope.client.search.NodeCond;
+import org.apache.syncope.client.to.RoleTO;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+@Path("/role")
+@RequestMapping("/role")
+public interface RoleService {
+
+	@GET
+    @Path("/{roleId}/children")
+	@RequestMapping(method = RequestMethod.GET, value = "/children/{roleId}")
+	List<RoleTO> children(@PathParam("roleId") @PathVariable("roleId") final Long roleId);
+
+	@POST
+    @Path("/")
+	@RequestMapping(method = RequestMethod.POST, value = "/create")
+	RoleTO create(@RequestBody final RoleTO roleTO);
+
+	@DELETE
+    @Path("/{roleId}")
+	@RequestMapping(method = RequestMethod.GET, value = "/delete/{roleId}")
+	RoleTO delete(@PathParam("roleId") @PathVariable("roleId") final Long roleId);
+
+	@GET
+	@RequestMapping(method = RequestMethod.GET, value = "/list")
+	List<RoleTO> list();
+
+	@GET
+    @Path("/{roleId}/parent")
+	@RequestMapping(method = RequestMethod.GET, value = "/parent/{roleId}")
+	RoleTO parent(@PathParam("roleId") @PathVariable("roleId") final Long roleId);
+
+	@GET
+	@Path("/{roleId}")
+	@RequestMapping(method = RequestMethod.GET, value = "/read/{roleId}")
+	RoleTO read(@PathParam("roleId") @PathVariable("roleId") final Long roleId);
+
+	
+	@RequestMapping(method = RequestMethod.POST, value = "/search")
+	List<RoleTO> search(@RequestBody final NodeCond searchCondition);
+
+	@RequestMapping(method = RequestMethod.POST, value = "/search/{page}/{size}")
+	List<RoleTO> search(@RequestBody final NodeCond searchCondition,
+			@PathVariable("page") final int page,
+			@PathVariable("size") final int size);
+
+	@RequestMapping(method = RequestMethod.POST, value = "/search/count")
+	int searchCount(@RequestBody final NodeCond searchCondition);
+
+	/**
+	 * @deprecated Authentication checks should not depend on the method called
+	 */
+	@Deprecated
+	@RequestMapping(method = RequestMethod.GET, value = "/selfRead/{roleId}")
+	RoleTO selfRead(@PathVariable("roleId") final Long roleId);
+
+	@POST
+    @Path("/{roleId}")
+	@RequestMapping(method = RequestMethod.POST, value = "/update")
+	RoleTO update(@PathParam("roleId") final Long roleId, @RequestBody final RoleMod roleMod);
+}
\ No newline at end of file

Added: syncope/trunk/client/src/main/java/org/apache/syncope/services/RoleServiceProxy.java
URL: http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/services/RoleServiceProxy.java?rev=1427826&view=auto
==============================================================================
--- syncope/trunk/client/src/main/java/org/apache/syncope/services/RoleServiceProxy.java (added)
+++ syncope/trunk/client/src/main/java/org/apache/syncope/services/RoleServiceProxy.java Wed
Jan  2 15:37:37 2013
@@ -0,0 +1,105 @@
+/*
+ * 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.mod.RoleMod;
+import org.apache.syncope.client.search.NodeCond;
+import org.apache.syncope.client.to.RoleTO;
+import org.springframework.web.client.RestTemplate;
+
+public class RoleServiceProxy implements RoleService {
+
+	RestTemplate restTemplate;
+	private String baseUrl;
+
+	public RoleServiceProxy(String baseUrl, RestTemplate restTemplate) {
+		this.baseUrl = baseUrl;
+		this.restTemplate = restTemplate;
+	}
+
+	@Override
+	public List<RoleTO> children(Long roleId) {
+		return Arrays.asList(restTemplate.getForObject(baseUrl
+				+ "role/children/{roleId}.json", RoleTO[].class, roleId));
+	}
+
+	@Override
+	public RoleTO create(RoleTO roleTO) {
+		return restTemplate.postForObject(baseUrl + "role/create", roleTO,
+				RoleTO.class);
+	}
+
+	@Override
+	public RoleTO delete(Long roleId) {
+		return restTemplate.getForObject(baseUrl + "role/delete/{roleId}",
+				RoleTO.class, roleId);
+	}
+
+	@Override
+	public List<RoleTO> list() {
+		return Arrays.asList(restTemplate.getForObject(baseUrl
+				+ "role/list.json", RoleTO[].class));
+	}
+
+	@Override
+	public RoleTO parent(Long roleId) {
+		return restTemplate.getForObject(baseUrl + "role/parent/{roleId}.json",
+				RoleTO.class, roleId);
+	}
+
+	@Override
+	public RoleTO read(Long roleId) {
+		return restTemplate.getForObject(baseUrl + "role/read/{roleId}.json",
+				RoleTO.class, roleId);
+	}
+
+	@Override
+	public List<RoleTO> search(NodeCond searchCondition) {
+		return Arrays.asList(restTemplate.postForObject(
+				baseUrl + "role/search", searchCondition, RoleTO[].class));
+	}
+
+	@Override
+	public List<RoleTO> search(NodeCond searchCondition, int page, int size) {
+		return Arrays.asList(restTemplate.postForObject(
+				baseUrl + "role/search/{page}/{size}", searchCondition, RoleTO[].class, page, size));
+	}
+
+	@Override
+	public int searchCount(NodeCond searchCondition) {
+		return restTemplate.postForObject(baseUrl + "role/search/count.json",
+				searchCondition, Integer.class);
+	}
+
+	@Override
+	public RoleTO selfRead(Long roleId) {
+		return restTemplate.getForObject(baseUrl + "role/selfRead/{roleId}",
+				RoleTO.class, roleId);
+	}
+
+	@Override
+	public RoleTO update(Long roleId, RoleMod roleMod) {
+		return restTemplate.postForObject(baseUrl + "role/update", roleMod,
+				RoleTO.class);
+	}
+
+}

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=1427826&r1=1427825&r2=1427826&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
 2 15:37:37 2013
@@ -19,11 +19,13 @@
 package org.apache.syncope.core.rest;
 
 import javax.sql.DataSource;
+
 import org.apache.http.auth.UsernamePasswordCredentials;
 import org.apache.http.impl.client.DefaultHttpClient;
 import org.apache.syncope.client.http.PreemptiveAuthHttpRequestFactory;
 import org.apache.syncope.client.mod.AttributeMod;
 import org.apache.syncope.client.to.AttributeTO;
+import org.apache.syncope.services.RoleServiceProxy;
 import org.apache.syncope.services.UserService;
 import org.apache.syncope.services.UserServiceProxy;
 import org.junit.Before;
@@ -36,57 +38,66 @@ import org.springframework.test.context.
 import org.springframework.web.client.RestTemplate;
 
 @RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(locations = {"classpath:restClientContext.xml", "classpath:testJDBCContext.xml"})
+@ContextConfiguration(locations = { "classpath:restClientContext.xml",
+		"classpath:testJDBCContext.xml" })
 public abstract class AbstractTest {
 
-    protected static AttributeTO attributeTO(final String schema, final String value) {
-        AttributeTO attr = new AttributeTO();
-        attr.setSchema(schema);
-        attr.addValue(value);
-        return attr;
-    }
-
-    protected static AttributeMod attributeMod(final String schema, final String valueToBeAdded)
{
-        AttributeMod attr = new AttributeMod();
-        attr.setSchema(schema);
-        attr.addValueToBeAdded(valueToBeAdded);
-        return attr;
-    }
-
-    /**
-     * Logger.
-     */
-    protected static final Logger LOG = LoggerFactory.getLogger(AbstractTest.class);
+	protected static AttributeTO attributeTO(final String schema,
+			final String value) {
+		AttributeTO attr = new AttributeTO();
+		attr.setSchema(schema);
+		attr.addValue(value);
+		return attr;
+	}
+
+	protected static AttributeMod attributeMod(final String schema,
+			final String valueToBeAdded) {
+		AttributeMod attr = new AttributeMod();
+		attr.setSchema(schema);
+		attr.addValueToBeAdded(valueToBeAdded);
+		return attr;
+	}
+
+	/**
+	 * Logger.
+	 */
+	protected static final Logger LOG = LoggerFactory
+			.getLogger(AbstractTest.class);
 
-    protected static final String BASE_URL = "http://localhost:9080/syncope/rest/";
+	protected static final String BASE_URL = "http://localhost:9080/syncope/rest/";
 
-    public static final String ADMIN_UID = "admin";
+	public static final String ADMIN_UID = "admin";
 
-    public static final String ADMIN_PWD = "password";
+	public static final String ADMIN_PWD = "password";
 
-    @Autowired
-    protected RestTemplate restTemplate;
+	@Autowired
+	protected RestTemplate restTemplate;
 
 	protected UserService userService;
-    
-    @Autowired
-    protected DataSource testDataSource;
-
-    protected RestTemplate anonymousRestTemplate() {
-        return new RestTemplate();
-    }
-
-    public void setupRestTemplate(final String uid, final String pwd) {
-        PreemptiveAuthHttpRequestFactory requestFactory =
-                ((PreemptiveAuthHttpRequestFactory) restTemplate.getRequestFactory());
-
-        ((DefaultHttpClient) requestFactory.getHttpClient()).getCredentialsProvider().setCredentials(
-                requestFactory.getAuthScope(), new UsernamePasswordCredentials(uid, pwd));
-    }
-
-    @Before
-    public void resetRestTemplate() {
-        setupRestTemplate(ADMIN_UID, ADMIN_PWD);
-        userService = new UserServiceProxy(BASE_URL, restTemplate);
-    }
+	
+	protected RoleServiceProxy roleService;
+
+	@Autowired
+	protected DataSource testDataSource;
+
+	protected RestTemplate anonymousRestTemplate() {
+		return new RestTemplate();
+	}
+
+	public void setupRestTemplate(final String uid, final String pwd) {
+		PreemptiveAuthHttpRequestFactory requestFactory = ((PreemptiveAuthHttpRequestFactory) restTemplate
+				.getRequestFactory());
+
+		((DefaultHttpClient) requestFactory.getHttpClient())
+				.getCredentialsProvider().setCredentials(
+						requestFactory.getAuthScope(),
+						new UsernamePasswordCredentials(uid, pwd));
+	}
+
+	@Before
+	public void resetRestTemplate() {
+		setupRestTemplate(ADMIN_UID, ADMIN_PWD);
+		userService = new UserServiceProxy(BASE_URL, restTemplate);
+		roleService = new RoleServiceProxy(BASE_URL, restTemplate);
+	}
 }

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=1427826&r1=1427825&r2=1427826&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 Wed
Jan  2 15:37:37 2013
@@ -18,11 +18,16 @@
  */
 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 static org.junit.Assert.fail;
 
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.List;
+
 import org.apache.http.auth.UsernamePasswordCredentials;
 import org.apache.http.impl.client.DefaultHttpClient;
 import org.apache.syncope.client.http.PreemptiveAuthHttpRequestFactory;
@@ -42,358 +47,372 @@ import org.springframework.web.client.Ht
 @FixMethodOrder(MethodSorters.JVM)
 public class RoleTestITCase extends AbstractTest {
 
-    @Test
-    public void createWithException() {
-        RoleTO newRoleTO = new RoleTO();
-        newRoleTO.addAttribute(attributeTO("attr1", "value1"));
-
-        Throwable t = null;
-        try {
-            restTemplate.postForObject(BASE_URL + "role/create", newRoleTO, RoleTO.class);
-            fail();
-        } catch (SyncopeClientCompositeErrorException sccee) {
-            t = sccee.getException(SyncopeClientExceptionType.InvalidSyncopeRole);
-        }
-        assertNotNull(t);
-    }
-
-    @Test
-    public void create() {
-        RoleTO roleTO = new RoleTO();
-        roleTO.setName("lastRole");
-        roleTO.setParent(8L);
-
-        // verify inheritance password and account policies
-        roleTO.setInheritAccountPolicy(false);
-        // not inherited so setter execution shouldn't be ignored
-        roleTO.setAccountPolicy(6L);
-
-        roleTO.setInheritPasswordPolicy(true);
-        // inherited so setter execution should be ignored
-        roleTO.setPasswordPolicy(2L);
-
-        roleTO.addAttribute(attributeTO("icon", "anIcon"));
-
-        roleTO.addDerivedAttribute(attributeTO("ownerDN", null));
-
-        roleTO.addVirtualAttribute(attributeTO("rvirtualdata", "rvirtualvalue"));
-
-        roleTO.setRoleOwner(8L);
-
-        roleTO.addResource("resource-ldap");
-
-        roleTO = restTemplate.postForObject(BASE_URL + "role/create", roleTO, RoleTO.class);
-        assertNotNull(roleTO);
-
-        assertNotNull(roleTO.getVirtualAttributeMap());
-        assertNotNull(roleTO.getVirtualAttributeMap().get("rvirtualdata").getValues());
-        assertFalse(roleTO.getVirtualAttributeMap().get("rvirtualdata").getValues().isEmpty());
-        assertEquals("rvirtualvalue", roleTO.getVirtualAttributeMap().get("rvirtualdata").getValues().get(0));
-
-        assertNotNull(roleTO.getAccountPolicy());
-        assertEquals(6L, (long) roleTO.getAccountPolicy());
-
-        assertNotNull(roleTO.getPasswordPolicy());
-        assertEquals(4L, (long) roleTO.getPasswordPolicy());
-
-        assertTrue(roleTO.getResources().contains("resource-ldap"));
-
-        ConnObjectTO connObjectTO = restTemplate.getForObject(BASE_URL
-                + "/resource/resource-ldap/read/ROLE/lastRole.json", ConnObjectTO.class);
-        assertNotNull(connObjectTO);
-        assertNotNull(connObjectTO.getAttributeMap().get("owner"));
-    }
-
-    @Test
-    public void createWithPasswordPolicy() {
-        RoleTO roleTO = new RoleTO();
-        roleTO.setName("roleWithPassword");
-        roleTO.setParent(8L);
-        roleTO.setPasswordPolicy(4L);
-
-        RoleTO actual = restTemplate.postForObject(BASE_URL + "role/create", roleTO, RoleTO.class);
-        assertNotNull(actual);
-
-        actual = restTemplate.getForObject(BASE_URL + "role/read/{roleId}.json", RoleTO.class,
actual.getId());
-        assertNotNull(actual);
-        assertNotNull(actual.getPasswordPolicy());
-        assertEquals(4L, (long) actual.getPasswordPolicy());
-    }
-
-    @Test
-    public void delete() {
-        try {
-            restTemplate.getForObject(BASE_URL + "role/delete/{roleId}", RoleTO.class, 0);
-        } catch (HttpStatusCodeException e) {
-            assertEquals(HttpStatus.NOT_FOUND, e.getStatusCode());
-        }
-
-        RoleTO roleTO = new RoleTO();
-        roleTO.setName("toBeDeleted");
-        roleTO.setParent(8L);
-
-        roleTO.addResource("resource-ldap");
-
-        roleTO = restTemplate.postForObject(BASE_URL + "role/create", roleTO, RoleTO.class);
-        assertNotNull(roleTO);
-
-        RoleTO deletedRole = restTemplate.getForObject(BASE_URL + "role/delete/{roleId}",
RoleTO.class, roleTO.getId());
-        assertNotNull(deletedRole);
-
-        try {
-            restTemplate.getForObject(BASE_URL + "role/read/{roleId}.json", RoleTO.class,
deletedRole.getId());
-        } catch (HttpStatusCodeException e) {
-            assertEquals(HttpStatus.NOT_FOUND, e.getStatusCode());
-        }
-    }
-
-    @Test
-    public void list() {
-        List<RoleTO> roleTOs = Arrays.asList(restTemplate.getForObject(BASE_URL + "role/list.json",
RoleTO[].class));
-        assertNotNull(roleTOs);
-        assertTrue(roleTOs.size() >= 8);
-        for (RoleTO roleTO : roleTOs) {
-            assertNotNull(roleTO);
-        }
-    }
-
-    @Test
-    public void parent() {
-        RoleTO roleTO = restTemplate.getForObject(BASE_URL + "role/parent/{roleId}.json",
RoleTO.class, 7);
-
-        assertNotNull(roleTO);
-        assertEquals(roleTO.getId(), 6L);
-    }
-
-    @Test
-    public void read() {
-        RoleTO roleTO = restTemplate.getForObject(BASE_URL + "role/read/{roleId}.json", RoleTO.class,
1);
-
-        assertNotNull(roleTO);
-        assertNotNull(roleTO.getAttributes());
-        assertFalse(roleTO.getAttributes().isEmpty());
-    }
-
-    @Test
-    public void selfRead() {
-        UserTO userTO = restTemplate.getForObject(BASE_URL + "user/read/{userId}", UserTO.class,
1);
-        assertNotNull(userTO);
-
-        assertTrue(userTO.getMembershipMap().containsKey(1L));
-        assertFalse(userTO.getMembershipMap().containsKey(3L));
-
-        PreemptiveAuthHttpRequestFactory requestFactory =
-                (PreemptiveAuthHttpRequestFactory) restTemplate.getRequestFactory();
-        ((DefaultHttpClient) requestFactory.getHttpClient()).getCredentialsProvider().setCredentials(
-                requestFactory.getAuthScope(), new UsernamePasswordCredentials("user1", "password"));
-
-        SyncopeClientException exception = null;
-        try {
-            restTemplate.getForObject(BASE_URL + "role/selfRead/{roleId}", RoleTO.class,
3);
-            fail();
-        } catch (SyncopeClientCompositeErrorException e) {
-            exception = e.getException(SyncopeClientExceptionType.UnauthorizedRole);
-        }
-        assertNotNull(exception);
-
-        RoleTO roleTO = restTemplate.getForObject(BASE_URL + "role/selfRead/{roleId}", RoleTO.class,
1);
-        assertNotNull(roleTO);
-        assertNotNull(roleTO.getAttributes());
-        assertFalse(roleTO.getAttributes().isEmpty());
-
-        // restore admin authentication
-        super.resetRestTemplate();
-    }
-
-    @Test
-    public void update() {
-        RoleTO roleTO = new RoleTO();
-        roleTO.setName("latestRole");
-        roleTO.setParent(8L);
-
-        // verify inheritance password and account policies
-        roleTO.setInheritAccountPolicy(false);
-        // not inherited so setter execution shouldn't be ignored
-        roleTO.setAccountPolicy(6L);
-
-        roleTO.setInheritPasswordPolicy(true);
-        // inherited so setter execution should be ignored
-        roleTO.setPasswordPolicy(2L);
-
-        roleTO.addAttribute(attributeTO("icon", "anIcon"));
-
-        roleTO.addResource("resource-ldap");
-
-        roleTO = restTemplate.postForObject(BASE_URL + "role/create", roleTO, RoleTO.class);
-
-        assertEquals(1, roleTO.getAttributes().size());
-
-        assertNotNull(roleTO.getAccountPolicy());
-        assertEquals(Long.valueOf(6), roleTO.getAccountPolicy());
-
-        assertNotNull(roleTO.getPasswordPolicy());
-        assertEquals(Long.valueOf(4), roleTO.getPasswordPolicy());
-
-        RoleMod roleMod = new RoleMod();
-        roleMod.setId(roleTO.getId());
-        roleMod.setName("finalRole");
-        roleMod.addAttributeToBeUpdated(attributeMod("show", "FALSE"));
-
-        // change password policy inheritance
-        roleMod.setInheritPasswordPolicy(Boolean.FALSE);
-
-        roleTO = restTemplate.postForObject(BASE_URL + "role/update", roleMod, RoleTO.class);
-
-        assertEquals("finalRole", roleTO.getName());
-        assertEquals(2, roleTO.getAttributes().size());
-
-        // changes ignored because not requested (null ReferenceMod)
-        assertNotNull(roleTO.getAccountPolicy());
-        assertEquals(6L, (long) roleTO.getAccountPolicy());
-
-        // password policy null because not inherited
-        assertNull(roleTO.getPasswordPolicy());
-    }
-
-    @Test
-    public void updateRemovingVirAttribute() {
-        RoleTO roleTO = new RoleTO();
-        roleTO.setName("withvirtual");
-        roleTO.setParent(8L);
-        roleTO.addVirtualAttribute(attributeTO("rvirtualdata", null));
-
-        roleTO = restTemplate.postForObject(BASE_URL + "role/create", roleTO, RoleTO.class);
-
-        assertNotNull(roleTO);
-        assertEquals(1, roleTO.getVirtualAttributes().size());
-
-        final RoleMod roleMod = new RoleMod();
-        roleMod.setId(roleTO.getId());
-        roleMod.addVirtualAttributeToBeRemoved("rvirtualdata");
-
-        roleTO = restTemplate.postForObject(BASE_URL + "role/update", roleMod, RoleTO.class);
-
-        assertNotNull(roleTO);
-        assertTrue(roleTO.getVirtualAttributes().isEmpty());
-    }
-
-    @Test
-    public void updateRemovingDerAttribute() {
-        RoleTO roleTO = new RoleTO();
-        roleTO.setName("withderived");
-        roleTO.setParent(8L);
-        roleTO.addDerivedAttribute(attributeTO("rderivedschema", null));
-
-        roleTO = restTemplate.postForObject(BASE_URL + "role/create", roleTO, RoleTO.class);
-
-        assertNotNull(roleTO);
-        assertEquals(1, roleTO.getDerivedAttributes().size());
-
-        final RoleMod roleMod = new RoleMod();
-        roleMod.setId(roleTO.getId());
-        roleMod.addDerivedAttributeToBeRemoved("rderivedschema");
-
-        roleTO = restTemplate.postForObject(BASE_URL + "role/update", roleMod, RoleTO.class);
-
-        assertNotNull(roleTO);
-        assertTrue(roleTO.getDerivedAttributes().isEmpty());
-    }
-
-    @Test
-    public void updateAsRoleOwner() {
-        // 1. read role as admin
-        RoleTO roleTO = restTemplate.getForObject(BASE_URL + "role/read/{roleId}.json", RoleTO.class,
7);
-
-        // 2. prepare update
-        RoleMod roleMod = new RoleMod();
-        roleMod.setId(roleTO.getId());
-        roleMod.setName("Managing Director");
-
-        // 3. try to update as user3, not owner of role 7 - fail
-        PreemptiveAuthHttpRequestFactory requestFactory =
-                (PreemptiveAuthHttpRequestFactory) restTemplate.getRequestFactory();
-        ((DefaultHttpClient) requestFactory.getHttpClient()).getCredentialsProvider().setCredentials(
-                requestFactory.getAuthScope(), new UsernamePasswordCredentials("user2", "password"));
-
-        try {
-            restTemplate.postForObject(BASE_URL + "role/update", roleMod, RoleTO.class);
-            fail();
-        } catch (HttpStatusCodeException e) {
-            assertEquals(HttpStatus.FORBIDDEN, e.getStatusCode());
-        }
-
-        // 4. update as user5, owner of role 7 because owner of role 6 with inheritance -
success
-        ((DefaultHttpClient) requestFactory.getHttpClient()).getCredentialsProvider().setCredentials(
-                requestFactory.getAuthScope(), new UsernamePasswordCredentials("user5", "password"));
-
-        roleTO = restTemplate.postForObject(BASE_URL + "role/update", roleMod, RoleTO.class);
-        assertEquals("Managing Director", roleTO.getName());
-
-        // restore admin authentication
-        super.resetRestTemplate();
-    }
-
-    /**
-     * Role rename used to fail in case of parent null.
-     *
-     * http://code.google.com/p/syncope/issues/detail?id=178
-     */
-    @Test
-    public void issue178() {
-        RoleTO roleTO = new RoleTO();
-        roleTO.setName("torename");
-
-        RoleTO actual = restTemplate.postForObject(BASE_URL + "role/create", roleTO, RoleTO.class);
-
-        assertNotNull(actual);
-        assertEquals("torename", actual.getName());
-        assertEquals(0L, actual.getParent());
-
-        RoleMod roleMod = new RoleMod();
-        roleMod.setId(actual.getId());
-        roleMod.setName("renamed");
-
-        actual = restTemplate.postForObject(BASE_URL + "role/update", roleMod, RoleTO.class);
-
-        assertNotNull(actual);
-        assertEquals("renamed", actual.getName());
-        assertEquals(0L, actual.getParent());
-    }
-
-    @Test
-    public void issueSYNCOPE228() {
-        RoleTO roleTO = new RoleTO();
-        roleTO.setName("issueSYNCOPE228");
-        roleTO.setParent(8L);
-        roleTO.setInheritAccountPolicy(false);
-        roleTO.setAccountPolicy(6L);
-        roleTO.setInheritPasswordPolicy(true);
-        roleTO.setPasswordPolicy(2L);
-        roleTO.addAttribute(attributeTO("icon", "anIcon"));
-        roleTO.addEntitlement("USER_READ");
-        roleTO.addEntitlement("SCHEMA_READ");
-
-        roleTO = restTemplate.postForObject(BASE_URL + "role/create", roleTO, RoleTO.class);
-        assertNotNull(roleTO);
-        assertNotNull(roleTO.getEntitlements());
-        assertFalse(roleTO.getEntitlements().isEmpty());
-
-        List<String> entitlements = roleTO.getEntitlements();
-
-        RoleMod roleMod = new RoleMod();
-        roleMod.setId(roleTO.getId());
-        roleMod.setInheritDerivedAttributes(Boolean.TRUE);
-
-        roleTO = restTemplate.postForObject(BASE_URL + "role/update", roleMod, RoleTO.class);
-        assertNotNull(roleTO);
-        assertEquals(entitlements, roleTO.getEntitlements());
-
-        roleMod = new RoleMod();
-        roleMod.setId(roleTO.getId());
-        roleMod.setEntitlements(new ArrayList<String>());
-
-        roleTO = restTemplate.postForObject(BASE_URL + "role/update", roleMod, RoleTO.class);
-        assertNotNull(roleTO);
-        assertTrue(roleTO.getEntitlements().isEmpty());
-    }
+	@Test
+	public void createWithException() {
+		RoleTO newRoleTO = new RoleTO();
+		newRoleTO.addAttribute(attributeTO("attr1", "value1"));
+
+		Throwable t = null;
+		try {
+			roleService.create(newRoleTO);
+			fail();
+		} catch (SyncopeClientCompositeErrorException sccee) {
+			t = sccee
+					.getException(SyncopeClientExceptionType.InvalidSyncopeRole);
+		}
+		assertNotNull(t);
+	}
+
+	@Test
+	public void create() {
+		RoleTO roleTO = new RoleTO();
+		roleTO.setName("lastRole");
+		roleTO.setParent(8L);
+
+		// verify inheritance password and account policies
+		roleTO.setInheritAccountPolicy(false);
+		// not inherited so setter execution shouldn't be ignored
+		roleTO.setAccountPolicy(6L);
+
+		roleTO.setInheritPasswordPolicy(true);
+		// inherited so setter execution should be ignored
+		roleTO.setPasswordPolicy(2L);
+
+		roleTO.addAttribute(attributeTO("icon", "anIcon"));
+
+		roleTO.addDerivedAttribute(attributeTO("ownerDN", null));
+
+		roleTO.addVirtualAttribute(attributeTO("rvirtualdata", "rvirtualvalue"));
+
+		roleTO.setRoleOwner(8L);
+
+		roleTO.addResource("resource-ldap");
+
+		roleTO = roleService.create(roleTO);
+		assertNotNull(roleTO);
+
+		assertNotNull(roleTO.getVirtualAttributeMap());
+		assertNotNull(roleTO.getVirtualAttributeMap().get("rvirtualdata")
+				.getValues());
+		assertFalse(roleTO.getVirtualAttributeMap().get("rvirtualdata")
+				.getValues().isEmpty());
+		assertEquals("rvirtualvalue",
+				roleTO.getVirtualAttributeMap().get("rvirtualdata").getValues()
+						.get(0));
+
+		assertNotNull(roleTO.getAccountPolicy());
+		assertEquals(6L, (long) roleTO.getAccountPolicy());
+
+		assertNotNull(roleTO.getPasswordPolicy());
+		assertEquals(4L, (long) roleTO.getPasswordPolicy());
+
+		assertTrue(roleTO.getResources().contains("resource-ldap"));
+
+		ConnObjectTO connObjectTO = restTemplate.getForObject(BASE_URL
+				+ "/resource/resource-ldap/read/ROLE/lastRole.json",
+				ConnObjectTO.class);
+		assertNotNull(connObjectTO);
+		assertNotNull(connObjectTO.getAttributeMap().get("owner"));
+	}
+
+	@Test
+	public void createWithPasswordPolicy() {
+		RoleTO roleTO = new RoleTO();
+		roleTO.setName("roleWithPassword");
+		roleTO.setParent(8L);
+		roleTO.setPasswordPolicy(4L);
+
+		RoleTO actual = roleService.create(roleTO);
+		assertNotNull(actual);
+
+		actual = roleService.read(actual.getId());
+		assertNotNull(actual);
+		assertNotNull(actual.getPasswordPolicy());
+		assertEquals(4L, (long) actual.getPasswordPolicy());
+	}
+
+	@Test
+	public void delete() {
+		try {
+			roleService.delete(0L);
+		} catch (HttpStatusCodeException e) {
+			assertEquals(HttpStatus.NOT_FOUND, e.getStatusCode());
+		}
+
+		RoleTO roleTO = new RoleTO();
+		roleTO.setName("toBeDeleted");
+		roleTO.setParent(8L);
+
+		roleTO.addResource("resource-ldap");
+
+		roleTO = roleService.create(roleTO);
+		assertNotNull(roleTO);
+
+		RoleTO deletedRole = roleService.delete(roleTO.getId());
+		assertNotNull(deletedRole);
+
+		try {
+			roleService.read(deletedRole.getId());
+		} catch (HttpStatusCodeException e) {
+			assertEquals(HttpStatus.NOT_FOUND, e.getStatusCode());
+		}
+	}
+
+	@Test
+	public void list() {
+		List<RoleTO> roleTOs = roleService.list();
+		assertNotNull(roleTOs);
+		assertTrue(roleTOs.size() >= 8);
+		for (RoleTO roleTO : roleTOs) {
+			assertNotNull(roleTO);
+		}
+	}
+
+	@Test
+	public void parent() {
+		RoleTO roleTO = roleService.parent(7L);
+
+		assertNotNull(roleTO);
+		assertEquals(roleTO.getId(), 6L);
+	}
+
+	@Test
+	public void read() {
+		RoleTO roleTO = roleService.read(1L);
+
+		assertNotNull(roleTO);
+		assertNotNull(roleTO.getAttributes());
+		assertFalse(roleTO.getAttributes().isEmpty());
+	}
+
+	@Test
+	public void selfRead() {
+		UserTO userTO = userService.read(1L);
+		assertNotNull(userTO);
+
+		assertTrue(userTO.getMembershipMap().containsKey(1L));
+		assertFalse(userTO.getMembershipMap().containsKey(3L));
+
+		PreemptiveAuthHttpRequestFactory requestFactory = (PreemptiveAuthHttpRequestFactory) restTemplate
+				.getRequestFactory();
+		((DefaultHttpClient) requestFactory.getHttpClient())
+				.getCredentialsProvider().setCredentials(
+						requestFactory.getAuthScope(),
+						new UsernamePasswordCredentials("user1", "password"));
+
+		SyncopeClientException exception = null;
+		try {
+			roleService.selfRead(3L);
+			fail();
+		} catch (SyncopeClientCompositeErrorException e) {
+			exception = e
+					.getException(SyncopeClientExceptionType.UnauthorizedRole);
+		}
+		assertNotNull(exception);
+
+		RoleTO roleTO = roleService.selfRead(1L);
+		assertNotNull(roleTO);
+		assertNotNull(roleTO.getAttributes());
+		assertFalse(roleTO.getAttributes().isEmpty());
+
+		// restore admin authentication
+		super.resetRestTemplate();
+	}
+
+	@Test
+	public void update() {
+		RoleTO roleTO = new RoleTO();
+		roleTO.setName("latestRole");
+		roleTO.setParent(8L);
+
+		// verify inheritance password and account policies
+		roleTO.setInheritAccountPolicy(false);
+		// not inherited so setter execution shouldn't be ignored
+		roleTO.setAccountPolicy(6L);
+
+		roleTO.setInheritPasswordPolicy(true);
+		// inherited so setter execution should be ignored
+		roleTO.setPasswordPolicy(2L);
+
+		roleTO.addAttribute(attributeTO("icon", "anIcon"));
+
+		roleTO.addResource("resource-ldap");
+
+		roleTO = roleService.create(roleTO);
+
+		assertEquals(1, roleTO.getAttributes().size());
+
+		assertNotNull(roleTO.getAccountPolicy());
+		assertEquals(Long.valueOf(6), roleTO.getAccountPolicy());
+
+		assertNotNull(roleTO.getPasswordPolicy());
+		assertEquals(Long.valueOf(4), roleTO.getPasswordPolicy());
+
+		RoleMod roleMod = new RoleMod();
+		roleMod.setId(roleTO.getId());
+		roleMod.setName("finalRole");
+		roleMod.addAttributeToBeUpdated(attributeMod("show", "FALSE"));
+
+		// change password policy inheritance
+		roleMod.setInheritPasswordPolicy(Boolean.FALSE);
+
+		roleTO = roleService.update(roleMod.getId(), roleMod);
+
+		assertEquals("finalRole", roleTO.getName());
+		assertEquals(2, roleTO.getAttributes().size());
+
+		// changes ignored because not requested (null ReferenceMod)
+		assertNotNull(roleTO.getAccountPolicy());
+		assertEquals(6L, (long) roleTO.getAccountPolicy());
+
+		// password policy null because not inherited
+		assertNull(roleTO.getPasswordPolicy());
+	}
+
+	@Test
+	public void updateRemovingVirAttribute() {
+		RoleTO roleTO = new RoleTO();
+		roleTO.setName("withvirtual");
+		roleTO.setParent(8L);
+		roleTO.addVirtualAttribute(attributeTO("rvirtualdata", null));
+
+		roleTO = roleService.create(roleTO);
+
+		assertNotNull(roleTO);
+		assertEquals(1, roleTO.getVirtualAttributes().size());
+
+		final RoleMod roleMod = new RoleMod();
+		roleMod.setId(roleTO.getId());
+		roleMod.addVirtualAttributeToBeRemoved("rvirtualdata");
+
+		roleTO = roleService.update(roleMod.getId(), roleMod);
+
+		assertNotNull(roleTO);
+		assertTrue(roleTO.getVirtualAttributes().isEmpty());
+	}
+
+	@Test
+	public void updateRemovingDerAttribute() {
+		RoleTO roleTO = new RoleTO();
+		roleTO.setName("withderived");
+		roleTO.setParent(8L);
+		roleTO.addDerivedAttribute(attributeTO("rderivedschema", null));
+
+		roleTO = roleService.create(roleTO);
+
+		assertNotNull(roleTO);
+		assertEquals(1, roleTO.getDerivedAttributes().size());
+
+		final RoleMod roleMod = new RoleMod();
+		roleMod.setId(roleTO.getId());
+		roleMod.addDerivedAttributeToBeRemoved("rderivedschema");
+
+		roleTO = roleService.update(roleMod.getId(), roleMod);
+
+		assertNotNull(roleTO);
+		assertTrue(roleTO.getDerivedAttributes().isEmpty());
+	}
+
+	@Test
+	public void updateAsRoleOwner() {
+		// 1. read role as admin
+		RoleTO roleTO = roleService.read(7L);
+
+		// 2. prepare update
+		RoleMod roleMod = new RoleMod();
+		roleMod.setId(roleTO.getId());
+		roleMod.setName("Managing Director");
+
+		// 3. try to update as user3, not owner of role 7 - fail
+		PreemptiveAuthHttpRequestFactory requestFactory = (PreemptiveAuthHttpRequestFactory) restTemplate
+				.getRequestFactory();
+		((DefaultHttpClient) requestFactory.getHttpClient())
+				.getCredentialsProvider().setCredentials(
+						requestFactory.getAuthScope(),
+						new UsernamePasswordCredentials("user2", "password"));
+
+		try {
+			roleService.update(roleMod.getId(), roleMod);
+			fail();
+		} catch (HttpStatusCodeException e) {
+			assertEquals(HttpStatus.FORBIDDEN, e.getStatusCode());
+		}
+
+		// 4. update as user5, owner of role 7 because owner of role 6 with
+		// inheritance - success
+		((DefaultHttpClient) requestFactory.getHttpClient())
+				.getCredentialsProvider().setCredentials(
+						requestFactory.getAuthScope(),
+						new UsernamePasswordCredentials("user5", "password"));
+
+		roleTO = roleService.update(roleMod.getId(), roleMod);
+		assertEquals("Managing Director", roleTO.getName());
+
+		// restore admin authentication
+		super.resetRestTemplate();
+	}
+
+	/**
+	 * Role rename used to fail in case of parent null.
+	 * 
+	 * http://code.google.com/p/syncope/issues/detail?id=178
+	 */
+	@Test
+	public void issue178() {
+		RoleTO roleTO = new RoleTO();
+		roleTO.setName("torename");
+
+		RoleTO actual = roleService.create(roleTO);
+
+		assertNotNull(actual);
+		assertEquals("torename", actual.getName());
+		assertEquals(0L, actual.getParent());
+
+		RoleMod roleMod = new RoleMod();
+		roleMod.setId(actual.getId());
+		roleMod.setName("renamed");
+
+		actual = roleService.update(roleMod.getId(), roleMod);;
+
+		assertNotNull(actual);
+		assertEquals("renamed", actual.getName());
+		assertEquals(0L, actual.getParent());
+	}
+
+	@Test
+	public void issueSYNCOPE228() {
+		RoleTO roleTO = new RoleTO();
+		roleTO.setName("issueSYNCOPE228");
+		roleTO.setParent(8L);
+		roleTO.setInheritAccountPolicy(false);
+		roleTO.setAccountPolicy(6L);
+		roleTO.setInheritPasswordPolicy(true);
+		roleTO.setPasswordPolicy(2L);
+		roleTO.addAttribute(attributeTO("icon", "anIcon"));
+		roleTO.addEntitlement("USER_READ");
+		roleTO.addEntitlement("SCHEMA_READ");
+
+		roleTO = roleService.create(roleTO);
+		assertNotNull(roleTO);
+		assertNotNull(roleTO.getEntitlements());
+		assertFalse(roleTO.getEntitlements().isEmpty());
+
+		List<String> entitlements = roleTO.getEntitlements();
+
+		RoleMod roleMod = new RoleMod();
+		roleMod.setId(roleTO.getId());
+		roleMod.setInheritDerivedAttributes(Boolean.TRUE);
+
+		roleTO = roleService.update(roleMod.getId(), roleMod);
+		assertNotNull(roleTO);
+		assertEquals(entitlements, roleTO.getEntitlements());
+
+		roleMod = new RoleMod();
+		roleMod.setId(roleTO.getId());
+		roleMod.setEntitlements(new ArrayList<String>());
+
+		roleTO = roleService.update(roleMod.getId(), roleMod);
+		assertNotNull(roleTO);
+		assertTrue(roleTO.getEntitlements().isEmpty());
+	}
 }

Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/SearchTestITCase.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/SearchTestITCase.java?rev=1427826&r1=1427825&r2=1427826&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/SearchTestITCase.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/SearchTestITCase.java Wed
Jan  2 15:37:37 2013
@@ -18,12 +18,15 @@
  */
 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 java.util.Arrays;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
+
 import org.apache.syncope.client.search.AttributableCond;
 import org.apache.syncope.client.search.AttributeCond;
 import org.apache.syncope.client.search.EntitlementCond;
@@ -117,8 +120,7 @@ public class SearchTestITCase extends Ab
 
         assertTrue(searchCondition.isValid());
 
-        final List<RoleTO> matchingRoles = Arrays.asList(restTemplate.postForObject(BASE_URL
+ "role/search",
-                searchCondition, RoleTO[].class));
+        final List<RoleTO> matchingRoles = roleService.search(searchCondition);
 
         assertNotNull(matchingRoles);
         assertEquals(1, matchingRoles.size());
@@ -210,8 +212,7 @@ public class SearchTestITCase extends Ab
 
         final NodeCond searchCondition = NodeCond.getLeafCond(cond);
 
-        final List<RoleTO> matchingRoles = Arrays.asList(restTemplate.postForObject(BASE_URL
+ "role/search",
-                searchCondition, RoleTO[].class));
+        final List<RoleTO> matchingRoles = roleService.search(searchCondition);
         assertNotNull(matchingRoles);
         assertFalse(matchingRoles.isEmpty());
     }
@@ -228,8 +229,7 @@ public class SearchTestITCase extends Ab
                 NodeCond.getLeafCond(userReadcond));
         assertTrue(searchCondition.isValid());
 
-        final List<RoleTO> matchingRoles = Arrays.asList(restTemplate.postForObject(BASE_URL
+ "role/search",
-                searchCondition, RoleTO[].class));
+        final List<RoleTO> matchingRoles = roleService.search(searchCondition);
         assertNotNull(matchingRoles);
         assertFalse(matchingRoles.isEmpty());
     }
@@ -248,8 +248,7 @@ public class SearchTestITCase extends Ab
 
         assertTrue(searchCondition.isValid());
 
-        final List<RoleTO> matchingRoles = Arrays.asList(restTemplate.postForObject(BASE_URL
+ "role/search",
-                searchCondition, RoleTO[].class));
+        final List<RoleTO> matchingRoles = roleService.search(searchCondition);
 
         assertNotNull(matchingRoles);
         assertEquals(1, matchingRoles.size());



Mime
View raw message