use of com.enonic.xp.schema.xdata.XDataService in project xp by enonic.
the class AbstractContentServiceTest method setUpAbstractContentServiceTest.
@BeforeEach
public void setUpAbstractContentServiceTest() {
executorService = Executors.newSingleThreadExecutor();
deleteAllIndices();
ContextAccessor.INSTANCE.set(ctxDefault());
final MemoryBlobStore blobStore = new MemoryBlobStore();
binaryService = new BinaryServiceImpl();
binaryService.setBlobStore(blobStore);
final StorageDaoImpl storageDao = new StorageDaoImpl();
storageDao.setClient(client);
final EventPublisherImpl eventPublisher = new EventPublisherImpl(executorService);
SearchDaoImpl searchDao = new SearchDaoImpl();
searchDao.setClient(client);
BranchServiceImpl branchService = new BranchServiceImpl();
branchService.setStorageDao(storageDao);
branchService.setSearchDao(searchDao);
VersionServiceImpl versionService = new VersionServiceImpl();
versionService.setStorageDao(storageDao);
CommitServiceImpl commitService = new CommitServiceImpl();
commitService.setStorageDao(storageDao);
IndexServiceInternalImpl indexServiceInternal = new IndexServiceInternalImpl();
indexServiceInternal.setClient(client);
indexService = new IndexServiceImpl();
indexService.setIndexServiceInternal(indexServiceInternal);
NodeVersionServiceImpl nodeDao = new NodeVersionServiceImpl();
nodeDao.setBlobStore(blobStore);
IndexDataServiceImpl indexedDataService = new IndexDataServiceImpl();
indexedDataService.setStorageDao(storageDao);
NodeStorageServiceImpl storageService = new NodeStorageServiceImpl();
storageService.setBranchService(branchService);
storageService.setVersionService(versionService);
storageService.setCommitService(commitService);
storageService.setNodeVersionService(nodeDao);
storageService.setIndexDataService(indexedDataService);
NodeSearchServiceImpl searchService = new NodeSearchServiceImpl();
searchService.setSearchDao(searchDao);
final NodeRepositoryServiceImpl nodeRepositoryService = new NodeRepositoryServiceImpl();
nodeRepositoryService.setIndexServiceInternal(indexServiceInternal);
final IndexServiceInternalImpl elasticsearchIndexService = new IndexServiceInternalImpl();
elasticsearchIndexService.setClient(client);
final RepositoryEntryServiceImpl repositoryEntryService = new RepositoryEntryServiceImpl();
repositoryEntryService.setIndexServiceInternal(elasticsearchIndexService);
repositoryEntryService.setNodeStorageService(storageService);
repositoryEntryService.setNodeSearchService(searchService);
repositoryEntryService.setEventPublisher(eventPublisher);
repositoryEntryService.setBinaryService(binaryService);
repositoryService = new RepositoryServiceImpl(repositoryEntryService, elasticsearchIndexService, nodeRepositoryService, storageService, searchService);
repositoryService.initialize();
nodeService = new NodeServiceImpl();
nodeService.setIndexServiceInternal(indexServiceInternal);
nodeService.setNodeStorageService(storageService);
nodeService.setNodeSearchService(searchService);
nodeService.setEventPublisher(eventPublisher);
nodeService.setBinaryService(binaryService);
nodeService.setRepositoryService(repositoryService);
nodeService.initialize();
mixinService = Mockito.mock(MixinService.class);
Mockito.when(mixinService.inlineFormItems(Mockito.isA(Form.class))).then(AdditionalAnswers.returnsFirstArg());
xDataService = Mockito.mock(XDataService.class);
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 = Mockito.mock(BinaryExtractor.class);
Mockito.when(extractor.extract(Mockito.isA(ByteSource.class))).thenReturn(extractedData);
mediaInfoService = new MediaInfoServiceImpl();
mediaInfoService.setBinaryExtractor(extractor);
final ResourceService resourceService = Mockito.mock(ResourceService.class);
final SiteServiceImpl siteService = new SiteServiceImpl();
siteService.setResourceService(resourceService);
siteService.setMixinService(mixinService);
contentTypeService = new ContentTypeServiceImpl(null, null, mixinService);
PageDescriptorService pageDescriptorService = Mockito.mock(PageDescriptorService.class);
PartDescriptorService partDescriptorService = Mockito.mock(PartDescriptorService.class);
LayoutDescriptorService layoutDescriptorService = Mockito.mock(LayoutDescriptorService.class);
auditLogService = Mockito.mock(AuditLogService.class);
final ContentConfig contentConfig = Mockito.mock(ContentConfig.class);
Mockito.when(contentConfig.auditlog_enabled()).thenReturn(Boolean.TRUE);
final ContentAuditLogSupportImpl contentAuditLogSupport = new ContentAuditLogSupportImpl(contentConfig, new ContentAuditLogExecutorImpl(), auditLogService);
final SecurityServiceImpl securityService = new SecurityServiceImpl(nodeService, indexService);
securityService.initialize();
final ProjectPermissionsContextManagerImpl projectAccessContextManager = new ProjectPermissionsContextManagerImpl();
final ProjectServiceImpl projectService = new ProjectServiceImpl(repositoryService, indexService, nodeService, securityService, projectAccessContextManager, eventPublisher);
projectService.initialize();
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.addContentValidator(new ContentNameValidator());
contentService.addContentValidator(new SiteConfigsValidator(siteService));
contentService.addContentValidator(new OccurrenceValidator());
contentService.addContentValidator(new ExtraDataValidator(xDataService));
contentService.initialize(mock(ContentConfig.class, invocation -> invocation.getMethod().getDefaultValue()));
}
use of com.enonic.xp.schema.xdata.XDataService 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.schema.xdata.XDataService in project xp by enonic.
the class UpdateNodeParamsFactory method toNodeEditor.
private NodeEditor toNodeEditor(final UpdateContentTranslatorParams params) {
final Content content = params.getEditedContent();
final PropertyTree nodeData = contentDataSerializer.toUpdateNodeData(params);
final ContentIndexConfigFactory indexConfigFactory = ContentIndexConfigFactory.create().contentTypeService(contentTypeService).pageDescriptorService(pageDescriptorService).partDescriptorService(partDescriptorService).layoutDescriptorService(layoutDescriptorService).siteService(this.siteService).xDataService(this.xDataService).contentTypeName(content.getType()).page(content.getPage()).siteConfigs(content.isSite() ? ((Site) content).getSiteConfigs() : null).extraDatas(content.getAllExtraData()).language(content.getLanguage() != null ? content.getLanguage().getLanguage() : null).build();
return editableNode -> {
editableNode.indexConfigDocument = indexConfigFactory.produce();
editableNode.data = nodeData;
editableNode.manualOrderValue = content.getManualOrderValue();
editableNode.permissions = content.getPermissions();
editableNode.inheritPermissions = content.inheritsPermissions();
};
}
use of com.enonic.xp.schema.xdata.XDataService in project xp by enonic.
the class HtmlAreaContentProcessorTest method setUp.
@BeforeEach
public void setUp() throws Exception {
this.siteService = Mockito.mock(SiteService.class);
this.xDataService = Mockito.mock(XDataService.class);
this.contentTypeService = Mockito.mock(ContentTypeService.class);
this.pageDescriptorService = Mockito.mock(PageDescriptorService.class);
this.partDescriptorService = Mockito.mock(PartDescriptorService.class);
this.layoutDescriptorService = Mockito.mock(LayoutDescriptorService.class);
contentTypeName = ContentTypeName.from("myContentType");
final GetContentTypeParams params = GetContentTypeParams.from(contentTypeName);
contentType = ContentType.create().name(contentTypeName).superType(ContentTypeName.folder()).form(Form.create().addFormItem(Input.create().name("htmlData").label("htmlData").inputType(InputTypeName.HTML_AREA).build()).build()).build();
final ProcessUpdateParams processUpdateParams = ProcessUpdateParams.create().contentType(contentType).build();
Mockito.when(contentTypeService.getByName(params)).thenReturn(contentType);
Mockito.when(xDataService.getByNames(Mockito.isA(XDataNames.class))).thenReturn(XDatas.empty());
htmlAreaContentProcessor = new HtmlAreaContentProcessor();
htmlAreaContentProcessor.setContentTypeService(contentTypeService);
htmlAreaContentProcessor.setSiteService(siteService);
htmlAreaContentProcessor.setXDataService(xDataService);
htmlAreaContentProcessor.setPageDescriptorService(pageDescriptorService);
htmlAreaContentProcessor.setPartDescriptorService(partDescriptorService);
htmlAreaContentProcessor.setLayoutDescriptorService(layoutDescriptorService);
result = htmlAreaContentProcessor.processUpdate(processUpdateParams);
}
Aggregations