Search in sources :

Example 11 with SubmodelElement

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

Example 12 with SubmodelElement

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

Example 13 with SubmodelElement

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);
}
Also used : SubmodelElement(io.adminshell.aas.v3.model.SubmodelElement) SubmodelElementCollectionValue(de.fraunhofer.iosb.ilt.faaast.service.model.value.SubmodelElementCollectionValue) PropertyValue(de.fraunhofer.iosb.ilt.faaast.service.model.value.PropertyValue) MultiLanguagePropertyValue(de.fraunhofer.iosb.ilt.faaast.service.model.value.MultiLanguagePropertyValue) DefaultSubmodelElementCollection(io.adminshell.aas.v3.model.impl.DefaultSubmodelElementCollection) StringValue(de.fraunhofer.iosb.ilt.faaast.service.model.value.primitive.StringValue) 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)

Example 14 with SubmodelElement

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

Example 15 with SubmodelElement

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);
}
Also used : SubmodelElement(io.adminshell.aas.v3.model.SubmodelElement) PropertyValue(de.fraunhofer.iosb.ilt.faaast.service.model.value.PropertyValue) MultiLanguagePropertyValue(de.fraunhofer.iosb.ilt.faaast.service.model.value.MultiLanguagePropertyValue) 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

SubmodelElement (io.adminshell.aas.v3.model.SubmodelElement)63 Test (org.junit.Test)47 Reference (io.adminshell.aas.v3.model.Reference)31 DefaultReference (io.adminshell.aas.v3.model.impl.DefaultReference)28 ResourceNotFoundException (de.fraunhofer.iosb.ilt.faaast.service.exception.ResourceNotFoundException)21 ElementValue (de.fraunhofer.iosb.ilt.faaast.service.model.value.ElementValue)20 OutputModifier (de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.OutputModifier)17 QueryModifier (de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.QueryModifier)16 DefaultKey (io.adminshell.aas.v3.model.impl.DefaultKey)16 Submodel (io.adminshell.aas.v3.model.Submodel)15 SubmodelElementCollection (io.adminshell.aas.v3.model.SubmodelElementCollection)15 List (java.util.List)15 Collectors (java.util.stream.Collectors)15 Assert (org.junit.Assert)13 AnnotatedRelationshipElementValue (de.fraunhofer.iosb.ilt.faaast.service.model.value.AnnotatedRelationshipElementValue)12 DefaultIdentifier (io.adminshell.aas.v3.model.impl.DefaultIdentifier)12 ReferenceElementValue (de.fraunhofer.iosb.ilt.faaast.service.model.value.ReferenceElementValue)11 RelationshipElementValue (de.fraunhofer.iosb.ilt.faaast.service.model.value.RelationshipElementValue)11 AssetAdministrationShell (io.adminshell.aas.v3.model.AssetAdministrationShell)11 Identifier (io.adminshell.aas.v3.model.Identifier)11