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());
}
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);
}
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();
}
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);
}
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);
}
Aggregations