use of javax.inject.Provider in project xwiki-platform by xwiki.
the class SerializedFilesMimeMessageFactoryTest method createMessageWhenNoExecution.
@Test
public void createMessageWhenNoExecution() throws Exception {
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("batchId", null);
fail("Should have thrown an exception");
} catch (MessagingException expected) {
assertEquals("Failed to find an Environment Component", expected.getMessage());
}
}
use of javax.inject.Provider in project xwiki-platform by xwiki.
the class GroupMimeMessageFactoryTest method createMessageWhenNotExistingMimeMessageFactory.
@Test
public void createMessageWhenNotExistingMimeMessageFactory() throws Exception {
DocumentReference groupReference = new DocumentReference("wiki", "space", "page");
Map<String, Object> parameters = new HashMap<>();
parameters.put("hint", "factoryHint");
parameters.put("source", "factorySource");
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(groupReference, parameters);
fail("Should have thrown an exception");
} catch (MessagingException expected) {
assertEquals("Failed to find a [MimeMessageFactory<MimeMessage>] for hint [factoryHint]", expected.getMessage());
}
}
use of javax.inject.Provider in project xwiki-platform by xwiki.
the class MailStorageScriptServiceTest method setUp.
@Before
public void setUp() throws Exception {
Provider<ComponentManager> componentManagerProvider = this.mocker.registerMockComponent(new DefaultParameterizedType(null, Provider.class, ComponentManager.class), "context");
when(componentManagerProvider.get()).thenReturn(this.mocker);
Execution execution = this.mocker.getInstance(Execution.class);
ExecutionContext executionContext = new ExecutionContext();
when(execution.getContext()).thenReturn(executionContext);
}
use of javax.inject.Provider in project xwiki-platform by xwiki.
the class UsersMimeMessageFactoryTest method createMessageWhenNotExistingMimeMessageFactory.
@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());
}
}
use of javax.inject.Provider in project xwiki-platform by xwiki.
the class XWikiDocument method init.
private void init(DocumentReference reference) {
// if the passed reference is null consider it points to the default reference
if (reference == null) {
setDocumentReference(Utils.<Provider<DocumentReference>>getComponent(DocumentReference.TYPE_PROVIDER).get());
} else {
setDocumentReference(reference);
}
this.updateDate = new Date();
this.updateDate.setTime((this.updateDate.getTime() / 1000) * 1000);
this.contentUpdateDate = new Date();
this.contentUpdateDate.setTime((this.contentUpdateDate.getTime() / 1000) * 1000);
this.creationDate = new Date();
this.creationDate.setTime((this.creationDate.getTime() / 1000) * 1000);
this.content = "";
this.format = "";
this.locale = Locale.ROOT;
this.defaultLocale = Locale.ROOT;
this.customClass = "";
this.comment = "";
// Note: As there's no notion of an Empty document we don't set the original document
// field. Thus getOriginalDocument() may return null.
}
Aggregations