Search in sources :

Example 1 with EntityValue

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);
}
Also used : SubmodelElement(io.adminshell.aas.v3.model.SubmodelElement) EntityValue(de.fraunhofer.iosb.ilt.faaast.service.model.value.EntityValue) DefaultKey(io.adminshell.aas.v3.model.impl.DefaultKey) Test(org.junit.Test)

Example 2 with EntityValue

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);
}
Also used : SubmodelElement(io.adminshell.aas.v3.model.SubmodelElement) EntityValue(de.fraunhofer.iosb.ilt.faaast.service.model.value.EntityValue) DefaultKey(io.adminshell.aas.v3.model.impl.DefaultKey) RelationshipElementValue(de.fraunhofer.iosb.ilt.faaast.service.model.value.RelationshipElementValue) ReferenceElementValue(de.fraunhofer.iosb.ilt.faaast.service.model.value.ReferenceElementValue) ElementValue(de.fraunhofer.iosb.ilt.faaast.service.model.value.ElementValue) AnnotatedRelationshipElementValue(de.fraunhofer.iosb.ilt.faaast.service.model.value.AnnotatedRelationshipElementValue) DefaultProperty(io.adminshell.aas.v3.model.impl.DefaultProperty) Test(org.junit.Test)

Aggregations

EntityValue (de.fraunhofer.iosb.ilt.faaast.service.model.value.EntityValue)2 SubmodelElement (io.adminshell.aas.v3.model.SubmodelElement)2 DefaultKey (io.adminshell.aas.v3.model.impl.DefaultKey)2 Test (org.junit.Test)2 AnnotatedRelationshipElementValue (de.fraunhofer.iosb.ilt.faaast.service.model.value.AnnotatedRelationshipElementValue)1 ElementValue (de.fraunhofer.iosb.ilt.faaast.service.model.value.ElementValue)1 ReferenceElementValue (de.fraunhofer.iosb.ilt.faaast.service.model.value.ReferenceElementValue)1 RelationshipElementValue (de.fraunhofer.iosb.ilt.faaast.service.model.value.RelationshipElementValue)1 DefaultProperty (io.adminshell.aas.v3.model.impl.DefaultProperty)1