Search in sources :

Example 1 with XData

use of com.enonic.xp.schema.xdata.XData in project xp by enonic.

the class XmlXDataParserTest method assertResult.

private void assertResult() throws Exception {
    final XData result = this.builder.build();
    assertEquals("myapplication:mymixin", result.getName().toString());
    assertEquals("display name", result.getDisplayName());
    assertEquals("key.display-name", result.getDisplayNameI18nKey());
    assertEquals("description", result.getDescription());
    assertEquals("key.description", result.getDescriptionI18nKey());
    assertEquals(1, result.getForm().size());
}
Also used : XData(com.enonic.xp.schema.xdata.XData)

Example 2 with XData

use of com.enonic.xp.schema.xdata.XData in project xp by enonic.

the class ImageContentProcessorTest method testProcessCreateWithGeoData.

@Test
public void testProcessCreateWithGeoData() throws IOException {
    final XData gpsInfo = createXData(GPS_INFO_METADATA_NAME, "Gps Info", createGpsInfoMixinForm());
    Mockito.when(this.xDataService.getFromContentType(Mockito.any())).thenReturn(XDatas.from(gpsInfo));
    final CreateContentParams params = createContentParams(createAttachments());
    final ProcessCreateParams processCreateParams = new ProcessCreateParams(params, MediaInfo.create().addMetadata("geo lat", "1").addMetadata("geo long", "2").build());
    final GeoPoint geoPoint = new GeoPoint(1.0, 2.0);
    final ProcessCreateResult result = this.imageContentProcessor.processCreate(processCreateParams);
    final ExtraData geoExtraData = result.getCreateContentParams().getExtraDatas().first();
    assertEquals(geoExtraData.getName(), GPS_INFO_METADATA_NAME);
    assertEquals(geoExtraData.getData().getGeoPoint(MediaInfo.GPS_INFO_GEO_POINT, 0), geoPoint);
}
Also used : GeoPoint(com.enonic.xp.util.GeoPoint) CreateContentParams(com.enonic.xp.content.CreateContentParams) ProcessCreateResult(com.enonic.xp.content.processor.ProcessCreateResult) XData(com.enonic.xp.schema.xdata.XData) ExtraData(com.enonic.xp.content.ExtraData) ProcessCreateParams(com.enonic.xp.content.processor.ProcessCreateParams) Test(org.junit.jupiter.api.Test)

Example 3 with XData

use of com.enonic.xp.schema.xdata.XData in project xp by enonic.

the class XDataLoader method load.

@Override
protected XData load(final XDataName name, final Resource resource) {
    final XData.Builder builder = XData.create();
    parseXml(resource, builder);
    final Instant modifiedTime = Instant.ofEpochMilli(resource.getTimestamp());
    builder.modifiedTime(modifiedTime);
    builder.createdTime(modifiedTime);
    builder.icon(loadIcon(name));
    return builder.name(name).build();
}
Also used : Instant(java.time.Instant) XData(com.enonic.xp.schema.xdata.XData)

Example 4 with XData

use of com.enonic.xp.schema.xdata.XData in project xp by enonic.

the class XDataServiceImplTest method testSystemMixins.

@Test
public void testSystemMixins() {
    XDatas xDatas = service.getAll();
    assertNotNull(xDatas);
    assertEquals(3, xDatas.getSize());
    xDatas = service.getByApplication(ApplicationKey.MEDIA_MOD);
    assertNotNull(xDatas);
    assertEquals(2, xDatas.getSize());
    XData xData = service.getByName(MediaInfo.GPS_INFO_METADATA_NAME);
    assertNotNull(xData);
    xData = service.getByName(MediaInfo.IMAGE_INFO_METADATA_NAME);
    assertNotNull(xData);
    xData = service.getByName(MediaInfo.CAMERA_INFO_METADATA_NAME);
    assertNotNull(xData);
}
Also used : XDatas(com.enonic.xp.schema.xdata.XDatas) XData(com.enonic.xp.schema.xdata.XData) Test(org.junit.jupiter.api.Test) AbstractSchemaTest(com.enonic.xp.core.impl.schema.AbstractSchemaTest)

Example 5 with XData

use of com.enonic.xp.schema.xdata.XData in project xp by enonic.

the class XDataServiceImplTest method testEmpty.

@Test
public void testEmpty() {
    final XDatas types1 = this.service.getAll();
    assertNotNull(types1);
    assertEquals(3, types1.getSize());
    final XDatas types2 = this.service.getByApplication(ApplicationKey.from("other"));
    assertNotNull(types2);
    assertEquals(0, types2.getSize());
    final XData xData = service.getByName(XDataName.from("other:mytype"));
    assertEquals(null, xData);
}
Also used : XDatas(com.enonic.xp.schema.xdata.XDatas) XData(com.enonic.xp.schema.xdata.XData) Test(org.junit.jupiter.api.Test) AbstractSchemaTest(com.enonic.xp.core.impl.schema.AbstractSchemaTest)

Aggregations

XData (com.enonic.xp.schema.xdata.XData)17 Test (org.junit.jupiter.api.Test)8 ExtraData (com.enonic.xp.content.ExtraData)7 PropertyTree (com.enonic.xp.data.PropertyTree)6 Form (com.enonic.xp.form.Form)5 CreateContentParams (com.enonic.xp.content.CreateContentParams)4 XDataName (com.enonic.xp.schema.xdata.XDataName)4 XDatas (com.enonic.xp.schema.xdata.XDatas)4 ProcessCreateParams (com.enonic.xp.content.processor.ProcessCreateParams)3 ProcessCreateResult (com.enonic.xp.content.processor.ProcessCreateResult)3 AbstractSchemaTest (com.enonic.xp.core.impl.schema.AbstractSchemaTest)3 ContentType (com.enonic.xp.schema.content.ContentType)3 FormItem (com.enonic.xp.form.FormItem)2 FormItemSet (com.enonic.xp.form.FormItemSet)2 Input (com.enonic.xp.form.Input)2 GetContentTypeParams (com.enonic.xp.schema.content.GetContentTypeParams)2 GeoPoint (com.enonic.xp.util.GeoPoint)2 Application (com.enonic.xp.app.Application)1 CreateAttachments (com.enonic.xp.attachment.CreateAttachments)1 EditableContent (com.enonic.xp.content.EditableContent)1