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