use of com.enonic.xp.schema.content.ContentType in project xp by enonic.
the class ApplicationInfoServiceImplTest method mockContentTypes.
private void mockContentTypes(final ApplicationKey applicationKey) {
final ContentType contentType = ContentType.create().name(ContentTypeName.media()).form(Form.create().build()).setAbstract().setFinal().allowChildContent(true).setBuiltIn().displayNameExpression("displayNameExpression").displayName("displayName").description("description").modifiedTime(Instant.ofEpochSecond(1000)).createdTime(Instant.ofEpochSecond(1000)).creator(PrincipalKey.ofAnonymous()).modifier(PrincipalKey.ofAnonymous()).build();
final ContentTypes contentTypes = ContentTypes.from(contentType);
Mockito.when(this.contentTypeService.getByApplication(applicationKey)).thenReturn(contentTypes);
}
use of com.enonic.xp.schema.content.ContentType in project xp by enonic.
the class UpdateContentCommand method processContent.
private Content processContent(final Content originalContent, Content editedContent) {
final ContentType contentType = this.contentTypeService.getByName(GetContentTypeParams.from(editedContent.getType()));
editedContent = runContentProcessors(originalContent, editedContent, contentType);
return editedContent;
}
use of com.enonic.xp.schema.content.ContentType in project xp by enonic.
the class ValidateContentDataCommand method execute.
ValidationErrors execute() {
final ContentType contentType = contentTypeService.getByName(new GetContentTypeParams().contentTypeName(contentTypeName));
Preconditions.checkArgument(contentType != null, "ContentType [%s] not found", contentTypeName);
final ContentValidatorParams validatorParams = contentValidatorParamsBuilder.contentType(contentType).build();
for (ContentValidator contentValidator : contentValidators) {
if (contentValidator.supports(contentTypeName)) {
contentValidator.validate(validatorParams, resultBuilder);
}
}
return this.resultBuilder.build();
}
use of com.enonic.xp.schema.content.ContentType in project xp by enonic.
the class RenameContentCommandTest method setUp.
@BeforeEach
void setUp() {
this.contentTypeService = mock(ContentTypeService.class);
this.contentService = mock(ContentService.class);
this.nodeService = mock(NodeService.class);
this.eventPublisher = mock(EventPublisher.class);
this.translator = mock(ContentNodeTranslator.class);
this.xDataService = mock(XDataService.class);
this.pageDescriptorService = mock(PageDescriptorService.class);
this.partDescriptorService = mock(PartDescriptorService.class);
this.layoutDescriptorService = mock(LayoutDescriptorService.class);
this.contentDataSerializer = ContentDataSerializer.create().layoutDescriptorService(layoutDescriptorService).pageDescriptorService(pageDescriptorService).partDescriptorService(partDescriptorService).build();
final ContentType contentType = ContentType.create().superType(ContentTypeName.documentMedia()).name(ContentTypeName.dataMedia()).build();
when(contentTypeService.getByName(isA(GetContentTypeParams.class))).thenReturn(contentType);
mockNode = Node.create().id(NodeId.from("testId")).build();
when(nodeService.rename(isA(RenameNodeParams.class))).thenReturn(mockNode);
when(nodeService.getById(mockNode.id())).thenReturn(mockNode);
}
use of com.enonic.xp.schema.content.ContentType in project xp by enonic.
the class ValidateContentDataCommandTest method testSiteConfigTextRegexpFailure.
@Test
public void testSiteConfigTextRegexpFailure() {
final ContentType contentType = ContentType.create().superType(ContentTypeName.structured()).name(ContentTypeName.site()).build();
Mockito.when(contentTypeService.getByName(Mockito.isA(GetContentTypeParams.class))).thenReturn(contentType);
PropertyTree rootDataSet = new PropertyTree();
PropertyTree siteConfigDataSet = new PropertyTree();
siteConfigDataSet.setString("textInput-1", "test");
SiteConfig siteConfig = SiteConfig.create().application(ApplicationKey.from("myapp")).config(siteConfigDataSet).build();
new SiteConfigsDataSerializer().toProperties(SiteConfigs.from(siteConfig), rootDataSet.getRoot());
Mockito.when(siteService.getDescriptor(Mockito.isA(ApplicationKey.class))).thenReturn(createSiteDescriptor());
// exercise
final ValidationErrors result = executeValidation(rootDataSet, ContentTypeName.site());
assertThat(result.stream()).hasSize(1);
}
Aggregations