Files
alfresco-community-repo/source/test-java/org/alfresco/util/email/EmailUtil.java
Jamal Kaabi-Mofrad de94938b0d Merged WEBAPP-API (5.2.1) to 5.2.N (5.2.1)
135804 jkaabimofrad: APPSREPO-35, APPSREPO-118: Added tests for reset password service and REST API.
       - Added a utility class (EmailUtil) to work with MailActionExecutor in test mode
       - Added a new workflow task responsible for sending the reset password confirmation email (per peer review)
       - Changed the reset-password endpoint to return a 202 response for an inactive workflow or invalid workflow id, key or mismatched user
       - Some other minor changes as the result of adding tests
       - Also, fixed tests failures by changing the reset password workflow definition target namespace URI.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@135931 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
2017-03-16 19:39:31 +00:00

83 lines
2.6 KiB
Java

/*
* #%L
* Alfresco Remote API
* %%
* Copyright (C) 2005 - 2017 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.util.email;
import org.alfresco.repo.management.subsystems.ApplicationContextFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ConfigurableApplicationContext;
import javax.mail.internet.MimeMessage;
import java.util.Map;
/**
* A utility class to work with {@link ExtendedMailActionExecutor} in test mode.
*
* @author Jamal Kaabi-Mofrad
*/
public class EmailUtil
{
private final ExtendedMailActionExecutor mailActionExecutor;
public EmailUtil(ApplicationContext applicationContext)
{
ApplicationContextFactory subsystem = (ApplicationContextFactory) applicationContext.getBean("OutboundSMTP");
ConfigurableApplicationContext childContext = (ConfigurableApplicationContext) subsystem.getApplicationContext();
this.mailActionExecutor = childContext.getBean("mail", ExtendedMailActionExecutor.class);
}
public Object getLastEmailActionParam(String name)
{
return mailActionExecutor.getLastMessageActionParam(name);
}
public Map<String, Object> getLastEmailTemplateModel()
{
return mailActionExecutor.getLastMessageTemplateModel();
}
public Object getLastEmailTemplateModelValue(String key)
{
return mailActionExecutor.getLastMessageTemplateModel().get(key);
}
public MimeMessage getLastEmail()
{
return mailActionExecutor.retrieveLastTestMessage();
}
public int getSentCount()
{
return mailActionExecutor.getTestSentCount();
}
public void reset()
{
mailActionExecutor.clearLastMessage();
}
}