From 41bea282a6347b0e572cbccdff283bce63c82bd9 Mon Sep 17 00:00:00 2001 From: Sara Date: Wed, 15 Jun 2022 06:45:58 +0100 Subject: [PATCH] Feature/acs 3015 analyse error prone action executor action (#1153) * ACS-3015 move ErrorProneAction code to test folder * ACS-3015 remove old commented out code * ACS-3015 fix context * ACS-3015 fix context path * ACS-3015 move test context to test resources * ACS-3015 correct path to moved test context * ACS-3015 fix context problem for TestCase tests * ACS-3015 moved MockUserNotifier to test folder --- .../alfresco/action-services-context.xml | 8 +- .../feed/ErrorProneActionExecutor.java | 196 +++++++++--------- .../feed/ErrorProneUserNotifier.java | 164 +++++++-------- .../activities/feed/FeedNotifierTest.java | 42 ++-- .../activities/feed/MockUserNotifier.java | 186 ++++++++--------- .../test-action-services-context.xml | 12 ++ 6 files changed, 293 insertions(+), 315 deletions(-) rename repository/src/{main => test}/java/org/alfresco/repo/activities/feed/ErrorProneActionExecutor.java (96%) rename repository/src/{main => test}/java/org/alfresco/repo/activities/feed/ErrorProneUserNotifier.java (77%) rename repository/src/{main => test}/java/org/alfresco/repo/activities/feed/MockUserNotifier.java (95%) create mode 100644 repository/src/test/resources/alfresco/feednotifier-tests/test-action-services-context.xml diff --git a/repository/src/main/resources/alfresco/action-services-context.xml b/repository/src/main/resources/alfresco/action-services-context.xml index 333344ce35..69d521e9a3 100644 --- a/repository/src/main/resources/alfresco/action-services-context.xml +++ b/repository/src/main/resources/alfresco/action-services-context.xml @@ -530,13 +530,7 @@ - - - - false - - - + diff --git a/repository/src/main/java/org/alfresco/repo/activities/feed/ErrorProneActionExecutor.java b/repository/src/test/java/org/alfresco/repo/activities/feed/ErrorProneActionExecutor.java similarity index 96% rename from repository/src/main/java/org/alfresco/repo/activities/feed/ErrorProneActionExecutor.java rename to repository/src/test/java/org/alfresco/repo/activities/feed/ErrorProneActionExecutor.java index 562b99c637..43151aeb14 100644 --- a/repository/src/main/java/org/alfresco/repo/activities/feed/ErrorProneActionExecutor.java +++ b/repository/src/test/java/org/alfresco/repo/activities/feed/ErrorProneActionExecutor.java @@ -2,7 +2,7 @@ * #%L * Alfresco Repository * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited + * Copyright (C) 2005 - 2022 Alfresco Software Limited * %% * This file is part of the Alfresco software. * If the software was purchased under a paid Alfresco license, the terms of @@ -23,100 +23,100 @@ * along with Alfresco. If not, see . * #L% */ -package org.alfresco.repo.activities.feed; - -import java.util.List; -import java.util.concurrent.atomic.AtomicInteger; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.repo.action.ParameterDefinitionImpl; -import org.alfresco.repo.action.executer.ActionExecuterAbstractBase; -import org.alfresco.repo.action.executer.TestModeable; -import org.alfresco.service.cmr.action.Action; -import org.alfresco.service.cmr.action.ParameterDefinition; -import org.alfresco.service.cmr.dictionary.DataTypeDefinition; -import org.alfresco.service.cmr.repository.NodeRef; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.beans.factory.InitializingBean; - -public class ErrorProneActionExecutor extends ActionExecuterAbstractBase - implements InitializingBean, TestModeable -{ - private static Log logger = LogFactory.getLog(ErrorProneActionExecutor.class); - - public static final String PARAM_FAILING_PERSON_NODEREF = "failingPersonNodeRef"; - public static final String PARAM_PERSON_NODEREF = "personNodeRef"; - public static final String PARAM_USERNAME = "userName"; - - public static final String NAME = "errorProneActionExecutor"; - - // count of number of successful notifications - private AtomicInteger numSuccessful = new AtomicInteger(); - - // count of number of failed notifications - private AtomicInteger numFailed = new AtomicInteger(); - - public int getNumSuccess() - { - return numSuccessful.get(); - } - - public int getNumFailed() - { - return numFailed.get(); - } - - /** - * Send an email message - * - * @throws AlfrescoRuntimeException - */ - @Override - protected void executeImpl( - final Action ruleAction, - final NodeRef actionedUponNodeRef) - { - NodeRef failingPersonNodeRef = (NodeRef)ruleAction.getParameterValue(PARAM_FAILING_PERSON_NODEREF); - NodeRef personNodeRef = (NodeRef)ruleAction.getParameterValue(PARAM_PERSON_NODEREF); - String userName = (String)ruleAction.getParameterValue(PARAM_USERNAME); - - System.out.println("userName = " + userName); - - if(personNodeRef.equals(failingPersonNodeRef)) - { - numFailed.incrementAndGet(); - throw new AlfrescoRuntimeException(""); - } - - numSuccessful.incrementAndGet(); - } - - /** - * Add the parameter definitions - */ - @Override - protected void addParameterDefinitions(List paramList) - { - paramList.add(new ParameterDefinitionImpl(PARAM_FAILING_PERSON_NODEREF, DataTypeDefinition.NODE_REF, true, "Failing Person NodeRef")); - paramList.add(new ParameterDefinitionImpl(PARAM_PERSON_NODEREF, DataTypeDefinition.NODE_REF, true, "Person NodeRef")); - paramList.add(new ParameterDefinitionImpl(PARAM_USERNAME, DataTypeDefinition.TEXT, true, "Username")); - } - - @Override - public boolean isTestMode() - { - return true; - } - - @Override - public void setTestMode(boolean testMode) - { - } - - @Override - public void afterPropertiesSet() throws Exception - { - - } -} +package org.alfresco.repo.activities.feed; + +import java.util.List; +import java.util.concurrent.atomic.AtomicInteger; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.repo.action.ParameterDefinitionImpl; +import org.alfresco.repo.action.executer.ActionExecuterAbstractBase; +import org.alfresco.repo.action.executer.TestModeable; +import org.alfresco.service.cmr.action.Action; +import org.alfresco.service.cmr.action.ParameterDefinition; +import org.alfresco.service.cmr.dictionary.DataTypeDefinition; +import org.alfresco.service.cmr.repository.NodeRef; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.InitializingBean; + +public class ErrorProneActionExecutor extends ActionExecuterAbstractBase + implements InitializingBean, TestModeable +{ + private static Log logger = LogFactory.getLog(ErrorProneActionExecutor.class); + + public static final String PARAM_FAILING_PERSON_NODEREF = "failingPersonNodeRef"; + public static final String PARAM_PERSON_NODEREF = "personNodeRef"; + public static final String PARAM_USERNAME = "userName"; + + public static final String NAME = "errorProneActionExecutor"; + + // count of number of successful notifications + private AtomicInteger numSuccessful = new AtomicInteger(); + + // count of number of failed notifications + private AtomicInteger numFailed = new AtomicInteger(); + + public int getNumSuccess() + { + return numSuccessful.get(); + } + + public int getNumFailed() + { + return numFailed.get(); + } + + /** + * Send an email message + * + * @throws AlfrescoRuntimeException + */ + @Override + protected void executeImpl( + final Action ruleAction, + final NodeRef actionedUponNodeRef) + { + NodeRef failingPersonNodeRef = (NodeRef)ruleAction.getParameterValue(PARAM_FAILING_PERSON_NODEREF); + NodeRef personNodeRef = (NodeRef)ruleAction.getParameterValue(PARAM_PERSON_NODEREF); + String userName = (String)ruleAction.getParameterValue(PARAM_USERNAME); + + System.out.println("userName = " + userName); + + if(personNodeRef.equals(failingPersonNodeRef)) + { + numFailed.incrementAndGet(); + throw new AlfrescoRuntimeException(""); + } + + numSuccessful.incrementAndGet(); + } + + /** + * Add the parameter definitions + */ + @Override + protected void addParameterDefinitions(List paramList) + { + paramList.add(new ParameterDefinitionImpl(PARAM_FAILING_PERSON_NODEREF, DataTypeDefinition.NODE_REF, true, "Failing Person NodeRef")); + paramList.add(new ParameterDefinitionImpl(PARAM_PERSON_NODEREF, DataTypeDefinition.NODE_REF, true, "Person NodeRef")); + paramList.add(new ParameterDefinitionImpl(PARAM_USERNAME, DataTypeDefinition.TEXT, true, "Username")); + } + + @Override + public boolean isTestMode() + { + return true; + } + + @Override + public void setTestMode(boolean testMode) + { + } + + @Override + public void afterPropertiesSet() throws Exception + { + + } +} diff --git a/repository/src/main/java/org/alfresco/repo/activities/feed/ErrorProneUserNotifier.java b/repository/src/test/java/org/alfresco/repo/activities/feed/ErrorProneUserNotifier.java similarity index 77% rename from repository/src/main/java/org/alfresco/repo/activities/feed/ErrorProneUserNotifier.java rename to repository/src/test/java/org/alfresco/repo/activities/feed/ErrorProneUserNotifier.java index 196e4de1c9..1cdfade1c1 100644 --- a/repository/src/main/java/org/alfresco/repo/activities/feed/ErrorProneUserNotifier.java +++ b/repository/src/test/java/org/alfresco/repo/activities/feed/ErrorProneUserNotifier.java @@ -2,7 +2,7 @@ * #%L * Alfresco Repository * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited + * Copyright (C) 2005 - 2022 Alfresco Software Limited * %% * This file is part of the Alfresco software. * If the software was purchased under a paid Alfresco license, the terms of @@ -23,96 +23,72 @@ * along with Alfresco. If not, see . * #L% */ -package org.alfresco.repo.activities.feed; - -import java.io.Serializable; -import java.util.Map; - -import org.alfresco.model.ContentModel; -import org.alfresco.service.cmr.action.Action; -import org.alfresco.service.cmr.action.ActionService; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; - -public class ErrorProneUserNotifier extends AbstractUserNotifier -{ -// private AtomicInteger numSuccessful = new AtomicInteger(); -// private AtomicInteger numFailed = new AtomicInteger(); - - private NodeRef failingPersonNodeRef; - private ActionService actionService; - - public ErrorProneUserNotifier(NodeRef failingPersonNodeRef) - { - this.failingPersonNodeRef = failingPersonNodeRef; - } - - public void setActionService(ActionService actionService) - { - this.actionService = actionService; - } - - @Override - protected boolean skipUser(NodeRef personNodeRef) - { - return false; - } - - @Override - protected Long getFeedId(NodeRef personNodeRef) - { - Map personProps = nodeService.getProperties(personNodeRef); - - // where did we get up to ? - Long emailFeedDBID = (Long)personProps.get(ContentModel.PROP_EMAIL_FEED_ID); - if (emailFeedDBID != null) - { - // increment min feed id - emailFeedDBID++; - } - else - { - emailFeedDBID = -1L; - } - - return emailFeedDBID; - } - -// public int getNumSuccess() -// { -// return numSuccessful.get(); -// } -// -// public int getNumFailed() -// { -// return numFailed.get(); -// } - - @Override - protected void notifyUser(NodeRef personNodeRef, String subjectText, Object[] subjectParams, - Map model, String templateNodeRef) - { -// super.notifyUser(personNodeRef, subjectText, model, templateNodeRef); - - String userName = (String)nodeService.getProperty(personNodeRef, ContentModel.PROP_USERNAME); - - Action action = actionService.createAction(ErrorProneActionExecutor.NAME); - - action.setParameterValue(ErrorProneActionExecutor.PARAM_FAILING_PERSON_NODEREF, failingPersonNodeRef); - action.setParameterValue(ErrorProneActionExecutor.PARAM_PERSON_NODEREF, personNodeRef); - action.setParameterValue(ErrorProneActionExecutor.PARAM_USERNAME, userName); - - actionService.executeAction(action, null); -// String userName = (String)nodeService.getProperty(personNodeRef, ContentModel.PROP_USERNAME); -// -// System.out.println("userName = " + userName); -// -// if(personNodeRef.equals(failingPersonNodeRef)) -// { -// numFailed.incrementAndGet(); -// throw new AlfrescoRuntimeException(""); -// } -// -// numSuccessful.incrementAndGet(); - } -} +package org.alfresco.repo.activities.feed; + +import java.io.Serializable; +import java.util.Map; + +import org.alfresco.model.ContentModel; +import org.alfresco.service.cmr.action.Action; +import org.alfresco.service.cmr.action.ActionService; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; + +public class ErrorProneUserNotifier extends AbstractUserNotifier +{ + + private NodeRef failingPersonNodeRef; + private ActionService actionService; + + public ErrorProneUserNotifier(NodeRef failingPersonNodeRef) + { + this.failingPersonNodeRef = failingPersonNodeRef; + } + + public void setActionService(ActionService actionService) + { + this.actionService = actionService; + } + + @Override + protected boolean skipUser(NodeRef personNodeRef) + { + return false; + } + + @Override + protected Long getFeedId(NodeRef personNodeRef) + { + Map personProps = nodeService.getProperties(personNodeRef); + + // where did we get up to ? + Long emailFeedDBID = (Long)personProps.get(ContentModel.PROP_EMAIL_FEED_ID); + if (emailFeedDBID != null) + { + // increment min feed id + emailFeedDBID++; + } + else + { + emailFeedDBID = -1L; + } + + return emailFeedDBID; + } + + @Override + protected void notifyUser(NodeRef personNodeRef, String subjectText, Object[] subjectParams, + Map model, String templateNodeRef) + { + + String userName = (String)nodeService.getProperty(personNodeRef, ContentModel.PROP_USERNAME); + + Action action = actionService.createAction(ErrorProneActionExecutor.NAME); + + action.setParameterValue(ErrorProneActionExecutor.PARAM_FAILING_PERSON_NODEREF, failingPersonNodeRef); + action.setParameterValue(ErrorProneActionExecutor.PARAM_PERSON_NODEREF, personNodeRef); + action.setParameterValue(ErrorProneActionExecutor.PARAM_USERNAME, userName); + + actionService.executeAction(action, null); + } +} diff --git a/repository/src/test/java/org/alfresco/repo/activities/feed/FeedNotifierTest.java b/repository/src/test/java/org/alfresco/repo/activities/feed/FeedNotifierTest.java index 33c79e3a08..9de5aa7c9f 100644 --- a/repository/src/test/java/org/alfresco/repo/activities/feed/FeedNotifierTest.java +++ b/repository/src/test/java/org/alfresco/repo/activities/feed/FeedNotifierTest.java @@ -2,7 +2,7 @@ * #%L * Alfresco Repository * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited + * Copyright (C) 2005 - 2022 Alfresco Software Limited * %% * This file is part of the Alfresco software. * If the software was purchased under a paid Alfresco license, the terms of @@ -25,10 +25,6 @@ */ package org.alfresco.repo.activities.feed; -import static junit.framework.Assert.fail; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - import org.alfresco.model.ContentModel; import org.alfresco.repo.activities.post.lookup.PostLookup; import org.alfresco.repo.domain.activities.ActivitiesDAO; @@ -52,6 +48,7 @@ import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.QName; import org.alfresco.service.transaction.TransactionService; import org.alfresco.util.ApplicationContextHelper; +import org.alfresco.util.BaseSpringTest; import org.alfresco.util.GUID; import org.alfresco.util.PropertyMap; import org.json.JSONObject; @@ -62,6 +59,7 @@ import org.quartz.JobDetail; import org.quartz.Scheduler; import org.springframework.beans.factory.ObjectFactory; import org.springframework.context.ApplicationContext; +import org.springframework.test.context.ContextConfiguration; import java.util.Collections; import java.util.List; @@ -71,10 +69,10 @@ import java.util.List; * * @author steveglover */ -public class FeedNotifierTest +@ContextConfiguration({"classpath:alfresco/application-context.xml", + "classpath:alfresco/feednotifier-tests/test-action-services-context.xml"}) +public class FeedNotifierTest extends BaseSpringTest { - private static ApplicationContext ctx = null; - private PersonService personService; private NodeService nodeService; private NamespaceService namespaceService; @@ -104,14 +102,12 @@ public class FeedNotifierTest { ApplicationContextHelper.setUseLazyLoading(false); ApplicationContextHelper.setNoAutoStart(true); - - ctx = ApplicationContextHelper.getApplicationContext(); } @Before public void before() throws Exception { - ChildApplicationContextFactory activitiesFeed = (ChildApplicationContextFactory) ctx.getBean("ActivitiesFeed"); + ChildApplicationContextFactory activitiesFeed = (ChildApplicationContextFactory) applicationContext.getBean("ActivitiesFeed"); ApplicationContext activitiesFeedCtx = activitiesFeed.getApplicationContext(); this.feedNotifier = (FeedNotifierImpl) activitiesFeedCtx.getBean("feedNotifier"); this.activityService = (ActivityService) activitiesFeedCtx.getBean("activityService"); @@ -119,7 +115,7 @@ public class FeedNotifierTest this.feedGenerator = (FeedGenerator) activitiesFeedCtx.getBean("feedGenerator"); ObjectFactory feedModelBuilderFactory = (ObjectFactory) activitiesFeedCtx.getBean("feedModelBuilderFactory"); - Scheduler scheduler = (Scheduler) ctx.getBean("schedulerFactory"); + Scheduler scheduler = (Scheduler) applicationContext.getBean("schedulerFactory"); JobDetail feedGeneratorJobDetail = (JobDetail) activitiesFeedCtx.getBean("feedGeneratorJobDetail"); JobDetail postLookupJobDetail = (JobDetail) activitiesFeedCtx.getBean("postLookupJobDetail"); @@ -134,17 +130,17 @@ public class FeedNotifierTest scheduler.pauseJob(postCleanerJobDetail.getKey()); scheduler.pauseJob(feedNotifierJobDetail.getKey()); - this.personService = (PersonService) ctx.getBean("personService"); - this.nodeService = (NodeService) ctx.getBean("nodeService"); - this.namespaceService = (NamespaceService) ctx.getBean("namespaceService"); - this.siteService = (SiteService) ctx.getBean("siteService"); - this.repoAdminService = (RepoAdminService) ctx.getBean("repoAdminService"); - this.transactionService = (TransactionService) ctx.getBean("transactionService"); - this.postDAO = (ActivityPostDAO) ctx.getBean("postDAO"); - this.fileFolderService = (FileFolderService) ctx.getBean("fileFolderService"); - this.subscriptionService = (SubscriptionService) ctx.getBean("SubscriptionService"); - this.errorProneActionExecutor = (ErrorProneActionExecutor) ctx.getBean("errorProneActionExecutor"); - this.actionService = (ActionService) ctx.getBean("ActionService"); + this.personService = (PersonService) applicationContext.getBean("personService"); + this.nodeService = (NodeService) applicationContext.getBean("nodeService"); + this.namespaceService = (NamespaceService) applicationContext.getBean("namespaceService"); + this.siteService = (SiteService) applicationContext.getBean("siteService"); + this.repoAdminService = (RepoAdminService) applicationContext.getBean("repoAdminService"); + this.transactionService = (TransactionService) applicationContext.getBean("transactionService"); + this.postDAO = (ActivityPostDAO) applicationContext.getBean("postDAO"); + this.fileFolderService = (FileFolderService) applicationContext.getBean("fileFolderService"); + this.subscriptionService = (SubscriptionService) applicationContext.getBean("SubscriptionService"); + this.errorProneActionExecutor = (ErrorProneActionExecutor) applicationContext.getBean("errorProneActionExecutor"); + this.actionService = (ActionService) applicationContext.getBean("ActionService"); // create some users transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() diff --git a/repository/src/main/java/org/alfresco/repo/activities/feed/MockUserNotifier.java b/repository/src/test/java/org/alfresco/repo/activities/feed/MockUserNotifier.java similarity index 95% rename from repository/src/main/java/org/alfresco/repo/activities/feed/MockUserNotifier.java rename to repository/src/test/java/org/alfresco/repo/activities/feed/MockUserNotifier.java index ca96dedf48..cbc297f8de 100644 --- a/repository/src/main/java/org/alfresco/repo/activities/feed/MockUserNotifier.java +++ b/repository/src/test/java/org/alfresco/repo/activities/feed/MockUserNotifier.java @@ -2,7 +2,7 @@ * #%L * Alfresco Repository * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited + * Copyright (C) 2005 - 2022 Alfresco Software Limited * %% * This file is part of the Alfresco software. * If the software was purchased under a paid Alfresco license, the terms of @@ -23,95 +23,95 @@ * along with Alfresco. If not, see . * #L% */ -package org.alfresco.repo.activities.feed; - -import java.io.Serializable; -import java.util.BitSet; -import java.util.Map; -import java.util.concurrent.atomic.AtomicInteger; - -import org.alfresco.model.ContentModel; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; - -/** - * A test user notifier. - * - * @since 4.0 - */ -public class MockUserNotifier extends AbstractUserNotifier -{ - /** - * Default alfresco installation url - */ - private BitSet notifiedPersonsTracker = new BitSet(); - private AtomicInteger count = new AtomicInteger(0); - - @Override - protected boolean skipUser(NodeRef personNodeRef) - { - return false; - } - - @Override - protected Long getFeedId(NodeRef personNodeRef) - { - Map personProps = nodeService.getProperties(personNodeRef); - - // where did we get up to ? - Long emailFeedDBID = (Long)personProps.get(ContentModel.PROP_EMAIL_FEED_ID); - if (emailFeedDBID != null) - { - // increment min feed id - emailFeedDBID++; - } - else - { - emailFeedDBID = -1L; - } - - return emailFeedDBID; - } - - @Override - protected void notifyUser(NodeRef personNodeRef, String subjectText, Object[] subjectParams, Map model, String templateNodeRef) - { - String username = (String)nodeService.getProperty(personNodeRef, ContentModel.PROP_USERNAME); - if(username.startsWith("user")) - { - int id = Integer.parseInt(username.substring(4)); - - boolean b = false; - synchronized(notifiedPersonsTracker) - { - b = notifiedPersonsTracker.get(id); - } - if(b) - { - System.out.println("Already set: " + id); - } - else - { - synchronized(notifiedPersonsTracker) - { - notifiedPersonsTracker.set(id); - } - } - } - - count.incrementAndGet(); - } - - public int countNotifications() - { - return count.get(); - } - - public int nextUserId() - { - synchronized(notifiedPersonsTracker) - { - return notifiedPersonsTracker.nextClearBit(1); - } - } -} +package org.alfresco.repo.activities.feed; + +import java.io.Serializable; +import java.util.BitSet; +import java.util.Map; +import java.util.concurrent.atomic.AtomicInteger; + +import org.alfresco.model.ContentModel; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; + +/** + * A test user notifier. + * + * @since 4.0 + */ +public class MockUserNotifier extends AbstractUserNotifier +{ + /** + * Default alfresco installation url + */ + private BitSet notifiedPersonsTracker = new BitSet(); + private AtomicInteger count = new AtomicInteger(0); + + @Override + protected boolean skipUser(NodeRef personNodeRef) + { + return false; + } + + @Override + protected Long getFeedId(NodeRef personNodeRef) + { + Map personProps = nodeService.getProperties(personNodeRef); + + // where did we get up to ? + Long emailFeedDBID = (Long)personProps.get(ContentModel.PROP_EMAIL_FEED_ID); + if (emailFeedDBID != null) + { + // increment min feed id + emailFeedDBID++; + } + else + { + emailFeedDBID = -1L; + } + + return emailFeedDBID; + } + + @Override + protected void notifyUser(NodeRef personNodeRef, String subjectText, Object[] subjectParams, Map model, String templateNodeRef) + { + String username = (String)nodeService.getProperty(personNodeRef, ContentModel.PROP_USERNAME); + if(username.startsWith("user")) + { + int id = Integer.parseInt(username.substring(4)); + + boolean b = false; + synchronized(notifiedPersonsTracker) + { + b = notifiedPersonsTracker.get(id); + } + if(b) + { + System.out.println("Already set: " + id); + } + else + { + synchronized(notifiedPersonsTracker) + { + notifiedPersonsTracker.set(id); + } + } + } + + count.incrementAndGet(); + } + + public int countNotifications() + { + return count.get(); + } + + public int nextUserId() + { + synchronized(notifiedPersonsTracker) + { + return notifiedPersonsTracker.nextClearBit(1); + } + } +} diff --git a/repository/src/test/resources/alfresco/feednotifier-tests/test-action-services-context.xml b/repository/src/test/resources/alfresco/feednotifier-tests/test-action-services-context.xml new file mode 100644 index 0000000000..357c0fdeba --- /dev/null +++ b/repository/src/test/resources/alfresco/feednotifier-tests/test-action-services-context.xml @@ -0,0 +1,12 @@ + + + + + + + + false + + + +