use of com.enonic.xp.content.ContentValidatorParams in project xp by enonic.
the class ContentValidatorParamsTest method createAttachments_null_safe.
@Test
void createAttachments_null_safe() {
final ContentValidatorParams params = ContentValidatorParams.create().build();
assertNotNull(params.getCreateAttachments());
}
use of com.enonic.xp.content.ContentValidatorParams in project xp by enonic.
the class ContentValidatorParamsTest method builder.
@Test
void builder() {
final ContentValidatorParams params = ContentValidatorParams.create().contentType(ContentType.create().name("ct").superType(ContentTypeName.unstructured()).build()).contentId(ContentId.from("ci")).data(new PropertyTree()).createAttachments(CreateAttachments.create().add(CreateAttachment.create().name("att").byteSource(ByteSource.empty()).build()).build()).extraDatas(ExtraDatas.create().add(new ExtraData(XDataName.from("xd"), new PropertyTree())).build()).build();
assertEquals(params.getContentType().getName(), ContentTypeName.from("ct"));
assertEquals(params.getContentId(), ContentId.from("ci"));
assertNotNull(params.getData());
assertThat(params.getCreateAttachments()).extracting("name").containsExactly("att");
assertThat(params.getExtraDatas()).extracting("name").containsExactly(XDataName.from("xd"));
}
use of com.enonic.xp.content.ContentValidatorParams in project xp by enonic.
the class ContentValidatorParamsTest method extraDatas_null_safe.
@Test
void extraDatas_null_safe() {
final ContentValidatorParams params = ContentValidatorParams.create().build();
assertNotNull(params.getExtraDatas());
}
use of com.enonic.xp.content.ContentValidatorParams 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();
}
Aggregations