@Test public void createMessage() throws Exception { DocumentReference userReference = new DocumentReference("userwiki", "userspace", "userpage"); Map<String, Object> source = Collections.<String, Object>singletonMap("users", Collections.singletonList(userReference)); Map<String, Object> parameters = new HashMap<>(); parameters.put("hint", "template"); parameters.put("source", new DocumentReference("templatewiki", "templatespace", "templatepage")); Provider<ComponentManager> componentManagerProvider = this.mocker.registerMockComponent( new DefaultParameterizedType(null, Provider.class, ComponentManager.class), "context"); when(componentManagerProvider.get()).thenReturn(this.mocker); this.mocker.registerMockComponent(new DefaultParameterizedType(null, MimeMessageFactory.class, MimeMessage.class), "template"); Execution execution = this.mocker.registerMockComponent(Execution.class); XWikiContext xwikiContext = mock(XWikiContext.class); ExecutionContext executionContext = new ExecutionContext(); executionContext.setProperty(XWikiContext.EXECUTIONCONTEXT_KEY, xwikiContext); when(execution.getContext()).thenReturn(executionContext); Iterator<MimeMessage> iterator = this.mocker.getComponentUnderTest().createMessage(source, parameters); assertNotNull(iterator); }
@Override public Iterator<MimeMessage> createMessage(Object sourceObject, Map<String, Object> parameters) throws MessagingException { Map<String, Object> source = getTypedSource(sourceObject, Map.class); validateParameters(parameters, HINT, SOURCE); String factoryHint = (String) parameters.get(HINT); MimeMessageFactory factory = getInternalMimeMessageFactory(factoryHint); UsersAndGroupsMimeMessageIterator iterator = new UsersAndGroupsMimeMessageIterator(source, factory, parameters, this.explicitDocumentReferenceResolver, this.execution); return iterator; }
UsersAndGroupsMimeMessageFactory extends AbstractIteratorMimeMessageFactory { @Override public Iterator<MimeMessage> createMessage(Object sourceObject, Map<String, Object> parameters) throws MessagingException { Map<String, Object> source = getTypedSource(sourceObject, Map.class); validateParameters(parameters, HINT, SOURCE); String factoryHint = (String) parameters.get(HINT); MimeMessageFactory factory = getInternalMimeMessageFactory(factoryHint); UsersAndGroupsMimeMessageIterator iterator = new UsersAndGroupsMimeMessageIterator(source, factory, parameters, this.explicitDocumentReferenceResolver, this.execution); return iterator; } }
UsersAndGroupsMimeMessageFactory extends AbstractIteratorMimeMessageFactory { @Override public Iterator<MimeMessage> createMessage(Object sourceObject, Map<String, Object> parameters) throws MessagingException { Map<String, Object> source = getTypedSource(sourceObject, Map.class); validateParameters(parameters, HINT, SOURCE); String factoryHint = (String) parameters.get(HINT); MimeMessageFactory factory = getInternalMimeMessageFactory(factoryHint); UsersAndGroupsMimeMessageIterator iterator = new UsersAndGroupsMimeMessageIterator(source, factory, parameters, this.explicitDocumentReferenceResolver, this.execution); return iterator; }  }
UsersAndGroupsMimeMessageFactory extends AbstractIteratorMimeMessageFactory { @Override public Iterator<MimeMessage> createMessage(Object sourceObject, Map<String, Object> parameters) throws MessagingException { Map<String, Object> source = getTypedSource(sourceObject, Map.class); validateParameters(parameters, HINT, SOURCE); String factoryHint = (String) parameters.get(HINT); MimeMessageFactory factory = getInternalMimeMessageFactory(factoryHint); UsersAndGroupsMimeMessageIterator iterator = new UsersAndGroupsMimeMessageIterator(source, factory, parameters, this.explicitDocumentReferenceResolver, this.execution); return iterator; }  @Override Iterator<MimeMessage> createMessage(Object sourceObject, Map<String, Object> parameters); }
UsersAndGroupsMimeMessageFactory extends AbstractIteratorMimeMessageFactory { @Override public Iterator<MimeMessage> createMessage(Object sourceObject, Map<String, Object> parameters) throws MessagingException { Map<String, Object> source = getTypedSource(sourceObject, Map.class); validateParameters(parameters, HINT, SOURCE); String factoryHint = (String) parameters.get(HINT); MimeMessageFactory factory = getInternalMimeMessageFactory(factoryHint); UsersAndGroupsMimeMessageIterator iterator = new UsersAndGroupsMimeMessageIterator(source, factory, parameters, this.explicitDocumentReferenceResolver, this.execution); return iterator; }  @Override Iterator<MimeMessage> createMessage(Object sourceObject, Map<String, Object> parameters);  }