Search in sources :

Example 96 with AttributeMetadata

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());
}
Also used : AttributeMetadata(org.hypertrace.core.attribute.service.v1.AttributeMetadata) Value(org.hypertrace.core.query.service.api.Value) Test(org.junit.jupiter.api.Test)

Example 97 with AttributeMetadata

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());
}
Also used : AttributeMetadata(org.hypertrace.core.attribute.service.v1.AttributeMetadata) Value(org.hypertrace.core.query.service.api.Value) Test(org.junit.jupiter.api.Test)

Example 98 with AttributeMetadata

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());
}
Also used : AttributeMetadata(org.hypertrace.core.attribute.service.v1.AttributeMetadata) Value(org.hypertrace.core.query.service.api.Value) Test(org.junit.jupiter.api.Test)

Example 99 with AttributeMetadata

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);
}
Also used : AttributeMetadata(org.hypertrace.core.attribute.service.v1.AttributeMetadata) Value(org.hypertrace.core.query.service.api.Value) Test(org.junit.jupiter.api.Test)

Example 100 with AttributeMetadata

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());
}
Also used : HashMap(java.util.HashMap) AttributeMetadata(org.hypertrace.core.attribute.service.v1.AttributeMetadata) Value(org.hypertrace.core.query.service.api.Value) Test(org.junit.jupiter.api.Test)

Aggregations

AttributeMetadata (org.hypertrace.core.attribute.service.v1.AttributeMetadata)140 Test (org.junit.jupiter.api.Test)109 Value (org.hypertrace.core.query.service.api.Value)55 HashMap (java.util.HashMap)44 ExploreRequest (org.hypertrace.gateway.service.v1.explore.ExploreRequest)15 QueryRequest (org.hypertrace.core.query.service.api.QueryRequest)11 ResultSetChunk (org.hypertrace.core.query.service.api.ResultSetChunk)11 EntitiesRequest (org.hypertrace.gateway.service.v1.entity.EntitiesRequest)11 Event (org.hypertrace.core.datamodel.Event)10 TimeAggregation (org.hypertrace.gateway.service.v1.common.TimeAggregation)9 Map (java.util.Map)8 Row (org.hypertrace.core.query.service.api.Row)8 List (java.util.List)7 ColumnMetadata (org.hypertrace.core.query.service.api.ColumnMetadata)7 RequestContext (org.hypertrace.gateway.service.common.RequestContext)7 ArrayList (java.util.ArrayList)6 TracesRequest (org.hypertrace.gateway.service.v1.trace.TracesRequest)6 Iterator (java.util.Iterator)5 BaselineEntitiesRequest (org.hypertrace.gateway.service.v1.baseline.BaselineEntitiesRequest)5 Instant (java.time.Instant)4