Search in sources :

Example 1 with MockServiceRegistry

use of com.enonic.xp.testing.mock.MockServiceRegistry in project xp by enonic.

the class ScriptTestSupport method initialize.

protected void initialize() throws Exception {
    this.serviceRegistry = new MockServiceRegistry();
    this.portalRequest = createPortalRequest();
    PortalRequestAccessor.set(this.portalRequest);
    this.bundleContext = createBundleContext();
    this.contentService = Mockito.mock(ContentService.class);
    this.resourceService = createResourceService();
    addService(ContentService.class, this.contentService);
    addService(ResourceService.class, this.resourceService);
    addService(ViewFunctionService.class, new MockViewFunctionService());
    this.scriptSettings = ScriptSettings.create();
    this.scriptSettings.binding(Context.class, ContextAccessor::current);
    this.scriptSettings.binding(PortalRequest.class, () -> this.portalRequest);
    this.scriptSettings.debug(new ScriptDebugSettings());
    this.scriptSettings.globalVariable("testInstance", this);
    this.executor = createExecutor();
}
Also used : ContextAccessor(com.enonic.xp.context.ContextAccessor) MockViewFunctionService(com.enonic.xp.testing.mock.MockViewFunctionService) MockServiceRegistry(com.enonic.xp.testing.mock.MockServiceRegistry) ContentService(com.enonic.xp.content.ContentService)

Aggregations

ContentService (com.enonic.xp.content.ContentService)1 ContextAccessor (com.enonic.xp.context.ContextAccessor)1 MockServiceRegistry (com.enonic.xp.testing.mock.MockServiceRegistry)1 MockViewFunctionService (com.enonic.xp.testing.mock.MockViewFunctionService)1