MailComposerImpl implements MailComposer { List<String> getResourcesId(final String htmlTemplate) { final List<String> resourceIds = new ArrayList<>(); final Matcher matcher = getResourcePattern().matcher(htmlTemplate); while (matcher.find()) { resourceIds.add(matcher.group(1)); } return resourceIds; } MailComposerImpl(final MailTemplateResourcesProvider mailTemplateResourcesProvider,
                            final TemplateProcessor templateSupport); String getResourceExpression(); void setResourceExpression(final String resourceExpression); @Override void composeMessage(final Mail mail,
                               final String shopCode,
                               final String locale,
                               final List<String> mailTemplateChain,
                               final String templateName,
                               final String from,
                               final String toEmail,
                               final String ccEmail,
                               final String bccEmail,
                               final Map<String, Object> model); @Override void convertMessage(final Mail mail, final MimeMessage mimeMessage); @Override String convertMessageToTXT(final Mail mail); @Override String convertMessageToHTML(final Mail mail);  }
@Test public void testGetResourcesId() throws ClassNotFoundException { final CacheManager cacheManager = mockery.mock(CacheManager.class); final Cache cache = mockery.mock(Cache.class); mockery.checking(new Expectations() {{ allowing(cacheManager).getCache("contentService-templateSupport"); will(returnValue(cache)); }}); final TemplateProcessor templates = new MailComposerTemplateSupportGroovyImpl(new GroovyGStringTemplateSupportImpl(cacheManager)); MailComposerImpl mailComposer = new MailComposerImpl(null, templates); List<String> rez = mailComposer.getResourcesId("'cid:identifier1234' \"cid:id\" 'cid:ident' \"cid:identifier5678\""); assertEquals(4, rez.size()); assertEquals("identifier1234", rez.get(0)); assertEquals("id", rez.get(1)); assertEquals("ident", rez.get(2)); assertEquals("identifier5678", rez.get(3)); mockery.assertIsSatisfied(); }