Skip to content
Snippets Groups Projects

F grpc null values

Merged Timm Fitschen requested to merge f-grpc-null-values into dev
1 file
+ 51
0
Compare changes
  • Side-by-side
  • Inline
@@ -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());
}
}
Loading