@Test public void createMessageWhenNotExistingMimeMessageFactory() throws Exception { DocumentReference userReference = new DocumentReference("wiki", "space", "page"); Map<String, Object> parameters = new HashMap<>(); parameters.put("hint", "factoryHint"); parameters.put("source", "factoryHint"); Provider<ComponentManager> componentManagerProvider = this.mocker.registerMockComponent( new DefaultParameterizedType(null, Provider.class, ComponentManager.class), "context"); when(componentManagerProvider.get()).thenReturn(this.mocker); try { this.mocker.getComponentUnderTest().createMessage(Arrays.asList(userReference), parameters); fail("Should have thrown an exception"); } catch (MessagingException expected) { assertEquals("Failed to find a [MimeMessageFactory<MimeMessage>] for hint [factoryHint]", expected.getMessage()); } }
@Override public Iterator<MimeMessage> createMessage(Object userReferencesObject, Map<String, Object> parameters) throws MessagingException { List<DocumentReference> userReferences = getTypedSource(userReferencesObject, List.class); validateParameters(parameters, HINT, SOURCE); String factoryHint = (String) parameters.get(HINT); MimeMessageFactory factory = getInternalMimeMessageFactory(factoryHint); UsersMimeMessageIterator iterator = new UsersMimeMessageIterator(userReferences, factory, parameters, this.componentManagerProvider.get()); return iterator; }
UsersMimeMessageFactory extends AbstractIteratorMimeMessageFactory { @Override public Iterator<MimeMessage> createMessage(Object userReferencesObject, Map<String, Object> parameters) throws MessagingException { List<DocumentReference> userReferences = getTypedSource(userReferencesObject, List.class); validateParameters(parameters, HINT, SOURCE); String factoryHint = (String) parameters.get(HINT); MimeMessageFactory factory = getInternalMimeMessageFactory(factoryHint); UsersMimeMessageIterator iterator = new UsersMimeMessageIterator(userReferences, factory, parameters, this.componentManagerProvider.get()); return iterator; } }
UsersMimeMessageFactory extends AbstractIteratorMimeMessageFactory { @Override public Iterator<MimeMessage> createMessage(Object userReferencesObject, Map<String, Object> parameters) throws MessagingException { List<DocumentReference> userReferences = getTypedSource(userReferencesObject, List.class); validateParameters(parameters, HINT, SOURCE); String factoryHint = (String) parameters.get(HINT); MimeMessageFactory factory = getInternalMimeMessageFactory(factoryHint); UsersMimeMessageIterator iterator = new UsersMimeMessageIterator(userReferences, factory, parameters, this.componentManagerProvider.get()); return iterator; }  }
UsersMimeMessageFactory extends AbstractIteratorMimeMessageFactory { @Override public Iterator<MimeMessage> createMessage(Object userReferencesObject, Map<String, Object> parameters) throws MessagingException { List<DocumentReference> userReferences = getTypedSource(userReferencesObject, List.class); validateParameters(parameters, HINT, SOURCE); String factoryHint = (String) parameters.get(HINT); MimeMessageFactory factory = getInternalMimeMessageFactory(factoryHint); UsersMimeMessageIterator iterator = new UsersMimeMessageIterator(userReferences, factory, parameters, this.componentManagerProvider.get()); return iterator; }  @Override Iterator<MimeMessage> createMessage(Object userReferencesObject, Map<String, Object> parameters); }
UsersMimeMessageFactory extends AbstractIteratorMimeMessageFactory { @Override public Iterator<MimeMessage> createMessage(Object userReferencesObject, Map<String, Object> parameters) throws MessagingException { List<DocumentReference> userReferences = getTypedSource(userReferencesObject, List.class); validateParameters(parameters, HINT, SOURCE); String factoryHint = (String) parameters.get(HINT); MimeMessageFactory factory = getInternalMimeMessageFactory(factoryHint); UsersMimeMessageIterator iterator = new UsersMimeMessageIterator(userReferences, factory, parameters, this.componentManagerProvider.get()); return iterator; }  @Override Iterator<MimeMessage> createMessage(Object userReferencesObject, Map<String, Object> parameters);  }