use of de.fraunhofer.iosb.ilt.faaast.service.model.value.EntityValue in project FAAAST-Service by FraunhoferIOSB.
the class ElementValueMapperTest method testEntitySetValueMapping.
@Test
public void testEntitySetValueMapping() throws ValueFormatException {
SubmodelElement actual = new DefaultEntity.Builder().statement(new DefaultProperty.Builder().idShort("property").build()).build();
EntityValue value = EntityValue.builder().statement("property", PropertyValue.of(Datatype.String, "foo")).entityType(EntityType.SELF_MANAGED_ENTITY).globalAssetId(List.of(new DefaultKey.Builder().idType(KeyType.IRI).type(KeyElements.SUBMODEL).value("http://example.org/submodel/1").build(), new DefaultKey.Builder().idType(KeyType.ID_SHORT).type(KeyElements.PROPERTY).value("property1").build())).build();
SubmodelElement expected = new DefaultEntity.Builder().statement(new DefaultProperty.Builder().idShort(value.getStatements().keySet().iterator().next()).valueType(Datatype.String.getName()).value("foo").build()).entityType(value.getEntityType()).globalAssetId(new DefaultReference.Builder().keys(value.getGlobalAssetId()).build()).build();
ElementValueMapper.setValue(actual, value);
Assert.assertEquals(expected, actual);
}
use of de.fraunhofer.iosb.ilt.faaast.service.model.value.EntityValue in project FAAAST-Service by FraunhoferIOSB.
the class ElementValueMapperTest method testEntityToValueMapping.
@Test
public void testEntityToValueMapping() throws ValueFormatException {
EntityValue expected = EntityValue.builder().statement("property", PropertyValue.of(Datatype.String, "foo")).entityType(EntityType.SELF_MANAGED_ENTITY).globalAssetId(List.of(new DefaultKey.Builder().idType(KeyType.IRI).type(KeyElements.SUBMODEL).value("http://example.org/submodel/1").build(), new DefaultKey.Builder().idType(KeyType.ID_SHORT).type(KeyElements.PROPERTY).value("property1").build())).build();
SubmodelElement input = new DefaultEntity.Builder().statement(new DefaultProperty.Builder().category("Test").idShort(expected.getStatements().keySet().iterator().next()).valueType(Datatype.String.getName()).value("foo").build()).entityType(expected.getEntityType()).globalAssetId(new DefaultReference.Builder().keys(expected.getGlobalAssetId()).build()).build();
ElementValue actual = ElementValueMapper.toValue(input);
Assert.assertEquals(expected, actual);
}
Aggregations