Search in sources :

Example 1 with ContentValidatorParams

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());
}
Also used : ContentValidatorParams(com.enonic.xp.content.ContentValidatorParams) Test(org.junit.jupiter.api.Test)

Example 2 with ContentValidatorParams

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"));
}
Also used : ContentValidatorParams(com.enonic.xp.content.ContentValidatorParams) PropertyTree(com.enonic.xp.data.PropertyTree) ExtraData(com.enonic.xp.content.ExtraData) Test(org.junit.jupiter.api.Test)

Example 3 with ContentValidatorParams

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());
}
Also used : ContentValidatorParams(com.enonic.xp.content.ContentValidatorParams) Test(org.junit.jupiter.api.Test)

Example 4 with ContentValidatorParams

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();
}
Also used : GetContentTypeParams(com.enonic.xp.schema.content.GetContentTypeParams) ContentValidatorParams(com.enonic.xp.content.ContentValidatorParams) ContentValidator(com.enonic.xp.content.ContentValidator) ContentType(com.enonic.xp.schema.content.ContentType)

Aggregations

ContentValidatorParams (com.enonic.xp.content.ContentValidatorParams)4 Test (org.junit.jupiter.api.Test)3 ContentValidator (com.enonic.xp.content.ContentValidator)1 ExtraData (com.enonic.xp.content.ExtraData)1 PropertyTree (com.enonic.xp.data.PropertyTree)1 ContentType (com.enonic.xp.schema.content.ContentType)1 GetContentTypeParams (com.enonic.xp.schema.content.GetContentTypeParams)1