use of org.hypertrace.core.attribute.service.v1.AttributeMetadata in project gateway-service by hypertrace.
the class QueryValueToGatewayValueConverterTest method whenValueTypeFloatArray_AttributeKindDoubleArray_thenExpectValueTypeDoubleArray.
@Test
public void whenValueTypeFloatArray_AttributeKindDoubleArray_thenExpectValueTypeDoubleArray() {
List<Float> input = DoubleStream.of(10.1, 10.2).boxed().map(Double::floatValue).collect(Collectors.toList());
List<Double> expected = input.stream().map(Float::doubleValue).collect(Collectors.toList());
Value value = Value.newBuilder().setValueType(org.hypertrace.core.query.service.api.ValueType.FLOAT_ARRAY).addAllFloatArray(input).build();
AttributeMetadata attributeMetadata = AttributeMetadata.newBuilder().setFqn("weights").setValueKind(AttributeKind.TYPE_DOUBLE_ARRAY).build();
org.hypertrace.gateway.service.v1.common.Value retVal = QueryAndGatewayDtoConverter.convertQueryValueToGatewayValue(value, attributeMetadata);
assertSame(retVal.getValueType(), ValueType.DOUBLE_ARRAY);
assertEquals(expected, retVal.getDoubleArrayList());
}
use of org.hypertrace.core.attribute.service.v1.AttributeMetadata in project gateway-service by hypertrace.
the class QueryValueToGatewayValueConverterTest method whenValueTypeBoolean_AttributeKindString_thenExpectValueTypeString.
@Test
public void whenValueTypeBoolean_AttributeKindString_thenExpectValueTypeString() {
Value value = Value.newBuilder().setValueType(org.hypertrace.core.query.service.api.ValueType.BOOL).setBoolean(true).build();
AttributeMetadata attributeMetadata = AttributeMetadata.newBuilder().setFqn("new_member").setValueKind(AttributeKind.TYPE_STRING).build();
org.hypertrace.gateway.service.v1.common.Value retVal = QueryAndGatewayDtoConverter.convertQueryValueToGatewayValue(value, attributeMetadata);
assertSame(retVal.getValueType(), ValueType.STRING);
assertEquals("true", retVal.getString());
}
use of org.hypertrace.core.attribute.service.v1.AttributeMetadata in project gateway-service by hypertrace.
the class QueryValueToGatewayValueConverterTest method whenValueTypeLong_AttributeKindString_thenExpectValueTypeString.
@Test
public void whenValueTypeLong_AttributeKindString_thenExpectValueTypeString() {
Value value = Value.newBuilder().setValueType(org.hypertrace.core.query.service.api.ValueType.LONG).setLong(10).build();
AttributeMetadata attributeMetadata = AttributeMetadata.newBuilder().setFqn("weight").setValueKind(AttributeKind.TYPE_STRING).build();
org.hypertrace.gateway.service.v1.common.Value retVal = QueryAndGatewayDtoConverter.convertQueryValueToGatewayValue(value, attributeMetadata);
assertSame(retVal.getValueType(), ValueType.STRING);
assertEquals("10", retVal.getString());
}
use of org.hypertrace.core.attribute.service.v1.AttributeMetadata in project gateway-service by hypertrace.
the class QueryValueToGatewayValueConverterTest method whenValueTypeString_AttributeKindUndefined_thenExpectValueFromFallback.
@Test
public void whenValueTypeString_AttributeKindUndefined_thenExpectValueFromFallback() {
Value value = Value.newBuilder().setValueType(org.hypertrace.core.query.service.api.ValueType.STRING).setString("10").build();
AttributeMetadata attributeMetadata = AttributeMetadata.newBuilder().setFqn("weight").setValueKind(AttributeKind.KIND_UNDEFINED).build();
org.hypertrace.gateway.service.v1.common.Value retVal = QueryAndGatewayDtoConverter.convertQueryValueToGatewayValue(value, attributeMetadata);
org.hypertrace.gateway.service.v1.common.Value fallBackVal = QueryAndGatewayDtoConverter.convertQueryValueToGatewayValue(value);
assertEquals(fallBackVal, retVal);
}
use of org.hypertrace.core.attribute.service.v1.AttributeMetadata in project gateway-service by hypertrace.
the class QueryValueToGatewayValueConverterTest method whenValueTypeStringMap_AttributeKindString_expectsString.
@Test
public void whenValueTypeStringMap_AttributeKindString_expectsString() {
String mapKey = "KEY1";
String mapValue = "VAL1";
Map<String, String> mapData = new HashMap<>();
mapData.put(mapKey, mapValue);
Value value = Value.newBuilder().setValueType(org.hypertrace.core.query.service.api.ValueType.STRING_MAP).putAllStringMap(Map.of(mapKey, mapValue)).build();
AttributeMetadata attributeMetadata = AttributeMetadata.newBuilder().setFqn("stringData").setValueKind(AttributeKind.TYPE_STRING).build();
org.hypertrace.gateway.service.v1.common.Value retVal = QueryAndGatewayDtoConverter.convertQueryValueToGatewayValue(value, attributeMetadata);
assertSame(retVal.getValueType(), ValueType.STRING);
assertEquals(mapData.toString(), retVal.getString());
}
Aggregations