From e2ef37c0da586d97f11f6afa348dd29400f8d318 Mon Sep 17 00:00:00 2001 From: Roy Wetherall Date: Wed, 23 May 2012 08:14:23 +0000 Subject: [PATCH] RM-230: RM Email Mapping tool behaves strangely * Added custom email service unit test * refactored service implementation git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/BRANCHES/V2.0@36754 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../bootstrap/RecordsManagementBootstrap.java | 2 +- .../email/CustomEmailMappingService.java | 22 +- .../email/CustomEmailMappingServiceImpl.java | 531 +++++++++--------- .../email/CustomMapping.java | 15 +- ...tomEMailMappingServiceServiceImplTest.java | 109 ++++ 5 files changed, 395 insertions(+), 284 deletions(-) create mode 100644 rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/service/CustomEMailMappingServiceServiceImplTest.java diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/bootstrap/RecordsManagementBootstrap.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/bootstrap/RecordsManagementBootstrap.java index cb97969465..35c1073f57 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/bootstrap/RecordsManagementBootstrap.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/bootstrap/RecordsManagementBootstrap.java @@ -82,7 +82,7 @@ public class RecordsManagementBootstrap extends AbstractLifecycleBean caveatConfigService.init(); // initialise custom email mapping - customEmailMappingService.init(); + //customEmailMappingService.init(); // Initialise the custom model adminService.initialiseCustomModel(); diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/email/CustomEmailMappingService.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/email/CustomEmailMappingService.java index a64df4f860..c80455da9c 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/email/CustomEmailMappingService.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/email/CustomEmailMappingService.java @@ -20,13 +20,31 @@ package org.alfresco.module.org_alfresco_module_rm.email; import java.util.Set; +/** + * Custom EMail Mapping Service + */ public interface CustomEmailMappingService { + /** + * Get the list of custom mappings + * + * @return {@link Set}<{@link CustomMapping}> + */ public Set getCustomMappings(); + /** + * Add custom mapping + * + * @param from + * @param to + */ public void addCustomMapping(String from, String to); + /** + * Delete custom mapping + * + * @param from + * @param to + */ public void deleteCustomMapping(String from, String to); - - public void init(); } diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/email/CustomEmailMappingServiceImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/email/CustomEmailMappingServiceImpl.java index 9b4be07048..dd92eb6006 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/email/CustomEmailMappingServiceImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/email/CustomEmailMappingServiceImpl.java @@ -18,20 +18,20 @@ */ package org.alfresco.module.org_alfresco_module_rm.email; -import java.util.Collections; +import java.io.Serializable; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; +import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.repo.content.ContentServicePolicies; import org.alfresco.repo.content.MimetypeMap; import org.alfresco.repo.content.metadata.RFC822MetadataExtracter; -import org.alfresco.repo.policy.JavaBehaviour; import org.alfresco.repo.policy.PolicyComponent; -import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; +import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; import org.alfresco.service.cmr.repository.ContentReader; import org.alfresco.service.cmr.repository.ContentService; import org.alfresco.service.cmr.repository.ContentWriter; @@ -39,6 +39,7 @@ import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.repository.StoreRef; import org.alfresco.service.namespace.NamespacePrefixResolver; +import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.QName; import org.alfresco.service.transaction.TransactionService; import org.apache.commons.logging.Log; @@ -47,85 +48,213 @@ import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import org.json.JSONTokener; +import org.springframework.context.ApplicationEvent; +import org.springframework.extensions.surf.util.AbstractLifecycleBean; -public class CustomEmailMappingServiceImpl implements CustomEmailMappingService +/** + * Custom Email Mapping Service + */ +public class CustomEmailMappingServiceImpl extends AbstractLifecycleBean implements CustomEmailMappingService { + /** Logger */ + @SuppressWarnings("unused") + private static Log logger = LogFactory.getLog(CustomEmailMappingServiceImpl.class); + /** Node reference's to configuration elements */ + private static final NodeRef CONFIG_NODE_REF = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, "rm_emailmapping_config"); + private static final NodeRef CONFIG_FOLDER_NODE_REF = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, "rm_config_folder"); + + /** Config file name */ + private static final String CONFIG_NAME = "imapConfig.json"; + + /** Default custom mappings (TODO move to spring config) */ + private static final CustomMapping[] DEFAULT_MAPPINGS = + { + new CustomMapping("Date", "rma:dateReceived"), + new CustomMapping("messageTo", "rma:address"), + new CustomMapping("messageFrom", "rma:originator"), + new CustomMapping("messageSent", "rma:publicationDate"), + new CustomMapping("messageCc", "rma:otherAddress") + }; + + /** Extractor */ private RFC822MetadataExtracter extracter; + + /** Services */ private NodeService nodeService; private NamespacePrefixResolver nspr; + @SuppressWarnings("unused") private PolicyComponent policyComponent; private ContentService contentService; private TransactionService transactionService; - private Set customMappings = Collections.synchronizedSet(new HashSet()); - - private static Log logger = LogFactory.getLog(CustomEmailMappingServiceImpl.class); - + /** Transient set of custom mappings */ + private Set customMappings; + /** + * @param policyComponent policy component + */ public void setPolicyComponent(PolicyComponent policyComponent) { this.policyComponent = policyComponent; } - - /** - * Get the name space prefix resolver - * @return the name space prefix resolver - */ - public NamespacePrefixResolver getNamespacePrefixResolver() - { - return nspr; - } /** - * Set the name space prefix resolver - * @param nspr + * @param nspr namespace service */ public void setNamespacePrefixResolver(NamespacePrefixResolver nspr) { this.nspr = nspr; } + + /** + * @param extractor extractor component + */ + public void setExtracter(RFC822MetadataExtracter extractor) + { + this.extracter = extractor; + } + + /** + * @param nodeService node service + */ + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } + + /** + * @param contentService content service + */ + public void setContentService(ContentService contentService) + { + this.contentService = contentService; + } + + /** + * @param transactionService transaction service + */ + public void setTransactionService(TransactionService transactionService) + { + this.transactionService = transactionService; + } /** - * + * @see org.alfresco.module.org_alfresco_module_rm.email.CustomEmailMappingService#getCustomMappings() */ - public void init() - { - CustomMapping[] rmHardCodedMappings = { - new CustomMapping("Date", "rma:dateReceived"), - new CustomMapping("messageTo", "rma:address"), - new CustomMapping("messageFrom", "rma:originator"), - new CustomMapping("messageSent", "rma:publicationDate"), - new CustomMapping("messageCc", "rma:otherAddress") - }; - - NodeRef configNode = getConfigNode(); - if(configNode != null) - { - /** - * Get any custom mappings. - */ - customMappings = readConfig(configNode); - } - - /** - * ensure that the customMappings contain the RM specific mappings - */ - for(CustomMapping mapping : rmHardCodedMappings) + public Set getCustomMappings() + { + if (customMappings == null) { - if(!customMappings.contains(mapping)) + // if we have a config file + if (nodeService.exists(CONFIG_NODE_REF) == true) { - customMappings.add(mapping); + // load the contents of the config file + customMappings = loadConfig(); + } + else + { + customMappings = new HashSet(); + + // load the contents of the extractors property file + Map> currentMapping = extracter.getCurrentMapping(); + for(String key : currentMapping.keySet()) + { + Set set = currentMapping.get(key); + + for(QName qname : set) + { + CustomMapping value = new CustomMapping(); + value.setFrom(key); + QName resolvedQname = qname.getPrefixedQName(nspr); + value.setTo(resolvedQname.toPrefixString()); + customMappings.add(value); + } + } + + // TODO + // if we have an old config file + { + // load the contents of the old config file + } + //else + { + // load the hard coded mappings + for(CustomMapping mapping : DEFAULT_MAPPINGS) + { + if(!customMappings.contains(mapping)) + { + customMappings.add(mapping); + } + } + } + + // create the config file + saveConfig(customMappings); } } + + return customMappings; + } - // Get the read only existing configuration - Map> currentMapping = extracter.getCurrentMapping(); + /** + * @see org.alfresco.module.org_alfresco_module_rm.email.CustomEmailMappingService#addCustomMapping(java.lang.String, java.lang.String) + */ + public void addCustomMapping(String from, String to) + { + // create custom mapping + CustomMapping customMapping = new CustomMapping(from, to); + + // check whether we already have this mapping or not + Set customMappings = getCustomMappings(); + if (customMappings.contains(customMapping) == true) + { + throw new AlfrescoRuntimeException("Can not add custom email mapping, because duplicate mapping already exists."); + } + + // else add the custom mapping (since we have already called getCustomMapping we can be sure + // the member variable is populated) + customMappings.add(customMapping); + + // save the changes into the config file + saveConfig(customMappings); + + // update the extractors configuration + updateExtractor(); + } - Map> newMapping = new HashMap>(17); - newMapping.putAll(currentMapping); - - for(CustomMapping mapping : customMappings) + /** + * @see org.alfresco.module.org_alfresco_module_rm.email.CustomEmailMappingService#deleteCustomMapping(java.lang.String, java.lang.String) + */ + public void deleteCustomMapping(String from, String to) + { + // create custom mapping + CustomMapping customMapping = new CustomMapping(from, to); + + // check whether we already have this mapping or not + Set customMappings = getCustomMappings(); + if (customMappings.contains(customMapping) == true) + { + // else remove the custom mapping (since we have already called getCustomMapping we can be sure + // the member variable is populated) + customMappings.remove(customMapping); + + // save the changes into the config file + saveConfig(customMappings); + + // update the extractors configuration + updateExtractor(); + } + } + + /** + * Updates the extractor with the custom configuration. + */ + private void updateExtractor() + { + // convert the mapping information into the form understood by the extractor + Map> newMapping = new HashMap>(17); + for(CustomMapping mapping : getCustomMappings()) { QName newQName = QName.createQName(mapping.getTo(), nspr); Set values = newMapping.get(mapping.getFrom()); @@ -137,159 +266,19 @@ public class CustomEmailMappingServiceImpl implements CustomEmailMappingService values.add(newQName); } - // Now update the metadata extracter - extracter.setMapping(newMapping); - - // Register interest in the onContentUpdate policy - policyComponent.bindClassBehaviour( - ContentServicePolicies.OnContentUpdatePolicy.QNAME, - RecordsManagementModel.TYPE_EMAIL_CONFIG, - new JavaBehaviour(this, "onContentUpdate")); - + // update the metadata extracter + extracter.setMapping(newMapping); } - public void onContentUpdate(NodeRef nodeRef, boolean newContent) - { - NodeRef configNode = getConfigNode(); - if(configNode != null) - { - Set newMappings = readConfig(configNode); - - customMappings.addAll(newMappings); - - for(CustomMapping mapping : customMappings) - { - if(!newMappings.contains(mapping)) - { - customMappings.remove(mapping); - } - } - } - } - - public void beforeDeleteNode(NodeRef nodeRef) - { - } - - public void onCreateNode(ChildAssociationRef childAssocRef) - { - - } - - public Set getCustomMappings() - { - // add all the lists data to a Map - Set emailMap = new HashSet(); - - Map> currentMapping = extracter.getCurrentMapping(); - - for(String key : currentMapping.keySet()) - { - Set set = currentMapping.get(key); - - for(QName qname : set) - { - CustomMapping value = new CustomMapping(); - value.setFrom(key); - QName resolvedQname = qname.getPrefixedQName(nspr); - value.setTo(resolvedQname.toPrefixString()); - emailMap.add(value); - } - } - - return emailMap; - } - - - public void addCustomMapping(String from, String to) - { - // Get the read only existing configuration - Map> currentMapping = extracter.getCurrentMapping(); - - Map> newMapping = new HashMap>(17); - newMapping.putAll(currentMapping); - - QName newQName = QName.createQName(to, nspr); - - Set values = newMapping.get(from); - if(values == null) - { - values = new HashSet(); - newMapping.put(from, values); - } - values.add(newQName); - - CustomMapping xxx = new CustomMapping(); - xxx.setFrom(from); - xxx.setTo(to); - customMappings.add(xxx); - - updateOrCreateEmailConfig(customMappings); - - // Crash in the new config. - extracter.setMapping(newMapping); - } - - public void deleteCustomMapping(String from, String to) - { - // Get the read only existing configuration - Map> currentMapping = extracter.getCurrentMapping(); - - Map> newMapping = new HashMap>(17); - newMapping.putAll(currentMapping); - - QName oldQName = QName.createQName(to, nspr); - - Set values = newMapping.get(from); - if(values != null) - { - values.remove(oldQName); - } - - CustomMapping toDelete = new CustomMapping(from, to); - customMappings.remove(toDelete); - - updateOrCreateEmailConfig(customMappings); - - // Crash in the new config. - extracter.setMapping(newMapping); - } - - public void setExtracter(RFC822MetadataExtracter extractor) - { - this.extracter = extractor; - } - - public RFC822MetadataExtracter getExtracter() - { - return extracter; - } - - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - public NodeService getNodeService() - { - return nodeService; - } - - // Default - private StoreRef storeRef = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "SpacesStore"); - - private static final String CONFIG_NAME = "imapConfig.json"; - /** + * Loads the custom mappings from the configuration file. * - * @param nodeRef - * @return + * @return */ - private Set readConfig(NodeRef nodeRef) + private Set loadConfig() { - Set newMappings = new HashSet(); - - ContentReader cr = contentService.getReader(nodeRef, ContentModel.PROP_CONTENT); + Set result = new HashSet(); + ContentReader cr = contentService.getReader(CONFIG_NODE_REF, ContentModel.PROP_CONTENT); if (cr != null) { String text = cr.getContentString(); @@ -303,109 +292,95 @@ public class CustomEmailMappingServiceImpl implements CustomEmailMappingService CustomMapping mapping = new CustomMapping(); mapping.setFrom(obj.getString("from")); mapping.setTo(obj.getString("to")); - newMappings.add(mapping); + result.add(mapping); } - return newMappings; } catch (JSONException je) { - logger.warn("unable to read custom email configuration", je); - return newMappings; - } - + throw new AlfrescoRuntimeException("Unable to read custom email configuration", je); + } } - return newMappings; - } - - public NodeRef updateOrCreateEmailConfig(Set customMappings) - { - NodeRef caveatConfig = updateOrCreateEmailConfig(); + return result; + } + + /** + * + * @param customMappingsToSave + */ + private void saveConfig(Set customMappingsToSave) + { + if (nodeService.exists(CONFIG_NODE_REF) == false) + { + // create the config node + Map properties = new HashMap(2); + properties.put(ContentModel.PROP_NAME, CONFIG_NAME); + properties.put(ContentModel.PROP_NODE_UUID, CONFIG_NODE_REF.getId()); + nodeService.createNode( + CONFIG_FOLDER_NODE_REF, + ContentModel.ASSOC_CONTAINS, + QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, CONFIG_NAME), + ContentModel.TYPE_CONTENT, + properties); + } + + // build JSON array of mappings + JSONArray jsonMappings = new JSONArray(); try { - JSONArray mappings = new JSONArray(); - for(CustomMapping mapping : customMappings) + for(CustomMapping mapping : customMappingsToSave) { JSONObject obj = new JSONObject(); obj.put("from", mapping.getFrom()); obj.put("to", mapping.getTo()); - mappings.put(obj); + jsonMappings.put(obj); } - - // Update the content - ContentWriter writer = this.contentService.getWriter(caveatConfig, ContentModel.PROP_CONTENT, true); - writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); - writer.setEncoding("UTF-8"); - writer.putContent(mappings.toString()); } catch (JSONException je) { - + throw new AlfrescoRuntimeException("Unable to create JSON email mapping configuration during save.", je); } - - return caveatConfig; - } - - public NodeRef updateOrCreateEmailConfig(String txt) - { - NodeRef caveatConfig = updateOrCreateEmailConfig(); - - // Update the content - ContentWriter writer = this.contentService.getWriter(caveatConfig, ContentModel.PROP_CONTENT, true); + // update the content + ContentWriter writer = this.contentService.getWriter(CONFIG_NODE_REF, ContentModel.PROP_CONTENT, true); writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); writer.setEncoding("UTF-8"); - writer.putContent(txt); - - return caveatConfig; + writer.putContent(jsonMappings.toString()); } - private NodeRef updateOrCreateEmailConfig() + /** + * @see org.springframework.extensions.surf.util.AbstractLifecycleBean#onBootstrap(org.springframework.context.ApplicationEvent) + */ + @Override + protected void onBootstrap(ApplicationEvent event) { - NodeRef caveatConfig = getConfigNode(); - if (caveatConfig == null) + // run as System on bootstrap + AuthenticationUtil.runAs(new RunAsWork() { - logger.debug("custom email configuration does not exist - creating new"); - NodeRef rootNode = nodeService.getRootNode(storeRef); - //nodeService.addAspect(rootNode, VersionModel.ASPECT_VERSION_STORE_ROOT, null); - - // Create caveat config - caveatConfig = nodeService.createNode(rootNode, - RecordsManagementModel.ASSOC_EMAIL_CONFIG, - QName.createQName(RecordsManagementModel.RM_URI, CONFIG_NAME), - RecordsManagementModel.TYPE_EMAIL_CONFIG).getChildRef(); - - nodeService.setProperty(caveatConfig, ContentModel.PROP_NAME, CONFIG_NAME); - } - - return caveatConfig; - } - - public NodeRef getConfigNode() - { - NodeRef rootNode = nodeService.getRootNode(storeRef); - return nodeService.getChildByName(rootNode, RecordsManagementModel.ASSOC_EMAIL_CONFIG, CONFIG_NAME); + public Object doWork() + { + RetryingTransactionCallback callback = new RetryingTransactionCallback() + { + public Void execute() throws Throwable + { + // update the extractor with the custom mappings + updateExtractor(); + return null; + } + }; + transactionService.getRetryingTransactionHelper().doInTransaction(callback); + + return null; + } + }, AuthenticationUtil.getSystemUserName()); } - public void setContentService(ContentService contentService) + /** + * @see org.springframework.extensions.surf.util.AbstractLifecycleBean#onShutdown(org.springframework.context.ApplicationEvent) + */ + @Override + protected void onShutdown(ApplicationEvent arg0) { - this.contentService = contentService; - } - - public ContentService getContentService() - { - return contentService; - } - - public void setTransactionService(TransactionService transactionService) - { - this.transactionService = transactionService; - } - - public TransactionService getTransactionService() - { - return transactionService; - } - - + // No implementation + } } diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/email/CustomMapping.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/email/CustomMapping.java index b9f75d1532..8f8e5f6c1e 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/email/CustomMapping.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/email/CustomMapping.java @@ -18,17 +18,26 @@ */ package org.alfresco.module.org_alfresco_module_rm.email; - +/** + * Custom EMail Mapping + */ public class CustomMapping { private String from; private String to; + /** + * Default constructor. + */ public CustomMapping() - { - + { } + /** + * Default constructor. + * @param from + * @param to + */ public CustomMapping(String from, String to) { this.from = from; diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/service/CustomEMailMappingServiceServiceImplTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/service/CustomEMailMappingServiceServiceImplTest.java new file mode 100644 index 0000000000..9e55d765a8 --- /dev/null +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/service/CustomEMailMappingServiceServiceImplTest.java @@ -0,0 +1,109 @@ +/* + * Copyright (C) 2005-2011 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * 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 . + */ +package org.alfresco.module.org_alfresco_module_rm.test.service; + +import java.util.Set; + +import org.alfresco.module.org_alfresco_module_rm.email.CustomEmailMappingService; +import org.alfresco.module.org_alfresco_module_rm.email.CustomMapping; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; + +/** + * Custom EMail Mapping Service + * + * @author Roy Wetherall + * @since 2.0 + */ +public class CustomEMailMappingServiceServiceImplTest extends BaseRMTestCase +{ + private CustomEmailMappingService eMailMappingService; + + @Override + protected void initServices() + { + super.initServices(); + + eMailMappingService = (CustomEmailMappingService)applicationContext.getBean("customEmailMappingService"); + } + + @Override + protected boolean isUserTest() + { + return true; + } + + public void testCRUD() throws Exception + { + doTestInTransaction(new Test() + { + public Void run() + { + checkCustomMappingSize(20); + + eMailMappingService.addCustomMapping("monkey", "cm:monkeyFace"); + + CustomMapping monkeyMapping = getCustomMapping("monkey", "cm:monkeyFace", checkCustomMappingSize(21), true); + assertNotNull(monkeyMapping); + assertEquals("monkey", monkeyMapping.getFrom()); + assertEquals("cm:monkeyFace", monkeyMapping.getTo()); + + eMailMappingService.deleteCustomMapping("monkey", "cm:monkeyFace"); + getCustomMapping("monkey", "cm:monkeyFace", checkCustomMappingSize(20), false); + + return null; + } + }, rmAdminName); + } + + private CustomMapping getCustomMapping(String from, String to, Set maps, boolean contains) + { + CustomMapping result = null; + CustomMapping key = new CustomMapping(from, to); + assertEquals(contains, maps.contains(key)); + + if (contains == true) + { + for (CustomMapping map : maps) + { + if (map.equals(key) == true) + { + result = key; + break; + } + } + } + return result; + } + + private Set checkCustomMappingSize(int expected) + { + Set maps = eMailMappingService.getCustomMappings(); + assertEquals(expected, maps.size()); + return maps; + } + + @SuppressWarnings("unused") + private void print(Set maps) + { + for (CustomMapping map : maps) + { + System.out.println(map.getFrom() + " -> " + map.getTo()); + } + } +}