Skip to content
Snippets Groups Projects
Verified Commit ca8a2fd9 authored by Timm Fitschen's avatar Timm Fitschen
Browse files

TST: add regression test

parent d5892ccf
No related branches found
No related tags found
2 merge requests!103Release 0.11.0,!98F grpc null values
Pipeline #39266 passed
......@@ -6,7 +6,9 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.TimeZone;
import org.caosdb.api.entity.v1.Value.Builder;
import org.caosdb.datetime.DateTimeFactory2;
import org.caosdb.server.datatype.CollectionValue;
import org.caosdb.server.datatype.GenericValue;
import org.caosdb.server.datatype.ReferenceValue;
import org.caosdb.server.datatype.Value;
import org.caosdb.server.entity.EntityID;
import org.caosdb.server.entity.FileProperties;
......@@ -119,4 +121,53 @@ public class CaosDBToGrpcConvertersTest {
"scalar_value {\n" + " special_value: SPECIAL_VALUE_UNSPECIFIED\n" + "}\n",
value.toString());
}
@Test
public void testGetSelectedValueWithListOfReferenceValue() {
CollectionValue col = new CollectionValue();
Property p = new Property(new RetrieveEntity());
p.setName("Person");
p.setDatatype("List<Person>");
Property fullName1 = new Property(new RetrieveEntity());
fullName1.setName("full name");
fullName1.setDatatype("TEXT");
fullName1.setValue(new GenericValue("Harry Belafonte"));
RetrieveEntity person1 = new RetrieveEntity();
person1.addProperty(fullName1);
ReferenceValue val1 = new ReferenceValue(new EntityID(1234));
val1.setEntity(person1, false);
col.add(val1);
Property fullName2 = new Property(new RetrieveEntity());
fullName2.setName("full name");
fullName2.setDatatype("TEXT");
fullName2.setValue(new GenericValue("Louis Prima"));
RetrieveEntity person2 = new RetrieveEntity();
person2.addProperty(fullName2);
ReferenceValue val2 = new ReferenceValue(new EntityID(1234));
val2.setEntity(person2, false);
col.add(val2);
p.setValue(col);
RetrieveEntity entity = new RetrieveEntity();
entity.addProperty(p);
CaosDBToGrpcConverters converters = new CaosDBToGrpcConverters(null);
Builder value =
converters.getSelectedValue(
new Selection("Person").setSubSelection(new Selection("full name")), entity);
assertEquals(
"list_values {\n"
+ " values {\n"
+ " string_value: \"Harry Belafonte\"\n"
+ " }\n"
+ " values {\n"
+ " string_value: \"Louis Prima\"\n"
+ " }\n"
+ "}\n",
value.toString());
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment