syncope-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ilgro...@apache.org
Subject [02/16] syncope git commit: [SYNCOPE-938] Switching from commons-collections to Java 8 features
Date Tue, 22 Aug 2017 15:09:06 GMT
http://git-wip-us.apache.org/repos/asf/syncope/blob/74ee038a/fit/core-reference/src/test/java/org/apache/syncope/fit/cli/CLIITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/cli/CLIITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/cli/CLIITCase.java
index 4f19f5a..c902481 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/cli/CLIITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/cli/CLIITCase.java
@@ -27,11 +27,9 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 import java.util.Properties;
-import org.apache.commons.collections4.CollectionUtils;
-import org.apache.commons.collections4.IterableUtils;
-import org.apache.commons.collections4.Predicate;
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang3.SystemUtils;
 import org.apache.syncope.client.cli.Command;
@@ -96,7 +94,7 @@ public class CLIITCase extends AbstractITCase {
             command.add(SCRIPT_FILENAME + ".sh");
         }
 
-        CollectionUtils.addAll(command, arguments);
+        command.addAll(Arrays.asList(arguments));
 
         return command.toArray(new String[command.size()]);
     }
@@ -137,15 +135,8 @@ public class CLIITCase extends AbstractITCase {
                     EntitlementCommand.EntitlementOptions.LIST.getOptionName()));
             process = PROCESS_BUILDER.start();
 
-            long entitlements = IterableUtils.countMatches(
-                    IOUtils.readLines(process.getInputStream(), StandardCharsets.UTF_8),
-                    new Predicate<String>() {
-
-                @Override
-                public boolean evaluate(final String line) {
-                    return line.startsWith("-");
-                }
-            });
+            long entitlements = IOUtils.readLines(process.getInputStream(), StandardCharsets.UTF_8).
+                    stream().filter(line -> line.startsWith("-")).count();
             assertEquals(syncopeService.platform().getEntitlements().size(), entitlements);
         } catch (IOException e) {
             fail(e.getMessage());
@@ -165,15 +156,8 @@ public class CLIITCase extends AbstractITCase {
                     ConnectorCommand.ConnectorOptions.LIST_BUNDLES.getOptionName()));
             process = PROCESS_BUILDER.start();
 
-            long bundles = IterableUtils.countMatches(
-                    IOUtils.readLines(process.getInputStream(), StandardCharsets.UTF_8),
-                    new Predicate<String>() {
-
-                @Override
-                public boolean evaluate(final String line) {
-                    return line.startsWith(" > BUNDLE NAME:");
-                }
-            });
+            long bundles = IOUtils.readLines(process.getInputStream(), StandardCharsets.UTF_8).
+                    stream().filter(line -> line.startsWith(" > BUNDLE NAME:")).count();
             assertEquals(connectorService.getBundles(null).size(), bundles);
         } catch (IOException e) {
             fail(e.getMessage());
@@ -209,15 +193,8 @@ public class CLIITCase extends AbstractITCase {
                     String.valueOf(userKey1), String.valueOf(userKey2),
                     String.valueOf(userKey3), String.valueOf(userKey4), String.valueOf(userKey5)));
             process2 = PROCESS_BUILDER.start();
-            long users = IterableUtils.countMatches(
-                    IOUtils.readLines(process2.getInputStream(), StandardCharsets.UTF_8),
-                    new Predicate<String>() {
-
-                @Override
-                public boolean evaluate(final String line) {
-                    return line.startsWith(" > USER KEY:");
-                }
-            });
+            long users = IOUtils.readLines(process2.getInputStream(), StandardCharsets.UTF_8).
+                    stream().filter(line -> line.startsWith(" > USER KEY:")).count();
             assertEquals(5, users);
 
             PROCESS_BUILDER.command(getCommand(

http://git-wip-us.apache.org/repos/asf/syncope/blob/74ee038a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/AnyObjectITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/AnyObjectITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/AnyObjectITCase.java
index a3251fe..31e7f1b 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/AnyObjectITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/AnyObjectITCase.java
@@ -69,8 +69,8 @@ public class AnyObjectITCase extends AbstractITCase {
         assertNotNull(connObjectTO);
         assertNotNull(connObjectTO.getAttr("LOCATION"));
         assertEquals(
-                anyObjectTO.getPlainAttr("location").getValues(),
-                connObjectTO.getAttr("LOCATION").getValues());
+                anyObjectTO.getPlainAttr("location").get().getValues(),
+                connObjectTO.getAttr("LOCATION").get().getValues());
     }
 
     @Test
@@ -127,9 +127,7 @@ public class AnyObjectITCase extends AbstractITCase {
                         build());
         assertNotNull(anyObjectTOs);
         assertTrue(anyObjectTOs.getResult().size() >= 2);
-        for (AnyObjectTO anyObjectTO : anyObjectTOs.getResult()) {
-            assertNotNull(anyObjectTO);
-        }
+        anyObjectTOs.getResult().forEach(anyObjectTO -> assertNotNull(anyObjectTO));
     }
 
     @Test
@@ -154,7 +152,7 @@ public class AnyObjectITCase extends AbstractITCase {
 
         anyObjectTO = updateAnyObject(anyObjectPatch).getEntity();
 
-        assertEquals(newLocation, anyObjectTO.getPlainAttr("location").getValues().get(0));
+        assertEquals(newLocation, anyObjectTO.getPlainAttr("location").get().getValues().get(0));
     }
 
     @Test
@@ -167,7 +165,7 @@ public class AnyObjectITCase extends AbstractITCase {
         assertEquals(anyObjectTO.getPlainAttrs(), attrs);
 
         AttrTO location = anyObjectService.read(anyObjectTO.getKey(), SchemaType.PLAIN, "location");
-        assertEquals(anyObjectTO.getPlainAttr("location"), location);
+        assertEquals(anyObjectTO.getPlainAttr("location").get(), location);
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/syncope/blob/74ee038a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/AuthenticationITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/AuthenticationITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/AuthenticationITCase.java
index ddabfac..a2cad27 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/AuthenticationITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/AuthenticationITCase.java
@@ -25,21 +25,17 @@ import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
 import java.security.AccessControlException;
-import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
+import java.util.stream.Collectors;
 import javax.sql.DataSource;
 import javax.ws.rs.ForbiddenException;
 import javax.ws.rs.core.GenericType;
 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.commons.lang3.tuple.Pair;
 import org.apache.syncope.client.lib.AnonymousAuthenticationHandler;
 import org.apache.syncope.client.lib.BasicAuthenticationHandler;
 import org.apache.syncope.client.lib.SyncopeClient;
-import org.apache.syncope.common.lib.EntityTOUtils;
 import org.apache.syncope.common.lib.SyncopeClientException;
 import org.apache.syncope.common.lib.SyncopeConstants;
 import org.apache.syncope.common.lib.patch.DeassociationPatch;
@@ -210,8 +206,8 @@ public class AuthenticationITCase extends AbstractITCase {
                 fiql(SyncopeClient.getUserSearchConditionBuilder().isNotNull("key").query()).build());
         assertNotNull(matchingUsers);
         assertFalse(matchingUsers.getResult().isEmpty());
-        Set<String> matchingUserKeys = CollectionUtils.collect(matchingUsers.getResult(),
-                EntityTOUtils.<UserTO>keyTransformer(), new HashSet<String>());
+        Set<String> matchingUserKeys = matchingUsers.getResult().stream().
+                map(user -> user.getKey()).collect(Collectors.toSet());
         assertTrue(matchingUserKeys.contains("1417acbe-cbf6-4277-9372-e75e04f97000"));
         assertFalse(matchingUserKeys.contains("74cd8ece-715a-44a4-a736-e17b46c4e7e6"));
         assertFalse(matchingUserKeys.contains("823074dc-d280-436d-a7dd-07399fae48ec"));
@@ -222,13 +218,7 @@ public class AuthenticationITCase extends AbstractITCase {
         matchingUsers = userService3.search(new AnyQuery.Builder().realm("/even/two").
                 fiql(SyncopeClient.getUserSearchConditionBuilder().isNotNull("loginDate").query()).build());
         assertNotNull(matchingUsers);
-        assertTrue(IterableUtils.matchesAll(matchingUsers.getResult(), new Predicate<UserTO>() {
-
-            @Override
-            public boolean evaluate(final UserTO matched) {
-                return "/even/two".equals(matched.getRealm());
-            }
-        }));
+        assertTrue(matchingUsers.getResult().stream().allMatch(matching -> "/even/two".equals(matching.getRealm())));
     }
 
     @Test
@@ -276,7 +266,7 @@ public class AuthenticationITCase extends AbstractITCase {
 
             user = response.readEntity(new GenericType<ProvisioningResult<UserTO>>() {
             }).getEntity();
-            assertEquals("surname", user.getPlainAttr("surname").getValues().get(0));
+            assertEquals("surname", user.getPlainAttr("surname").get().getValues().get(0));
 
             // 5. as delegated, update user attempting to move under realm / -> fail
             UserPatch userPatch = new UserPatch();
@@ -299,7 +289,7 @@ public class AuthenticationITCase extends AbstractITCase {
 
             user = response.readEntity(new GenericType<ProvisioningResult<UserTO>>() {
             }).getEntity();
-            assertEquals("surname2", user.getPlainAttr("surname").getValues().get(0));
+            assertEquals("surname2", user.getPlainAttr("surname").get().getValues().get(0));
 
             // 7. as delegated, delete user
             delegatedUserService.delete(user.getKey());
@@ -426,13 +416,8 @@ public class AuthenticationITCase extends AbstractITCase {
         final String anyTypeKey = "FOLDER " + getUUIDString();
 
         // 1. no entitlement exists (yet) for the any type to be created
-        assertFalse(IterableUtils.matchesAny(syncopeService.platform().getEntitlements(), new Predicate<String>() {
-
-            @Override
-            public boolean evaluate(final String entitlement) {
-                return entitlement.contains(anyTypeKey);
-            }
-        }));
+        assertFalse(syncopeService.platform().getEntitlements().stream().
+                anyMatch(entitlement -> entitlement.contains(anyTypeKey)));
 
         // 2. create plain schema, any type class and any type
         PlainSchemaTO path = new PlainSchemaTO();
@@ -452,13 +437,8 @@ public class AuthenticationITCase extends AbstractITCase {
         anyTypeService.create(anyTypeTO);
 
         // 2. now entitlement exists for the any type just created
-        assertTrue(IterableUtils.matchesAny(syncopeService.platform().getEntitlements(), new Predicate<String>() {
-
-            @Override
-            public boolean evaluate(final String entitlement) {
-                return entitlement.contains(anyTypeKey);
-            }
-        }));
+        assertTrue(syncopeService.platform().getEntitlements().stream().
+                anyMatch(entitlement -> entitlement.contains(anyTypeKey)));
 
         // 3. attempt to create an instance of the type above: fail because no entitlement was assigned
         AnyObjectTO folder = new AnyObjectTO();
@@ -522,7 +502,7 @@ public class AuthenticationITCase extends AbstractITCase {
         // 3. approve user
         WorkflowFormTO form = userWorkflowService.getFormForUser(userTO.getKey());
         form = userWorkflowService.claimForm(form.getTaskId());
-        form.getProperty("approve").setValue(Boolean.TRUE.toString());
+        form.getProperty("approve").get().setValue(Boolean.TRUE.toString());
         userTO = userWorkflowService.submitForm(form);
         assertNotNull(userTO);
         assertEquals("active", userTO.getStatus());

http://git-wip-us.apache.org/repos/asf/syncope/blob/74ee038a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/CamelRouteITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/CamelRouteITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/CamelRouteITCase.java
index 4f4f475..f3b9693 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/CamelRouteITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/CamelRouteITCase.java
@@ -46,9 +46,7 @@ public class CamelRouteITCase extends AbstractITCase {
         List<CamelRouteTO> userRoutes = camelRouteService.list(AnyTypeKind.USER);
         assertNotNull(userRoutes);
         assertEquals(16, userRoutes.size());
-        for (CamelRouteTO route : userRoutes) {
-            assertNotNull(route.getContent());
-        }
+        userRoutes.forEach(route -> assertNotNull(route.getContent()));
     }
 
     @Test
@@ -58,9 +56,7 @@ public class CamelRouteITCase extends AbstractITCase {
         List<CamelRouteTO> groupRoutes = camelRouteService.list(AnyTypeKind.GROUP);
         assertNotNull(groupRoutes);
         assertEquals(8, groupRoutes.size());
-        for (CamelRouteTO route : groupRoutes) {
-            assertNotNull(route.getContent());
-        }
+        groupRoutes.forEach(route -> assertNotNull(route.getContent()));
     }
 
     private CamelRouteTO doUpdate(final String key, final String content) {
@@ -120,7 +116,7 @@ public class CamelRouteITCase extends AbstractITCase {
                 + "    </setProperty>\n"
                 + "    <setBody>\n"
                 + "     <groovy>\n"
-                + "request.body.getPlainAttr(\"camelAttribute\").getValues().set(0,\"true\")\n"
+                + "request.body.getPlainAttr(\"camelAttribute\").get().getValues().set(0,\"true\")\n"
                 + "       return request.body\n"
                 + "     </groovy>\n"
                 + "    </setBody>\n"
@@ -165,7 +161,7 @@ public class CamelRouteITCase extends AbstractITCase {
 
             userTO = createUser(userTO).getEntity();
             assertNotNull(userTO);
-            assertEquals("true", userTO.getPlainAttr("camelAttribute").getValues().get(0));
+            assertEquals("true", userTO.getPlainAttr("camelAttribute").get().getValues().get(0));
         } finally {
             doUpdate(oldRoute.getKey(), oldRoute.getContent());
         }

http://git-wip-us.apache.org/repos/asf/syncope/blob/74ee038a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/ConnectorITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/ConnectorITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/ConnectorITCase.java
index 09a2653..5f01974 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/ConnectorITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/ConnectorITCase.java
@@ -36,11 +36,8 @@ import java.util.Locale;
 import java.util.Properties;
 import java.util.Set;
 import java.util.UUID;
+import java.util.stream.Collectors;
 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.commons.collections4.Transformer;
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang3.SerializationUtils;
 import org.apache.commons.lang3.exception.ExceptionUtils;
@@ -295,9 +292,7 @@ public class ConnectorITCase extends AbstractITCase {
         List<ConnInstanceTO> connectorInstanceTOs = connectorService.list(null);
         assertNotNull(connectorInstanceTOs);
         assertFalse(connectorInstanceTOs.isEmpty());
-        for (ConnInstanceTO instance : connectorInstanceTOs) {
-            assertNotNull(instance);
-        }
+        connectorInstanceTOs.forEach(instance -> assertNotNull(instance));
     }
 
     @Test
@@ -312,9 +307,7 @@ public class ConnectorITCase extends AbstractITCase {
         List<ConnBundleTO> bundles = connectorService.getBundles(Locale.ENGLISH.getLanguage());
         assertNotNull(bundles);
         assertFalse(bundles.isEmpty());
-        for (ConnBundleTO bundle : bundles) {
-            assertNotNull(bundle);
-        }
+        bundles.forEach(bundle -> assertNotNull(bundle));
     }
 
     @Test
@@ -347,7 +340,7 @@ public class ConnectorITCase extends AbstractITCase {
 
         for (ConnInstanceTO instance : connectorInstanceTOs) {
             if ("net.tirasa.connid.bundles.db.table".equals(instance.getBundleName())) {
-                assertEquals("Utente", instance.getConf("user").getSchema().getDisplayName());
+                assertEquals("Utente", instance.getConf("user").get().getSchema().getDisplayName());
             }
         }
 
@@ -356,7 +349,7 @@ public class ConnectorITCase extends AbstractITCase {
 
         for (ConnInstanceTO instance : connectorInstanceTOs) {
             if ("net.tirasa.connid.bundles.db.table".equals(instance.getBundleName())) {
-                assertEquals("User", instance.getConf("user").getSchema().getDisplayName());
+                assertEquals("User", instance.getConf("user").get().getSchema().getDisplayName());
             }
         }
     }
@@ -478,15 +471,8 @@ public class ConnectorITCase extends AbstractITCase {
         objectClassInfo = connectorService.buildObjectClassInfo(ldap, true);
         assertNotNull(objectClassInfo);
 
-        Collection<String> objectClasses = CollectionUtils.collect(objectClassInfo,
-                new Transformer<ConnIdObjectClassTO, String>() {
-
-            @Override
-            public String transform(final ConnIdObjectClassTO info) {
-                return info.getType();
-            }
-
-        });
+        Collection<String> objectClasses = objectClassInfo.stream().
+                map(info -> info.getType()).collect(Collectors.toSet());
         assertTrue(objectClasses.contains(ObjectClass.ACCOUNT_NAME));
         assertTrue(objectClasses.contains(ObjectClass.GROUP_NAME));
     }
@@ -500,13 +486,14 @@ public class ConnectorITCase extends AbstractITCase {
         ConnInstanceTO ldapConn = connectorService.read("74141a3b-0762-4720-a4aa-fc3e374ef3ef", null);
         String originalDisplayName = ldapConn.getDisplayName();
         Set<ConnectorCapability> originalCapabilities = new HashSet<>(ldapConn.getCapabilities());
-        ConnConfProperty originalConfProp = SerializationUtils.clone(ldapConn.getConf("maintainPosixGroupMembership"));
+        ConnConfProperty originalConfProp = SerializationUtils.clone(
+                ldapConn.getConf("maintainPosixGroupMembership").get());
         assertEquals(1, originalConfProp.getValues().size());
         assertEquals("false", originalConfProp.getValues().get(0));
 
         ldapConn.setDisplayName(originalDisplayName + " modified");
         ldapConn.getCapabilities().clear();
-        ldapConn.getConf("maintainPosixGroupMembership").getValues().set(0, "true");
+        ldapConn.getConf("maintainPosixGroupMembership").get().getValues().set(0, "true");
         connectorService.update(ldapConn);
 
         ldapConn = connectorService.read("74141a3b-0762-4720-a4aa-fc3e374ef3ef", null);
@@ -522,7 +509,7 @@ public class ConnectorITCase extends AbstractITCase {
         ldapConn = connectorService.read("74141a3b-0762-4720-a4aa-fc3e374ef3ef", null);
         assertEquals(originalDisplayName, ldapConn.getDisplayName());
         assertEquals(originalCapabilities, ldapConn.getCapabilities());
-        assertEquals(originalConfProp, ldapConn.getConf("maintainPosixGroupMembership"));
+        assertEquals(originalConfProp, ldapConn.getConf("maintainPosixGroupMembership").get());
     }
 
     @Test
@@ -534,14 +521,9 @@ public class ConnectorITCase extends AbstractITCase {
         List<ConnInstanceTO> connInstances = pcs.list(null);
         assertEquals(2, connInstances.size());
 
-        assertTrue(IterableUtils.matchesAll(connInstances, new Predicate<ConnInstanceTO>() {
-
-            @Override
-            public boolean evaluate(final ConnInstanceTO object) {
-                return "a6d017fd-a705-4507-bb7c-6ab6a6745997".equals(object.getKey())
-                        || "44c02549-19c3-483c-8025-4919c3283c37".equals(object.getKey());
-            }
-        }));
+        assertTrue(connInstances.stream().allMatch(connInstance
+                -> "a6d017fd-a705-4507-bb7c-6ab6a6745997".equals(connInstance.getKey())
+                || "44c02549-19c3-483c-8025-4919c3283c37".equals(connInstance.getKey())));
 
         // 2. attempt to read a connector with a different admin realm: fail
         try {
@@ -554,18 +536,18 @@ public class ConnectorITCase extends AbstractITCase {
         // 3. read and upate a connector in the realm for which entitlements are owned: succeed
         try {
             ConnInstanceTO scriptedsql = pcs.read("a6d017fd-a705-4507-bb7c-6ab6a6745997", null);
-            ConnConfProperty reloadScriptOnExecution = scriptedsql.getConf("reloadScriptOnExecution");
+            ConnConfProperty reloadScriptOnExecution = scriptedsql.getConf("reloadScriptOnExecution").get();
             assertEquals("true", reloadScriptOnExecution.getValues().get(0).toString());
 
             reloadScriptOnExecution.getValues().set(0, "false");
             pcs.update(scriptedsql);
 
             scriptedsql = pcs.read(scriptedsql.getKey(), null);
-            reloadScriptOnExecution = scriptedsql.getConf("reloadScriptOnExecution");
+            reloadScriptOnExecution = scriptedsql.getConf("reloadScriptOnExecution").get();
             assertEquals("false", reloadScriptOnExecution.getValues().get(0).toString());
         } finally {
             ConnInstanceTO scriptedsql = connectorService.read("a6d017fd-a705-4507-bb7c-6ab6a6745997", null);
-            ConnConfProperty reloadScriptOnExecution = scriptedsql.getConf("reloadScriptOnExecution");
+            ConnConfProperty reloadScriptOnExecution = scriptedsql.getConf("reloadScriptOnExecution").get();
             reloadScriptOnExecution.getValues().set(0, "true");
             connectorService.update(scriptedsql);
         }
@@ -582,17 +564,13 @@ public class ConnectorITCase extends AbstractITCase {
         assertNotNull(connInstanceTO);
 
         // check for resource
-        Collection<ResourceTO> resources = CollectionUtils.select(resourceService.list(), new Predicate<ResourceTO>() {
-
-            @Override
-            public boolean evaluate(final ResourceTO object) {
-                return "fcf9f2b0-f7d6-42c9-84a6-61b28255a42b".equals(object.getConnector());
-            }
-        });
+        List<ResourceTO> resources = resourceService.list().stream().
+                filter(resource -> "fcf9f2b0-f7d6-42c9-84a6-61b28255a42b".equals(resource.getConnector())).
+                collect(Collectors.toList());
         assertEquals(4, resources.size());
 
         // Retrieve a resource TO template.
-        ResourceTO resourceTO = resources.iterator().next();
+        ResourceTO resourceTO = resources.get(0);
 
         // Make it new.
         resourceTO.setKey("newAbout103" + getUUIDString());
@@ -628,13 +606,8 @@ public class ConnectorITCase extends AbstractITCase {
 
         assertNotNull(resourceTO);
 
-        resources = CollectionUtils.select(resourceService.list(), new Predicate<ResourceTO>() {
-
-            @Override
-            public boolean evaluate(final ResourceTO object) {
-                return connKey.equals(object.getConnector());
-            }
-        });
+        resources = resourceService.list().stream().
+                filter(resource -> connKey.equals(resource.getConnector())).collect(Collectors.toList());
         assertEquals(1, resources.size());
         // ----------------------------------
 

http://git-wip-us.apache.org/repos/asf/syncope/blob/74ee038a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/DynRealmITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/DynRealmITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/DynRealmITCase.java
index 7d745a7..3506b8d 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/DynRealmITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/DynRealmITCase.java
@@ -26,8 +26,6 @@ import static org.junit.Assert.fail;
 
 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.syncope.client.lib.SyncopeClient;
 import org.apache.syncope.common.lib.SyncopeClientException;
 import org.apache.syncope.common.lib.patch.AttrPatch;
@@ -141,22 +139,11 @@ public class DynRealmITCase extends AbstractITCase {
             // 5. verify that the new user and group are found when searching by dynamic realm
             PagedResult<UserTO> matchingUsers = userService.search(new AnyQuery.Builder().realm("/").fiql(
                     SyncopeClient.getUserSearchConditionBuilder().inDynRealms(dynRealm.getKey()).query()).build());
-            assertTrue(IterableUtils.matchesAny(matchingUsers.getResult(), new Predicate<UserTO>() {
+            assertTrue(matchingUsers.getResult().stream().anyMatch(object -> object.getKey().equals(userKey)));
 
-                @Override
-                public boolean evaluate(final UserTO object) {
-                    return object.getKey().equals(userKey);
-                }
-            }));
             PagedResult<GroupTO> matchingGroups = groupService.search(new AnyQuery.Builder().realm("/").fiql(
                     SyncopeClient.getGroupSearchConditionBuilder().inDynRealms(dynRealm.getKey()).query()).build());
-            assertTrue(IterableUtils.matchesAny(matchingGroups.getResult(), new Predicate<GroupTO>() {
-
-                @Override
-                public boolean evaluate(final GroupTO object) {
-                    return object.getKey().equals(groupKey);
-                }
-            }));
+            assertTrue(matchingGroups.getResult().stream().anyMatch(object -> object.getKey().equals(groupKey)));
 
             // 6. prepare to act as delegated admin
             SyncopeClient delegatedClient = clientFactory.create(dynRealmAdmin.getUsername(), "password123");
@@ -172,13 +159,7 @@ public class DynRealmITCase extends AbstractITCase {
 
             // USER_SEARCH
             matchingUsers = delegatedUserService.search(new AnyQuery.Builder().realm("/").build());
-            assertTrue(IterableUtils.matchesAny(matchingUsers.getResult(), new Predicate<UserTO>() {
-
-                @Override
-                public boolean evaluate(final UserTO object) {
-                    return object.getKey().equals(userKey);
-                }
-            }));
+            assertTrue(matchingUsers.getResult().stream().anyMatch(object -> object.getKey().equals(userKey)));
 
             // USER_UPDATE
             UserPatch userPatch = new UserPatch();
@@ -209,7 +190,7 @@ public class DynRealmITCase extends AbstractITCase {
                     readEntity(new GenericType<ProvisioningResult<GroupTO>>() {
                     }).getEntity();
             assertNotNull(group);
-            assertEquals("modified", group.getPlainAttr("icon").getValues().get(0));
+            assertEquals("modified", group.getPlainAttr("icon").get().getValues().get(0));
         } finally {
             if (role != null) {
                 roleService.delete(role.getKey());

http://git-wip-us.apache.org/repos/asf/syncope/blob/74ee038a/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 9d833cc..817d8e4 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
@@ -38,8 +38,6 @@ 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;
@@ -121,9 +119,9 @@ public class GroupITCase extends AbstractITCase {
         groupTO = createGroup(groupTO).getEntity();
         assertNotNull(groupTO);
 
-        assertNotNull(groupTO.getVirAttr("rvirtualdata").getValues());
-        assertFalse(groupTO.getVirAttr("rvirtualdata").getValues().isEmpty());
-        assertEquals("rvirtualvalue", groupTO.getVirAttr("rvirtualdata").getValues().get(0));
+        assertNotNull(groupTO.getVirAttr("rvirtualdata").get().getValues());
+        assertFalse(groupTO.getVirAttr("rvirtualdata").get().getValues().isEmpty());
+        assertEquals("rvirtualvalue", groupTO.getVirAttr("rvirtualdata").get().getValues().get(0));
 
         assertTrue(groupTO.getResources().contains(RESOURCE_NAME_LDAP));
 
@@ -181,9 +179,7 @@ public class GroupITCase extends AbstractITCase {
                 groupService.search(new AnyQuery.Builder().realm(SyncopeConstants.ROOT_REALM).build());
         assertNotNull(groupTOs);
         assertTrue(groupTOs.getResult().size() >= 8);
-        for (GroupTO groupTO : groupTOs.getResult()) {
-            assertNotNull(groupTO);
-        }
+        groupTOs.getResult().forEach(groupTO -> assertNotNull(groupTO));
     }
 
     @Test
@@ -200,8 +196,8 @@ public class GroupITCase extends AbstractITCase {
         UserTO userTO = userService.read("1417acbe-cbf6-4277-9372-e75e04f97000");
         assertNotNull(userTO);
 
-        assertNotNull(userTO.getMembership("37d15e4c-cdc1-460b-a591-8505c8133806"));
-        assertNull(userTO.getMembership("29f96485-729e-4d31-88a1-6fc60e4677f3"));
+        assertTrue(userTO.getMembership("37d15e4c-cdc1-460b-a591-8505c8133806").isPresent());
+        assertFalse(userTO.getMembership("29f96485-729e-4d31-88a1-6fc60e4677f3").isPresent());
 
         GroupService groupService2 = clientFactory.create("rossini", ADMIN_PWD).getService(GroupService.class);
 
@@ -214,13 +210,7 @@ public class GroupITCase extends AbstractITCase {
 
         List<GroupTO> groups = groupService2.own();
         assertNotNull(groups);
-        assertTrue(IterableUtils.matchesAny(groups, new Predicate<GroupTO>() {
-
-            @Override
-            public boolean evaluate(final GroupTO group) {
-                return "37d15e4c-cdc1-460b-a591-8505c8133806".equals(group.getKey());
-            }
-        }));
+        assertTrue(groups.stream().anyMatch(group -> "37d15e4c-cdc1-460b-a591-8505c8133806".equals(group.getKey())));
     }
 
     @Test
@@ -241,12 +231,12 @@ public class GroupITCase extends AbstractITCase {
         assertEquals(modName, groupTO.getName());
         assertEquals(2, groupTO.getPlainAttrs().size());
 
-        groupTO.getPlainAttr("show").getValues().clear();
+        groupTO.getPlainAttr("show").get().getValues().clear();
 
         groupTO = groupService.update(groupTO).readEntity(new GenericType<ProvisioningResult<GroupTO>>() {
         }).getEntity();
 
-        assertNull(groupTO.getPlainAttr("show"));
+        assertFalse(groupTO.getPlainAttr("show").isPresent());
     }
 
     @Test
@@ -575,10 +565,10 @@ public class GroupITCase extends AbstractITCase {
 
         // 2. create a group *without* an attribute for that schema: it works
         GroupTO groupTO = getSampleTO("lastGroup");
-        assertNull(groupTO.getPlainAttr(badge.getKey()));
+        assertFalse(groupTO.getPlainAttr(badge.getKey()).isPresent());
         groupTO = createGroup(groupTO).getEntity();
         assertNotNull(groupTO);
-        assertNull(groupTO.getPlainAttr(badge.getKey()));
+        assertFalse(groupTO.getPlainAttr(badge.getKey()).isPresent());
 
         // 3. add the new mandatory schema to the default group type
         AnyTypeTO type = anyTypeService.read(AnyTypeKind.GROUP.name());
@@ -651,7 +641,7 @@ public class GroupITCase extends AbstractITCase {
         final String groupKey = group.getKey();
 
         List<MembershipTO> memberships = userService.read(
-            "c9b2dec2-00a7-4855-97c0-d854842b4b24").getDynMemberships();
+                "c9b2dec2-00a7-4855-97c0-d854842b4b24").getDynMemberships();
         assertTrue(memberships.stream().anyMatch(m -> m.getGroupKey().equals(groupKey)));
 
         GroupPatch patch = new GroupPatch();
@@ -682,11 +672,11 @@ public class GroupITCase extends AbstractITCase {
         newAny = createAnyObject(newAny).getEntity();
         assertNotNull(newAny.getPlainAttr("location"));
         List<MembershipTO> memberships = anyObjectService.read(
-            "fc6dbc3a-6c07-4965-8781-921e7401a4a5").getDynMemberships();
+                "fc6dbc3a-6c07-4965-8781-921e7401a4a5").getDynMemberships();
         assertTrue(memberships.stream().anyMatch(m -> m.getGroupKey().equals(groupKey)));
 
         memberships = anyObjectService.read(
-            "8559d14d-58c2-46eb-a2d4-a7d35161e8f8").getDynMemberships();
+                "8559d14d-58c2-46eb-a2d4-a7d35161e8f8").getDynMemberships();
         assertTrue(memberships.stream().anyMatch(m -> m.getGroupKey().equals(groupKey)));
 
         memberships = anyObjectService.read(newAny.getKey()).getDynMemberships();
@@ -713,13 +703,13 @@ public class GroupITCase extends AbstractITCase {
                 attrTO(new AttrTO.Builder().schema("location").build()).
                 build());
         newAny = updateAnyObject(anyPatch).getEntity();
-        assertNull(newAny.getPlainAttr("location"));
+        assertFalse(newAny.getPlainAttr("location").isPresent());
 
         memberships = anyObjectService.read(
-            "fc6dbc3a-6c07-4965-8781-921e7401a4a5").getDynMemberships();
+                "fc6dbc3a-6c07-4965-8781-921e7401a4a5").getDynMemberships();
         assertFalse(memberships.stream().anyMatch(m -> m.getGroupKey().equals(groupKey)));
         memberships = anyObjectService.read(
-            "8559d14d-58c2-46eb-a2d4-a7d35161e8f8").getDynMemberships();
+                "8559d14d-58c2-46eb-a2d4-a7d35161e8f8").getDynMemberships();
         assertFalse(memberships.stream().anyMatch(m -> m.getGroupKey().equals(groupKey)));
         memberships = anyObjectService.read(newAny.getKey()).getDynMemberships();
         assertTrue(memberships.stream().anyMatch(m -> m.getGroupKey().equals(groupKey)));
@@ -826,8 +816,8 @@ public class GroupITCase extends AbstractITCase {
         groupTO = createGroup(groupTO).getEntity();
         assertNotNull(groupTO);
         assertEquals(1, groupTO.getTypeExtensions().size());
-        assertEquals(1, groupTO.getTypeExtension(AnyTypeKind.USER.name()).getAuxClasses().size());
-        assertTrue(groupTO.getTypeExtension(AnyTypeKind.USER.name()).getAuxClasses().contains("csv"));
+        assertEquals(1, groupTO.getTypeExtension(AnyTypeKind.USER.name()).get().getAuxClasses().size());
+        assertTrue(groupTO.getTypeExtension(AnyTypeKind.USER.name()).get().getAuxClasses().contains("csv"));
 
         typeExtension = new TypeExtensionTO();
         typeExtension.setAnyType(AnyTypeKind.USER.name());
@@ -841,9 +831,9 @@ public class GroupITCase extends AbstractITCase {
         groupTO = updateGroup(groupPatch).getEntity();
         assertNotNull(groupTO);
         assertEquals(1, groupTO.getTypeExtensions().size());
-        assertEquals(2, groupTO.getTypeExtension(AnyTypeKind.USER.name()).getAuxClasses().size());
-        assertTrue(groupTO.getTypeExtension(AnyTypeKind.USER.name()).getAuxClasses().contains("csv"));
-        assertTrue(groupTO.getTypeExtension(AnyTypeKind.USER.name()).getAuxClasses().contains("other"));
+        assertEquals(2, groupTO.getTypeExtension(AnyTypeKind.USER.name()).get().getAuxClasses().size());
+        assertTrue(groupTO.getTypeExtension(AnyTypeKind.USER.name()).get().getAuxClasses().contains("csv"));
+        assertTrue(groupTO.getTypeExtension(AnyTypeKind.USER.name()).get().getAuxClasses().contains("other"));
     }
 
     @Test
@@ -958,7 +948,7 @@ public class GroupITCase extends AbstractITCase {
                 provision.getVirSchemas().clear();
             }
 
-            MappingTO mapping = newLDAP.getProvision(AnyTypeKind.GROUP.name()).getMapping();
+            MappingTO mapping = newLDAP.getProvision(AnyTypeKind.GROUP.name()).get().getMapping();
 
             ItemTO connObjectKey = mapping.getConnObjectKeyItem();
             connObjectKey.setIntAttrName("displayProperty");
@@ -1055,7 +1045,7 @@ public class GroupITCase extends AbstractITCase {
 
         groupTO = createGroup(groupTO).getEntity();
         assertNotNull(groupTO);
-        assertEquals("11.23", groupTO.getPlainAttr(doubleSchemaName).getValues().get(0));
+        assertEquals("11.23", groupTO.getPlainAttr(doubleSchemaName).get().getValues().get(0));
 
         // 3. update schema, set conversion pattern
         schema = schemaService.read(SchemaType.PLAIN, schema.getKey());
@@ -1065,7 +1055,7 @@ public class GroupITCase extends AbstractITCase {
         // 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));
+        assertEquals("11.230", groupTO.getPlainAttr(doubleSchemaName).get().getValues().get(0));
 
         // 5. modify group with new double value
         GroupPatch patch = new GroupPatch();
@@ -1074,7 +1064,7 @@ public class GroupITCase extends AbstractITCase {
 
         groupTO = updateGroup(patch).getEntity();
         assertNotNull(groupTO);
-        assertEquals("11.257", groupTO.getPlainAttr(doubleSchemaName).getValues().get(0));
+        assertEquals("11.257", groupTO.getPlainAttr(doubleSchemaName).get().getValues().get(0));
 
         // 6. update schema, unset conversion pattern
         schema.setConversionPattern(null);
@@ -1087,6 +1077,6 @@ public class GroupITCase extends AbstractITCase {
 
         groupTO = updateGroup(patch).getEntity();
         assertNotNull(groupTO);
-        assertEquals("11.23", groupTO.getPlainAttr(doubleSchemaName).getValues().get(0));
+        assertEquals("11.23", groupTO.getPlainAttr(doubleSchemaName).get().getValues().get(0));
     }
 }

http://git-wip-us.apache.org/repos/asf/syncope/blob/74ee038a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/IdentityRecertificationITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/IdentityRecertificationITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/IdentityRecertificationITCase.java
index 3a9ee36..00f8fdb 100755
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/IdentityRecertificationITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/IdentityRecertificationITCase.java
@@ -39,7 +39,7 @@ public class IdentityRecertificationITCase extends AbstractTaskITCase {
         assertFalse(forms.isEmpty());
         for (WorkflowFormTO form : forms) {
             userWorkflowService.claimForm(form.getTaskId());
-            WorkflowFormPropertyTO approve = form.getProperty("approve");
+            WorkflowFormPropertyTO approve = form.getProperty("approve").get();
             approve.setValue("true");
             userWorkflowService.submitForm(form);
         }

http://git-wip-us.apache.org/repos/asf/syncope/blob/74ee038a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/LoggerITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/LoggerITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/LoggerITCase.java
index 0f7253e..e90e9d2 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/LoggerITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/LoggerITCase.java
@@ -33,8 +33,6 @@ import java.util.List;
 import java.util.Properties;
 import javax.ws.rs.core.Response;
 import javax.xml.ws.WebServiceException;
-import org.apache.commons.collections4.IterableUtils;
-import org.apache.commons.collections4.Predicate;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang3.StringUtils;
@@ -69,10 +67,10 @@ public class LoggerITCase extends AbstractITCase {
         List<LogAppender> memoryAppenders = loggerService.memoryAppenders();
         assertNotNull(memoryAppenders);
         assertFalse(memoryAppenders.isEmpty());
-        for (LogAppender appender : memoryAppenders) {
+        memoryAppenders.forEach(appender -> {
             assertNotNull(appender);
             assertNotNull(appender.getName());
-        }
+        });
     }
 
     @Test
@@ -94,9 +92,9 @@ public class LoggerITCase extends AbstractITCase {
         List<LoggerTO> loggers = loggerService.list(LoggerType.LOG);
         assertNotNull(loggers);
         assertFalse(loggers.isEmpty());
-        for (LoggerTO logger : loggers) {
+        loggers.forEach(logger -> {
             assertNotNull(logger);
-        }
+        });
     }
 
     @Test
@@ -354,14 +352,9 @@ public class LoggerITCase extends AbstractITCase {
         List<EventCategoryTO> events = loggerService.events();
         assertNotNull(events);
 
-        EventCategoryTO userLogic = IterableUtils.find(events, new Predicate<EventCategoryTO>() {
-
-            @Override
-            public boolean evaluate(final EventCategoryTO object) {
-                return "UserLogic".equals(object.getCategory());
-            }
-        });
+        EventCategoryTO userLogic = events.stream().
+                filter(object -> "UserLogic".equals(object.getCategory())).findAny().get();
         assertNotNull(userLogic);
-        assertEquals(1, IterableUtils.frequency(userLogic.getEvents(), "create"));
+        assertEquals(1, userLogic.getEvents().stream().filter(event -> "create".equals(event)).count());
     }
 }

http://git-wip-us.apache.org/repos/asf/syncope/blob/74ee038a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/MembershipITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/MembershipITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/MembershipITCase.java
index 6a4abd1..3511552 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/MembershipITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/MembershipITCase.java
@@ -21,15 +21,11 @@ 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.assertNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
 import javax.sql.DataSource;
 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.SyncopeClientException;
 import org.apache.syncope.common.lib.patch.AttrPatch;
@@ -75,7 +71,7 @@ public class MembershipITCase extends AbstractITCase {
         UserTO user = UserITCase.getUniqueSampleTO("memb@apache.org");
         user.setRealm("/even/two");
         user.getPlainAttrs().add(new AttrTO.Builder().schema("aLong").value("1976").build());
-        user.getPlainAttrs().remove(user.getPlainAttr("ctype"));
+        user.getPlainAttrs().remove(user.getPlainAttr("ctype").get());
 
         // the group 034740a9-fa10-453b-af37-dc7897e98fb1 has USER type extensions for 'csv' and 'other' 
         // any type classes
@@ -97,30 +93,24 @@ public class MembershipITCase extends AbstractITCase {
         }
 
         // remove fullname and try again
-        CollectionUtils.filterInverse(membership.getPlainAttrs(), new Predicate<AttrTO>() {
-
-            @Override
-            public boolean evaluate(final AttrTO object) {
-                return "fullname".equals(object.getSchema());
-            }
-        });
+        membership.getPlainAttrs().remove(membership.getPlainAttr("fullname").get());
         try {
             user = createUser(user).getEntity();
 
             // 1. verify that 'aLong' is correctly populated for user
-            assertEquals(1, user.getPlainAttr("aLong").getValues().size());
-            assertEquals("1976", user.getPlainAttr("aLong").getValues().get(0));
+            assertEquals(1, user.getPlainAttr("aLong").get().getValues().size());
+            assertEquals("1976", user.getPlainAttr("aLong").get().getValues().get(0));
 
             // 2. verify that 'aLong' is correctly populated for user's membership
             assertEquals(1, user.getMemberships().size());
-            membership = user.getMembership("034740a9-fa10-453b-af37-dc7897e98fb1");
+            membership = user.getMembership("034740a9-fa10-453b-af37-dc7897e98fb1").get();
             assertNotNull(membership);
-            assertEquals(1, membership.getPlainAttr("aLong").getValues().size());
-            assertEquals("1977", membership.getPlainAttr("aLong").getValues().get(0));
+            assertEquals(1, membership.getPlainAttr("aLong").get().getValues().size());
+            assertEquals("1977", membership.getPlainAttr("aLong").get().getValues().get(0));
 
             // 3. verify that derived attrbutes from 'csv' and 'other' are also populated for user's membership
-            assertFalse(membership.getDerAttr("csvuserid").getValues().isEmpty());
-            assertFalse(membership.getDerAttr("noschema").getValues().isEmpty());
+            assertFalse(membership.getDerAttr("csvuserid").get().getValues().isEmpty());
+            assertFalse(membership.getDerAttr("noschema").get().getValues().isEmpty());
 
             // update user - change some values and add new membership attribute
             UserPatch userPatch = new UserPatch();
@@ -139,19 +129,19 @@ public class MembershipITCase extends AbstractITCase {
             user = updateUser(userPatch).getEntity();
 
             // 4. verify that 'aLong' is correctly populated for user
-            assertEquals(1, user.getPlainAttr("aLong").getValues().size());
-            assertEquals("1977", user.getPlainAttr("aLong").getValues().get(0));
-            assertNull(user.getPlainAttr("ctype"));
+            assertEquals(1, user.getPlainAttr("aLong").get().getValues().size());
+            assertEquals("1977", user.getPlainAttr("aLong").get().getValues().get(0));
+            assertFalse(user.getPlainAttr("ctype").isPresent());
 
             // 5. verify that 'aLong' is correctly populated for user's membership
             assertEquals(1, user.getMemberships().size());
-            membership = user.getMembership("034740a9-fa10-453b-af37-dc7897e98fb1");
+            membership = user.getMembership("034740a9-fa10-453b-af37-dc7897e98fb1").get();
             assertNotNull(membership);
-            assertEquals(1, membership.getPlainAttr("aLong").getValues().size());
-            assertEquals("1976", membership.getPlainAttr("aLong").getValues().get(0));
+            assertEquals(1, membership.getPlainAttr("aLong").get().getValues().size());
+            assertEquals("1976", membership.getPlainAttr("aLong").get().getValues().get(0));
 
             // 6. verify that 'ctype' is correctly populated for user's membership
-            assertEquals("membership type", membership.getPlainAttr("ctype").getValues().get(0));
+            assertEquals("membership type", membership.getPlainAttr("ctype").get().getValues().get(0));
 
             // finally remove membership
             userPatch = new UserPatch();
@@ -211,14 +201,14 @@ public class MembershipITCase extends AbstractITCase {
 
         // verify that 'aLong' is correctly populated for user's membership
         assertEquals(1, user.getMemberships().size());
-        membership = user.getMembership(groupTO.getKey());
+        membership = user.getMembership(groupTO.getKey()).get();
         assertNotNull(membership);
-        assertEquals(1, membership.getPlainAttr("aLong").getValues().size());
-        assertEquals("1454", membership.getPlainAttr("aLong").getValues().get(0));
+        assertEquals(1, membership.getPlainAttr("aLong").get().getValues().size());
+        assertEquals("1454", membership.getPlainAttr("aLong").get().getValues().get(0));
 
         // verify that derived attrbutes from 'csv' and 'other' are also populated for user's membership
-        assertFalse(membership.getDerAttr("csvuserid").getValues().isEmpty());
-        assertFalse(membership.getDerAttr("noschema").getValues().isEmpty());
+        assertFalse(membership.getDerAttr("csvuserid").get().getValues().isEmpty());
+        assertFalse(membership.getDerAttr("noschema").get().getValues().isEmpty());
 
         // now remove the group -> all related memberships should have been removed as well
         groupService.delete(groupTO.getKey());
@@ -234,27 +224,15 @@ public class MembershipITCase extends AbstractITCase {
         ResourceTO newResource = resourceService.read(RESOURCE_NAME_DBPULL);
         newResource.setKey(getUUIDString());
 
-        ItemTO item = IterableUtils.find(newResource.getProvision("USER").getMapping().getItems(),
-                new Predicate<ItemTO>() {
-
-            @Override
-            public boolean evaluate(final ItemTO object) {
-                return "firstname".equals(object.getIntAttrName());
-            }
-        });
+        ItemTO item = newResource.getProvision("USER").get().getMapping().getItems().stream().
+                filter(object -> "firstname".equals(object.getIntAttrName())).findFirst().get();
         assertNotNull(item);
         assertEquals("ID", item.getExtAttrName());
         item.setIntAttrName("memberships[additional].aLong");
         item.setPurpose(MappingPurpose.BOTH);
 
-        item = IterableUtils.find(newResource.getProvision("USER").getMapping().getItems(),
-                new Predicate<ItemTO>() {
-
-            @Override
-            public boolean evaluate(final ItemTO object) {
-                return "fullname".equals(object.getIntAttrName());
-            }
-        });
+        item = newResource.getProvision("USER").get().getMapping().getItems().stream().
+                filter(object -> "fullname".equals(object.getIntAttrName())).findFirst().get();
         item.setPurpose(MappingPurpose.PULL);
 
         PullTaskTO newTask = null;
@@ -265,7 +243,7 @@ public class MembershipITCase extends AbstractITCase {
             // 1. create user with new resource assigned
             UserTO user = UserITCase.getUniqueSampleTO("memb@apache.org");
             user.setRealm("/even/two");
-            user.getPlainAttrs().remove(user.getPlainAttr("ctype"));
+            user.getPlainAttrs().remove(user.getPlainAttr("ctype").get());
             user.getResources().clear();
             user.getResources().add(newResource.getKey());
 
@@ -311,7 +289,7 @@ public class MembershipITCase extends AbstractITCase {
             assertEquals(1, users.getTotalCount());
             assertEquals(1, users.getResult().get(0).getMemberships().size());
             assertEquals("5432", users.getResult().get(0).getMemberships().get(0).
-                    getPlainAttr("aLong").getValues().get(0));
+                    getPlainAttr("aLong").get().getValues().get(0));
         } catch (Exception e) {
             LOG.error("Unexpected error", e);
             fail(e.getMessage());

http://git-wip-us.apache.org/repos/asf/syncope/blob/74ee038a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/MigrationITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/MigrationITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/MigrationITCase.java
index 7600340..40e878a 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/MigrationITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/MigrationITCase.java
@@ -27,12 +27,9 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.util.Properties;
 import javax.ws.rs.core.Response;
-import org.apache.commons.collections4.IterableUtils;
-import org.apache.commons.collections4.Predicate;
 import org.apache.commons.io.IOUtils;
 import org.apache.syncope.common.lib.SyncopeClientException;
 import org.apache.syncope.common.lib.SyncopeConstants;
-import org.apache.syncope.common.lib.to.AbstractTaskTO;
 import org.apache.syncope.common.lib.to.AnyTypeClassTO;
 import org.apache.syncope.common.lib.to.AttrTO;
 import org.apache.syncope.common.lib.to.BulkAction;
@@ -40,7 +37,6 @@ import org.apache.syncope.common.lib.to.ConnInstanceTO;
 import org.apache.syncope.common.lib.to.GroupTO;
 import org.apache.syncope.common.lib.to.ItemTO;
 import org.apache.syncope.common.lib.to.MappingTO;
-import org.apache.syncope.common.lib.to.MembershipTO;
 import org.apache.syncope.common.lib.to.PlainSchemaTO;
 import org.apache.syncope.common.lib.to.ProvisionTO;
 import org.apache.syncope.common.lib.to.PullTaskTO;
@@ -428,13 +424,12 @@ public class MigrationITCase extends AbstractTaskITCase {
     public void migrateFromSyncope12() throws InterruptedException {
         // 1. cleanup
         try {
-            for (AbstractTaskTO task : taskService.list(
-                    new TaskQuery.Builder(TaskType.PULL).resource(RESOURCE_KEY).build()).getResult()) {
-
-                if (PULL_TASK_NAME.equals(PullTaskTO.class.cast(task).getName())) {
-                    taskService.delete(task.getKey());
-                }
-            }
+            taskService.list(
+                    new TaskQuery.Builder(TaskType.PULL).resource(RESOURCE_KEY).build()).getResult().stream().
+                    filter(task -> PULL_TASK_NAME.equals(PullTaskTO.class.cast(task).getName())).
+                    forEachOrdered(task -> {
+                        taskService.delete(task.getKey());
+                    });
         } catch (Exception e) {
             // ignore
         }
@@ -444,11 +439,11 @@ public class MigrationITCase extends AbstractTaskITCase {
             // ignore
         }
         try {
-            for (ConnInstanceTO connInstance : connectorService.list(null)) {
-                if (CONNINSTANCE_DISPLAY_NAME.equals(connInstance.getDisplayName())) {
-                    connectorService.delete(connInstance.getKey());
-                }
-            }
+            connectorService.list(null).stream().
+                    filter(connInstance -> CONNINSTANCE_DISPLAY_NAME.equals(connInstance.getDisplayName())).
+                    forEachOrdered(connInstance -> {
+                        connectorService.delete(connInstance.getKey());
+                    });
         } catch (Exception e) {
             // ignore
         }
@@ -464,15 +459,17 @@ public class MigrationITCase extends AbstractTaskITCase {
         BulkAction bulkAction = new BulkAction();
         bulkAction.setType(BulkAction.Type.DELETE);
 
-        for (UserTO user : userService.search(new AnyQuery.Builder().fiql("username==*12").build()).getResult()) {
-            bulkAction.getTargets().add(user.getKey());
-        }
+        userService.search(new AnyQuery.Builder().fiql("username==*12").build()).getResult().
+                forEach(user -> {
+                    bulkAction.getTargets().add(user.getKey());
+                });
         userService.bulk(bulkAction);
 
         bulkAction.getTargets().clear();
-        for (GroupTO group : groupService.search(new AnyQuery.Builder().fiql("name==*12").build()).getResult()) {
-            bulkAction.getTargets().add(group.getKey());
-        }
+        groupService.search(new AnyQuery.Builder().fiql("name==*12").build()).getResult().
+                forEach(group -> {
+                    bulkAction.getTargets().add(group.getKey());
+                });
         groupService.bulk(bulkAction);
 
         // 2. setup
@@ -498,13 +495,8 @@ public class MigrationITCase extends AbstractTaskITCase {
                 user = userService.read("rossini12");
                 assertNotNull(user);
 
-                membershipFound = IterableUtils.matchesAny(user.getMemberships(), new Predicate<MembershipTO>() {
-
-                    @Override
-                    public boolean evaluate(final MembershipTO object) {
-                        return "1 root12".equals(object.getGroupName());
-                    }
-                });
+                membershipFound = user.getMemberships().stream().
+                        anyMatch(object -> "1 root12".equals(object.getGroupName()));
             } catch (Exception e) {
                 // ignore
             }
@@ -520,8 +512,8 @@ public class MigrationITCase extends AbstractTaskITCase {
         assertEquals("/" + MIGRATION_REALM, group.getRealm());
 
         // 4a. user plain attrs
-        assertEquals("Gioacchino", user.getPlainAttr("firstname").getValues().get(0));
-        assertEquals("Rossini", user.getPlainAttr("surname").getValues().get(0));
+        assertEquals("Gioacchino", user.getPlainAttr("firstname").get().getValues().get(0));
+        assertEquals("Rossini", user.getPlainAttr("surname").get().getValues().get(0));
 
         // 4b. user resources
         assertTrue(user.getResources().contains(RESOURCE_NAME_TESTDB2));
@@ -530,7 +522,7 @@ public class MigrationITCase extends AbstractTaskITCase {
         assertNotNull(clientFactory.create("bellini12", ADMIN_PWD).self());
 
         // 4d. group plain attrs
-        assertEquals("r12", group.getPlainAttr("title").getValues().get(0));
+        assertEquals("r12", group.getPlainAttr("title").get().getValues().get(0));
 
         // 4e. group resources
         assertTrue(group.getResources().contains(RESOURCE_NAME_CSV));

http://git-wip-us.apache.org/repos/asf/syncope/blob/74ee038a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/PlainSchemaITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/PlainSchemaITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/PlainSchemaITCase.java
index 8841851..152fcdd 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/PlainSchemaITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/PlainSchemaITCase.java
@@ -28,8 +28,6 @@ import static org.junit.Assert.fail;
 import java.util.List;
 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.common.lib.SyncopeClientException;
 import org.apache.syncope.common.lib.to.AnyTypeClassTO;
@@ -163,9 +161,9 @@ public class PlainSchemaITCase extends AbstractITCase {
     public void list() {
         List<PlainSchemaTO> schemas = schemaService.list(new SchemaQuery.Builder().type(SchemaType.PLAIN).build());
         assertFalse(schemas.isEmpty());
-        for (PlainSchemaTO schemaTO : schemas) {
+        schemas.forEach(schemaTO -> {
             assertNotNull(schemaTO);
-        }
+        });
     }
 
     @Test
@@ -173,24 +171,14 @@ public class PlainSchemaITCase extends AbstractITCase {
         List<PlainSchemaTO> userSchemas = schemaService.list(
                 new SchemaQuery.Builder().type(SchemaType.PLAIN).anyTypeClass("minimal user").build());
 
-        assertTrue(IterableUtils.matchesAny(userSchemas, new Predicate<PlainSchemaTO>() {
-
-            @Override
-            public boolean evaluate(final PlainSchemaTO object) {
-                return "fullname".equals(object.getKey());
-            }
-        }));
-
-        assertFalse(IterableUtils.matchesAny(userSchemas, new Predicate<PlainSchemaTO>() {
+        assertTrue(userSchemas.stream().anyMatch(object -> "fullname".equals(object.getKey())));
 
-            @Override
-            public boolean evaluate(final PlainSchemaTO object) {
-                return "password.cipher.algorithm".equals(object.getKey())
-                        || "rderived_dx".equals(object.getKey())
-                        || "icon".equals(object.getKey())
-                        || "mderived_sx".equals(object.getKey())
-                        || "self.membership.layout".equals(object.getKey());
-            }
+        assertFalse(userSchemas.stream().anyMatch(object -> {
+            return "password.cipher.algorithm".equals(object.getKey())
+                    || "rderived_dx".equals(object.getKey())
+                    || "icon".equals(object.getKey())
+                    || "mderived_sx".equals(object.getKey())
+                    || "self.membership.layout".equals(object.getKey());
         }));
     }
 

http://git-wip-us.apache.org/repos/asf/syncope/blob/74ee038a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/PropagationTaskITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/PropagationTaskITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/PropagationTaskITCase.java
index f4aa9bf..20b61ac 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/PropagationTaskITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/PropagationTaskITCase.java
@@ -25,8 +25,7 @@ import static org.junit.Assert.assertTrue;
 
 import java.util.ArrayList;
 import java.util.List;
-import org.apache.commons.collections4.IterableUtils;
-import org.apache.commons.collections4.Predicate;
+import java.util.Optional;
 import org.apache.commons.lang3.SerializationUtils;
 import org.apache.syncope.common.lib.to.AbstractTaskTO;
 import org.apache.syncope.common.lib.to.AnyObjectTO;
@@ -98,9 +97,7 @@ public class PropagationTaskITCase extends AbstractTaskITCase {
 
         BulkAction bulkAction = new BulkAction();
         bulkAction.setType(BulkAction.Type.DELETE);
-        for (PropagationTaskTO taskTO : tasks) {
-            bulkAction.getTargets().add(taskTO.getKey());
-        }
+        tasks.forEach(taskTO -> bulkAction.getTargets().add(taskTO.getKey()));
 
         taskService.bulk(bulkAction);
 
@@ -113,29 +110,23 @@ public class PropagationTaskITCase extends AbstractTaskITCase {
         // 0. Set propagation JEXL MappingItemTransformer
         ResourceTO resource = resourceService.read(RESOURCE_NAME_DBSCRIPTED);
         ResourceTO originalResource = SerializationUtils.clone(resource);
-        ProvisionTO provision = resource.getProvision("PRINTER");
+        ProvisionTO provision = resource.getProvision("PRINTER").get();
         assertNotNull(provision);
 
-        ItemTO mappingItem = IterableUtils.find(
-                provision.getMapping().getItems(), new Predicate<ItemTO>() {
-
-            @Override
-            public boolean evaluate(final ItemTO object) {
-                return "location".equals(object.getIntAttrName());
-            }
-        });
-        assertNotNull(mappingItem);
-        assertTrue(mappingItem.getTransformerClassNames().isEmpty());
+        Optional<ItemTO> mappingItem = provision.getMapping().getItems().stream().
+                filter(item -> "location".equals(item.getIntAttrName())).findFirst();
+        assertTrue(mappingItem.isPresent());
+        assertTrue(mappingItem.get().getTransformerClassNames().isEmpty());
 
         String suffix = getUUIDString();
-        mappingItem.setPropagationJEXLTransformer("value + '" + suffix + "'");
+        mappingItem.get().setPropagationJEXLTransformer("value + '" + suffix + "'");
 
         try {
             resourceService.update(resource);
 
             // 1. create printer on external resource
             AnyObjectTO anyObjectTO = AnyObjectITCase.getSampleTO("propagationJEXLTransformer");
-            String originalLocation = anyObjectTO.getPlainAttr("location").getValues().get(0);
+            String originalLocation = anyObjectTO.getPlainAttr("location").get().getValues().get(0);
             assertFalse(originalLocation.endsWith(suffix));
 
             anyObjectTO = createAnyObject(anyObjectTO).getEntity();
@@ -145,8 +136,8 @@ public class PropagationTaskITCase extends AbstractTaskITCase {
             // (location ends with given suffix on external resource)
             ConnObjectTO connObjectTO = resourceService.
                     readConnObject(RESOURCE_NAME_DBSCRIPTED, anyObjectTO.getType(), anyObjectTO.getKey());
-            assertFalse(anyObjectTO.getPlainAttr("location").getValues().get(0).endsWith(suffix));
-            assertTrue(connObjectTO.getAttr("LOCATION").getValues().get(0).endsWith(suffix));
+            assertFalse(anyObjectTO.getPlainAttr("location").get().getValues().get(0).endsWith(suffix));
+            assertTrue(connObjectTO.getAttr("LOCATION").get().getValues().get(0).endsWith(suffix));
         } finally {
             resourceService.update(originalResource);
         }

http://git-wip-us.apache.org/repos/asf/syncope/blob/74ee038a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/PullTaskITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/PullTaskITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/PullTaskITCase.java
index c0ac469..9427672 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/PullTaskITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/PullTaskITCase.java
@@ -39,8 +39,6 @@ import java.util.Set;
 import java.util.UUID;
 import javax.sql.DataSource;
 import javax.ws.rs.core.Response;
-import org.apache.commons.collections4.IterableUtils;
-import org.apache.commons.collections4.Predicate;
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang3.SerializationUtils;
 import org.apache.commons.lang3.tuple.Pair;
@@ -121,11 +119,9 @@ public class PullTaskITCase extends AbstractTaskITCase {
     public void list() {
         PagedResult<PullTaskTO> tasks = taskService.list(new TaskQuery.Builder(TaskType.PULL).build());
         assertFalse(tasks.getResult().isEmpty());
-        for (AbstractTaskTO task : tasks.getResult()) {
-            if (!(task instanceof PullTaskTO)) {
-                fail();
-            }
-        }
+        tasks.getResult().stream().
+                filter(task -> (!(task instanceof PullTaskTO))).
+                forEach(item -> fail());
     }
 
     @Test
@@ -228,9 +224,9 @@ public class PullTaskITCase extends AbstractTaskITCase {
             assertEquals(userName, userTO.getUsername());
             assertEquals(ActivitiDetector.isActivitiEnabledForUsers(syncopeService)
                     ? "active" : "created", userTO.getStatus());
-            assertEquals("test9@syncope.apache.org", userTO.getPlainAttr("email").getValues().get(0));
-            assertEquals("test9@syncope.apache.org", userTO.getPlainAttr("userId").getValues().get(0));
-            assertTrue(Integer.valueOf(userTO.getPlainAttr("fullname").getValues().get(0)) <= 10);
+            assertEquals("test9@syncope.apache.org", userTO.getPlainAttr("email").get().getValues().get(0));
+            assertEquals("test9@syncope.apache.org", userTO.getPlainAttr("userId").get().getValues().get(0));
+            assertTrue(Integer.valueOf(userTO.getPlainAttr("fullname").get().getValues().get(0)) <= 10);
             assertTrue(userTO.getResources().contains(RESOURCE_NAME_TESTDB));
             assertTrue(userTO.getResources().contains(RESOURCE_NAME_WS2));
 
@@ -240,7 +236,7 @@ public class PullTaskITCase extends AbstractTaskITCase {
             // check for user template
             userTO = userService.read("test7");
             assertNotNull(userTO);
-            assertEquals("TYPE_OTHER", userTO.getPlainAttr("ctype").getValues().get(0));
+            assertEquals("TYPE_OTHER", userTO.getPlainAttr("ctype").get().getValues().get(0));
             assertEquals(3, userTO.getResources().size());
             assertTrue(userTO.getResources().contains(RESOURCE_NAME_TESTDB));
             assertTrue(userTO.getResources().contains(RESOURCE_NAME_WS2));
@@ -249,17 +245,12 @@ public class PullTaskITCase extends AbstractTaskITCase {
 
             // Unmatching --> Assign (link) - SYNCOPE-658
             assertTrue(userTO.getResources().contains(RESOURCE_NAME_CSV));
-            assertEquals(1, IterableUtils.countMatches(userTO.getDerAttrs(), new Predicate<AttrTO>() {
-
-                @Override
-                public boolean evaluate(final AttrTO attrTO) {
-                    return "csvuserid".equals(attrTO.getSchema());
-                }
-            }));
+            assertEquals(1, userTO.getDerAttrs().stream().
+                    filter(attrTO -> "csvuserid".equals(attrTO.getSchema())).count());
 
             userTO = userService.read("test8");
             assertNotNull(userTO);
-            assertEquals("TYPE_8", userTO.getPlainAttr("ctype").getValues().get(0));
+            assertEquals("TYPE_8", userTO.getPlainAttr("ctype").get().getValues().get(0));
 
             // Check for ignored user - SYNCOPE-663
             try {
@@ -312,7 +303,7 @@ public class PullTaskITCase extends AbstractTaskITCase {
 
             userTO = userService.read("testuser1");
             assertNotNull(userTO);
-            assertEquals("reconciled@syncope.apache.org", userTO.getPlainAttr("userId").getValues().get(0));
+            assertEquals("reconciled@syncope.apache.org", userTO.getPlainAttr("userId").get().getValues().get(0));
             assertEquals("suspended", userTO.getStatus());
 
             // enable user on external resource
@@ -370,7 +361,7 @@ public class PullTaskITCase extends AbstractTaskITCase {
 
         // Check for SYNCOPE-436
         assertEquals("pullFromLDAP",
-                matchingUsers.getResult().get(0).getVirAttr("virtualReadOnly").getValues().get(0));
+                matchingUsers.getResult().get(0).getVirAttr("virtualReadOnly").get().getValues().get(0));
         // Check for SYNCOPE-270
         assertNotNull(matchingUsers.getResult().get(0).getPlainAttr("obscure"));
         // Check for SYNCOPE-123
@@ -379,7 +370,7 @@ public class PullTaskITCase extends AbstractTaskITCase {
         GroupTO groupTO = matchingGroups.getResult().iterator().next();
         assertNotNull(groupTO);
         assertEquals("testLDAPGroup", groupTO.getName());
-        assertEquals("true", groupTO.getPlainAttr("show").getValues().get(0));
+        assertEquals("true", groupTO.getPlainAttr("show").get().getValues().get(0));
         assertEquals(matchingUsers.getResult().iterator().next().getKey(), groupTO.getUserOwner());
         assertNull(groupTO.getGroupOwner());
 
@@ -414,16 +405,11 @@ public class PullTaskITCase extends AbstractTaskITCase {
         // 0. reset sync token and set MappingItemTransformer
         ResourceTO resource = resourceService.read(RESOURCE_NAME_DBSCRIPTED);
         ResourceTO originalResource = SerializationUtils.clone(resource);
-        ProvisionTO provision = resource.getProvision("PRINTER");
+        ProvisionTO provision = resource.getProvision("PRINTER").get();
         assertNotNull(provision);
 
-        ItemTO mappingItem = IterableUtils.find(provision.getMapping().getItems(), new Predicate<ItemTO>() {
-
-            @Override
-            public boolean evaluate(final ItemTO object) {
-                return "location".equals(object.getIntAttrName());
-            }
-        });
+        ItemTO mappingItem = provision.getMapping().getItems().stream().
+                filter(object -> "location".equals(object.getIntAttrName())).findFirst().get();
         assertNotNull(mappingItem);
         mappingItem.getTransformerClassNames().clear();
         mappingItem.getTransformerClassNames().add(PrefixItemTransformer.class.getName());
@@ -441,7 +427,7 @@ public class PullTaskITCase extends AbstractTaskITCase {
 
             // 1. create printer on external resource
             AnyObjectTO anyObjectTO = AnyObjectITCase.getSampleTO("pull");
-            String originalLocation = anyObjectTO.getPlainAttr("location").getValues().get(0);
+            String originalLocation = anyObjectTO.getPlainAttr("location").get().getValues().get(0);
             assertFalse(originalLocation.startsWith(PrefixItemTransformer.PREFIX));
 
             anyObjectTO = createAnyObject(anyObjectTO).getEntity();
@@ -451,9 +437,9 @@ public class PullTaskITCase extends AbstractTaskITCase {
             // (location starts with given prefix on external resource)
             ConnObjectTO connObjectTO = resourceService.
                     readConnObject(RESOURCE_NAME_DBSCRIPTED, anyObjectTO.getType(), anyObjectTO.getKey());
-            assertFalse(anyObjectTO.getPlainAttr("location").getValues().get(0).
+            assertFalse(anyObjectTO.getPlainAttr("location").get().getValues().get(0).
                     startsWith(PrefixItemTransformer.PREFIX));
-            assertTrue(connObjectTO.getAttr("LOCATION").getValues().get(0).
+            assertTrue(connObjectTO.getAttr("LOCATION").get().getValues().get(0).
                     startsWith(PrefixItemTransformer.PREFIX));
 
             // 3. unlink any existing printer and delete from Syncope (printer is now only on external resource)
@@ -487,8 +473,8 @@ public class PullTaskITCase extends AbstractTaskITCase {
             assertTrue(matchingPrinters.getSize() > 0);
 
             // 6. verify that synctoken was updated
-            assertNotNull(
-                    resourceService.read(RESOURCE_NAME_DBSCRIPTED).getProvision(anyObjectTO.getType()).getSyncToken());
+            assertNotNull(resourceService.read(RESOURCE_NAME_DBSCRIPTED).
+                    getProvision(anyObjectTO.getType()).get().getSyncToken());
         } finally {
             resourceService.update(originalResource);
         }
@@ -562,7 +548,7 @@ public class PullTaskITCase extends AbstractTaskITCase {
         try {
             connForTest.getCapabilities().add(ConnectorCapability.SYNC);
 
-            ConnConfProperty changeLogColumn = connForTest.getConf("changeLogColumn");
+            ConnConfProperty changeLogColumn = connForTest.getConf("changeLogColumn").get();
             assertNotNull(changeLogColumn);
             assertTrue(changeLogColumn.getValues().isEmpty());
             changeLogColumn.getValues().add("lastModification");
@@ -607,7 +593,7 @@ public class PullTaskITCase extends AbstractTaskITCase {
             assertEquals(PropagationTaskExecStatus.SUCCESS, PropagationTaskExecStatus.valueOf(exec.getStatus()));
 
             resForTest = resourceService.read(resForTest.getKey());
-            assertTrue(resForTest.getProvision(AnyTypeKind.USER.name()).getSyncToken().contains("2014-05-23"));
+            assertTrue(resForTest.getProvision(AnyTypeKind.USER.name()).get().getSyncToken().contains("2014-05-23"));
 
             jdbcTemplate.execute("UPDATE testpull "
                     + "SET email='syncTokenWithErrors2@syncope.apache.org', lastModification='2016-05-23 13:53:24.293' "
@@ -617,7 +603,7 @@ public class PullTaskITCase extends AbstractTaskITCase {
             assertEquals(PropagationTaskExecStatus.SUCCESS, PropagationTaskExecStatus.valueOf(exec.getStatus()));
 
             resForTest = resourceService.read(resForTest.getKey());
-            assertTrue(resForTest.getProvision(AnyTypeKind.USER.name()).getSyncToken().contains("2016-05-23"));
+            assertTrue(resForTest.getProvision(AnyTypeKind.USER.name()).get().getSyncToken().contains("2016-05-23"));
         } finally {
             if (resForTest.getConnector() != null) {
                 resourceService.delete(resForTest.getKey());
@@ -689,7 +675,7 @@ public class PullTaskITCase extends AbstractTaskITCase {
 
             userTO = userService.read("testuser2");
             assertNotNull(userTO);
-            assertEquals("testuser2@syncope.apache.org", userTO.getPlainAttr("userId").getValues().get(0));
+            assertEquals("testuser2@syncope.apache.org", userTO.getPlainAttr("userId").get().getValues().get(0));
             assertEquals(2, userTO.getMemberships().size());
             assertEquals(4, userTO.getResources().size());
         } finally {
@@ -714,7 +700,7 @@ public class PullTaskITCase extends AbstractTaskITCase {
         // 3. read e-mail address for user created by the PullTask first execution
         UserTO userTO = userService.read("issuesyncope230");
         assertNotNull(userTO);
-        String email = userTO.getPlainAttr("email").getValues().iterator().next();
+        String email = userTO.getPlainAttr("email").get().getValues().iterator().next();
         assertNotNull(email);
 
         // 4. update TESTPULL on external H2 by changing e-mail address
@@ -726,7 +712,7 @@ public class PullTaskITCase extends AbstractTaskITCase {
         // 6. verify that the e-mail was updated
         userTO = userService.read("issuesyncope230");
         assertNotNull(userTO);
-        email = userTO.getPlainAttr("email").getValues().iterator().next();
+        email = userTO.getPlainAttr("email").get().getValues().iterator().next();
         assertNotNull(email);
         assertEquals("updatedSYNCOPE230@syncope.apache.org", email);
     }
@@ -806,7 +792,7 @@ public class PullTaskITCase extends AbstractTaskITCase {
 
             userTO = userService.read(userTO.getKey());
             assertNotNull(userTO);
-            assertNotNull(userTO.getPlainAttr("firstname").getValues().get(0));
+            assertNotNull(userTO.getPlainAttr("firstname").get().getValues().get(0));
         } finally {
             removeTestUsers();
         }
@@ -816,8 +802,8 @@ public class PullTaskITCase extends AbstractTaskITCase {
     public void issueSYNCOPE307() {
         UserTO userTO = UserITCase.getUniqueSampleTO("s307@apache.org");
         userTO.setUsername("test0");
-        userTO.getPlainAttr("firstname").getValues().clear();
-        userTO.getPlainAttr("firstname").getValues().add("nome0");
+        userTO.getPlainAttr("firstname").get().getValues().clear();
+        userTO.getPlainAttr("firstname").get().getValues().add("nome0");
         userTO.getAuxClasses().add("csv");
 
         userTO.getResources().clear();
@@ -847,7 +833,7 @@ public class PullTaskITCase extends AbstractTaskITCase {
 
         // check that template was successfully applied...
         userTO = userService.read(userTO.getKey());
-        assertEquals("virtualvalue", userTO.getVirAttr("virtualdata").getValues().get(0));
+        assertEquals("virtualvalue", userTO.getVirAttr("virtualdata").get().getValues().get(0));
 
         // ...and that propagation to db succeeded
         JdbcTemplate jdbcTemplate = new JdbcTemplate(testDataSource);
@@ -944,15 +930,15 @@ public class PullTaskITCase extends AbstractTaskITCase {
             ConnObjectTO connObject =
                     resourceService.readConnObject(RESOURCE_NAME_LDAP, AnyTypeKind.USER.name(), user.getKey());
             assertNotNull(getLdapRemoteObject(
-                    connObject.getAttr(Name.NAME).getValues().get(0),
+                    connObject.getAttr(Name.NAME).get().getValues().get(0),
                     oldCleanPassword,
-                    connObject.getAttr(Name.NAME).getValues().get(0)));
+                    connObject.getAttr(Name.NAME).get().getValues().get(0)));
 
             // 5. Update the LDAP Connector to retrieve passwords
             ResourceTO ldapResource = resourceService.read(RESOURCE_NAME_LDAP);
             resourceConnector = connectorService.read(
                     ldapResource.getConnector(), Locale.ENGLISH.getLanguage());
-            property = resourceConnector.getConf("retrievePasswordsWithSearch");
+            property = resourceConnector.getConf("retrievePasswordsWithSearch").get();
             property.getValues().clear();
             property.getValues().add(Boolean.TRUE);
             connectorService.update(resourceConnector);
@@ -1038,7 +1024,7 @@ public class PullTaskITCase extends AbstractTaskITCase {
             // the user is successfully pulled...
             user = userService.read("pullFromLDAP");
             assertNotNull(user);
-            assertEquals("pullFromLDAP@syncope.apache.org", user.getPlainAttr("email").getValues().get(0));
+            assertEquals("pullFromLDAP@syncope.apache.org", user.getPlainAttr("email").get().getValues().get(0));
 
             group = groupService.read("testLDAPGroup");
             assertNotNull(group);
@@ -1046,8 +1032,8 @@ public class PullTaskITCase extends AbstractTaskITCase {
             ConnObjectTO connObject =
                     resourceService.readConnObject(RESOURCE_NAME_LDAP, AnyTypeKind.USER.name(), user.getKey());
             assertNotNull(connObject);
-            assertEquals("pullFromLDAP@syncope.apache.org", connObject.getAttr("mail").getValues().get(0));
-            AttrTO userDn = connObject.getAttr(Name.NAME);
+            assertEquals("pullFromLDAP@syncope.apache.org", connObject.getAttr("mail").get().getValues().get(0));
+            AttrTO userDn = connObject.getAttr(Name.NAME).get();
             assertNotNull(userDn);
             assertEquals(1, userDn.getValues().size());
             assertNotNull(
@@ -1065,7 +1051,7 @@ public class PullTaskITCase extends AbstractTaskITCase {
 
             connObject = resourceService.readConnObject(RESOURCE_NAME_LDAP, AnyTypeKind.USER.name(), user.getKey());
             assertNotNull(connObject);
-            assertEquals("pullFromLDAP2@syncope.apache.org", connObject.getAttr("mail").getValues().get(0));
+            assertEquals("pullFromLDAP2@syncope.apache.org", connObject.getAttr("mail").get().getValues().get(0));
 
             // 5. exec the pull task again
             execution = execProvisioningTask(taskService, pullTask.getKey(), 50, false);
@@ -1074,7 +1060,7 @@ public class PullTaskITCase extends AbstractTaskITCase {
             // the internal is updated...
             user = userService.read("pullFromLDAP");
             assertNotNull(user);
-            assertEquals("pullFromLDAP2@syncope.apache.org", user.getPlainAttr("email").getValues().get(0));
+            assertEquals("pullFromLDAP2@syncope.apache.org", user.getPlainAttr("email").get().getValues().get(0));
 
             // ...and propagated
             propagationTasks = taskService.list(new TaskQuery.Builder(TaskType.PROPAGATION).

http://git-wip-us.apache.org/repos/asf/syncope/blob/74ee038a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/PushTaskITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/PushTaskITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/PushTaskITCase.java
index fe62261..368acde 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/PushTaskITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/PushTaskITCase.java
@@ -31,7 +31,6 @@ import javax.sql.DataSource;
 import javax.ws.rs.core.Response;
 import org.apache.syncope.client.lib.SyncopeClient;
 import org.apache.syncope.common.lib.SyncopeConstants;
-import org.apache.syncope.common.lib.to.AbstractTaskTO;
 import org.apache.syncope.common.lib.to.AnyTypeClassTO;
 import org.apache.syncope.common.lib.to.PagedResult;
 import org.apache.syncope.common.lib.to.PushTaskTO;
@@ -90,11 +89,9 @@ public class PushTaskITCase extends AbstractTaskITCase {
     public void list() {
         PagedResult<PushTaskTO> tasks = taskService.list(new TaskQuery.Builder(TaskType.PUSH).build());
         assertFalse(tasks.getResult().isEmpty());
-        for (AbstractTaskTO task : tasks.getResult()) {
-            if (!(task instanceof PushTaskTO)) {
-                fail();
-            }
-        }
+        tasks.getResult().stream().
+                filter((task) -> (!(task instanceof PushTaskTO))).
+                forEach(item -> fail());
     }
 
     @Test
@@ -358,8 +355,8 @@ public class PushTaskITCase extends AbstractTaskITCase {
             Response response = resourceService.create(resourceTO);
             newResourceTO = getObject(response.getLocation(), ResourceService.class, ResourceTO.class);
             assertNotNull(newResourceTO);
-            assertNull(newResourceTO.getProvision(AnyTypeKind.USER.name()));
-            assertNotNull(newResourceTO.getProvision(AnyTypeKind.GROUP.name()).getMapping());
+            assertFalse(newResourceTO.getProvision(AnyTypeKind.USER.name()).isPresent());
+            assertNotNull(newResourceTO.getProvision(AnyTypeKind.GROUP.name()).get().getMapping());
 
             // create push task ad-hoc
             PushTaskTO task = new PushTaskTO();


Mime
View raw message