mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
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
This commit is contained in:
@@ -531,12 +531,6 @@
|
|||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="errorProneActionExecutor" class="org.alfresco.repo.activities.feed.ErrorProneActionExecutor" parent="action-executer">
|
|
||||||
<property name="publicAction">
|
|
||||||
<value>false</value>
|
|
||||||
</property>
|
|
||||||
</bean>
|
|
||||||
|
|
||||||
<!-- Import MailService from the OutboundSMTP subsystem (needed for email space/invited users actions) -->
|
<!-- Import MailService from the OutboundSMTP subsystem (needed for email space/invited users actions) -->
|
||||||
<bean id="mailService" class="org.alfresco.repo.management.subsystems.SubsystemProxyFactory">
|
<bean id="mailService" class="org.alfresco.repo.management.subsystems.SubsystemProxyFactory">
|
||||||
<property name="sourceApplicationContextFactory">
|
<property name="sourceApplicationContextFactory">
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
* #%L
|
* #%L
|
||||||
* Alfresco Repository
|
* Alfresco Repository
|
||||||
* %%
|
* %%
|
||||||
* Copyright (C) 2005 - 2016 Alfresco Software Limited
|
* Copyright (C) 2005 - 2022 Alfresco Software Limited
|
||||||
* %%
|
* %%
|
||||||
* This file is part of the Alfresco software.
|
* This file is part of the Alfresco software.
|
||||||
* If the software was purchased under a paid Alfresco license, the terms of
|
* If the software was purchased under a paid Alfresco license, the terms of
|
@@ -2,7 +2,7 @@
|
|||||||
* #%L
|
* #%L
|
||||||
* Alfresco Repository
|
* Alfresco Repository
|
||||||
* %%
|
* %%
|
||||||
* Copyright (C) 2005 - 2016 Alfresco Software Limited
|
* Copyright (C) 2005 - 2022 Alfresco Software Limited
|
||||||
* %%
|
* %%
|
||||||
* This file is part of the Alfresco software.
|
* This file is part of the Alfresco software.
|
||||||
* If the software was purchased under a paid Alfresco license, the terms of
|
* If the software was purchased under a paid Alfresco license, the terms of
|
||||||
@@ -36,8 +36,6 @@ import org.alfresco.service.namespace.QName;
|
|||||||
|
|
||||||
public class ErrorProneUserNotifier extends AbstractUserNotifier
|
public class ErrorProneUserNotifier extends AbstractUserNotifier
|
||||||
{
|
{
|
||||||
// private AtomicInteger numSuccessful = new AtomicInteger();
|
|
||||||
// private AtomicInteger numFailed = new AtomicInteger();
|
|
||||||
|
|
||||||
private NodeRef failingPersonNodeRef;
|
private NodeRef failingPersonNodeRef;
|
||||||
private ActionService actionService;
|
private ActionService actionService;
|
||||||
@@ -78,21 +76,10 @@ public class ErrorProneUserNotifier extends AbstractUserNotifier
|
|||||||
return emailFeedDBID;
|
return emailFeedDBID;
|
||||||
}
|
}
|
||||||
|
|
||||||
// public int getNumSuccess()
|
|
||||||
// {
|
|
||||||
// return numSuccessful.get();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public int getNumFailed()
|
|
||||||
// {
|
|
||||||
// return numFailed.get();
|
|
||||||
// }
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void notifyUser(NodeRef personNodeRef, String subjectText, Object[] subjectParams,
|
protected void notifyUser(NodeRef personNodeRef, String subjectText, Object[] subjectParams,
|
||||||
Map<String, Object> model, String templateNodeRef)
|
Map<String, Object> model, String templateNodeRef)
|
||||||
{
|
{
|
||||||
// super.notifyUser(personNodeRef, subjectText, model, templateNodeRef);
|
|
||||||
|
|
||||||
String userName = (String)nodeService.getProperty(personNodeRef, ContentModel.PROP_USERNAME);
|
String userName = (String)nodeService.getProperty(personNodeRef, ContentModel.PROP_USERNAME);
|
||||||
|
|
||||||
@@ -103,16 +90,5 @@ public class ErrorProneUserNotifier extends AbstractUserNotifier
|
|||||||
action.setParameterValue(ErrorProneActionExecutor.PARAM_USERNAME, userName);
|
action.setParameterValue(ErrorProneActionExecutor.PARAM_USERNAME, userName);
|
||||||
|
|
||||||
actionService.executeAction(action, null);
|
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();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -2,7 +2,7 @@
|
|||||||
* #%L
|
* #%L
|
||||||
* Alfresco Repository
|
* Alfresco Repository
|
||||||
* %%
|
* %%
|
||||||
* Copyright (C) 2005 - 2016 Alfresco Software Limited
|
* Copyright (C) 2005 - 2022 Alfresco Software Limited
|
||||||
* %%
|
* %%
|
||||||
* This file is part of the Alfresco software.
|
* This file is part of the Alfresco software.
|
||||||
* If the software was purchased under a paid Alfresco license, the terms of
|
* If the software was purchased under a paid Alfresco license, the terms of
|
||||||
@@ -25,10 +25,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.repo.activities.feed;
|
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.model.ContentModel;
|
||||||
import org.alfresco.repo.activities.post.lookup.PostLookup;
|
import org.alfresco.repo.activities.post.lookup.PostLookup;
|
||||||
import org.alfresco.repo.domain.activities.ActivitiesDAO;
|
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.namespace.QName;
|
||||||
import org.alfresco.service.transaction.TransactionService;
|
import org.alfresco.service.transaction.TransactionService;
|
||||||
import org.alfresco.util.ApplicationContextHelper;
|
import org.alfresco.util.ApplicationContextHelper;
|
||||||
|
import org.alfresco.util.BaseSpringTest;
|
||||||
import org.alfresco.util.GUID;
|
import org.alfresco.util.GUID;
|
||||||
import org.alfresco.util.PropertyMap;
|
import org.alfresco.util.PropertyMap;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
@@ -62,6 +59,7 @@ import org.quartz.JobDetail;
|
|||||||
import org.quartz.Scheduler;
|
import org.quartz.Scheduler;
|
||||||
import org.springframework.beans.factory.ObjectFactory;
|
import org.springframework.beans.factory.ObjectFactory;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -71,10 +69,10 @@ import java.util.List;
|
|||||||
*
|
*
|
||||||
* @author steveglover
|
* @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 PersonService personService;
|
||||||
private NodeService nodeService;
|
private NodeService nodeService;
|
||||||
private NamespaceService namespaceService;
|
private NamespaceService namespaceService;
|
||||||
@@ -104,14 +102,12 @@ public class FeedNotifierTest
|
|||||||
{
|
{
|
||||||
ApplicationContextHelper.setUseLazyLoading(false);
|
ApplicationContextHelper.setUseLazyLoading(false);
|
||||||
ApplicationContextHelper.setNoAutoStart(true);
|
ApplicationContextHelper.setNoAutoStart(true);
|
||||||
|
|
||||||
ctx = ApplicationContextHelper.getApplicationContext();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void before() throws Exception
|
public void before() throws Exception
|
||||||
{
|
{
|
||||||
ChildApplicationContextFactory activitiesFeed = (ChildApplicationContextFactory) ctx.getBean("ActivitiesFeed");
|
ChildApplicationContextFactory activitiesFeed = (ChildApplicationContextFactory) applicationContext.getBean("ActivitiesFeed");
|
||||||
ApplicationContext activitiesFeedCtx = activitiesFeed.getApplicationContext();
|
ApplicationContext activitiesFeedCtx = activitiesFeed.getApplicationContext();
|
||||||
this.feedNotifier = (FeedNotifierImpl) activitiesFeedCtx.getBean("feedNotifier");
|
this.feedNotifier = (FeedNotifierImpl) activitiesFeedCtx.getBean("feedNotifier");
|
||||||
this.activityService = (ActivityService) activitiesFeedCtx.getBean("activityService");
|
this.activityService = (ActivityService) activitiesFeedCtx.getBean("activityService");
|
||||||
@@ -119,7 +115,7 @@ public class FeedNotifierTest
|
|||||||
this.feedGenerator = (FeedGenerator) activitiesFeedCtx.getBean("feedGenerator");
|
this.feedGenerator = (FeedGenerator) activitiesFeedCtx.getBean("feedGenerator");
|
||||||
ObjectFactory<ActivitiesFeedModelBuilder> feedModelBuilderFactory = (ObjectFactory<ActivitiesFeedModelBuilder>) activitiesFeedCtx.getBean("feedModelBuilderFactory");
|
ObjectFactory<ActivitiesFeedModelBuilder> feedModelBuilderFactory = (ObjectFactory<ActivitiesFeedModelBuilder>) activitiesFeedCtx.getBean("feedModelBuilderFactory");
|
||||||
|
|
||||||
Scheduler scheduler = (Scheduler) ctx.getBean("schedulerFactory");
|
Scheduler scheduler = (Scheduler) applicationContext.getBean("schedulerFactory");
|
||||||
|
|
||||||
JobDetail feedGeneratorJobDetail = (JobDetail) activitiesFeedCtx.getBean("feedGeneratorJobDetail");
|
JobDetail feedGeneratorJobDetail = (JobDetail) activitiesFeedCtx.getBean("feedGeneratorJobDetail");
|
||||||
JobDetail postLookupJobDetail = (JobDetail) activitiesFeedCtx.getBean("postLookupJobDetail");
|
JobDetail postLookupJobDetail = (JobDetail) activitiesFeedCtx.getBean("postLookupJobDetail");
|
||||||
@@ -134,17 +130,17 @@ public class FeedNotifierTest
|
|||||||
scheduler.pauseJob(postCleanerJobDetail.getKey());
|
scheduler.pauseJob(postCleanerJobDetail.getKey());
|
||||||
scheduler.pauseJob(feedNotifierJobDetail.getKey());
|
scheduler.pauseJob(feedNotifierJobDetail.getKey());
|
||||||
|
|
||||||
this.personService = (PersonService) ctx.getBean("personService");
|
this.personService = (PersonService) applicationContext.getBean("personService");
|
||||||
this.nodeService = (NodeService) ctx.getBean("nodeService");
|
this.nodeService = (NodeService) applicationContext.getBean("nodeService");
|
||||||
this.namespaceService = (NamespaceService) ctx.getBean("namespaceService");
|
this.namespaceService = (NamespaceService) applicationContext.getBean("namespaceService");
|
||||||
this.siteService = (SiteService) ctx.getBean("siteService");
|
this.siteService = (SiteService) applicationContext.getBean("siteService");
|
||||||
this.repoAdminService = (RepoAdminService) ctx.getBean("repoAdminService");
|
this.repoAdminService = (RepoAdminService) applicationContext.getBean("repoAdminService");
|
||||||
this.transactionService = (TransactionService) ctx.getBean("transactionService");
|
this.transactionService = (TransactionService) applicationContext.getBean("transactionService");
|
||||||
this.postDAO = (ActivityPostDAO) ctx.getBean("postDAO");
|
this.postDAO = (ActivityPostDAO) applicationContext.getBean("postDAO");
|
||||||
this.fileFolderService = (FileFolderService) ctx.getBean("fileFolderService");
|
this.fileFolderService = (FileFolderService) applicationContext.getBean("fileFolderService");
|
||||||
this.subscriptionService = (SubscriptionService) ctx.getBean("SubscriptionService");
|
this.subscriptionService = (SubscriptionService) applicationContext.getBean("SubscriptionService");
|
||||||
this.errorProneActionExecutor = (ErrorProneActionExecutor) ctx.getBean("errorProneActionExecutor");
|
this.errorProneActionExecutor = (ErrorProneActionExecutor) applicationContext.getBean("errorProneActionExecutor");
|
||||||
this.actionService = (ActionService) ctx.getBean("ActionService");
|
this.actionService = (ActionService) applicationContext.getBean("ActionService");
|
||||||
|
|
||||||
// create some users
|
// create some users
|
||||||
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Void>()
|
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Void>()
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
* #%L
|
* #%L
|
||||||
* Alfresco Repository
|
* Alfresco Repository
|
||||||
* %%
|
* %%
|
||||||
* Copyright (C) 2005 - 2016 Alfresco Software Limited
|
* Copyright (C) 2005 - 2022 Alfresco Software Limited
|
||||||
* %%
|
* %%
|
||||||
* This file is part of the Alfresco software.
|
* This file is part of the Alfresco software.
|
||||||
* If the software was purchased under a paid Alfresco license, the terms of
|
* If the software was purchased under a paid Alfresco license, the terms of
|
@@ -0,0 +1,12 @@
|
|||||||
|
<?xml version='1.0' encoding='UTF-8'?>
|
||||||
|
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
|
||||||
|
|
||||||
|
<beans>
|
||||||
|
|
||||||
|
<bean id="errorProneActionExecutor" class="org.alfresco.repo.activities.feed.ErrorProneActionExecutor" parent="action-executer">
|
||||||
|
<property name="publicAction">
|
||||||
|
<value>false</value>
|
||||||
|
</property>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
</beans>
|
Reference in New Issue
Block a user