Search in sources :

Example 1 with ScriptServicePermissionChecker

use of org.xwiki.mail.script.ScriptServicePermissionChecker in project xwiki-platform by xwiki.

the class ScriptingIntegrationTest method registerConfiguration.

@BeforeComponent
public void registerConfiguration() throws Exception {
    MailSenderConfiguration configuration = new TestMailSenderConfiguration(this.mail.getSmtp().getPort(), null, null, new Properties());
    this.componentManager.registerComponent(MailSenderConfiguration.class, configuration);
    // Register a test Permission Checker that allows sending mails
    ScriptServicePermissionChecker checker = mock(ScriptServicePermissionChecker.class);
    this.componentManager.registerComponent(ScriptServicePermissionChecker.class, "test", checker);
    // Set the current wiki in the Context
    ModelContext modelContext = this.componentManager.registerMockComponent(ModelContext.class);
    Mockito.when(modelContext.getCurrentEntityReference()).thenReturn(new WikiReference("wiki"));
    Provider<XWikiContext> xwikiContextProvider = this.componentManager.registerMockComponent(XWikiContext.TYPE_PROVIDER);
    when(xwikiContextProvider.get()).thenReturn(Mockito.mock(XWikiContext.class));
    this.componentManager.registerMockComponent(ExecutionContextManager.class);
    this.componentManager.registerMockComponent(new DefaultParameterizedType(null, Copier.class, ExecutionContext.class));
    EnvironmentConfiguration environmentConfiguration = this.componentManager.registerMockComponent(EnvironmentConfiguration.class);
    when(environmentConfiguration.getPermanentDirectoryPath()).thenReturn(System.getProperty("java.io.tmpdir"));
    this.componentManager.registerMockComponent(ConverterManager.class);
}
Also used : ModelContext(org.xwiki.model.ModelContext) ExecutionContext(org.xwiki.context.ExecutionContext) EnvironmentConfiguration(org.xwiki.environment.internal.EnvironmentConfiguration) Copier(org.xwiki.mail.internal.thread.context.Copier) XWikiContext(com.xpn.xwiki.XWikiContext) Properties(java.util.Properties) WikiReference(org.xwiki.model.reference.WikiReference) DefaultParameterizedType(org.xwiki.component.util.DefaultParameterizedType) ScriptServicePermissionChecker(org.xwiki.mail.script.ScriptServicePermissionChecker) MailSenderConfiguration(org.xwiki.mail.MailSenderConfiguration) BeforeComponent(org.xwiki.test.annotation.BeforeComponent)

Aggregations

XWikiContext (com.xpn.xwiki.XWikiContext)1 Properties (java.util.Properties)1 DefaultParameterizedType (org.xwiki.component.util.DefaultParameterizedType)1 ExecutionContext (org.xwiki.context.ExecutionContext)1 EnvironmentConfiguration (org.xwiki.environment.internal.EnvironmentConfiguration)1 MailSenderConfiguration (org.xwiki.mail.MailSenderConfiguration)1 Copier (org.xwiki.mail.internal.thread.context.Copier)1 ScriptServicePermissionChecker (org.xwiki.mail.script.ScriptServicePermissionChecker)1 ModelContext (org.xwiki.model.ModelContext)1 WikiReference (org.xwiki.model.reference.WikiReference)1 BeforeComponent (org.xwiki.test.annotation.BeforeComponent)1