Search in sources :

Example 1 with RelationshipElementValue

use of de.fraunhofer.iosb.ilt.faaast.service.model.value.RelationshipElementValue in project FAAAST-Service by FraunhoferIOSB.

the class ElementValueMapperTest method testRelationshipElementSetValueMapping.

@Test
public void testRelationshipElementSetValueMapping() {
    SubmodelElement actual = new DefaultRelationshipElement.Builder().build();
    RelationshipElementValue value = RelationshipElementValue.builder().first(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())).second(List.of(new DefaultKey.Builder().idType(KeyType.IRI).type(KeyElements.SUBMODEL).value("http://example.org/submodel/2").build(), new DefaultKey.Builder().idType(KeyType.ID_SHORT).type(KeyElements.PROPERTY).value("property2").build())).build();
    SubmodelElement expected = new DefaultRelationshipElement.Builder().first(new DefaultReference.Builder().keys(value.getFirst()).build()).second(new DefaultReference.Builder().keys(value.getSecond()).build()).build();
    ElementValueMapper.setValue(actual, value);
    Assert.assertEquals(expected, actual);
}
Also used : SubmodelElement(io.adminshell.aas.v3.model.SubmodelElement) RelationshipElementValue(de.fraunhofer.iosb.ilt.faaast.service.model.value.RelationshipElementValue) AnnotatedRelationshipElementValue(de.fraunhofer.iosb.ilt.faaast.service.model.value.AnnotatedRelationshipElementValue) DefaultRelationshipElement(io.adminshell.aas.v3.model.impl.DefaultRelationshipElement) DefaultKey(io.adminshell.aas.v3.model.impl.DefaultKey) DefaultReference(io.adminshell.aas.v3.model.impl.DefaultReference) Test(org.junit.Test)

Example 2 with RelationshipElementValue

use of de.fraunhofer.iosb.ilt.faaast.service.model.value.RelationshipElementValue in project FAAAST-Service by FraunhoferIOSB.

the class RelationshipElementValueMapper method toValue.

@Override
public RelationshipElementValue toValue(RelationshipElement submodelElement) {
    if (submodelElement == null) {
        return null;
    }
    RelationshipElementValue relationshipElementValue = new RelationshipElementValue();
    relationshipElementValue.setFirst(submodelElement.getFirst().getKeys());
    relationshipElementValue.setSecond(submodelElement.getSecond().getKeys());
    return relationshipElementValue;
}
Also used : RelationshipElementValue(de.fraunhofer.iosb.ilt.faaast.service.model.value.RelationshipElementValue)

Example 3 with RelationshipElementValue

use of de.fraunhofer.iosb.ilt.faaast.service.model.value.RelationshipElementValue in project FAAAST-Service by FraunhoferIOSB.

the class ElementValueMapperTest method testRelationshipElementToValueMapping.

@Test
public void testRelationshipElementToValueMapping() {
    RelationshipElementValue expected = RelationshipElementValue.builder().first(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())).second(List.of(new DefaultKey.Builder().idType(KeyType.IRI).type(KeyElements.SUBMODEL).value("http://example.org/submodel/2").build(), new DefaultKey.Builder().idType(KeyType.ID_SHORT).type(KeyElements.PROPERTY).value("property2").build())).build();
    SubmodelElement input = new DefaultRelationshipElement.Builder().first(new DefaultReference.Builder().keys(expected.getFirst()).build()).second(new DefaultReference.Builder().keys(expected.getSecond()).build()).build();
    ElementValue actual = ElementValueMapper.toValue(input);
    Assert.assertEquals(expected, actual);
}
Also used : SubmodelElement(io.adminshell.aas.v3.model.SubmodelElement) RelationshipElementValue(de.fraunhofer.iosb.ilt.faaast.service.model.value.RelationshipElementValue) AnnotatedRelationshipElementValue(de.fraunhofer.iosb.ilt.faaast.service.model.value.AnnotatedRelationshipElementValue) DefaultKey(io.adminshell.aas.v3.model.impl.DefaultKey) DefaultRelationshipElement(io.adminshell.aas.v3.model.impl.DefaultRelationshipElement) 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) DefaultReference(io.adminshell.aas.v3.model.impl.DefaultReference) Test(org.junit.Test)

Aggregations

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