syncope-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ilgro...@apache.org
Subject [2/2] syncope git commit: [SYNCOPE-976] Checking for duplicates before insertion
Date Mon, 28 Nov 2016 12:10:52 GMT
[SYNCOPE-976] Checking for duplicates before insertion


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

Branch: refs/heads/master
Commit: 16b3f89a6dec0831f9098a62b9a033f749dcb401
Parents: 8fafe9a
Author: Francesco Chicchiriccò <ilgrosso@apache.org>
Authored: Mon Nov 28 13:10:26 2016 +0100
Committer: Francesco Chicchiriccò <ilgrosso@apache.org>
Committed: Mon Nov 28 13:10:38 2016 +0100

----------------------------------------------------------------------
 .../apache/syncope/core/logic/LoggerLogic.java    |  5 ++++-
 .../org/apache/syncope/fit/core/LoggerITCase.java | 18 ++++++++++++++++++
 2 files changed, 22 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/syncope/blob/16b3f89a/core/logic/src/main/java/org/apache/syncope/core/logic/LoggerLogic.java
----------------------------------------------------------------------
diff --git a/core/logic/src/main/java/org/apache/syncope/core/logic/LoggerLogic.java b/core/logic/src/main/java/org/apache/syncope/core/logic/LoggerLogic.java
index 4ecd0a1..070395e 100644
--- a/core/logic/src/main/java/org/apache/syncope/core/logic/LoggerLogic.java
+++ b/core/logic/src/main/java/org/apache/syncope/core/logic/LoggerLogic.java
@@ -278,10 +278,13 @@ public class LoggerLogic extends AbstractTransactionalLogic<LoggerTO>
{
                         EventCategoryTO eventCategoryTO = new EventCategoryTO();
                         eventCategoryTO.setCategory(clazz.getSimpleName());
                         for (Method method : clazz.getDeclaredMethods()) {
-                            if (Modifier.isPublic(method.getModifiers())) {
+                            if (Modifier.isPublic(method.getModifiers())
+                                    && !eventCategoryTO.getEvents().contains(method.getName()))
{
+
                                 eventCategoryTO.getEvents().add(method.getName());
                             }
                         }
+
                         events.add(eventCategoryTO);
                     }
                 }

http://git-wip-us.apache.org/repos/asf/syncope/blob/16b3f89a/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 ccd5d24..373f28a 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
@@ -28,6 +28,8 @@ import java.text.ParseException;
 import java.util.List;
 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.syncope.common.lib.SyncopeClientException;
 import org.apache.syncope.common.lib.to.EventCategoryTO;
 import org.apache.syncope.common.lib.to.LoggerTO;
@@ -225,4 +227,20 @@ public class LoggerITCase extends AbstractITCase {
             assertEquals(Response.Status.NOT_FOUND, ex.getType().getResponseStatus());
         }
     }
+
+    @Test
+    public void issueSYNCOPE976() {
+        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());
+            }
+        });
+        assertNotNull(userLogic);
+        assertEquals(1, IterableUtils.frequency(userLogic.getEvents(), "create"));
+    }
 }


Mime
View raw message