Search in sources :

Example 1 with Value

use of org.hypertrace.core.query.service.api.Value in project gateway-service by hypertrace.

the class QueryValueToGatewayValueConverterTest method whenMetricValueTypeAlreadyIsDoubleOrFloat_expectsSameType.

@Test
public void whenMetricValueTypeAlreadyIsDoubleOrFloat_expectsSameType() {
    Value value = Value.newBuilder().setValueType(org.hypertrace.core.query.service.api.ValueType.DOUBLE).setDouble(10.25f).build();
    Map<String, AttributeKind> aliasToAttributeKind = new HashMap<>();
    aliasToAttributeKind.put(WEIGHT_METRIC_NAME, AttributeKind.TYPE_DOUBLE);
    org.hypertrace.gateway.service.v1.common.Value actual = QueryAndGatewayDtoConverter.convertToGatewayValueForMetricValue(aliasToAttributeKind, attributeMetadataMap, weightColumnMetadata, value);
    org.hypertrace.gateway.service.v1.common.Value expected = QueryAndGatewayDtoConverter.convertQueryValueToGatewayValue(value);
    assertEquals(expected, actual);
}
Also used : HashMap(java.util.HashMap) Value(org.hypertrace.core.query.service.api.Value) AttributeKind(org.hypertrace.core.attribute.service.v1.AttributeKind) Test(org.junit.jupiter.api.Test)

Example 2 with Value

use of org.hypertrace.core.query.service.api.Value in project gateway-service by hypertrace.

the class QueryValueToGatewayValueConverterTest method whenValueTypeTimestamp_AttributeKindUndefined_thenExpectValueFromFallback.

@Test
public void whenValueTypeTimestamp_AttributeKindUndefined_thenExpectValueFromFallback() {
    Value value = Value.newBuilder().setValueType(org.hypertrace.core.query.service.api.ValueType.TIMESTAMP).setTimestamp(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 3 with Value

use of org.hypertrace.core.query.service.api.Value in project gateway-service by hypertrace.

the class QueryValueToGatewayValueConverterTest method whenValueTypeFloat_AttributeKindString_thenExpectValueTypeString.

@Test
public void whenValueTypeFloat_AttributeKindString_thenExpectValueTypeString() {
    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.TYPE_STRING).build();
    org.hypertrace.gateway.service.v1.common.Value retVal = QueryAndGatewayDtoConverter.convertQueryValueToGatewayValue(value, attributeMetadata);
    assertSame(retVal.getValueType(), ValueType.STRING);
    assertEquals("10.25", 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 4 with Value

use of org.hypertrace.core.query.service.api.Value in project gateway-service by hypertrace.

the class QueryValueToGatewayValueConverterTest method whenMetricValueTypeIsString_AndNullOverrideMapping_thenExpectValueTypeToBeConvertedToDouble.

@Test
public void whenMetricValueTypeIsString_AndNullOverrideMapping_thenExpectValueTypeToBeConvertedToDouble() {
    Value value = Value.newBuilder().setValueType(org.hypertrace.core.query.service.api.ValueType.STRING).setString("10.25").build();
    org.hypertrace.gateway.service.v1.common.Value actual = QueryAndGatewayDtoConverter.convertToGatewayValueForMetricValue(Collections.emptyMap(), attributeMetadataMap, weightColumnMetadata, value);
    org.hypertrace.gateway.service.v1.common.Value expected = org.hypertrace.gateway.service.v1.common.Value.newBuilder().setDouble(10.25f).setValueType(ValueType.DOUBLE).build();
    assertEquals(expected, actual);
}
Also used : Value(org.hypertrace.core.query.service.api.Value) Test(org.junit.jupiter.api.Test)

Example 5 with Value

use of org.hypertrace.core.query.service.api.Value in project gateway-service by hypertrace.

the class QueryValueToGatewayValueConverterTest method whenValueTypeIntegerArray_AttributeKindUndefined_thenExpectValueFromFallback.

@Test
public void whenValueTypeIntegerArray_AttributeKindUndefined_thenExpectValueFromFallback() {
    Value value = Value.newBuilder().setValueType(org.hypertrace.core.query.service.api.ValueType.INT_ARRAY).addAllIntArray(IntStream.range(1, 11).boxed().collect(Collectors.toList())).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)

Aggregations

Value (org.hypertrace.core.query.service.api.Value)57 Test (org.junit.jupiter.api.Test)57 AttributeMetadata (org.hypertrace.core.attribute.service.v1.AttributeMetadata)55 HashMap (java.util.HashMap)5 AttributeKind (org.hypertrace.core.attribute.service.v1.AttributeKind)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1