Search in sources :

Example 26 with AttributeMetadata

use of org.hypertrace.core.attribute.service.v1.AttributeMetadata in project gateway-service by hypertrace.

the class QueryValueToGatewayValueConverterTest method whenValueTypeLong_AttributeKindDouble_thenExpectValueTypeDouble.

@Test
public void whenValueTypeLong_AttributeKindDouble_thenExpectValueTypeDouble() {
    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_DOUBLE).build();
    org.hypertrace.gateway.service.v1.common.Value retVal = QueryAndGatewayDtoConverter.convertQueryValueToGatewayValue(value, attributeMetadata);
    assertSame(retVal.getValueType(), ValueType.DOUBLE);
    assertEquals(10, retVal.getDouble(), 0);
}
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 27 with AttributeMetadata

use of org.hypertrace.core.attribute.service.v1.AttributeMetadata in project gateway-service by hypertrace.

the class QueryValueToGatewayValueConverterTest method whenValueTypeFloat_AttributeKindUndefined_thenExpectValueFromFallback.

@Test
public void whenValueTypeFloat_AttributeKindUndefined_thenExpectValueFromFallback() {
    Value value = Value.newBuilder().setValueType(org.hypertrace.core.query.service.api.ValueType.FLOAT).setFloat(10.25f).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 28 with AttributeMetadata

use of org.hypertrace.core.attribute.service.v1.AttributeMetadata in project gateway-service by hypertrace.

the class QueryValueToGatewayValueConverterTest method whenValueTypeIntegerArray_AttributeKindInt64Array_thenExpectValueTypeLongArray.

@Test
public void whenValueTypeIntegerArray_AttributeKindInt64Array_thenExpectValueTypeLongArray() {
    List<Integer> input = IntStream.range(1, 11).boxed().collect(Collectors.toList());
    List<Long> expected = input.stream().map(Integer::longValue).collect(Collectors.toList());
    Value value = Value.newBuilder().setValueType(org.hypertrace.core.query.service.api.ValueType.INT_ARRAY).addAllIntArray(input).build();
    AttributeMetadata attributeMetadata = AttributeMetadata.newBuilder().setFqn("weights").setValueKind(AttributeKind.TYPE_INT64_ARRAY).build();
    org.hypertrace.gateway.service.v1.common.Value retVal = QueryAndGatewayDtoConverter.convertQueryValueToGatewayValue(value, attributeMetadata);
    assertSame(retVal.getValueType(), ValueType.LONG_ARRAY);
    assertEquals(expected, retVal.getLongArrayList());
}
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 29 with AttributeMetadata

use of org.hypertrace.core.attribute.service.v1.AttributeMetadata in project gateway-service by hypertrace.

the class QueryValueToGatewayValueConverterTest method whenValueTypeTimestamp_AttributeKindInt64_thenExpectValueTypeLong.

@Test
public void whenValueTypeTimestamp_AttributeKindInt64_thenExpectValueTypeLong() {
    Value value = Value.newBuilder().setValueType(org.hypertrace.core.query.service.api.ValueType.TIMESTAMP).setTimestamp(10).build();
    AttributeMetadata attributeMetadata = AttributeMetadata.newBuilder().setFqn("weight").setValueKind(AttributeKind.TYPE_INT64).build();
    org.hypertrace.gateway.service.v1.common.Value retVal = QueryAndGatewayDtoConverter.convertQueryValueToGatewayValue(value, attributeMetadata);
    assertSame(retVal.getValueType(), ValueType.LONG);
    assertEquals(10, retVal.getLong());
}
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 30 with AttributeMetadata

use of org.hypertrace.core.attribute.service.v1.AttributeMetadata in project gateway-service by hypertrace.

the class QueryValueToGatewayValueConverterTest method whenValueTypeStringArray_AttributeKindString_thenExpectValueTypeString.

@Test
public void whenValueTypeStringArray_AttributeKindString_thenExpectValueTypeString() {
    List<String> input = Arrays.asList("one", "two");
    String expected = input.toString();
    Value value = Value.newBuilder().setValueType(org.hypertrace.core.query.service.api.ValueType.STRING_ARRAY).addAllStringArray(input).build();
    AttributeMetadata attributeMetadata = AttributeMetadata.newBuilder().setFqn("weights").setValueKind(AttributeKind.TYPE_STRING).build();
    org.hypertrace.gateway.service.v1.common.Value retVal = QueryAndGatewayDtoConverter.convertQueryValueToGatewayValue(value, attributeMetadata);
    assertSame(retVal.getValueType(), ValueType.STRING);
    assertEquals(expected, 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)

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