use of io.adminshell.aas.v3.model.SubmodelElement 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);
}
use of io.adminshell.aas.v3.model.SubmodelElement in project FAAAST-Service by FraunhoferIOSB.
the class ElementValueMapperTest method testReferenceElementSetValueMapping.
@Test
public void testReferenceElementSetValueMapping() {
SubmodelElement actual = new DefaultReferenceElement.Builder().value(new DefaultReference.Builder().build()).build();
ReferenceElementValue value = ReferenceElementValue.builder().key(KeyType.IRI, KeyElements.SUBMODEL, "http://example.org/submodel/1").key(KeyType.ID_SHORT, KeyElements.PROPERTY, "property1").build();
SubmodelElement expected = new DefaultReferenceElement.Builder().value(new DefaultReference.Builder().keys(value.getKeys()).build()).build();
ElementValueMapper.setValue(actual, value);
Assert.assertEquals(expected, actual);
}
use of io.adminshell.aas.v3.model.SubmodelElement in project FAAAST-Service by FraunhoferIOSB.
the class ElementValueMapperTest method testSubmodelElementCollectionToValueMapping.
@Test
public void testSubmodelElementCollectionToValueMapping() {
PropertyValue propertyValue = PropertyValue.builder().value(new StringValue("testValue")).build();
PropertyValue propertyValue2 = PropertyValue.builder().value(new StringValue("testValue2")).build();
SubmodelElementCollectionValue expected = SubmodelElementCollectionValue.builder().value("prop1", propertyValue).value("prop2", propertyValue2).build();
SubmodelElement input = new DefaultSubmodelElementCollection.Builder().value(new DefaultProperty.Builder().idShort("prop1").value("testValue").build()).value(new DefaultProperty.Builder().idShort("prop2").value("testValue2").build()).build();
ElementValue actual = ElementValueMapper.toValue(input);
Assert.assertEquals(expected, actual);
}
use of io.adminshell.aas.v3.model.SubmodelElement in project FAAAST-Service by FraunhoferIOSB.
the class ElementValueMapperTest method testPropertySetValueMapping.
@Test
public void testPropertySetValueMapping() {
PropertyValue value = new PropertyValue(new StringValue("foo"));
SubmodelElement expected = new DefaultProperty.Builder().valueType(value.getValue().getDataType().getName()).value(value.getValue().asString()).build();
SubmodelElement actual = new DefaultProperty.Builder().build();
ElementValueMapper.setValue(actual, value);
Assert.assertEquals(expected, actual);
}
use of io.adminshell.aas.v3.model.SubmodelElement in project FAAAST-Service by FraunhoferIOSB.
the class ElementValueMapperTest method testPropertyToValueMapping.
@Test
public void testPropertyToValueMapping() throws ValueFormatException {
PropertyValue expected = PropertyValue.of(Datatype.String, "foo");
SubmodelElement input = new DefaultProperty.Builder().category("Test").idShort("TestProperty").valueType(expected.getValue().getDataType().getName()).value(expected.getValue().asString()).build();
ElementValue actual = ElementValueMapper.toValue(input);
Assert.assertEquals(expected, actual);
}
Aggregations