You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by il...@apache.org on 2016/01/26 13:04:39 UTC
[08/21] syncope git commit: [SYNCOPE-152] Moving console IT under
fit/core-reference in order to speed-up the total build time
http://git-wip-us.apache.org/repos/asf/syncope/blob/17d5d892/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/ResourceITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/ResourceITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/ResourceITCase.java
deleted file mode 100644
index f2c940c..0000000
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/ResourceITCase.java
+++ /dev/null
@@ -1,696 +0,0 @@
-/*
- * 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.fit.core.reference;
-
-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.security.AccessControlException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import javax.ws.rs.core.Response;
-import org.apache.commons.collections4.CollectionUtils;
-import org.apache.commons.collections4.Transformer;
-import org.apache.syncope.common.lib.SyncopeClientException;
-import org.apache.syncope.common.lib.to.BulkAction;
-import org.apache.syncope.common.lib.to.ConnObjectTO;
-import org.apache.syncope.common.lib.to.GroupTO;
-import org.apache.syncope.common.lib.to.MappingItemTO;
-import org.apache.syncope.common.lib.to.MappingTO;
-import org.apache.syncope.common.lib.to.PagedConnObjectTOResult;
-import org.apache.syncope.common.lib.to.ProvisionTO;
-import org.apache.syncope.common.lib.to.ResourceTO;
-import org.apache.syncope.common.lib.types.AnyTypeKind;
-import org.apache.syncope.common.lib.types.ClientExceptionType;
-import org.apache.syncope.common.lib.types.ConnConfPropSchema;
-import org.apache.syncope.common.lib.types.ConnConfProperty;
-import org.apache.syncope.common.lib.types.EntityViolationType;
-import org.apache.syncope.common.lib.types.IntMappingType;
-import org.apache.syncope.common.lib.types.MappingPurpose;
-import org.apache.syncope.common.rest.api.beans.ConnObjectTOListQuery;
-import org.apache.syncope.common.rest.api.service.ResourceService;
-import org.identityconnectors.framework.common.objects.ObjectClass;
-import org.junit.FixMethodOrder;
-import org.junit.Test;
-import org.junit.runners.MethodSorters;
-
-@FixMethodOrder(MethodSorters.JVM)
-public class ResourceITCase extends AbstractITCase {
-
- private ResourceTO buildResourceTO(final String resourceName) {
- ResourceTO resourceTO = new ResourceTO();
-
- resourceTO.setKey(resourceName);
- resourceTO.setConnector(102L);
-
- ProvisionTO provisionTO = new ProvisionTO();
- provisionTO.setAnyType(AnyTypeKind.USER.name());
- provisionTO.setObjectClass(ObjectClass.ACCOUNT_NAME);
- resourceTO.getProvisions().add(provisionTO);
-
- MappingTO mapping = new MappingTO();
- provisionTO.setMapping(mapping);
-
- MappingItemTO item = new MappingItemTO();
- item.setExtAttrName("userId");
- item.setIntAttrName("userId");
- item.setIntMappingType(IntMappingType.UserPlainSchema);
- item.setPurpose(MappingPurpose.BOTH);
- mapping.add(item);
-
- item = new MappingItemTO();
- item.setExtAttrName("username");
- item.setIntAttrName("fullname");
- item.setIntMappingType(IntMappingType.UserKey);
- item.setPurpose(MappingPurpose.BOTH);
- mapping.setConnObjectKeyItem(item);
-
- item = new MappingItemTO();
- item.setExtAttrName("fullname");
- item.setIntAttrName("cn");
- item.setIntMappingType(IntMappingType.UserPlainSchema);
- item.setConnObjectKey(false);
- item.setPurpose(MappingPurpose.BOTH);
- mapping.add(item);
-
- return resourceTO;
- }
-
- @Test
- public void getPropagationActionsClasses() {
- Set<String> actions = syncopeService.info().getPropagationActions();
- assertNotNull(actions);
- assertFalse(actions.isEmpty());
- }
-
- @Test
- public void create() {
- String resourceName = RESOURCE_NAME_CREATE;
- ResourceTO resourceTO = buildResourceTO(resourceName);
-
- Response response = resourceService.create(resourceTO);
- ResourceTO actual = getObject(response.getLocation(), ResourceService.class, ResourceTO.class);
- assertNotNull(actual);
-
- // check for existence
- actual = resourceService.read(resourceName);
- assertNotNull(actual);
- }
-
- @Test
- public void createOverridingProps() {
- String resourceName = "overriding-conn-conf-target-resource-create";
- ResourceTO resourceTO = new ResourceTO();
-
- ProvisionTO provisionTO = new ProvisionTO();
- provisionTO.setAnyType(AnyTypeKind.USER.name());
- provisionTO.setObjectClass(ObjectClass.ACCOUNT_NAME);
- resourceTO.getProvisions().add(provisionTO);
-
- MappingTO mapping = new MappingTO();
- provisionTO.setMapping(mapping);
-
- MappingItemTO item = new MappingItemTO();
- item.setExtAttrName("uid");
- item.setIntAttrName("userId");
- item.setIntMappingType(IntMappingType.UserPlainSchema);
- item.setPurpose(MappingPurpose.BOTH);
- mapping.add(item);
-
- item = new MappingItemTO();
- item.setExtAttrName("username");
- item.setIntAttrName("fullname");
- item.setIntMappingType(IntMappingType.UserKey);
- item.setConnObjectKey(true);
- item.setPurpose(MappingPurpose.BOTH);
- mapping.setConnObjectKeyItem(item);
-
- item = new MappingItemTO();
- item.setExtAttrName("fullname");
- item.setIntAttrName("cn");
- item.setIntMappingType(IntMappingType.UserPlainSchema);
- item.setConnObjectKey(false);
- item.setPurpose(MappingPurpose.BOTH);
- mapping.add(item);
-
- resourceTO.setKey(resourceName);
- resourceTO.setConnector(102L);
-
- ConnConfProperty prop = new ConnConfProperty();
- ConnConfPropSchema schema = new ConnConfPropSchema();
- schema.setType("java.lang.String");
- schema.setName("endpoint");
- schema.setRequired(true);
- prop.setSchema(schema);
- prop.getValues().add("http://invalidurl/");
-
- Set<ConnConfProperty> connectorConfigurationProperties = new HashSet<>(Arrays.asList(prop));
- resourceTO.getConfOverride().addAll(connectorConfigurationProperties);
-
- Response response = resourceService.create(resourceTO);
- ResourceTO actual = getObject(response.getLocation(), ResourceService.class, ResourceTO.class);
- assertNotNull(actual);
-
- // check the existence
- actual = resourceService.read(resourceName);
- assertNotNull(actual);
- }
-
- @Test
- public void createWithSingleMappingItem() {
- String resourceName = RESOURCE_NAME_CREATE_SINGLE;
- ResourceTO resourceTO = new ResourceTO();
- resourceTO.setKey(resourceName);
- resourceTO.setConnector(102L);
-
- ProvisionTO provisionTO = new ProvisionTO();
- provisionTO.setAnyType(AnyTypeKind.USER.name());
- provisionTO.setObjectClass(ObjectClass.ACCOUNT_NAME);
- resourceTO.getProvisions().add(provisionTO);
-
- MappingTO mapping = new MappingTO();
- provisionTO.setMapping(mapping);
-
- MappingItemTO item = new MappingItemTO();
- item.setIntMappingType(IntMappingType.UserKey);
- item.setExtAttrName("userId");
- item.setConnObjectKey(true);
- item.setPurpose(MappingPurpose.PROPAGATION);
- mapping.setConnObjectKeyItem(item);
-
- provisionTO = new ProvisionTO();
- provisionTO.setAnyType(AnyTypeKind.GROUP.name());
- provisionTO.setObjectClass(ObjectClass.GROUP_NAME);
- resourceTO.getProvisions().add(provisionTO);
-
- mapping = new MappingTO();
- provisionTO.setMapping(mapping);
- item = new MappingItemTO();
- item.setIntMappingType(IntMappingType.GroupKey);
- item.setExtAttrName("groupId");
- item.setConnObjectKey(true);
- item.setPurpose(MappingPurpose.SYNCHRONIZATION);
- mapping.setConnObjectKeyItem(item);
-
- Response response = resourceService.create(resourceTO);
- ResourceTO actual = getObject(response.getLocation(), ResourceService.class, ResourceTO.class);
-
- assertNotNull(actual);
- assertNotNull(actual.getProvision(AnyTypeKind.USER.name()).getMapping());
- assertNotNull(actual.getProvision(AnyTypeKind.USER.name()).getMapping().getItems());
- assertNotNull(actual.getProvision(AnyTypeKind.GROUP.name()).getMapping());
- assertNotNull(actual.getProvision(AnyTypeKind.GROUP.name()).getMapping().getItems());
- assertEquals(MappingPurpose.SYNCHRONIZATION,
- actual.getProvision(AnyTypeKind.GROUP.name()).getMapping().getConnObjectKeyItem().getPurpose());
- assertEquals(MappingPurpose.PROPAGATION,
- actual.getProvision(AnyTypeKind.USER.name()).getMapping().getConnObjectKeyItem().getPurpose());
- }
-
- @Test
- public void createWithInvalidMapping() {
- String resourceName = RESOURCE_NAME_CREATE_WRONG;
- ResourceTO resourceTO = new ResourceTO();
- resourceTO.setKey(resourceName);
- resourceTO.setConnector(102L);
-
- ProvisionTO provisionTO = new ProvisionTO();
- provisionTO.setAnyType(AnyTypeKind.USER.name());
- provisionTO.setObjectClass(ObjectClass.ACCOUNT_NAME);
- resourceTO.getProvisions().add(provisionTO);
-
- MappingTO mapping = new MappingTO();
- provisionTO.setMapping(mapping);
-
- MappingItemTO item = new MappingItemTO();
- item.setIntMappingType(IntMappingType.UserKey);
- item.setExtAttrName("userId");
- item.setConnObjectKey(true);
- mapping.setConnObjectKeyItem(item);
-
- item = new MappingItemTO();
- item.setIntMappingType(IntMappingType.UserPlainSchema);
- item.setExtAttrName("email");
- // missing intAttrName ...
- mapping.add(item);
-
- try {
- createResource(resourceTO);
- fail("Create should not have worked");
- } catch (SyncopeClientException e) {
- assertEquals(ClientExceptionType.RequiredValuesMissing, e.getType());
- assertEquals("intAttrName", e.getElements().iterator().next());
- }
- }
-
- @Test(expected = SyncopeClientException.class)
- public void createWithoutExtAttr() {
- String resourceName = RESOURCE_NAME_CREATE_WRONG;
- ResourceTO resourceTO = new ResourceTO();
- resourceTO.setKey(resourceName);
- resourceTO.setConnector(102L);
-
- ProvisionTO provisionTO = new ProvisionTO();
- provisionTO.setAnyType(AnyTypeKind.USER.name());
- provisionTO.setObjectClass(ObjectClass.ACCOUNT_NAME);
- resourceTO.getProvisions().add(provisionTO);
-
- MappingTO mapping = new MappingTO();
- provisionTO.setMapping(mapping);
-
- MappingItemTO item = new MappingItemTO();
- item.setIntMappingType(IntMappingType.UserKey);
- item.setExtAttrName("userId");
- item.setConnObjectKey(true);
- mapping.setConnObjectKeyItem(item);
-
- item = new MappingItemTO();
- item.setIntMappingType(IntMappingType.UserPlainSchema);
- item.setIntAttrName("usernane");
- // missing extAttrName ...
- mapping.add(item);
-
- createResource(resourceTO);
- }
-
- @Test
- public void createWithPasswordPolicy() {
- String resourceName = "res-with-password-policy";
- ResourceTO resourceTO = new ResourceTO();
- resourceTO.setKey(resourceName);
- resourceTO.setConnector(102L);
- resourceTO.setPasswordPolicy(4L);
-
- ProvisionTO provisionTO = new ProvisionTO();
- provisionTO.setAnyType(AnyTypeKind.USER.name());
- provisionTO.setObjectClass(ObjectClass.ACCOUNT_NAME);
- resourceTO.getProvisions().add(provisionTO);
-
- MappingTO mapping = new MappingTO();
- provisionTO.setMapping(mapping);
-
- MappingItemTO item = new MappingItemTO();
- item.setExtAttrName("userId");
- item.setIntAttrName("userId");
- item.setIntMappingType(IntMappingType.UserPlainSchema);
- item.setConnObjectKey(true);
- item.setPurpose(MappingPurpose.BOTH);
- mapping.setConnObjectKeyItem(item);
-
- Response response = resourceService.create(resourceTO);
- ResourceTO actual = getObject(response.getLocation(), ResourceService.class, ResourceTO.class);
- assertNotNull(actual);
-
- // check the existence
- actual = resourceService.read(resourceName);
- assertNotNull(actual);
- assertNotNull(actual.getPasswordPolicy());
- assertEquals(4L, (long) actual.getPasswordPolicy());
- }
-
- @Test
- public void updateWithException() {
- try {
- ResourceTO resourceTO = new ResourceTO();
- resourceTO.setKey("resourcenotfound");
- resourceService.update(resourceTO);
-
- fail();
- } catch (SyncopeClientException e) {
- assertEquals(Response.Status.NOT_FOUND, e.getType().getResponseStatus());
- }
- }
-
- @Test
- public void update() {
- String resourceName = RESOURCE_NAME_UPDATE;
- ResourceTO resourceTO = new ResourceTO();
- resourceTO.setKey(resourceName);
- resourceTO.setConnector(101L);
-
- ProvisionTO provisionTO = new ProvisionTO();
- provisionTO.setAnyType(AnyTypeKind.USER.name());
- provisionTO.setObjectClass(ObjectClass.ACCOUNT_NAME);
- resourceTO.getProvisions().add(provisionTO);
-
- MappingTO mapping = new MappingTO();
- provisionTO.setMapping(mapping);
-
- // Update with an existing and already assigned mapping
- MappingItemTO item = new MappingItemTO();
- item.setKey(112L);
- item.setExtAttrName("test3");
- item.setIntAttrName("fullname");
- item.setIntMappingType(IntMappingType.UserPlainSchema);
- item.setPurpose(MappingPurpose.BOTH);
- mapping.add(item);
-
- // Update defining new mappings
- for (int i = 4; i < 6; i++) {
- item = new MappingItemTO();
- item.setExtAttrName("test" + i);
- item.setIntAttrName("fullname");
- item.setIntMappingType(IntMappingType.UserPlainSchema);
- item.setPurpose(MappingPurpose.BOTH);
- mapping.add(item);
- }
- item = new MappingItemTO();
- item.setExtAttrName("username");
- item.setIntAttrName("fullname");
- item.setIntMappingType(IntMappingType.UserKey);
- item.setConnObjectKey(true);
- item.setPurpose(MappingPurpose.BOTH);
- mapping.setConnObjectKeyItem(item);
-
- resourceService.update(resourceTO);
- ResourceTO actual = resourceService.read(resourceTO.getKey());
- assertNotNull(actual);
-
- // check for existence
- Collection<MappingItemTO> mapItems = actual.getProvision(AnyTypeKind.USER.name()).getMapping().getItems();
- assertNotNull(mapItems);
- assertEquals(4, mapItems.size());
- }
-
- @Test
- public void deleteWithException() {
- try {
- resourceService.delete("resourcenotfound");
- fail();
- } catch (SyncopeClientException e) {
- assertEquals(Response.Status.NOT_FOUND, e.getType().getResponseStatus());
- }
- }
-
- @Test
- public void updateResetSyncToken() {
- // create resource with sync token
- String resourceName = RESOURCE_NAME_RESETSYNCTOKEN + getUUIDString();
- ResourceTO pre = buildResourceTO(resourceName);
-
- pre.getProvision(AnyTypeKind.USER.name()).setSyncToken("test");
- resourceService.create(pre);
-
- pre.getProvision(AnyTypeKind.USER.name()).setSyncToken(null);
- resourceService.update(pre);
- ResourceTO actual = resourceService.read(pre.getKey());
- // check that the synctoken has been reset
- assertNull(actual.getProvision(AnyTypeKind.USER.name()).getSyncToken());
- }
-
- @Test
- public void delete() {
- String resourceName = "tobedeleted";
-
- ResourceTO resource = buildResourceTO(resourceName);
- Response response = resourceService.create(resource);
- ResourceTO actual = getObject(response.getLocation(), ResourceService.class, ResourceTO.class);
- assertNotNull(actual);
-
- resourceService.delete(resourceName);
-
- try {
- resourceService.read(resourceName);
- fail();
- } catch (SyncopeClientException e) {
- assertEquals(Response.Status.NOT_FOUND, e.getType().getResponseStatus());
- }
- }
-
- @Test
- public void list() {
- List<ResourceTO> actuals = resourceService.list();
- assertNotNull(actuals);
- assertFalse(actuals.isEmpty());
- for (ResourceTO resourceTO : actuals) {
- assertNotNull(resourceTO);
- }
- }
-
- @Test
- public void read() {
- ResourceTO resource = resourceService.read(RESOURCE_NAME_DBVIRATTR);
- assertNotNull(resource);
-
- ProvisionTO provision = resource.getProvision(AnyTypeKind.USER.name());
- assertNotNull(provision);
- assertFalse(provision.getMapping().getItems().isEmpty());
- assertFalse(provision.getMapping().getLinkingItems().isEmpty());
- }
-
- @Test
- public void issueSYNCOPE323() {
- ResourceTO actual = resourceService.read(RESOURCE_NAME_TESTDB);
- assertNotNull(actual);
-
- try {
- createResource(actual);
- fail();
- } catch (SyncopeClientException e) {
- assertEquals(Response.Status.CONFLICT, e.getType().getResponseStatus());
- assertEquals(ClientExceptionType.EntityExists, e.getType());
- }
-
- actual.setKey(null);
- try {
- createResource(actual);
- fail();
- } catch (SyncopeClientException e) {
- assertEquals(Response.Status.BAD_REQUEST, e.getType().getResponseStatus());
- assertEquals(ClientExceptionType.RequiredValuesMissing, e.getType());
- }
- }
-
- @Test
- public void bulkAction() {
- resourceService.create(buildResourceTO("forBulk1"));
- resourceService.create(buildResourceTO("forBulk2"));
-
- assertNotNull(resourceService.read("forBulk1"));
- assertNotNull(resourceService.read("forBulk2"));
-
- final BulkAction bulkAction = new BulkAction();
- bulkAction.setType(BulkAction.Type.DELETE);
-
- bulkAction.getTargets().add(String.valueOf("forBulk1"));
- bulkAction.getTargets().add(String.valueOf("forBulk2"));
-
- resourceService.bulk(bulkAction);
-
- try {
- resourceService.read("forBulk1");
- fail();
- } catch (SyncopeClientException e) {
- }
-
- try {
- resourceService.read("forBulk2");
- fail();
- } catch (SyncopeClientException e) {
- }
- }
-
- @Test
- public void anonymous() {
- ResourceService unauthenticated = clientFactory.create().getService(ResourceService.class);
- try {
- unauthenticated.list();
- fail();
- } catch (AccessControlException e) {
- assertNotNull(e);
- }
-
- ResourceService anonymous = clientFactory.create(ANONYMOUS_UNAME, ANONYMOUS_KEY).
- getService(ResourceService.class);
- assertFalse(anonymous.list().isEmpty());
- }
-
- @Test
- public void listConnObjects() {
- List<Long> groupKeys = new ArrayList<>();
- for (int i = 0; i < 10; i++) {
- GroupTO group = GroupITCase.getSampleTO("group");
- group.getResources().add(RESOURCE_NAME_LDAP);
- group = createGroup(group).getAny();
- groupKeys.add(group.getKey());
- }
-
- int totalRead = 0;
- Set<String> read = new HashSet<>();
- try {
- ConnObjectTOListQuery.Builder builder = new ConnObjectTOListQuery.Builder().size(10);
- PagedConnObjectTOResult list;
- do {
- list = null;
-
- boolean succeeded = false;
- // needed because ApacheDS seems to randomly fail when searching with cookie
- for (int i = 0; i < 5 && !succeeded; i++) {
- try {
- list = resourceService.listConnObjects(
- RESOURCE_NAME_LDAP,
- AnyTypeKind.GROUP.name(),
- builder.build());
- succeeded = true;
- } catch (SyncopeClientException e) {
- assertEquals(ClientExceptionType.ConnectorException, e.getType());
- }
- }
- assertNotNull(list);
-
- totalRead += list.getResult().size();
- CollectionUtils.collect(list.getResult(), new Transformer<ConnObjectTO, String>() {
-
- @Override
- public String transform(final ConnObjectTO input) {
- return input.getPlainAttrMap().get("__NAME__").getValues().get(0);
- }
- }, read);
-
- if (list.getPagedResultsCookie() != null) {
- builder.pagedResultsCookie(list.getPagedResultsCookie());
- }
- } while (list.getPagedResultsCookie() != null);
-
- assertEquals(totalRead, read.size());
- assertTrue(totalRead >= 10);
- } finally {
- for (Long key : groupKeys) {
- groupService.delete(key);
- }
- }
- }
-
- @Test
- public void issueSYNCOPE360() {
- final String name = "SYNCOPE360-" + getUUIDString();
- resourceService.create(buildResourceTO(name));
-
- ResourceTO resource = resourceService.read(name);
- assertNotNull(resource);
- assertNotNull(resource.getProvision(AnyTypeKind.USER.name()).getMapping());
-
- resource.getProvision(AnyTypeKind.USER.name()).setMapping(null);
- resourceService.update(resource);
-
- resource = resourceService.read(name);
- assertNotNull(resource);
- assertNull(resource.getProvision(AnyTypeKind.USER.name()).getMapping());
- }
-
- @Test
- public void issueSYNCOPE368() {
- final String name = "SYNCOPE368-" + getUUIDString();
-
- ResourceTO resourceTO = new ResourceTO();
-
- resourceTO.setKey(name);
- resourceTO.setConnector(105L);
-
- ProvisionTO provisionTO = new ProvisionTO();
- provisionTO.setAnyType(AnyTypeKind.GROUP.name());
- provisionTO.setObjectClass(ObjectClass.GROUP_NAME);
- resourceTO.getProvisions().add(provisionTO);
-
- MappingTO mapping = new MappingTO();
- provisionTO.setMapping(mapping);
-
- MappingItemTO item = new MappingItemTO();
- item.setIntMappingType(IntMappingType.GroupName);
- item.setExtAttrName("cn");
- item.setPurpose(MappingPurpose.BOTH);
- mapping.setConnObjectKeyItem(item);
-
- item = new MappingItemTO();
- item.setIntMappingType(IntMappingType.GroupOwnerSchema);
- item.setExtAttrName("owner");
- item.setPurpose(MappingPurpose.BOTH);
- mapping.add(item);
-
- resourceTO = createResource(resourceTO);
- assertNotNull(resourceTO);
- assertEquals(2, resourceTO.getProvision(AnyTypeKind.GROUP.name()).getMapping().getItems().size());
- }
-
- @Test
- public void issueSYNCOPE418() {
- try {
- resourceService.create(
- buildResourceTO("http://schemas.examples.org/security/authorization/organizationUnit"));
- fail();
- } catch (SyncopeClientException e) {
- assertEquals(ClientExceptionType.InvalidExternalResource, e.getType());
-
- assertTrue(e.getElements().iterator().next().contains(EntityViolationType.InvalidName.name()));
- }
- }
-
- @Test
- public void issueSYNCOPE493() {
- // create resource with attribute mapping set to NONE and check its propagation
- String resourceName = RESOURCE_NAME_CREATE_NONE;
- ResourceTO resourceTO = new ResourceTO();
- resourceTO.setKey(resourceName);
- resourceTO.setConnector(102L);
-
- ProvisionTO provisionTO = new ProvisionTO();
- provisionTO.setAnyType(AnyTypeKind.USER.name());
- provisionTO.setObjectClass(ObjectClass.ACCOUNT_NAME);
- resourceTO.getProvisions().add(provisionTO);
-
- MappingTO mapping = new MappingTO();
- provisionTO.setMapping(mapping);
-
- MappingItemTO item = new MappingItemTO();
- item.setIntMappingType(IntMappingType.UserKey);
- item.setExtAttrName("userId");
- item.setConnObjectKey(true);
- item.setPurpose(MappingPurpose.PROPAGATION);
- mapping.setConnObjectKeyItem(item);
-
- MappingItemTO item2 = new MappingItemTO();
- item2.setIntMappingType(IntMappingType.UserPlainSchema);
- item2.setConnObjectKey(false);
- item2.setIntAttrName("gender");
- item2.setExtAttrName("gender");
- item2.setPurpose(MappingPurpose.NONE);
- mapping.add(item2);
-
- Response response = resourceService.create(resourceTO);
- ResourceTO actual = getObject(response.getLocation(), ResourceService.class, ResourceTO.class);
-
- assertNotNull(actual);
- assertNotNull(actual.getProvision(AnyTypeKind.USER.name()).getMapping());
- assertNotNull(actual.getProvision(AnyTypeKind.USER.name()).getMapping().getItems());
- assertEquals(MappingPurpose.PROPAGATION,
- actual.getProvision(AnyTypeKind.USER.name()).getMapping().getConnObjectKeyItem().getPurpose());
- for (MappingItemTO itemTO : actual.getProvision(AnyTypeKind.USER.name()).getMapping().getItems()) {
- if ("gender".equals(itemTO.getIntAttrName())) {
- assertEquals(MappingPurpose.NONE, itemTO.getPurpose());
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/17d5d892/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/RoleITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/RoleITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/RoleITCase.java
deleted file mode 100644
index e7787e0..0000000
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/RoleITCase.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * 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.fit.core.reference;
-
-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.util.List;
-import javax.ws.rs.core.Response;
-import org.apache.syncope.common.lib.SyncopeClientException;
-import org.apache.syncope.common.lib.SyncopeConstants;
-import org.apache.syncope.common.lib.to.RoleTO;
-import org.apache.syncope.common.lib.types.ClientExceptionType;
-import org.apache.syncope.common.lib.types.StandardEntitlement;
-import org.apache.syncope.common.rest.api.service.RoleService;
-import org.junit.FixMethodOrder;
-import org.junit.Test;
-import org.junit.runners.MethodSorters;
-
-@FixMethodOrder(MethodSorters.JVM)
-public class RoleITCase extends AbstractITCase {
-
- public static RoleTO getSampleRoleTO(final String name) {
- RoleTO role = new RoleTO();
- role.setKey(name + getUUIDString());
- role.getRealms().add("/even");
- role.getEntitlements().add(StandardEntitlement.LOG_SET_LEVEL);
-
- return role;
- }
-
- @Test
- public void list() {
- List<RoleTO> roleTOs = roleService.list();
- assertNotNull(roleTOs);
- assertFalse(roleTOs.isEmpty());
- for (RoleTO instance : roleTOs) {
- assertNotNull(instance);
- }
- }
-
- @Test
- public void read() {
- RoleTO roleTO = roleService.read("Search for realm evenTwo");
- assertNotNull(roleTO);
- assertTrue(roleTO.getEntitlements().contains(StandardEntitlement.USER_READ));
- }
-
- @Test
- public void create() {
- RoleTO role = new RoleTO();
- role.getRealms().add(SyncopeConstants.ROOT_REALM);
- role.getRealms().add("/even/two");
- role.getEntitlements().add(StandardEntitlement.LOG_LIST);
- role.getEntitlements().add(StandardEntitlement.LOG_SET_LEVEL);
-
- try {
- createRole(role);
- fail();
- } catch (SyncopeClientException e) {
- assertEquals(ClientExceptionType.InvalidRole, e.getType());
- }
-
- role.setKey("new" + getUUIDString());
- role = createRole(role);
- assertNotNull(role);
- }
-
- @Test
- public void update() {
- RoleTO role = getSampleRoleTO("update");
- role = createRole(role);
- assertNotNull(role);
-
- assertFalse(role.getEntitlements().contains(StandardEntitlement.WORKFLOW_TASK_LIST));
- assertFalse(role.getRealms().contains("/even/two"));
-
- role.getEntitlements().add(StandardEntitlement.WORKFLOW_TASK_LIST);
- role.getRealms().add("/even/two");
-
- roleService.update(role);
-
- role = roleService.read(role.getKey());
- assertTrue(role.getEntitlements().contains(StandardEntitlement.WORKFLOW_TASK_LIST));
- assertTrue(role.getRealms().contains("/even/two"));
- }
-
- @Test
- public void delete() {
- RoleTO role = getSampleRoleTO("delete");
- Response response = roleService.create(role);
-
- RoleTO actual = getObject(response.getLocation(), RoleService.class, RoleTO.class);
- assertNotNull(actual);
-
- roleService.delete(actual.getKey());
-
- try {
- roleService.read(actual.getKey());
- fail();
- } catch (SyncopeClientException e) {
- assertEquals(ClientExceptionType.NotFound, e.getType());
- }
- }
-
- @Test
- public void dynMembership() {
- assertTrue(userService.read(4L).getDynRoles().isEmpty());
-
- RoleTO role = getSampleRoleTO("dynMembership");
- role.setDynMembershipCond("cool==true");
- Response response = roleService.create(role);
- role = getObject(response.getLocation(), RoleService.class, RoleTO.class);
- assertNotNull(role);
-
- assertTrue(userService.read(4L).getDynRoles().contains(role.getKey()));
-
- role.setDynMembershipCond("cool==false");
- roleService.update(role);
-
- assertTrue(userService.read(4L).getDynGroups().isEmpty());
- }
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/17d5d892/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/SchedTaskITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/SchedTaskITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/SchedTaskITCase.java
deleted file mode 100644
index 8832540..0000000
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/SchedTaskITCase.java
+++ /dev/null
@@ -1,213 +0,0 @@
-/*
- * 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.fit.core.reference;
-
-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.Date;
-import java.util.List;
-import java.util.Set;
-import javax.ws.rs.core.Response;
-import org.apache.commons.lang3.time.DateUtils;
-import org.apache.syncope.common.lib.to.AbstractTaskTO;
-import org.apache.syncope.common.lib.to.PagedResult;
-import org.apache.syncope.common.lib.to.PushTaskTO;
-import org.apache.syncope.common.lib.to.SchedTaskTO;
-import org.apache.syncope.common.lib.to.SyncTaskTO;
-import org.apache.syncope.common.lib.to.TaskExecTO;
-import org.apache.syncope.common.lib.types.JobAction;
-import org.apache.syncope.common.lib.types.JobStatusType;
-import org.apache.syncope.common.lib.types.TaskType;
-import org.apache.syncope.common.rest.api.beans.ExecuteQuery;
-import org.apache.syncope.common.rest.api.beans.TaskExecQuery;
-import org.apache.syncope.common.rest.api.beans.TaskQuery;
-import org.apache.syncope.common.rest.api.service.TaskService;
-import org.junit.FixMethodOrder;
-import org.junit.Test;
-import org.junit.runners.MethodSorters;
-
-@FixMethodOrder(MethodSorters.JVM)
-public class SchedTaskITCase extends AbstractTaskITCase {
-
- @Test
- public void getJobClasses() {
- Set<String> jobClasses = syncopeService.info().getTaskJobs();
- assertNotNull(jobClasses);
- assertFalse(jobClasses.isEmpty());
- }
-
- @Test
- public void list() {
- PagedResult<SchedTaskTO> tasks =
- taskService.list(new TaskQuery.Builder().type(TaskType.SCHEDULED).build());
- assertFalse(tasks.getResult().isEmpty());
- for (AbstractTaskTO task : tasks.getResult()) {
- if (!(task instanceof SchedTaskTO) || task instanceof SyncTaskTO || task instanceof PushTaskTO) {
- fail();
- }
- }
- }
-
- @Test
- public void update() {
- SchedTaskTO task = taskService.read(SCHED_TASK_ID, true);
- assertNotNull(task);
-
- SchedTaskTO taskMod = new SchedTaskTO();
- taskMod.setKey(5L);
- taskMod.setCronExpression(null);
-
- taskService.update(taskMod);
- SchedTaskTO actual = taskService.read(taskMod.getKey(), true);
- assertNotNull(actual);
- assertEquals(task.getKey(), actual.getKey());
- assertNull(actual.getCronExpression());
- }
-
- @Test
- public void deferred() {
- SchedTaskTO task = new SchedTaskTO();
- task.setActive(true);
- task.setName("deferred");
- task.setJobDelegateClassName(TestSampleJobDelegate.class.getName());
-
- Response response = taskService.create(task);
- task = getObject(response.getLocation(), TaskService.class, SchedTaskTO.class);
- assertNotNull(task);
-
- Date initial = new Date();
- Date later = DateUtils.addSeconds(initial, 2);
-
- taskService.execute(new ExecuteQuery.Builder().key(task.getKey()).startAt(later).build());
-
- int i = 0;
- int maxit = 50;
-
- // wait for completion (executions incremented)
- do {
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- }
-
- task = taskService.read(task.getKey(), true);
-
- assertNotNull(task);
- assertNotNull(task.getExecutions());
-
- i++;
- } while (task.getExecutions().isEmpty() && i < maxit);
-
- PagedResult<TaskExecTO> execs =
- taskService.listExecutions(new TaskExecQuery.Builder().key(task.getKey()).build());
- assertEquals(1, execs.getTotalCount());
- assertTrue(execs.getResult().get(0).getStart().after(initial));
- // round 1 sec for safety
- assertTrue(DateUtils.addSeconds(execs.getResult().get(0).getStart(), 1).after(later));
- }
-
- @Test
- public void issueSYNCOPE144() {
- SchedTaskTO task = new SchedTaskTO();
- task.setName("issueSYNCOPE144");
- task.setDescription("issueSYNCOPE144 Description");
- task.setJobDelegateClassName(TestSampleJobDelegate.class.getName());
-
- Response response = taskService.create(task);
- task = getObject(response.getLocation(), TaskService.class, SchedTaskTO.class);
- assertNotNull(task);
- assertEquals("issueSYNCOPE144", task.getName());
- assertEquals("issueSYNCOPE144 Description", task.getDescription());
-
- task = taskService.read(task.getKey(), true);
- assertNotNull(task);
- assertEquals("issueSYNCOPE144", task.getName());
- assertEquals("issueSYNCOPE144 Description", task.getDescription());
-
- task.setName("issueSYNCOPE144_2");
- task.setDescription("issueSYNCOPE144 Description_2");
-
- response = taskService.create(task);
- task = getObject(response.getLocation(), TaskService.class, SchedTaskTO.class);
- assertNotNull(task);
- assertEquals("issueSYNCOPE144_2", task.getName());
- assertEquals("issueSYNCOPE144 Description_2", task.getDescription());
- }
-
- @Test
- public void issueSYNCOPE660() {
- List<TaskExecTO> list = taskService.listJobs(JobStatusType.ALL);
- int old_size = list.size();
-
- SchedTaskTO task = new SchedTaskTO();
- task.setName("issueSYNCOPE660");
- task.setDescription("issueSYNCOPE660 Description");
- task.setJobDelegateClassName(TestSampleJobDelegate.class.getName());
-
- Response response = taskService.create(task);
- task = getObject(response.getLocation(), TaskService.class, SchedTaskTO.class);
-
- list = taskService.listJobs(JobStatusType.ALL);
- assertEquals(old_size + 1, list.size());
-
- taskService.actionJob(task.getKey(), JobAction.START);
-
- int i = 0, maxit = 50;
-
- do {
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- // ignore
- }
-
- list = taskService.listJobs(JobStatusType.RUNNING);
-
- assertNotNull(list);
- i++;
- } while (list.size() < 1 && i < maxit);
-
- assertEquals(1, list.size());
- assertEquals(task.getKey(), list.get(0).getTask(), 0);
-
- taskService.actionJob(task.getKey(), JobAction.STOP);
-
- i = 0;
-
- do {
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- // ignore
- }
-
- list = taskService.listJobs(JobStatusType.RUNNING);
-
- assertNotNull(list);
- i++;
- } while (list.size() >= 1 && i < maxit);
-
- assertTrue(list.isEmpty());
- }
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/17d5d892/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/SearchITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/SearchITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/SearchITCase.java
deleted file mode 100644
index d047347..0000000
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/SearchITCase.java
+++ /dev/null
@@ -1,397 +0,0 @@
-/*
- * 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.fit.core.reference;
-
-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.Collection;
-import javax.ws.rs.core.Response;
-import org.apache.commons.collections4.CollectionUtils;
-import org.apache.commons.collections4.IterableUtils;
-import org.apache.commons.collections4.Predicate;
-import org.apache.syncope.client.lib.SyncopeClient;
-import org.apache.syncope.common.lib.SyncopeConstants;
-import org.apache.syncope.common.lib.to.AnyObjectTO;
-import org.apache.syncope.common.lib.to.PagedResult;
-import org.apache.syncope.common.lib.to.GroupTO;
-import org.apache.syncope.common.lib.to.RoleTO;
-import org.apache.syncope.common.lib.to.UserTO;
-import org.apache.syncope.common.rest.api.beans.AnySearchQuery;
-import org.apache.syncope.common.rest.api.service.RoleService;
-import org.junit.FixMethodOrder;
-import org.junit.Test;
-import org.junit.runners.MethodSorters;
-
-@FixMethodOrder(MethodSorters.JVM)
-public class SearchITCase extends AbstractITCase {
-
- @Test
- public void searchUser() {
- // LIKE
- PagedResult<UserTO> matchingUsers = userService.search(
- new AnySearchQuery.Builder().realm(SyncopeConstants.ROOT_REALM).
- fiql(SyncopeClient.getUserSearchConditionBuilder().
- is("fullname").equalTo("*o*").and("fullname").equalTo("*i*").query()).build());
- assertNotNull(matchingUsers);
- assertFalse(matchingUsers.getResult().isEmpty());
-
- for (UserTO user : matchingUsers.getResult()) {
- assertNotNull(user);
- }
-
- // ISNULL
- matchingUsers = userService.search(
- new AnySearchQuery.Builder().realm(SyncopeConstants.ROOT_REALM).
- fiql(SyncopeClient.getUserSearchConditionBuilder().isNull("loginDate").query()).build());
- assertNotNull(matchingUsers);
- assertFalse(matchingUsers.getResult().isEmpty());
-
- Collection<UserTO> found = CollectionUtils.select(matchingUsers.getResult(), new Predicate<UserTO>() {
-
- @Override
- public boolean evaluate(final UserTO user) {
- return user.getKey() == 2L || user.getKey() == 3L;
- }
- });
- assertEquals(2, found.size());
- }
-
- @Test
- public void searchByUsernameAndKey() {
- PagedResult<UserTO> matchingUsers = userService.search(
- new AnySearchQuery.Builder().realm(SyncopeConstants.ROOT_REALM).
- fiql(SyncopeClient.getUserSearchConditionBuilder().
- is("username").equalTo("rossini").and("key").lessThan(2).query()).build());
- assertNotNull(matchingUsers);
- assertEquals(1, matchingUsers.getResult().size());
- assertEquals("rossini", matchingUsers.getResult().iterator().next().getUsername());
- assertEquals(1L, matchingUsers.getResult().iterator().next().getKey(), 0);
- }
-
- @Test
- public void searchByGroupNameAndKey() {
- PagedResult<GroupTO> groups = groupService.search(
- new AnySearchQuery.Builder().realm(SyncopeConstants.ROOT_REALM).
- fiql(SyncopeClient.getGroupSearchConditionBuilder().
- is("name").equalTo("root").and("key").lessThan(2).query()).build());
- assertNotNull(groups);
- assertEquals(1, groups.getResult().size());
- assertEquals("root", groups.getResult().iterator().next().getName());
- assertEquals(1L, groups.getResult().iterator().next().getKey(), 0);
- }
-
- @Test
- public void searchByGroup() {
- PagedResult<UserTO> matchingUsers = userService.search(
- new AnySearchQuery.Builder().realm(SyncopeConstants.ROOT_REALM).
- fiql(SyncopeClient.getUserSearchConditionBuilder().inGroups(1L).query()).
- build());
- assertNotNull(matchingUsers);
- assertFalse(matchingUsers.getResult().isEmpty());
-
- assertTrue(IterableUtils.matchesAny(matchingUsers.getResult(), new Predicate<UserTO>() {
-
- @Override
- public boolean evaluate(final UserTO user) {
- return user.getKey() == 1;
- }
- }));
- }
-
- @Test
- public void searchByDynGroup() {
- GroupTO group = GroupITCase.getBasicSampleTO("dynMembership");
- group.setUDynMembershipCond("cool==true");
- group = createGroup(group).getAny();
- assertNotNull(group);
-
- PagedResult<UserTO> matchingUsers = userService.search(
- new AnySearchQuery.Builder().realm(SyncopeConstants.ROOT_REALM).
- fiql(SyncopeClient.getUserSearchConditionBuilder().inGroups(group.getKey()).query()).
- build());
- assertNotNull(matchingUsers);
- assertFalse(matchingUsers.getResult().isEmpty());
-
- assertTrue(IterableUtils.matchesAny(matchingUsers.getResult(), new Predicate<UserTO>() {
-
- @Override
- public boolean evaluate(final UserTO user) {
- return user.getKey() == 4;
- }
- }));
- }
-
- @Test
- public void searchByRole() {
- PagedResult<UserTO> matchingUsers = userService.search(
- new AnySearchQuery.Builder().realm(SyncopeConstants.ROOT_REALM).
- fiql(SyncopeClient.getUserSearchConditionBuilder().inRoles("Other").query()).
- build());
- assertNotNull(matchingUsers);
- assertFalse(matchingUsers.getResult().isEmpty());
-
- assertTrue(IterableUtils.matchesAny(matchingUsers.getResult(), new Predicate<UserTO>() {
-
- @Override
- public boolean evaluate(final UserTO user) {
- return user.getKey() == 1;
- }
- }));
- }
-
- @Test
- public void searchByDynRole() {
- RoleTO role = RoleITCase.getSampleRoleTO("dynMembership");
- role.setDynMembershipCond("cool==true");
- Response response = roleService.create(role);
- role = getObject(response.getLocation(), RoleService.class, RoleTO.class);
- assertNotNull(role);
-
- PagedResult<UserTO> matchingUsers = userService.search(
- new AnySearchQuery.Builder().realm(SyncopeConstants.ROOT_REALM).
- fiql(SyncopeClient.getUserSearchConditionBuilder().inRoles(role.getKey()).query()).
- build());
- assertNotNull(matchingUsers);
- assertFalse(matchingUsers.getResult().isEmpty());
-
- assertTrue(IterableUtils.matchesAny(matchingUsers.getResult(), new Predicate<UserTO>() {
-
- @Override
- public boolean evaluate(final UserTO user) {
- return user.getKey() == 4;
- }
- }));
- }
-
- @Test
- public void searchUserByResourceName() {
- PagedResult<UserTO> matchingUsers = userService.search(
- new AnySearchQuery.Builder().realm(SyncopeConstants.ROOT_REALM).
- fiql(SyncopeClient.getUserSearchConditionBuilder().hasResources(RESOURCE_NAME_MAPPINGS2).query()).
- build());
- assertNotNull(matchingUsers);
- assertFalse(matchingUsers.getResult().isEmpty());
-
- assertTrue(IterableUtils.matchesAny(matchingUsers.getResult(), new Predicate<UserTO>() {
-
- @Override
- public boolean evaluate(final UserTO user) {
- return user.getKey() == 2;
- }
- }));
- }
-
- @Test
- public void paginatedSearch() {
- // LIKE
- PagedResult<UserTO> matchingUsers = userService.search(
- new AnySearchQuery.Builder().realm(SyncopeConstants.ROOT_REALM).
- fiql(SyncopeClient.getUserSearchConditionBuilder().
- is("fullname").equalTo("*o*").and("fullname").equalTo("*i*").query()).page(1).size(2).build());
- assertNotNull(matchingUsers);
-
- assertFalse(matchingUsers.getResult().isEmpty());
- for (UserTO user : matchingUsers.getResult()) {
- assertNotNull(user);
- }
-
- // ISNULL
- matchingUsers = userService.search(
- new AnySearchQuery.Builder().realm(SyncopeConstants.ROOT_REALM).
- fiql(SyncopeClient.getUserSearchConditionBuilder().isNull("loginDate").query()).page(2).size(2).
- build());
- assertNotNull(matchingUsers);
- assertEquals(2, matchingUsers.getPage());
- assertEquals(2, matchingUsers.getResult().size());
- }
-
- @Test
- public void searchByBooleanAnyCond() {
- PagedResult<GroupTO> groups = groupService.search(
- new AnySearchQuery.Builder().realm(SyncopeConstants.ROOT_REALM).
- fiql(SyncopeClient.getGroupSearchConditionBuilder().is("show").equalTo("true").query()).build());
- assertNotNull(groups);
- assertFalse(groups.getResult().isEmpty());
- }
-
- @Test
- public void searchByRelationshipAnyCond() {
- PagedResult<GroupTO> groups = groupService.search(
- new AnySearchQuery.Builder().realm(SyncopeConstants.ROOT_REALM).
- fiql(SyncopeClient.getGroupSearchConditionBuilder().is("userOwner").equalTo(5).query()).build());
- assertNotNull(groups);
- assertEquals(1, groups.getResult().size());
- assertEquals(6L, groups.getResult().iterator().next().getKey(), 0);
- }
-
- @Test
- public void nested() {
- PagedResult<UserTO> matchingUsers = userService.search(
- new AnySearchQuery.Builder().realm(SyncopeConstants.ROOT_REALM).
- fiql("((fullname==*o*,fullname==*i*);$resources!=ws-target-resource-1)").page(1).size(2).build());
- assertNotNull(matchingUsers);
-
- assertFalse(matchingUsers.getResult().isEmpty());
- for (UserTO user : matchingUsers.getResult()) {
- assertNotNull(user);
- }
- }
-
- @Test
- public void searchByType() {
- PagedResult<AnyObjectTO> matching = anyObjectService.search(
- new AnySearchQuery.Builder().realm(SyncopeConstants.ROOT_REALM).
- fiql(SyncopeClient.getAnyObjectSearchConditionBuilder("PRINTER").query()).build());
- assertNotNull(matching);
-
- assertFalse(matching.getResult().isEmpty());
- for (AnyObjectTO printer : matching.getResult()) {
- assertNotNull(printer);
- }
-
- matching = anyObjectService.search(
- new AnySearchQuery.Builder().realm(SyncopeConstants.ROOT_REALM).
- fiql(SyncopeClient.getAnyObjectSearchConditionBuilder("UNEXISTING").query()).build());
- assertNotNull(matching);
-
- assertTrue(matching.getResult().isEmpty());
- }
-
- @Test
- public void searchByRelationship() {
- PagedResult<AnyObjectTO> anyObjects = anyObjectService.search(
- new AnySearchQuery.Builder().realm(SyncopeConstants.ROOT_REALM).
- fiql(SyncopeClient.getAnyObjectSearchConditionBuilder("PRINTER").
- inRelationships(2L).query()).
- build());
- assertNotNull(anyObjects);
- assertTrue(IterableUtils.matchesAny(anyObjects.getResult(), new Predicate<AnyObjectTO>() {
-
- @Override
- public boolean evaluate(final AnyObjectTO anyObject) {
- return anyObject.getKey() == 1L;
- }
- }));
-
- PagedResult<UserTO> users = userService.search(
- new AnySearchQuery.Builder().realm(SyncopeConstants.ROOT_REALM).
- fiql(SyncopeClient.getUserSearchConditionBuilder().inRelationships(1L).query()).
- build());
- assertNotNull(users);
- assertTrue(IterableUtils.matchesAny(users.getResult(), new Predicate<UserTO>() {
-
- @Override
- public boolean evaluate(final UserTO user) {
- return user.getKey() == 4L;
- }
- }));
- }
-
- @Test
- public void searchByRelationshipType() {
- PagedResult<AnyObjectTO> anyObjects = anyObjectService.search(
- new AnySearchQuery.Builder().realm(SyncopeConstants.ROOT_REALM).
- fiql(SyncopeClient.getAnyObjectSearchConditionBuilder("PRINTER").
- inRelationshipTypes("neighborhood").query()).
- build());
- assertNotNull(anyObjects);
- assertTrue(IterableUtils.matchesAny(anyObjects.getResult(), new Predicate<AnyObjectTO>() {
-
- @Override
- public boolean evaluate(final AnyObjectTO anyObject) {
- return anyObject.getKey() == 1L;
- }
- }));
- assertTrue(IterableUtils.matchesAny(anyObjects.getResult(), new Predicate<AnyObjectTO>() {
-
- @Override
- public boolean evaluate(final AnyObjectTO anyObject) {
- return anyObject.getKey() == 2L;
- }
- }));
-
- PagedResult<UserTO> users = userService.search(
- new AnySearchQuery.Builder().realm(SyncopeConstants.ROOT_REALM).
- fiql(SyncopeClient.getUserSearchConditionBuilder().inRelationshipTypes("neighborhood").query()).
- build());
- assertNotNull(users);
- assertTrue(IterableUtils.matchesAny(users.getResult(), new Predicate<UserTO>() {
-
- @Override
- public boolean evaluate(final UserTO user) {
- return user.getKey() == 4L;
- }
- }));
- }
-
- @Test
- public void assignable() {
- PagedResult<GroupTO> groups = groupService.search(
- new AnySearchQuery.Builder().realm("/even/two").page(1).size(1000).
- fiql(SyncopeClient.getGroupSearchConditionBuilder().isAssignable().
- and("name").equalTo("*").query()).
- build());
- assertNotNull(groups);
- assertTrue(IterableUtils.matchesAny(groups.getResult(), new Predicate<GroupTO>() {
-
- @Override
- public boolean evaluate(final GroupTO group) {
- return group.getKey() == 15L;
- }
- }));
- assertFalse(IterableUtils.matchesAny(groups.getResult(), new Predicate<GroupTO>() {
-
- @Override
- public boolean evaluate(final GroupTO group) {
- return group.getKey() == 16L;
- }
- }));
-
- PagedResult<AnyObjectTO> anyObjects = anyObjectService.search(
- new AnySearchQuery.Builder().realm("/odd").
- fiql(SyncopeClient.getAnyObjectSearchConditionBuilder("PRINTER").isAssignable().
- and("name").equalTo("*").query()).
- build());
- assertNotNull(anyObjects);
- assertFalse(IterableUtils.matchesAny(anyObjects.getResult(), new Predicate<AnyObjectTO>() {
-
- @Override
- public boolean evaluate(final AnyObjectTO anyObject) {
- return anyObject.getKey() == 3L;
- }
- }));
- }
-
- @Test
- public void orderBy() {
- PagedResult<UserTO> matchingUsers = userService.search(
- new AnySearchQuery.Builder().realm(SyncopeConstants.ROOT_REALM).
- fiql(SyncopeClient.getUserSearchConditionBuilder().is("userId").equalTo("*@apache.org").query()).
- orderBy(SyncopeClient.getOrderByClauseBuilder().asc("status").desc("firstname").build()).build());
- assertNotNull(matchingUsers);
-
- assertFalse(matchingUsers.getResult().isEmpty());
- for (UserTO user : matchingUsers.getResult()) {
- assertNotNull(user);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/17d5d892/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/SecurityQuestionITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/SecurityQuestionITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/SecurityQuestionITCase.java
deleted file mode 100644
index 36214c9..0000000
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/SecurityQuestionITCase.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * 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.fit.core.reference;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
-
-import java.util.List;
-import javax.ws.rs.core.Response;
-import org.apache.syncope.common.lib.SyncopeClientException;
-import org.apache.syncope.common.lib.to.SecurityQuestionTO;
-import org.apache.syncope.common.lib.types.ClientExceptionType;
-import org.apache.syncope.common.rest.api.service.SecurityQuestionService;
-import org.junit.FixMethodOrder;
-import org.junit.Test;
-import org.junit.runners.MethodSorters;
-
-@FixMethodOrder(MethodSorters.JVM)
-public class SecurityQuestionITCase extends AbstractITCase {
-
- @Test
- public void read() {
- SecurityQuestionTO securityQuestionTO = securityQuestionService.read(1L);
- assertNotNull(securityQuestionTO);
- }
-
- @Test
- public void list() {
- List<SecurityQuestionTO> securityQuestionTOs = securityQuestionService.list();
- assertNotNull(securityQuestionTOs);
- assertFalse(securityQuestionTOs.isEmpty());
- for (SecurityQuestionTO instance : securityQuestionTOs) {
- assertNotNull(instance);
- }
- }
-
- @Test
- public void create() {
- SecurityQuestionTO securityQuestionTO = new SecurityQuestionTO();
- securityQuestionTO.setContent("What is your favorite pet's name?");
-
- Response response = securityQuestionService.create(securityQuestionTO);
- SecurityQuestionTO actual = getObject(response.getLocation(), SecurityQuestionService.class,
- SecurityQuestionTO.class);
-
- assertNotNull(actual);
- assertNotNull(actual.getKey());
- securityQuestionTO.setKey(actual.getKey());
- assertEquals(actual, securityQuestionTO);
- }
-
- @Test
- public void update() {
- SecurityQuestionTO securityQuestionTO = securityQuestionService.read(1L);
- securityQuestionTO.setContent("What is your favorite color?");
-
- securityQuestionService.update(securityQuestionTO);
- SecurityQuestionTO actual = securityQuestionService.read(securityQuestionTO.getKey());
- assertNotNull(actual);
- assertEquals(actual, securityQuestionTO);
- }
-
- @Test
- public void delete() {
- SecurityQuestionTO securityQuestion = new SecurityQuestionTO();
- securityQuestion.setContent("What is your first pet's name?");
-
- Response response = securityQuestionService.create(securityQuestion);
- securityQuestion = getObject(response.getLocation(), SecurityQuestionService.class, SecurityQuestionTO.class);
-
- securityQuestionService.delete(securityQuestion.getKey());
-
- try {
- securityQuestionService.read(securityQuestion.getKey());
- fail();
- } catch (SyncopeClientException e) {
- assertEquals(ClientExceptionType.NotFound, e.getType());
- }
- }
-
-}