use of com.enonic.xp.resource.ResourceService in project xp by enonic.
the class AbstractContentSynchronizerTest method setUpContentService.
private void setUpContentService() {
final Map<String, List<String>> metadata = new HashMap<>();
metadata.put(HttpHeaders.CONTENT_TYPE, List.of("image/jpg"));
final ExtractedData extractedData = ExtractedData.create().metadata(metadata).build();
final BinaryExtractor extractor = mock(BinaryExtractor.class);
when(extractor.extract(isA(ByteSource.class))).thenReturn(extractedData);
mediaInfoService = new MediaInfoServiceImpl();
mediaInfoService.setBinaryExtractor(extractor);
XDataService xDataService = mock(XDataService.class);
MixinService mixinService = mock(MixinService.class);
when(mixinService.inlineFormItems(isA(Form.class))).then(AdditionalAnswers.returnsFirstArg());
pageDescriptorService = mock(PageDescriptorService.class);
partDescriptorService = mock(PartDescriptorService.class);
layoutDescriptorService = mock(LayoutDescriptorService.class);
contentTypeService = new ContentTypeServiceImpl(null, null, mixinService);
final ResourceService resourceService = mock(ResourceService.class);
final SiteServiceImpl siteService = new SiteServiceImpl();
siteService.setResourceService(resourceService);
siteService.setMixinService(mixinService);
final AuditLogService auditLogService = mock(AuditLogService.class);
final ContentConfig contentConfig = mock(ContentConfig.class);
final ContentAuditLogSupportImpl contentAuditLogSupport = new ContentAuditLogSupportImpl(contentConfig, new ContentAuditLogExecutorImpl(), auditLogService);
contentService = new ContentServiceImpl(nodeService, pageDescriptorService, partDescriptorService, layoutDescriptorService);
contentService.setEventPublisher(eventPublisher);
contentService.setMediaInfoService(mediaInfoService);
contentService.setSiteService(siteService);
contentService.setContentTypeService(contentTypeService);
contentService.setxDataService(xDataService);
contentService.setFormDefaultValuesProcessor((form, data) -> {
});
contentService.setContentAuditLogSupport(contentAuditLogSupport);
contentService.initialize(mock(ContentConfig.class, invocation -> invocation.getMethod().getDefaultValue()));
}
use of com.enonic.xp.resource.ResourceService in project xp by enonic.
the class IOHandlerBean method getResource.
public Resource getResource(final Object key) {
final ResourceKey resourceKey = toResourceKey(key);
final ResourceService service = this.context.getService(ResourceService.class).get();
return service.getResource(resourceKey);
}
use of com.enonic.xp.resource.ResourceService in project xp by enonic.
the class ExceptionRendererImplTest method setup.
@BeforeEach
void setup() {
this.resourceService = mock(ResourceService.class);
this.contentService = mock(ContentService.class);
this.errorHandlerScriptFactory = mock(ErrorHandlerScriptFactory.class);
this.postProcessor = new MockPostProcessor();
this.renderer = new ExceptionRendererImpl(resourceService, errorHandlerScriptFactory, contentService, null, postProcessor, RunMode.DEV);
this.request = new PortalRequest();
final HttpServletRequest rawRequest = mock(HttpServletRequest.class);
this.request.setRawRequest(rawRequest);
}
use of com.enonic.xp.resource.ResourceService in project xp by enonic.
the class MappingHandlerTest method setup.
@BeforeEach
public final void setup() throws Exception {
this.request = new PortalRequest();
final ControllerScriptFactory controllerScriptFactory = mock(ControllerScriptFactory.class);
ControllerScript controllerScript = mock(ControllerScript.class);
when(controllerScriptFactory.fromDir(Mockito.any())).thenReturn(controllerScript);
final PortalResponse portalResponse = PortalResponse.create().build();
when(controllerScript.execute(Mockito.any())).thenReturn(portalResponse);
FilterScriptFactory filterScriptFactory = mock(FilterScriptFactory.class);
FilterScript filterScript = mock(FilterScript.class);
when(filterScriptFactory.fromScript(Mockito.any())).thenReturn(filterScript);
when(filterScript.execute(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(portalResponse);
this.resourceService = mock(ResourceService.class);
final Resource resourceNotFound = mock(Resource.class);
when(resourceNotFound.exists()).thenReturn(false);
final Resource resource = mock(Resource.class);
when(resource.exists()).thenReturn(true);
when(this.resourceService.getResource(ResourceKey.from("demo:/services/test"))).thenReturn(resource);
this.contentService = mock(ContentService.class);
this.rendererDelegate = mock(RendererDelegate.class);
this.siteService = mock(SiteService.class);
this.handler = new MappingHandler(resourceService, controllerScriptFactory, filterScriptFactory, rendererDelegate, new ControllerMappingsResolver(siteService), new ContentResolver(contentService));
this.request.setMethod(HttpMethod.GET);
}
Aggregations