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

DOC: update CHANGELOG, TST: add regression tests

parent 7dea663f
No related branches found
No related tags found
2 merge requests!103Release 0.11.0,!98F grpc null values
Pipeline #39262 failed
......@@ -22,6 +22,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed ###
* `NullPointerException` in GRPC API converters when executing SELECT query on
NULL values.
### Security ###
### Documentation ###
......
......@@ -706,7 +706,7 @@ public class CaosDBToGrpcConverters {
return null;
}
private org.caosdb.api.entity.v1.Value.Builder getSelectedValue(Selection s, EntityInterface e) {
org.caosdb.api.entity.v1.Value.Builder getSelectedValue(Selection s, EntityInterface e) {
org.caosdb.api.entity.v1.Value.Builder result = null;
String selector = s.getSelector();
result = handleSpecialSelectors(selector, e);
......
package org.caosdb.server.grpc;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
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.GenericValue;
import org.caosdb.server.datatype.Value;
......@@ -17,6 +17,7 @@ import org.caosdb.server.entity.StatementStatus;
import org.caosdb.server.entity.wrapper.Parent;
import org.caosdb.server.entity.wrapper.Property;
import org.caosdb.server.entity.xml.IdAndServerMessagesOnlyStrategy;
import org.caosdb.server.query.Query.Selection;
import org.junit.jupiter.api.Test;
public class CaosDBToGrpcConvertersTest {
......@@ -27,7 +28,9 @@ public class CaosDBToGrpcConvertersTest {
DateTimeFactory2 factory = new DateTimeFactory2(timeZone);
CaosDBToGrpcConverters converters = new CaosDBToGrpcConverters(timeZone);
Value value = null;
assertNull(converters.convertScalarValue(value));
assertEquals(
converters.convertScalarValue(value).toString(),
"special_value: SPECIAL_VALUE_UNSPECIFIED\n");
value = factory.parse("2022");
assertEquals(converters.convertScalarValue(value).toString(), "string_value: \"2022\"\n");
value = factory.parse("2022-12");
......@@ -101,4 +104,19 @@ public class CaosDBToGrpcConvertersTest {
converters.convert(entity).toString(),
"entity {\n id: \"1234\"\n}\nerrors {\n code: 1\n description: \"error\"\n}\nwarnings {\n code: 1\n description: \"warning\"\n}\ninfos {\n code: 1\n description: \"info\"\n}\n");
}
@Test
public void testGetSelectedValueWithNullValue() {
Property p = new Property(new RetrieveEntity());
p.setName("p0");
p.setDatatype("DOUBLE");
RetrieveEntity entity = new RetrieveEntity();
entity.addProperty(p);
CaosDBToGrpcConverters converters = new CaosDBToGrpcConverters(null);
Builder value = converters.getSelectedValue(new Selection("p0"), entity);
assertEquals(
"scalar_value {\n" + " special_value: SPECIAL_VALUE_UNSPECIFIED\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