Reduce number of integration test cases executed by default build, moving 
time-consuming to full-it profile


Project: http://git-wip-us.apache.org/repos/asf/syncope/repo
Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/b6dfd13e
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/b6dfd13e
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/b6dfd13e

Branch: refs/heads/2_0_X
Commit: b6dfd13e2f9cf3dadcd4121a1e978a5b05bfd2a3
Parents: b1aa1cb
Author: Francesco Chicchiriccò <ilgro...@apache.org>
Authored: Mon Jun 19 16:19:14 2017 +0200
Committer: Francesco Chicchiriccò <ilgro...@apache.org>
Committed: Mon Jun 19 16:20:11 2017 +0200

----------------------------------------------------------------------
 fit/core-reference/pom.xml                      |   3 +
 .../org/apache/syncope/fit/AbstractITCase.java  |  61 +-
 .../core/AbstractNotificationTaskITCase.java    | 107 ++++
 .../syncope/fit/core/AbstractTaskITCase.java    |  41 ++
 .../apache/syncope/fit/core/GroupITCase.java    | 195 -------
 .../syncope/fit/core/GroupIssuesITCase.java     | 235 ++++++++
 .../fit/core/NotificationTaskITCase.java        | 309 +---------
 .../fit/core/NotificationTaskIssuesITCase.java  | 207 +++++++
 .../apache/syncope/fit/core/PullTaskITCase.java | 558 -------------------
 .../syncope/fit/core/PullTaskIssuesITCase.java  | 550 ++++++++++++++++++
 .../apache/syncope/fit/core/ReportITCase.java   |  64 ---
 .../syncope/fit/core/ReportIssuesITCase.java    |  90 +++
 12 files changed, 1294 insertions(+), 1126 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/syncope/blob/b6dfd13e/fit/core-reference/pom.xml
----------------------------------------------------------------------
diff --git a/fit/core-reference/pom.xml b/fit/core-reference/pom.xml
index 8aa248b..3040b95 100644
--- a/fit/core-reference/pom.xml
+++ b/fit/core-reference/pom.xml
@@ -230,6 +230,9 @@ under the License.
           <includes>
             <include>**/org/apache/syncope/fit/core/*ITCase.java</include>
           </includes>
+          <excludes>
+            <exclude>**/*IssuesITCase.java</exclude>
+          </excludes>
         </configuration>
         <executions>
           <execution>

http://git-wip-us.apache.org/repos/asf/syncope/blob/b6dfd13e/fit/core-reference/src/test/java/org/apache/syncope/fit/AbstractITCase.java
----------------------------------------------------------------------
diff --git 
a/fit/core-reference/src/test/java/org/apache/syncope/fit/AbstractITCase.java 
b/fit/core-reference/src/test/java/org/apache/syncope/fit/AbstractITCase.java
index d39ca3c..ba819af 100644
--- 
a/fit/core-reference/src/test/java/org/apache/syncope/fit/AbstractITCase.java
+++ 
b/fit/core-reference/src/test/java/org/apache/syncope/fit/AbstractITCase.java
@@ -18,6 +18,7 @@
  */
 package org.apache.syncope.fit;
 
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.fail;
 
@@ -36,6 +37,7 @@ import javax.naming.directory.InitialDirContext;
 import javax.naming.directory.ModificationItem;
 import javax.ws.rs.core.GenericType;
 import javax.ws.rs.core.Response;
+import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.tuple.Pair;
@@ -52,14 +54,18 @@ import org.apache.syncope.common.lib.to.AnyObjectTO;
 import org.apache.syncope.common.lib.to.AttrTO;
 import org.apache.syncope.common.lib.to.ResourceTO;
 import org.apache.syncope.common.lib.to.GroupTO;
+import org.apache.syncope.common.lib.to.MembershipTO;
+import org.apache.syncope.common.lib.to.NotificationTO;
 import org.apache.syncope.common.lib.to.ProvisioningResult;
+import org.apache.syncope.common.lib.to.ReportTO;
 import org.apache.syncope.common.lib.to.RoleTO;
 import org.apache.syncope.common.lib.to.UserTO;
+import org.apache.syncope.common.lib.types.AnyTypeKind;
 import org.apache.syncope.common.lib.types.ConnConfProperty;
 import org.apache.syncope.common.lib.types.PatchOperation;
 import org.apache.syncope.common.lib.types.SchemaType;
+import org.apache.syncope.common.lib.types.TraceLevel;
 import org.apache.syncope.common.rest.api.RESTHeaders;
-import org.apache.syncope.common.rest.api.service.AccessTokenService;
 import org.apache.syncope.common.rest.api.service.AnyObjectService;
 import org.apache.syncope.common.rest.api.service.AnyTypeClassService;
 import org.apache.syncope.common.rest.api.service.AnyTypeService;
@@ -89,6 +95,7 @@ import 
org.apache.syncope.common.rest.api.service.UserSelfService;
 import org.apache.syncope.common.rest.api.service.UserService;
 import org.apache.syncope.common.rest.api.service.UserWorkflowService;
 import org.apache.syncope.common.rest.api.service.WorkflowService;
+import org.apache.syncope.fit.core.UserITCase;
 import org.identityconnectors.common.security.Encryptor;
 import org.junit.BeforeClass;
 import org.slf4j.Logger;
@@ -343,6 +350,58 @@ public abstract class AbstractITCase {
         return getObject(response.getLocation(), RoleService.class, 
RoleTO.class);
     }
 
+    protected ReportTO createReport(final ReportTO report) {
+        Response response = reportService.create(report);
+        assertEquals(Response.Status.CREATED.getStatusCode(), 
response.getStatusInfo().getStatusCode());
+        return getObject(response.getLocation(), ReportService.class, 
ReportTO.class);
+    }
+
+    protected Pair<String, String> createNotificationTask(
+            final boolean active,
+            final boolean includeAbout,
+            final TraceLevel traceLevel,
+            final String sender,
+            final String subject,
+            final String... staticRecipients) {
+
+        // 1. Create notification
+        NotificationTO notification = new NotificationTO();
+        notification.setTraceLevel(traceLevel);
+        
notification.getEvents().add("[LOGIC]:[UserLogic]:[]:[create]:[SUCCESS]");
+
+        if (includeAbout) {
+            notification.getAbouts().put(AnyTypeKind.USER.name(),
+                    SyncopeClient.getUserSearchConditionBuilder().
+                            
inGroups("bf825fe1-7320-4a54-bd64-143b5c18ab97").query());
+        }
+
+        
notification.setRecipientsFIQL(SyncopeClient.getUserSearchConditionBuilder().
+                inGroups("f779c0d4-633b-4be5-8f57-32eb478a3ca5").query());
+        notification.setSelfAsRecipient(true);
+        notification.setRecipientAttrName("email");
+        if (staticRecipients != null) {
+            CollectionUtils.addAll(notification.getStaticRecipients(), 
staticRecipients);
+        }
+
+        notification.setSender(sender);
+        notification.setSubject(subject);
+        notification.setTemplate("optin");
+        notification.setActive(active);
+
+        Response response = notificationService.create(notification);
+        notification = getObject(response.getLocation(), 
NotificationService.class, NotificationTO.class);
+        assertNotNull(notification);
+
+        // 2. create user
+        UserTO userTO = 
UserITCase.getUniqueSampleTO("notificationt...@syncope.apache.org");
+        userTO.getMemberships().add(
+                new 
MembershipTO.Builder().group("bf825fe1-7320-4a54-bd64-143b5c18ab97").build());
+
+        userTO = createUser(userTO).getEntity();
+        assertNotNull(userTO);
+        return Pair.of(notification.getKey(), userTO.getUsername());
+    }
+
     protected ProvisioningResult<UserTO> createUser(final UserTO userTO) {
         return createUser(userTO, true);
     }

http://git-wip-us.apache.org/repos/asf/syncope/blob/b6dfd13e/fit/core-reference/src/test/java/org/apache/syncope/fit/core/AbstractNotificationTaskITCase.java
----------------------------------------------------------------------
diff --git 
a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/AbstractNotificationTaskITCase.java
 
b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/AbstractNotificationTaskITCase.java
new file mode 100644
index 0000000..41c7844
--- /dev/null
+++ 
b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/AbstractNotificationTaskITCase.java
@@ -0,0 +1,107 @@
+/*
+ * 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;
+
+import static org.junit.Assert.assertNotNull;
+
+import com.icegreen.greenmail.util.GreenMail;
+import com.icegreen.greenmail.util.ServerSetup;
+import java.io.InputStream;
+import java.util.Properties;
+import javax.mail.Flags;
+import javax.mail.Folder;
+import javax.mail.Message;
+import javax.mail.Session;
+import javax.mail.Store;
+import org.apache.commons.io.IOUtils;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+
+public abstract class AbstractNotificationTaskITCase extends 
AbstractTaskITCase {
+
+    private static final String POP3_HOST = "localhost";
+
+    private static final int POP3_PORT = 1110;
+
+    private static String SMTP_HOST;
+
+    private static int SMTP_PORT;
+
+    private static GreenMail greenMail;
+
+    @BeforeClass
+    public static void startGreenMail() {
+        Properties props = new Properties();
+        InputStream propStream = null;
+        try {
+            propStream = 
ExceptionMapperITCase.class.getResourceAsStream("/mail.properties");
+            props.load(propStream);
+        } catch (Exception e) {
+            LOG.error("Could not load /mail.properties", e);
+        } finally {
+            IOUtils.closeQuietly(propStream);
+        }
+
+        SMTP_HOST = props.getProperty("smtpHost");
+        assertNotNull(SMTP_HOST);
+        SMTP_PORT = Integer.parseInt(props.getProperty("smtpPort"));
+        assertNotNull(SMTP_PORT);
+
+        ServerSetup[] config = new ServerSetup[2];
+        config[0] = new ServerSetup(SMTP_PORT, SMTP_HOST, 
ServerSetup.PROTOCOL_SMTP);
+        config[1] = new ServerSetup(POP3_PORT, POP3_HOST, 
ServerSetup.PROTOCOL_POP3);
+        greenMail = new GreenMail(config);
+        greenMail.start();
+    }
+
+    @AfterClass
+    public static void stopGreenMail() {
+        if (greenMail != null) {
+            greenMail.stop();
+        }
+    }
+
+    protected boolean verifyMail(final String sender, final String subject, 
final String mailAddress) throws Exception {
+        LOG.info("Waiting for notification to be sent...");
+        greenMail.waitForIncomingEmail(1);
+
+        boolean found = false;
+        Session session = Session.getDefaultInstance(System.getProperties());
+        session.setDebug(true);
+        Store store = session.getStore("pop3");
+        store.connect(POP3_HOST, POP3_PORT, mailAddress, mailAddress);
+
+        Folder inbox = store.getFolder("INBOX");
+        assertNotNull(inbox);
+        inbox.open(Folder.READ_WRITE);
+
+        Message[] messages = inbox.getMessages();
+        for (Message message : messages) {
+            if (sender.equals(message.getFrom()[0].toString()) && 
subject.equals(message.getSubject())) {
+                found = true;
+                message.setFlag(Flags.Flag.DELETED, true);
+            }
+        }
+
+        inbox.close(true);
+        store.close();
+        return found;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/b6dfd13e/fit/core-reference/src/test/java/org/apache/syncope/fit/core/AbstractTaskITCase.java
----------------------------------------------------------------------
diff --git 
a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/AbstractTaskITCase.java
 
b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/AbstractTaskITCase.java
index 6d7c897..94dafbd 100644
--- 
a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/AbstractTaskITCase.java
+++ 
b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/AbstractTaskITCase.java
@@ -30,12 +30,18 @@ import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
+import org.apache.syncope.client.lib.SyncopeClient;
+import org.apache.syncope.common.lib.SyncopeConstants;
+import org.apache.syncope.common.lib.patch.DeassociationPatch;
 import org.apache.syncope.common.lib.to.AbstractTaskTO;
 import org.apache.syncope.common.lib.to.ExecTO;
+import org.apache.syncope.common.lib.to.GroupTO;
 import org.apache.syncope.common.lib.to.NotificationTaskTO;
 import org.apache.syncope.common.lib.to.PagedResult;
 import org.apache.syncope.common.lib.to.UserTO;
+import org.apache.syncope.common.lib.types.ResourceDeassociationAction;
 import org.apache.syncope.common.lib.types.TaskType;
+import org.apache.syncope.common.rest.api.beans.AnyQuery;
 import org.apache.syncope.common.rest.api.beans.ExecuteQuery;
 import org.apache.syncope.common.rest.api.beans.TaskQuery;
 import org.apache.syncope.common.rest.api.service.TaskService;
@@ -88,6 +94,41 @@ public abstract class AbstractTaskITCase extends 
AbstractITCase {
         }
     }
 
+    /**
+     * Clean Syncope and LDAP resource status.
+     */
+    protected void ldapCleanup() {
+        PagedResult<GroupTO> matchingGroups = groupService.search(new 
AnyQuery.Builder().realm(
+                SyncopeConstants.ROOT_REALM).
+                
fiql(SyncopeClient.getGroupSearchConditionBuilder().is("name").equalTo("testLDAPGroup").query()).
+                build());
+        if (matchingGroups.getSize() > 0) {
+            for (GroupTO group : matchingGroups.getResult()) {
+                DeassociationPatch deassociationPatch = new 
DeassociationPatch();
+                deassociationPatch.setKey(group.getKey());
+                
deassociationPatch.setAction(ResourceDeassociationAction.UNLINK);
+                deassociationPatch.getResources().add(RESOURCE_NAME_LDAP);
+                groupService.deassociate(deassociationPatch);
+                groupService.delete(group.getKey());
+            }
+        }
+        PagedResult<UserTO> matchingUsers = userService.search(
+                new AnyQuery.Builder().realm(SyncopeConstants.ROOT_REALM).
+                        
fiql(SyncopeClient.getUserSearchConditionBuilder().is("username").equalTo("pullFromLDAP").
+                                query()).
+                        build());
+        if (matchingUsers.getSize() > 0) {
+            for (UserTO user : matchingUsers.getResult()) {
+                DeassociationPatch deassociationPatch = new 
DeassociationPatch();
+                deassociationPatch.setKey(user.getKey());
+                
deassociationPatch.setAction(ResourceDeassociationAction.UNLINK);
+                deassociationPatch.getResources().add(RESOURCE_NAME_LDAP);
+                userService.deassociate(deassociationPatch);
+                userService.delete(user.getKey());
+            }
+        }
+    }
+
     protected static ExecTO execTask(final TaskService taskService, final 
String taskKey, final String initialStatus,
             final int maxWaitSeconds, final boolean dryRun) {
 

http://git-wip-us.apache.org/repos/asf/syncope/blob/b6dfd13e/fit/core-reference/src/test/java/org/apache/syncope/fit/core/GroupITCase.java
----------------------------------------------------------------------
diff --git 
a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/GroupITCase.java 
b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/GroupITCase.java
index 3dff239..e24fc66 100644
--- 
a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/GroupITCase.java
+++ 
b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/GroupITCase.java
@@ -30,17 +30,11 @@ import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 import java.util.UUID;
-import javax.naming.NamingEnumeration;
-import javax.naming.NamingException;
-import javax.naming.directory.DirContext;
-import javax.naming.directory.SearchControls;
-import javax.naming.directory.SearchResult;
 import javax.ws.rs.ForbiddenException;
 import javax.ws.rs.core.GenericType;
 import javax.ws.rs.core.Response;
 import org.apache.commons.collections4.IterableUtils;
 import org.apache.commons.collections4.Predicate;
-import org.apache.commons.lang3.SerializationUtils;
 import org.apache.syncope.client.lib.AnonymousAuthenticationHandler;
 import org.apache.syncope.client.lib.SyncopeClient;
 import org.apache.syncope.common.lib.AnyOperations;
@@ -61,27 +55,21 @@ import org.apache.syncope.common.lib.to.AttrTO;
 import org.apache.syncope.common.lib.to.BulkActionResult;
 import org.apache.syncope.common.lib.to.ConnInstanceTO;
 import org.apache.syncope.common.lib.to.ConnObjectTO;
-import org.apache.syncope.common.lib.to.DerSchemaTO;
 import org.apache.syncope.common.lib.to.ExecTO;
-import org.apache.syncope.common.lib.to.MappingItemTO;
 import org.apache.syncope.common.lib.to.PagedResult;
 import org.apache.syncope.common.lib.to.PlainSchemaTO;
 import org.apache.syncope.common.lib.to.ResourceTO;
 import org.apache.syncope.common.lib.to.GroupTO;
-import org.apache.syncope.common.lib.to.MappingTO;
 import org.apache.syncope.common.lib.to.MembershipTO;
 import org.apache.syncope.common.lib.to.PropagationStatus;
-import org.apache.syncope.common.lib.to.ProvisionTO;
 import org.apache.syncope.common.lib.to.ProvisioningResult;
 import org.apache.syncope.common.lib.to.SchedTaskTO;
 import org.apache.syncope.common.lib.to.TypeExtensionTO;
 import org.apache.syncope.common.lib.to.UserTO;
 import org.apache.syncope.common.lib.types.AnyTypeKind;
-import org.apache.syncope.common.lib.types.AttrSchemaType;
 import org.apache.syncope.common.lib.types.BulkMembersActionType;
 import org.apache.syncope.common.lib.types.ClientExceptionType;
 import org.apache.syncope.common.lib.types.ConnectorCapability;
-import org.apache.syncope.common.lib.types.MappingPurpose;
 import org.apache.syncope.common.lib.types.PatchOperation;
 import org.apache.syncope.common.lib.types.PropagationTaskExecStatus;
 import org.apache.syncope.common.lib.types.ResourceAssociationAction;
@@ -888,187 +876,4 @@ public class GroupITCase extends AbstractITCase {
             userService.delete(userTO.getKey());
         }
     }
-
-    @Test
-    public void issue178() {
-        GroupTO groupTO = new GroupTO();
-        String groupName = "torename" + getUUIDString();
-        groupTO.setName(groupName);
-        groupTO.setRealm("/");
-
-        GroupTO actual = createGroup(groupTO).getEntity();
-
-        assertNotNull(actual);
-        assertEquals(groupName, actual.getName());
-
-        GroupPatch groupPatch = new GroupPatch();
-        groupPatch.setKey(actual.getKey());
-        String renamedGroup = "renamed" + getUUIDString();
-        groupPatch.setName(new 
StringReplacePatchItem.Builder().value(renamedGroup).build());
-
-        actual = updateGroup(groupPatch).getEntity();
-        assertNotNull(actual);
-        assertEquals(renamedGroup, actual.getName());
-    }
-
-    @Test
-    public void issueSYNCOPE632() {
-        DerSchemaTO orig = schemaService.read(SchemaType.DERIVED, 
"displayProperty");
-        DerSchemaTO modified = SerializationUtils.clone(orig);
-        modified.setExpression("icon + '_' + show");
-
-        GroupTO groupTO = getSampleTO("lastGroup");
-        try {
-            schemaService.update(SchemaType.DERIVED, modified);
-
-            // 0. create group
-            groupTO.getPlainAttrs().add(attrTO("icon", "anIcon"));
-            groupTO.getPlainAttrs().add(attrTO("show", "true"));
-            groupTO.getDerAttrs().add(attrTO("displayProperty", null));
-            groupTO.getResources().clear();
-
-            groupTO = createGroup(groupTO).getEntity();
-            assertNotNull(groupTO);
-
-            // 1. create new LDAP resource having ConnObjectKey mapped to a 
derived attribute
-            ResourceTO newLDAP = resourceService.read(RESOURCE_NAME_LDAP);
-            newLDAP.setKey("new-ldap");
-            newLDAP.setPropagationPriority(0);
-
-            for (ProvisionTO provision : newLDAP.getProvisions()) {
-                provision.getVirSchemas().clear();
-            }
-
-            MappingTO mapping = 
newLDAP.getProvision(AnyTypeKind.GROUP.name()).getMapping();
-
-            MappingItemTO connObjectKey = mapping.getConnObjectKeyItem();
-            connObjectKey.setIntAttrName("displayProperty");
-            connObjectKey.setPurpose(MappingPurpose.PROPAGATION);
-            mapping.setConnObjectKeyItem(connObjectKey);
-            mapping.setConnObjectLink("'cn=' + displayProperty + 
',ou=groups,o=isp'");
-
-            MappingItemTO description = new MappingItemTO();
-            description.setIntAttrName("key");
-            description.setExtAttrName("description");
-            description.setPurpose(MappingPurpose.PROPAGATION);
-            mapping.add(description);
-
-            newLDAP = createResource(newLDAP);
-            assertNotNull(newLDAP);
-
-            // 2. update group and give the resource created above
-            GroupPatch patch = new GroupPatch();
-            patch.setKey(groupTO.getKey());
-            patch.getResources().add(new StringPatchItem.Builder().
-                    operation(PatchOperation.ADD_REPLACE).
-                    value("new-ldap").build());
-
-            groupTO = updateGroup(patch).getEntity();
-            assertNotNull(groupTO);
-
-            // 3. update the group
-            GroupPatch groupPatch = new GroupPatch();
-            groupPatch.setKey(groupTO.getKey());
-            groupPatch.getPlainAttrs().add(attrAddReplacePatch("icon", 
"anotherIcon"));
-
-            groupTO = updateGroup(groupPatch).getEntity();
-            assertNotNull(groupTO);
-
-            // 4. check that a single group exists in LDAP for the group 
created and updated above
-            int entries = 0;
-            DirContext ctx = null;
-            try {
-                ctx = getLdapResourceDirContext(null, null);
-
-                SearchControls ctls = new SearchControls();
-                ctls.setReturningAttributes(new String[] { "*", "+" });
-                ctls.setSearchScope(SearchControls.SUBTREE_SCOPE);
-
-                NamingEnumeration<SearchResult> result =
-                        ctx.search("ou=groups,o=isp", "(description=" + 
groupTO.getKey() + ")", ctls);
-                while (result.hasMore()) {
-                    result.next();
-                    entries++;
-                }
-            } catch (Exception e) {
-                // ignore
-            } finally {
-                if (ctx != null) {
-                    try {
-                        ctx.close();
-                    } catch (NamingException e) {
-                        // ignore
-                    }
-                }
-            }
-
-            assertEquals(1, entries);
-        } finally {
-            schemaService.update(SchemaType.DERIVED, orig);
-            if (groupTO.getKey() != null) {
-                groupService.delete(groupTO.getKey());
-            }
-            resourceService.delete("new-ldap");
-        }
-    }
-
-    @Test
-    public void issueSYNCOPE717() {
-        String doubleSchemaName = "double" + getUUIDString();
-
-        // 1. create double schema without conversion pattern
-        PlainSchemaTO schema = new PlainSchemaTO();
-        schema.setKey(doubleSchemaName);
-        schema.setType(AttrSchemaType.Double);
-
-        schema = createSchema(SchemaType.PLAIN, schema);
-        assertNotNull(schema);
-        assertNull(schema.getConversionPattern());
-
-        AnyTypeClassTO minimalGroup = anyTypeClassService.read("minimal 
group");
-        assertNotNull(minimalGroup);
-        minimalGroup.getPlainSchemas().add(doubleSchemaName);
-        anyTypeClassService.update(minimalGroup);
-
-        // 2. create group, provide valid input value
-        GroupTO groupTO = getBasicSampleTO("syncope717");
-        groupTO.getPlainAttrs().add(attrTO(doubleSchemaName, "11.23"));
-
-        groupTO = createGroup(groupTO).getEntity();
-        assertNotNull(groupTO);
-        assertEquals("11.23", 
groupTO.getPlainAttr(doubleSchemaName).getValues().get(0));
-
-        // 3. update schema, set conversion pattern
-        schema = schemaService.read(SchemaType.PLAIN, schema.getKey());
-        schema.setConversionPattern("0.000");
-        schemaService.update(SchemaType.PLAIN, schema);
-
-        // 4. re-read group, verify that pattern was applied
-        groupTO = groupService.read(groupTO.getKey());
-        assertNotNull(groupTO);
-        assertEquals("11.230", 
groupTO.getPlainAttr(doubleSchemaName).getValues().get(0));
-
-        // 5. modify group with new double value
-        GroupPatch patch = new GroupPatch();
-        patch.setKey(groupTO.getKey());
-        patch.getPlainAttrs().add(new 
AttrPatch.Builder().attrTO(attrTO(doubleSchemaName, "11.257")).build());
-
-        groupTO = updateGroup(patch).getEntity();
-        assertNotNull(groupTO);
-        assertEquals("11.257", 
groupTO.getPlainAttr(doubleSchemaName).getValues().get(0));
-
-        // 6. update schema, unset conversion pattern
-        schema.setConversionPattern(null);
-        schemaService.update(SchemaType.PLAIN, schema);
-
-        // 7. modify group with new double value, verify that no pattern is 
applied
-        patch = new GroupPatch();
-        patch.setKey(groupTO.getKey());
-        patch.getPlainAttrs().add(new 
AttrPatch.Builder().attrTO(attrTO(doubleSchemaName, "11.23")).build());
-
-        groupTO = updateGroup(patch).getEntity();
-        assertNotNull(groupTO);
-        assertEquals("11.23", 
groupTO.getPlainAttr(doubleSchemaName).getValues().get(0));
-    }
-
 }

http://git-wip-us.apache.org/repos/asf/syncope/blob/b6dfd13e/fit/core-reference/src/test/java/org/apache/syncope/fit/core/GroupIssuesITCase.java
----------------------------------------------------------------------
diff --git 
a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/GroupIssuesITCase.java
 
b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/GroupIssuesITCase.java
new file mode 100644
index 0000000..7f1a03d
--- /dev/null
+++ 
b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/GroupIssuesITCase.java
@@ -0,0 +1,235 @@
+/*
+ * 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;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.directory.DirContext;
+import javax.naming.directory.SearchControls;
+import javax.naming.directory.SearchResult;
+import org.apache.commons.lang3.SerializationUtils;
+import org.apache.syncope.common.lib.patch.AttrPatch;
+import org.apache.syncope.common.lib.patch.GroupPatch;
+import org.apache.syncope.common.lib.patch.StringPatchItem;
+import org.apache.syncope.common.lib.patch.StringReplacePatchItem;
+import org.apache.syncope.common.lib.to.AnyTypeClassTO;
+import org.apache.syncope.common.lib.to.DerSchemaTO;
+import org.apache.syncope.common.lib.to.MappingItemTO;
+import org.apache.syncope.common.lib.to.PlainSchemaTO;
+import org.apache.syncope.common.lib.to.ResourceTO;
+import org.apache.syncope.common.lib.to.GroupTO;
+import org.apache.syncope.common.lib.to.MappingTO;
+import org.apache.syncope.common.lib.to.ProvisionTO;
+import org.apache.syncope.common.lib.types.AnyTypeKind;
+import org.apache.syncope.common.lib.types.AttrSchemaType;
+import org.apache.syncope.common.lib.types.MappingPurpose;
+import org.apache.syncope.common.lib.types.PatchOperation;
+import org.apache.syncope.common.lib.types.SchemaType;
+import org.apache.syncope.fit.AbstractITCase;
+import org.junit.Test;
+
+public class GroupIssuesITCase extends AbstractITCase {
+
+    @Test
+    public void issue178() {
+        GroupTO groupTO = new GroupTO();
+        String groupName = "torename" + getUUIDString();
+        groupTO.setName(groupName);
+        groupTO.setRealm("/");
+
+        GroupTO actual = createGroup(groupTO).getEntity();
+
+        assertNotNull(actual);
+        assertEquals(groupName, actual.getName());
+
+        GroupPatch groupPatch = new GroupPatch();
+        groupPatch.setKey(actual.getKey());
+        String renamedGroup = "renamed" + getUUIDString();
+        groupPatch.setName(new 
StringReplacePatchItem.Builder().value(renamedGroup).build());
+
+        actual = updateGroup(groupPatch).getEntity();
+        assertNotNull(actual);
+        assertEquals(renamedGroup, actual.getName());
+    }
+
+    @Test
+    public void issueSYNCOPE632() {
+        DerSchemaTO orig = schemaService.read(SchemaType.DERIVED, 
"displayProperty");
+        DerSchemaTO modified = SerializationUtils.clone(orig);
+        modified.setExpression("icon + '_' + show");
+
+        GroupTO groupTO = GroupITCase.getSampleTO("lastGroup");
+        try {
+            schemaService.update(SchemaType.DERIVED, modified);
+
+            // 0. create group
+            groupTO.getPlainAttrs().add(attrTO("icon", "anIcon"));
+            groupTO.getPlainAttrs().add(attrTO("show", "true"));
+            groupTO.getDerAttrs().add(attrTO("displayProperty", null));
+            groupTO.getResources().clear();
+
+            groupTO = createGroup(groupTO).getEntity();
+            assertNotNull(groupTO);
+
+            // 1. create new LDAP resource having ConnObjectKey mapped to a 
derived attribute
+            ResourceTO newLDAP = resourceService.read(RESOURCE_NAME_LDAP);
+            newLDAP.setKey("new-ldap");
+            newLDAP.setPropagationPriority(0);
+
+            for (ProvisionTO provision : newLDAP.getProvisions()) {
+                provision.getVirSchemas().clear();
+            }
+
+            MappingTO mapping = 
newLDAP.getProvision(AnyTypeKind.GROUP.name()).getMapping();
+
+            MappingItemTO connObjectKey = mapping.getConnObjectKeyItem();
+            connObjectKey.setIntAttrName("displayProperty");
+            connObjectKey.setPurpose(MappingPurpose.PROPAGATION);
+            mapping.setConnObjectKeyItem(connObjectKey);
+            mapping.setConnObjectLink("'cn=' + displayProperty + 
',ou=groups,o=isp'");
+
+            MappingItemTO description = new MappingItemTO();
+            description.setIntAttrName("key");
+            description.setExtAttrName("description");
+            description.setPurpose(MappingPurpose.PROPAGATION);
+            mapping.add(description);
+
+            newLDAP = createResource(newLDAP);
+            assertNotNull(newLDAP);
+
+            // 2. update group and give the resource created above
+            GroupPatch patch = new GroupPatch();
+            patch.setKey(groupTO.getKey());
+            patch.getResources().add(new StringPatchItem.Builder().
+                    operation(PatchOperation.ADD_REPLACE).
+                    value("new-ldap").build());
+
+            groupTO = updateGroup(patch).getEntity();
+            assertNotNull(groupTO);
+
+            // 3. update the group
+            GroupPatch groupPatch = new GroupPatch();
+            groupPatch.setKey(groupTO.getKey());
+            groupPatch.getPlainAttrs().add(attrAddReplacePatch("icon", 
"anotherIcon"));
+
+            groupTO = updateGroup(groupPatch).getEntity();
+            assertNotNull(groupTO);
+
+            // 4. check that a single group exists in LDAP for the group 
created and updated above
+            int entries = 0;
+            DirContext ctx = null;
+            try {
+                ctx = getLdapResourceDirContext(null, null);
+
+                SearchControls ctls = new SearchControls();
+                ctls.setReturningAttributes(new String[] { "*", "+" });
+                ctls.setSearchScope(SearchControls.SUBTREE_SCOPE);
+
+                NamingEnumeration<SearchResult> result =
+                        ctx.search("ou=groups,o=isp", "(description=" + 
groupTO.getKey() + ")", ctls);
+                while (result.hasMore()) {
+                    result.next();
+                    entries++;
+                }
+            } catch (Exception e) {
+                // ignore
+            } finally {
+                if (ctx != null) {
+                    try {
+                        ctx.close();
+                    } catch (NamingException e) {
+                        // ignore
+                    }
+                }
+            }
+
+            assertEquals(1, entries);
+        } finally {
+            schemaService.update(SchemaType.DERIVED, orig);
+            if (groupTO.getKey() != null) {
+                groupService.delete(groupTO.getKey());
+            }
+            resourceService.delete("new-ldap");
+        }
+    }
+
+    @Test
+    public void issueSYNCOPE717() {
+        String doubleSchemaName = "double" + getUUIDString();
+
+        // 1. create double schema without conversion pattern
+        PlainSchemaTO schema = new PlainSchemaTO();
+        schema.setKey(doubleSchemaName);
+        schema.setType(AttrSchemaType.Double);
+
+        schema = createSchema(SchemaType.PLAIN, schema);
+        assertNotNull(schema);
+        assertNull(schema.getConversionPattern());
+
+        AnyTypeClassTO minimalGroup = anyTypeClassService.read("minimal 
group");
+        assertNotNull(minimalGroup);
+        minimalGroup.getPlainSchemas().add(doubleSchemaName);
+        anyTypeClassService.update(minimalGroup);
+
+        // 2. create group, provide valid input value
+        GroupTO groupTO = GroupITCase.getBasicSampleTO("syncope717");
+        groupTO.getPlainAttrs().add(attrTO(doubleSchemaName, "11.23"));
+
+        groupTO = createGroup(groupTO).getEntity();
+        assertNotNull(groupTO);
+        assertEquals("11.23", 
groupTO.getPlainAttr(doubleSchemaName).getValues().get(0));
+
+        // 3. update schema, set conversion pattern
+        schema = schemaService.read(SchemaType.PLAIN, schema.getKey());
+        schema.setConversionPattern("0.000");
+        schemaService.update(SchemaType.PLAIN, schema);
+
+        // 4. re-read group, verify that pattern was applied
+        groupTO = groupService.read(groupTO.getKey());
+        assertNotNull(groupTO);
+        assertEquals("11.230", 
groupTO.getPlainAttr(doubleSchemaName).getValues().get(0));
+
+        // 5. modify group with new double value
+        GroupPatch patch = new GroupPatch();
+        patch.setKey(groupTO.getKey());
+        patch.getPlainAttrs().add(new 
AttrPatch.Builder().attrTO(attrTO(doubleSchemaName, "11.257")).build());
+
+        groupTO = updateGroup(patch).getEntity();
+        assertNotNull(groupTO);
+        assertEquals("11.257", 
groupTO.getPlainAttr(doubleSchemaName).getValues().get(0));
+
+        // 6. update schema, unset conversion pattern
+        schema.setConversionPattern(null);
+        schemaService.update(SchemaType.PLAIN, schema);
+
+        // 7. modify group with new double value, verify that no pattern is 
applied
+        patch = new GroupPatch();
+        patch.setKey(groupTO.getKey());
+        patch.getPlainAttrs().add(new 
AttrPatch.Builder().attrTO(attrTO(doubleSchemaName, "11.23")).build());
+
+        groupTO = updateGroup(patch).getEntity();
+        assertNotNull(groupTO);
+        assertEquals("11.23", 
groupTO.getPlainAttr(doubleSchemaName).getValues().get(0));
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/b6dfd13e/fit/core-reference/src/test/java/org/apache/syncope/fit/core/NotificationTaskITCase.java
----------------------------------------------------------------------
diff --git 
a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/NotificationTaskITCase.java
 
b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/NotificationTaskITCase.java
index e7fc955..421dab7 100644
--- 
a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/NotificationTaskITCase.java
+++ 
b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/NotificationTaskITCase.java
@@ -23,113 +23,15 @@ import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
-import com.icegreen.greenmail.util.GreenMail;
-import com.icegreen.greenmail.util.ServerSetup;
-import java.io.InputStream;
-import java.util.Properties;
-import javax.mail.Flags;
-import javax.mail.Folder;
-import javax.mail.Message;
-import javax.mail.Session;
-import javax.mail.Store;
-import javax.ws.rs.core.Response;
-import org.apache.commons.collections4.CollectionUtils;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.tuple.Pair;
-import org.apache.syncope.client.lib.SyncopeClient;
 import org.apache.syncope.common.lib.to.AttrTO;
-import org.apache.syncope.common.lib.to.GroupTO;
-import org.apache.syncope.common.lib.to.MembershipTO;
-import org.apache.syncope.common.lib.to.NotificationTO;
 import org.apache.syncope.common.lib.to.NotificationTaskTO;
 import org.apache.syncope.common.lib.to.ExecTO;
-import org.apache.syncope.common.lib.to.PagedResult;
-import org.apache.syncope.common.lib.to.UserTO;
-import org.apache.syncope.common.lib.types.AnyTypeKind;
-import org.apache.syncope.common.lib.types.TaskType;
 import org.apache.syncope.common.lib.types.TraceLevel;
-import org.apache.syncope.common.rest.api.beans.ExecuteQuery;
-import org.apache.syncope.common.rest.api.beans.TaskQuery;
-import org.apache.syncope.common.rest.api.service.NotificationService;
 import 
org.apache.syncope.core.provisioning.java.job.notification.NotificationJob;
-import 
org.apache.syncope.fit.core.reference.TestNotificationRecipientsProvider;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
 import org.junit.Test;
 
-public class NotificationTaskITCase extends AbstractTaskITCase {
-
-    private static final String MAIL_ADDRESS = 
"notificationt...@syncope.apache.org";
-
-    private static final String POP3_HOST = "localhost";
-
-    private static final int POP3_PORT = 1110;
-
-    private static String SMTP_HOST;
-
-    private static int SMTP_PORT;
-
-    private static GreenMail greenMail;
-
-    @BeforeClass
-    public static void startGreenMail() {
-        Properties props = new Properties();
-        InputStream propStream = null;
-        try {
-            propStream = 
ExceptionMapperITCase.class.getResourceAsStream("/mail.properties");
-            props.load(propStream);
-        } catch (Exception e) {
-            LOG.error("Could not load /mail.properties", e);
-        } finally {
-            IOUtils.closeQuietly(propStream);
-        }
-
-        SMTP_HOST = props.getProperty("smtpHost");
-        assertNotNull(SMTP_HOST);
-        SMTP_PORT = Integer.parseInt(props.getProperty("smtpPort"));
-        assertNotNull(SMTP_PORT);
-
-        ServerSetup[] config = new ServerSetup[2];
-        config[0] = new ServerSetup(SMTP_PORT, SMTP_HOST, 
ServerSetup.PROTOCOL_SMTP);
-        config[1] = new ServerSetup(POP3_PORT, POP3_HOST, 
ServerSetup.PROTOCOL_POP3);
-        greenMail = new GreenMail(config);
-        greenMail.start();
-    }
-
-    @AfterClass
-    public static void stopGreenMail() {
-        if (greenMail != null) {
-            greenMail.stop();
-        }
-    }
-
-    private boolean verifyMail(final String sender, final String subject, 
final String mailAddress) throws Exception {
-        LOG.info("Waiting for notification to be sent...");
-        greenMail.waitForIncomingEmail(1);
-
-        boolean found = false;
-        Session session = Session.getDefaultInstance(System.getProperties());
-        session.setDebug(true);
-        Store store = session.getStore("pop3");
-        store.connect(POP3_HOST, POP3_PORT, mailAddress, mailAddress);
-
-        Folder inbox = store.getFolder("INBOX");
-        assertNotNull(inbox);
-        inbox.open(Folder.READ_WRITE);
-
-        Message[] messages = inbox.getMessages();
-        for (Message message : messages) {
-            if (sender.equals(message.getFrom()[0].toString()) && 
subject.equals(message.getSubject())) {
-                found = true;
-                message.setFlag(Flags.Flag.DELETED, true);
-            }
-        }
-
-        inbox.close(true);
-        store.close();
-        return found;
-    }
+public class NotificationTaskITCase extends AbstractNotificationTaskITCase {
 
     @Test
     public void notifyByMail() throws Exception {
@@ -208,213 +110,4 @@ public class NotificationTaskITCase extends 
AbstractTaskITCase {
             configurationService.set(origMaxRetries);
         }
     }
-
-    @Test
-    public void issueSYNCOPE81() {
-        String sender = "syncop...@syncope.apache.org";
-        Pair<String, String> created = createNotificationTask(true, true, 
TraceLevel.ALL, sender, "Test notification");
-        NotificationTaskTO taskTO = findNotificationTask(created.getLeft(), 
50);
-        assertNotNull(taskTO);
-        assertNotNull(taskTO.getNotification());
-        assertTrue(taskTO.getExecutions().isEmpty());
-
-        // generate an execution in order to verify the deletion of a 
notification task with one or more executions
-        execNotificationTask(taskService, taskTO.getKey(), 50);
-
-        taskTO = taskService.read(taskTO.getKey(), true);
-        assertTrue(taskTO.isExecuted());
-        assertFalse(taskTO.getExecutions().isEmpty());
-
-        taskService.delete(taskTO.getKey());
-    }
-
-    @Test
-    public void issueSYNCOPE86() {
-        // 1. create notification task
-        String sender = "syncop...@syncope.apache.org";
-        Pair<String, String> created = createNotificationTask(true, true, 
TraceLevel.ALL, sender, "Test notification");
-
-        // 2. get NotificationTaskTO for user just created
-        NotificationTaskTO taskTO = findNotificationTask(created.getLeft(), 
50);
-        assertNotNull(taskTO);
-        assertNotNull(taskTO.getNotification());
-        assertTrue(taskTO.getExecutions().isEmpty());
-
-        try {
-            // 3. execute the generated NotificationTask
-            execNotificationTask(taskService, taskTO.getKey(), 50);
-
-            // 4. verify
-            taskTO = taskService.read(taskTO.getKey(), true);
-            assertNotNull(taskTO);
-            assertTrue(taskTO.isExecuted());
-            assertEquals(1, taskTO.getExecutions().size());
-        } finally {
-            // Remove execution to make test re-runnable
-            
taskService.deleteExecution(taskTO.getExecutions().get(0).getKey());
-        }
-    }
-
-    @Test
-    public void issueSYNCOPE192() throws Exception {
-        String sender = "syncopetest-" + getUUIDString() + 
"@syncope.apache.org";
-        String subject = "Test notification " + getUUIDString();
-        Pair<String, String> created = createNotificationTask(true, true, 
TraceLevel.NONE, sender, subject);
-        NotificationTaskTO taskTO = findNotificationTask(created.getLeft(), 
50);
-        assertNotNull(taskTO);
-        assertNotNull(taskTO.getNotification());
-        assertTrue(taskTO.getExecutions().isEmpty());
-
-        taskService.execute(new 
ExecuteQuery.Builder().key(taskTO.getKey()).build());
-
-        try {
-            Thread.sleep(5);
-        } catch (InterruptedException e) {
-        }
-
-        assertTrue(verifyMail(sender, subject, created.getRight()));
-
-        // verify that last exec status was updated
-        taskTO = taskService.read(taskTO.getKey(), true);
-        assertNotNull(taskTO);
-        assertTrue(taskTO.isExecuted());
-        assertTrue(taskTO.getExecutions().isEmpty());
-        assertTrue(StringUtils.isNotBlank(taskTO.getLatestExecStatus()));
-    }
-
-    @Test
-    public void issueSYNCOPE445() throws Exception {
-        String sender = "syncopetest-" + getUUIDString() + 
"@syncope.apache.org";
-        String subject = "Test notification " + getUUIDString();
-        Pair<String, String> created = createNotificationTask(
-                true, true, TraceLevel.ALL, sender, subject, 
"syncope...@syncope.apache.org");
-        NotificationTaskTO taskTO = findNotificationTask(created.getLeft(), 
50);
-        assertNotNull(taskTO);
-        assertNotNull(taskTO.getNotification());
-        assertTrue(taskTO.getExecutions().isEmpty());
-
-        execNotificationTask(taskService, taskTO.getKey(), 50);
-
-        assertTrue(verifyMail(sender, subject, created.getRight()));
-
-        // verify task
-        taskTO = taskService.read(taskTO.getKey(), true);
-        assertTrue(taskTO.isExecuted());
-        assertNotNull(taskTO);
-        
assertTrue(taskTO.getRecipients().contains("syncope...@syncope.apache.org"));
-    }
-
-    @Test
-    public void issueSYNCOPE446() throws Exception {
-        // 1. Create notification
-        NotificationTO notification = new NotificationTO();
-        notification.setTraceLevel(TraceLevel.ALL);
-        
notification.getEvents().add("[LOGIC]:[GroupLogic]:[]:[create]:[SUCCESS]");
-
-        String groupName = "group" + getUUIDString();
-        notification.getAbouts().put(AnyTypeKind.GROUP.name(),
-                
SyncopeClient.getGroupSearchConditionBuilder().is("name").equalTo(groupName).query());
-
-        
notification.setRecipientsFIQL(SyncopeClient.getUserSearchConditionBuilder().
-                inGroups("f779c0d4-633b-4be5-8f57-32eb478a3ca5").query());
-        notification.setSelfAsRecipient(false);
-        notification.setRecipientAttrName("email");
-        notification.getStaticRecipients().add(MAIL_ADDRESS);
-        
notification.setRecipientsProviderClassName(TestNotificationRecipientsProvider.class.getName());
-
-        String sender = "syncopetest-" + getUUIDString() + 
"@syncope.apache.org";
-        notification.setSender(sender);
-        String subject = "Test notification " + getUUIDString();
-        notification.setSubject(subject);
-        notification.setTemplate("optin");
-        notification.setActive(true);
-
-        Response response = notificationService.create(notification);
-        notification = getObject(response.getLocation(), 
NotificationService.class, NotificationTO.class);
-        assertNotNull(notification);
-        assertEquals(TestNotificationRecipientsProvider.class.getName(), 
notification.getRecipientsProviderClassName());
-
-        // 2. create group
-        GroupTO groupTO = new GroupTO();
-        groupTO.setName(groupName);
-        groupTO.setRealm("/even/two");
-        groupTO = createGroup(groupTO).getEntity();
-        assertNotNull(groupTO);
-
-        // 3. verify
-        NotificationTaskTO taskTO = 
findNotificationTask(notification.getKey(), 50);
-        assertNotNull(taskTO);
-        assertNotNull(taskTO.getNotification());
-        assertTrue(taskTO.getRecipients().containsAll(
-                new 
TestNotificationRecipientsProvider().provideRecipients(null)));
-
-        NotificationTaskTO foundViaList = taskService.<NotificationTaskTO>list(
-                new 
TaskQuery.Builder(TaskType.NOTIFICATION).notification(notification.getKey()).build()).
-                getResult().get(0);
-        assertEquals(taskTO, foundViaList);
-
-        execNotificationTask(taskService, taskTO.getKey(), 50);
-
-        assertTrue(verifyMail(sender, subject, MAIL_ADDRESS));
-    }
-
-    @Test
-    public void issueSYNCOPE492() throws Exception {
-        String sender = "syncopetest-" + getUUIDString() + 
"@syncope.apache.org";
-        String subject = "Test notification " + getUUIDString();
-        Pair<String, String> created =
-                createNotificationTask(false, true, TraceLevel.NONE, sender, 
subject, "syncope...@syncope.apache.org");
-
-        // verify that no task was created for disabled notification
-        PagedResult<NotificationTaskTO> tasks =
-                taskService.list(new 
TaskQuery.Builder(TaskType.NOTIFICATION).notification(created.getLeft()).build());
-        assertEquals(0, tasks.getSize());
-    }
-
-    private Pair<String, String> createNotificationTask(
-            final boolean active,
-            final boolean includeAbout,
-            final TraceLevel traceLevel,
-            final String sender,
-            final String subject,
-            final String... staticRecipients) {
-
-        // 1. Create notification
-        NotificationTO notification = new NotificationTO();
-        notification.setTraceLevel(traceLevel);
-        
notification.getEvents().add("[LOGIC]:[UserLogic]:[]:[create]:[SUCCESS]");
-
-        if (includeAbout) {
-            notification.getAbouts().put(AnyTypeKind.USER.name(),
-                    SyncopeClient.getUserSearchConditionBuilder().
-                            
inGroups("bf825fe1-7320-4a54-bd64-143b5c18ab97").query());
-        }
-
-        
notification.setRecipientsFIQL(SyncopeClient.getUserSearchConditionBuilder().
-                inGroups("f779c0d4-633b-4be5-8f57-32eb478a3ca5").query());
-        notification.setSelfAsRecipient(true);
-        notification.setRecipientAttrName("email");
-        if (staticRecipients != null) {
-            CollectionUtils.addAll(notification.getStaticRecipients(), 
staticRecipients);
-        }
-
-        notification.setSender(sender);
-        notification.setSubject(subject);
-        notification.setTemplate("optin");
-        notification.setActive(active);
-
-        Response response = notificationService.create(notification);
-        notification = getObject(response.getLocation(), 
NotificationService.class, NotificationTO.class);
-        assertNotNull(notification);
-
-        // 2. create user
-        UserTO userTO = UserITCase.getUniqueSampleTO(MAIL_ADDRESS);
-        userTO.getMemberships().add(
-                new 
MembershipTO.Builder().group("bf825fe1-7320-4a54-bd64-143b5c18ab97").build());
-
-        userTO = createUser(userTO).getEntity();
-        assertNotNull(userTO);
-        return Pair.of(notification.getKey(), userTO.getUsername());
-    }
-
 }

http://git-wip-us.apache.org/repos/asf/syncope/blob/b6dfd13e/fit/core-reference/src/test/java/org/apache/syncope/fit/core/NotificationTaskIssuesITCase.java
----------------------------------------------------------------------
diff --git 
a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/NotificationTaskIssuesITCase.java
 
b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/NotificationTaskIssuesITCase.java
new file mode 100644
index 0000000..a695eb7
--- /dev/null
+++ 
b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/NotificationTaskIssuesITCase.java
@@ -0,0 +1,207 @@
+/*
+ * 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;
+
+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 javax.ws.rs.core.Response;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.tuple.Pair;
+import org.apache.syncope.client.lib.SyncopeClient;
+import org.apache.syncope.common.lib.to.GroupTO;
+import org.apache.syncope.common.lib.to.NotificationTO;
+import org.apache.syncope.common.lib.to.NotificationTaskTO;
+import org.apache.syncope.common.lib.to.PagedResult;
+import org.apache.syncope.common.lib.types.AnyTypeKind;
+import org.apache.syncope.common.lib.types.TaskType;
+import org.apache.syncope.common.lib.types.TraceLevel;
+import org.apache.syncope.common.rest.api.beans.ExecuteQuery;
+import org.apache.syncope.common.rest.api.beans.TaskQuery;
+import org.apache.syncope.common.rest.api.service.NotificationService;
+import 
org.apache.syncope.fit.core.reference.TestNotificationRecipientsProvider;
+import org.junit.Test;
+
+public class NotificationTaskIssuesITCase extends 
AbstractNotificationTaskITCase {
+
+    @Test
+    public void issueSYNCOPE81() {
+        String sender = "syncop...@syncope.apache.org";
+        Pair<String, String> created = createNotificationTask(true, true, 
TraceLevel.ALL, sender, "Test notification");
+        NotificationTaskTO taskTO = findNotificationTask(created.getLeft(), 
50);
+        assertNotNull(taskTO);
+        assertNotNull(taskTO.getNotification());
+        assertTrue(taskTO.getExecutions().isEmpty());
+
+        // generate an execution in order to verify the deletion of a 
notification task with one or more executions
+        execNotificationTask(taskService, taskTO.getKey(), 50);
+
+        taskTO = taskService.read(taskTO.getKey(), true);
+        assertTrue(taskTO.isExecuted());
+        assertFalse(taskTO.getExecutions().isEmpty());
+
+        taskService.delete(taskTO.getKey());
+    }
+
+    @Test
+    public void issueSYNCOPE86() {
+        // 1. create notification task
+        String sender = "syncop...@syncope.apache.org";
+        Pair<String, String> created = createNotificationTask(true, true, 
TraceLevel.ALL, sender, "Test notification");
+
+        // 2. get NotificationTaskTO for user just created
+        NotificationTaskTO taskTO = findNotificationTask(created.getLeft(), 
50);
+        assertNotNull(taskTO);
+        assertNotNull(taskTO.getNotification());
+        assertTrue(taskTO.getExecutions().isEmpty());
+
+        try {
+            // 3. execute the generated NotificationTask
+            execNotificationTask(taskService, taskTO.getKey(), 50);
+
+            // 4. verify
+            taskTO = taskService.read(taskTO.getKey(), true);
+            assertNotNull(taskTO);
+            assertTrue(taskTO.isExecuted());
+            assertEquals(1, taskTO.getExecutions().size());
+        } finally {
+            // Remove execution to make test re-runnable
+            
taskService.deleteExecution(taskTO.getExecutions().get(0).getKey());
+        }
+    }
+
+    @Test
+    public void issueSYNCOPE192() throws Exception {
+        String sender = "syncopetest-" + getUUIDString() + 
"@syncope.apache.org";
+        String subject = "Test notification " + getUUIDString();
+        Pair<String, String> created = createNotificationTask(true, true, 
TraceLevel.NONE, sender, subject);
+        NotificationTaskTO taskTO = findNotificationTask(created.getLeft(), 
50);
+        assertNotNull(taskTO);
+        assertNotNull(taskTO.getNotification());
+        assertTrue(taskTO.getExecutions().isEmpty());
+
+        taskService.execute(new 
ExecuteQuery.Builder().key(taskTO.getKey()).build());
+
+        try {
+            Thread.sleep(5);
+        } catch (InterruptedException e) {
+        }
+
+        assertTrue(verifyMail(sender, subject, created.getRight()));
+
+        // verify that last exec status was updated
+        taskTO = taskService.read(taskTO.getKey(), true);
+        assertNotNull(taskTO);
+        assertTrue(taskTO.isExecuted());
+        assertTrue(taskTO.getExecutions().isEmpty());
+        assertTrue(StringUtils.isNotBlank(taskTO.getLatestExecStatus()));
+    }
+
+    @Test
+    public void issueSYNCOPE445() throws Exception {
+        String sender = "syncopetest-" + getUUIDString() + 
"@syncope.apache.org";
+        String subject = "Test notification " + getUUIDString();
+        Pair<String, String> created = createNotificationTask(
+                true, true, TraceLevel.ALL, sender, subject, 
"syncope...@syncope.apache.org");
+        NotificationTaskTO taskTO = findNotificationTask(created.getLeft(), 
50);
+        assertNotNull(taskTO);
+        assertNotNull(taskTO.getNotification());
+        assertTrue(taskTO.getExecutions().isEmpty());
+
+        execNotificationTask(taskService, taskTO.getKey(), 50);
+
+        assertTrue(verifyMail(sender, subject, created.getRight()));
+
+        // verify task
+        taskTO = taskService.read(taskTO.getKey(), true);
+        assertTrue(taskTO.isExecuted());
+        assertNotNull(taskTO);
+        
assertTrue(taskTO.getRecipients().contains("syncope...@syncope.apache.org"));
+    }
+
+    @Test
+    public void issueSYNCOPE446() throws Exception {
+        // 1. Create notification
+        NotificationTO notification = new NotificationTO();
+        notification.setTraceLevel(TraceLevel.ALL);
+        
notification.getEvents().add("[LOGIC]:[GroupLogic]:[]:[create]:[SUCCESS]");
+
+        String groupName = "group" + getUUIDString();
+        notification.getAbouts().put(AnyTypeKind.GROUP.name(),
+                
SyncopeClient.getGroupSearchConditionBuilder().is("name").equalTo(groupName).query());
+
+        
notification.setRecipientsFIQL(SyncopeClient.getUserSearchConditionBuilder().
+                inGroups("f779c0d4-633b-4be5-8f57-32eb478a3ca5").query());
+        notification.setSelfAsRecipient(false);
+        notification.setRecipientAttrName("email");
+        
notification.getStaticRecipients().add("notificationt...@syncope.apache.org");
+        
notification.setRecipientsProviderClassName(TestNotificationRecipientsProvider.class.getName());
+
+        String sender = "syncopetest-" + getUUIDString() + 
"@syncope.apache.org";
+        notification.setSender(sender);
+        String subject = "Test notification " + getUUIDString();
+        notification.setSubject(subject);
+        notification.setTemplate("optin");
+        notification.setActive(true);
+
+        Response response = notificationService.create(notification);
+        notification = getObject(response.getLocation(), 
NotificationService.class, NotificationTO.class);
+        assertNotNull(notification);
+        assertEquals(TestNotificationRecipientsProvider.class.getName(), 
notification.getRecipientsProviderClassName());
+
+        // 2. create group
+        GroupTO groupTO = new GroupTO();
+        groupTO.setName(groupName);
+        groupTO.setRealm("/even/two");
+        groupTO = createGroup(groupTO).getEntity();
+        assertNotNull(groupTO);
+
+        // 3. verify
+        NotificationTaskTO taskTO = 
findNotificationTask(notification.getKey(), 50);
+        assertNotNull(taskTO);
+        assertNotNull(taskTO.getNotification());
+        assertTrue(taskTO.getRecipients().containsAll(
+                new 
TestNotificationRecipientsProvider().provideRecipients(null)));
+
+        NotificationTaskTO foundViaList = taskService.<NotificationTaskTO>list(
+                new 
TaskQuery.Builder(TaskType.NOTIFICATION).notification(notification.getKey()).build()).
+                getResult().get(0);
+        assertEquals(taskTO, foundViaList);
+
+        execNotificationTask(taskService, taskTO.getKey(), 50);
+
+        assertTrue(verifyMail(sender, subject, 
"notificationt...@syncope.apache.org"));
+    }
+
+    @Test
+    public void issueSYNCOPE492() throws Exception {
+        String sender = "syncopetest-" + getUUIDString() + 
"@syncope.apache.org";
+        String subject = "Test notification " + getUUIDString();
+        Pair<String, String> created =
+                createNotificationTask(false, true, TraceLevel.NONE, sender, 
subject, "syncope...@syncope.apache.org");
+
+        // verify that no task was created for disabled notification
+        PagedResult<NotificationTaskTO> tasks =
+                taskService.list(new 
TaskQuery.Builder(TaskType.NOTIFICATION).notification(created.getLeft()).build());
+        assertEquals(0, tasks.getSize());
+    }
+
+}

Reply via email to