Search in sources :

Example 1 with AttributeScope

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

the class ExecutionVisitorTest method test_visitDataFetcherNodeWithoutPagination.

@Test
public void test_visitDataFetcherNodeWithoutPagination() {
    long startTime = 0;
    long endTime = 10;
    String tenantId = "TENANT_ID";
    Map<String, String> requestHeaders = Map.of("x-tenant-id", tenantId);
    AttributeScope entityType = AttributeScope.API;
    Expression selectionExpression = buildExpression(API_NAME_ATTR);
    EntitiesRequest entitiesRequest = EntitiesRequest.newBuilder().setEntityType(entityType.name()).setStartTimeMillis(startTime).setEndTimeMillis(endTime).addSelection(selectionExpression).setFilter(generateEQFilter(API_DISCOVERY_STATE, "DISCOVERED")).build();
    EntitiesRequestContext entitiesRequestContext = new EntitiesRequestContext(tenantId, startTime, endTime, entityType.name(), "API.startTime", requestHeaders);
    Map<EntityKey, Builder> entityKeyBuilderResponseMap = Map.of(EntityKey.of("entity-id-0"), Entity.newBuilder().putAttribute("API.name", getStringValue("entity-0")), EntityKey.of("entity-id-1"), Entity.newBuilder().putAttribute("API.name", getStringValue("entity-1")), EntityKey.of("entity-id-2"), Entity.newBuilder().putAttribute("API.name", getStringValue("entity-2")));
    EntityFetcherResponse entityFetcherResponse = new EntityFetcherResponse(entityKeyBuilderResponseMap);
    when(expressionContext.getSourceToSelectionExpressionMap()).thenReturn(Map.of("QS", List.of(selectionExpression)));
    when(executionContext.getEntitiesRequest()).thenReturn(entitiesRequest);
    when(executionContext.getTenantId()).thenReturn(tenantId);
    when(executionContext.getRequestHeaders()).thenReturn(requestHeaders);
    when(executionContext.getTimestampAttributeId()).thenReturn("API.startTime");
    when(queryServiceEntityFetcher.getEntities(eq(entitiesRequestContext), eq(entitiesRequest))).thenReturn(entityFetcherResponse);
    when(queryServiceEntityFetcher.getTimeAggregatedMetrics(eq(entitiesRequestContext), eq(entitiesRequest))).thenReturn(new EntityFetcherResponse());
    // no pagination in data fetcher node
    DataFetcherNode dataFetcherNode = new DataFetcherNode("QS", entitiesRequest.getFilter());
    compareEntityResponses(new EntityResponse(entityFetcherResponse, entityFetcherResponse.getEntityKeyBuilderMap().size()), executionVisitor.visit(dataFetcherNode));
    verify(queryServiceEntityFetcher, times(1)).getEntities(any(), any());
}
Also used : Builder(org.hypertrace.gateway.service.v1.entity.Entity.Builder) EntityKey(org.hypertrace.gateway.service.entity.EntityKey) EntityFetcherResponse(org.hypertrace.gateway.service.common.datafetcher.EntityFetcherResponse) EntitiesRequest(org.hypertrace.gateway.service.v1.entity.EntitiesRequest) AttributeScope(org.hypertrace.core.attribute.service.v1.AttributeScope) EntitiesRequestAndResponseUtils.buildAggregateExpression(org.hypertrace.gateway.service.common.EntitiesRequestAndResponseUtils.buildAggregateExpression) EntitiesRequestAndResponseUtils.buildOrderByExpression(org.hypertrace.gateway.service.common.EntitiesRequestAndResponseUtils.buildOrderByExpression) EntitiesRequestAndResponseUtils.buildExpression(org.hypertrace.gateway.service.common.EntitiesRequestAndResponseUtils.buildExpression) Expression(org.hypertrace.gateway.service.v1.common.Expression) OrderByExpression(org.hypertrace.gateway.service.v1.common.OrderByExpression) EntityResponse(org.hypertrace.gateway.service.common.datafetcher.EntityResponse) DataFetcherNode(org.hypertrace.gateway.service.entity.query.DataFetcherNode) EntitiesRequestContext(org.hypertrace.gateway.service.entity.EntitiesRequestContext) Test(org.junit.jupiter.api.Test)

Example 2 with AttributeScope

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

the class ExecutionVisitorTest method test_visitPaginateOnlyNode.

@Test
public void test_visitPaginateOnlyNode() {
    List<OrderByExpression> orderByExpressions = List.of(buildOrderByExpression(API_ID_ATTR));
    int limit = 2;
    int offset = 2;
    long startTime = 0;
    long endTime = 10;
    String tenantId = "TENANT_ID";
    Map<String, String> requestHeaders = Map.of("x-tenant-id", tenantId);
    AttributeScope entityType = AttributeScope.API;
    Expression selectionExpression = buildExpression(API_NAME_ATTR);
    Expression metricExpression = buildAggregateExpression(API_DURATION_ATTR, FunctionType.AVG, "AVG_API.duration", List.of());
    TimeAggregation timeAggregation = buildTimeAggregation(30, API_NUM_CALLS_ATTR, FunctionType.SUM, "SUM_API.numCalls", List.of());
    EntitiesRequest entitiesRequest = EntitiesRequest.newBuilder().setEntityType(entityType.name()).setStartTimeMillis(startTime).setEndTimeMillis(endTime).addSelection(selectionExpression).addSelection(metricExpression).addTimeAggregation(timeAggregation).setFilter(generateEQFilter(API_DISCOVERY_STATE, "DISCOVERED")).addAllOrderBy(orderByExpressions).setLimit(limit).setOffset(offset).build();
    EntitiesRequestContext entitiesRequestContext = new EntitiesRequestContext(tenantId, startTime, endTime, entityType.name(), "API.startTime", requestHeaders);
    // Order matters since we will do the pagination ourselves. So we use a LinkedHashMap
    Map<EntityKey, Builder> entityKeyBuilderResponseMap1 = new LinkedHashMap<>();
    entityKeyBuilderResponseMap1.put(EntityKey.of("entity-id-0"), Entity.newBuilder().putAttribute("API.name", getStringValue("entity-0")));
    entityKeyBuilderResponseMap1.put(EntityKey.of("entity-id-1"), Entity.newBuilder().putAttribute("API.name", getStringValue("entity-1")));
    entityKeyBuilderResponseMap1.put(EntityKey.of("entity-id-2"), Entity.newBuilder().putAttribute("API.name", getStringValue("entity-2")));
    entityKeyBuilderResponseMap1.put(EntityKey.of("entity-id-3"), Entity.newBuilder().putAttribute("API.name", getStringValue("entity-3")));
    Map<EntityKey, Builder> entityKeyBuilderResponseMap2 = new LinkedHashMap<>();
    entityKeyBuilderResponseMap2.put(EntityKey.of("entity-id-2"), Entity.newBuilder().putMetric("AVG_API.duration", getAggregatedMetricValue(FunctionType.AVG, 14.0)));
    entityKeyBuilderResponseMap2.put(EntityKey.of("entity-id-3"), Entity.newBuilder().putMetric("AVG_API.duration", getAggregatedMetricValue(FunctionType.AVG, 15.0)));
    Map<EntityKey, Builder> entityKeyBuilderResponseMap3 = new LinkedHashMap<>();
    entityKeyBuilderResponseMap3.put(EntityKey.of("entity-id-2"), Entity.newBuilder().putMetricSeries("SUM_API.numCalls", getMockMetricSeries(30, "SUM")));
    entityKeyBuilderResponseMap3.put(EntityKey.of("entity-id-3"), Entity.newBuilder().putMetricSeries("SUM_API.numCalls", getMockMetricSeries(30, "SUM")));
    Map<EntityKey, Builder> expectedEntityKeyBuilderResponseMap = new LinkedHashMap<>();
    expectedEntityKeyBuilderResponseMap.put(EntityKey.of("entity-id-2"), Entity.newBuilder().putAttribute("API.name", getStringValue("entity-2")).putMetric("AVG_API.duration", getAggregatedMetricValue(FunctionType.AVG, 14.0)).putMetricSeries("SUM_API.numCalls", getMockMetricSeries(30, "SUM")));
    expectedEntityKeyBuilderResponseMap.put(EntityKey.of("entity-id-3"), Entity.newBuilder().putAttribute("API.name", getStringValue("entity-3")).putMetric("AVG_API.duration", getAggregatedMetricValue(FunctionType.AVG, 15.0)).putMetricSeries("SUM_API.numCalls", getMockMetricSeries(30, "SUM")));
    when(executionContext.getEntityIdExpressions()).thenReturn(List.of(buildExpression(API_ID_ATTR)));
    when(expressionContext.getSourceToSelectionExpressionMap()).thenReturn(Map.of("QS", List.of(selectionExpression)));
    when(expressionContext.getSourceToMetricExpressionMap()).thenReturn(Map.of("QS", List.of(metricExpression)));
    when(expressionContext.getSourceToTimeAggregationMap()).thenReturn(Map.of("QS", List.of(timeAggregation)));
    when(executionContext.getEntitiesRequest()).thenReturn(entitiesRequest);
    when(executionContext.getTenantId()).thenReturn(tenantId);
    when(executionContext.getRequestHeaders()).thenReturn(requestHeaders);
    when(executionContext.getTimestampAttributeId()).thenReturn("API.startTime");
    EntitiesRequest entitiesRequestForAttributes = EntitiesRequest.newBuilder(entitiesRequest).clearSelection().clearTimeAggregation().addSelection(selectionExpression).setLimit(limit + offset).setOffset(0).build();
    EntityFetcherResponse attributesResponse = new EntityFetcherResponse(entityKeyBuilderResponseMap1);
    EntitiesRequest entitiesRequestForMetricAggregation = EntitiesRequest.newBuilder(entitiesRequest).clearLimit().clearOffset().clearOrderBy().clearSelection().clearTimeAggregation().addSelection(metricExpression).clearFilter().setFilter(generateInFilter(API_ID_ATTR, List.of("entity-id-3", "entity-id-2"))).build();
    EntitiesRequest entitiesRequestForTimeAggregation = EntitiesRequest.newBuilder(entitiesRequest).clearSelection().clearLimit().clearOffset().clearOrderBy().clearFilter().setFilter(generateInFilter(API_ID_ATTR, List.of("entity-id-3", "entity-id-2"))).build();
    when(queryServiceEntityFetcher.getEntities(entitiesRequestContext, entitiesRequestForAttributes)).thenReturn(attributesResponse);
    when(queryServiceEntityFetcher.getTotal(eq(entitiesRequestContext), eq(entitiesRequest))).thenReturn(100L);
    when(queryServiceEntityFetcher.getEntities(entitiesRequestContext, entitiesRequestForMetricAggregation)).thenReturn(new EntityFetcherResponse(entityKeyBuilderResponseMap2));
    when(queryServiceEntityFetcher.getTimeAggregatedMetrics(entitiesRequestContext, entitiesRequestForTimeAggregation)).thenReturn(new EntityFetcherResponse(entityKeyBuilderResponseMap3));
    DataFetcherNode dataFetcherNode = new DataFetcherNode("QS", entitiesRequest.getFilter(), limit + offset, 0, orderByExpressions, true);
    PaginateOnlyNode paginateOnlyNode = new PaginateOnlyNode(dataFetcherNode, limit, offset);
    SelectionNode childSelectionNode = new SelectionNode.Builder(paginateOnlyNode).setAggMetricSelectionSources(Set.of("QS")).build();
    SelectionNode selectionNode = new SelectionNode.Builder(childSelectionNode).setTimeSeriesSelectionSources(Set.of("QS")).build();
    compareEntityResponses(new EntityResponse(new EntityFetcherResponse(expectedEntityKeyBuilderResponseMap), 100), executionVisitor.visit(selectionNode));
}
Also used : Builder(org.hypertrace.gateway.service.v1.entity.Entity.Builder) LinkedHashMap(java.util.LinkedHashMap) EntityKey(org.hypertrace.gateway.service.entity.EntityKey) EntityFetcherResponse(org.hypertrace.gateway.service.common.datafetcher.EntityFetcherResponse) EntitiesRequest(org.hypertrace.gateway.service.v1.entity.EntitiesRequest) AttributeScope(org.hypertrace.core.attribute.service.v1.AttributeScope) EntitiesRequestAndResponseUtils.buildAggregateExpression(org.hypertrace.gateway.service.common.EntitiesRequestAndResponseUtils.buildAggregateExpression) EntitiesRequestAndResponseUtils.buildOrderByExpression(org.hypertrace.gateway.service.common.EntitiesRequestAndResponseUtils.buildOrderByExpression) EntitiesRequestAndResponseUtils.buildExpression(org.hypertrace.gateway.service.common.EntitiesRequestAndResponseUtils.buildExpression) Expression(org.hypertrace.gateway.service.v1.common.Expression) OrderByExpression(org.hypertrace.gateway.service.v1.common.OrderByExpression) EntityResponse(org.hypertrace.gateway.service.common.datafetcher.EntityResponse) DataFetcherNode(org.hypertrace.gateway.service.entity.query.DataFetcherNode) EntitiesRequestContext(org.hypertrace.gateway.service.entity.EntitiesRequestContext) EntitiesRequestAndResponseUtils.buildOrderByExpression(org.hypertrace.gateway.service.common.EntitiesRequestAndResponseUtils.buildOrderByExpression) OrderByExpression(org.hypertrace.gateway.service.v1.common.OrderByExpression) EntitiesRequestAndResponseUtils.buildTimeAggregation(org.hypertrace.gateway.service.common.EntitiesRequestAndResponseUtils.buildTimeAggregation) TimeAggregation(org.hypertrace.gateway.service.v1.common.TimeAggregation) PaginateOnlyNode(org.hypertrace.gateway.service.entity.query.PaginateOnlyNode) SelectionNode(org.hypertrace.gateway.service.entity.query.SelectionNode) Test(org.junit.jupiter.api.Test)

Example 3 with AttributeScope

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

the class EntityDataServiceEntityFetcherTests method test_getEntities_WithoutPagination.

@Test
public void test_getEntities_WithoutPagination() {
    List<OrderByExpression> orderByExpressions = List.of(buildOrderByExpression(API_ID_ATTR));
    long startTime = 1L;
    long endTime = 10L;
    int limit = 0;
    int offset = 0;
    String tenantId = "TENANT_ID";
    Map<String, String> requestHeaders = Map.of("x-tenant-id", tenantId);
    AttributeScope entityType = AttributeScope.API;
    EntitiesRequest entitiesRequest = EntitiesRequest.newBuilder().setEntityType(entityType.name()).setStartTimeMillis(startTime).setEndTimeMillis(endTime).setFilter(Filter.newBuilder().setOperator(AND).addChildFilter(generateEQFilter(API_TYPE_ATTR, "HTTP")).addChildFilter(generateEQFilter(API_NAME_ATTR, "DISCOVERED"))).addAllOrderBy(orderByExpressions).setLimit(limit).setOffset(offset).build();
    EntitiesRequestContext entitiesRequestContext = new EntitiesRequestContext(tenantId, startTime, endTime, entityType.name(), "API.startTime", requestHeaders);
    EntityQueryRequest expectedQueryRequest = EntityQueryRequest.newBuilder().setEntityType("API").addSelection(convertToEntityServiceExpression(Expression.newBuilder().setColumnIdentifier(ColumnIdentifier.newBuilder().setColumnName(API_ID_ATTR)).build())).setFilter(convertToEntityServiceFilter(entitiesRequest.getFilter())).addAllOrderBy(EntityServiceAndGatewayServiceConverter.convertToOrderByExpressions(orderByExpressions)).build();
    List<ResultSetChunk> resultSetChunks = List.of(getResultSetChunk(List.of("API.apiId"), new String[][] { { "apiId1" }, { "apiId2" } }));
    when(entityQueryServiceClient.execute(eq(expectedQueryRequest), eq(requestHeaders))).thenReturn(resultSetChunks.iterator());
    assertEquals(2, entityDataServiceEntityFetcher.getEntities(entitiesRequestContext, entitiesRequest).size());
}
Also used : TotalEntitiesRequest(org.hypertrace.entity.query.service.v1.TotalEntitiesRequest) EntitiesRequest(org.hypertrace.gateway.service.v1.entity.EntitiesRequest) AttributeScope(org.hypertrace.core.attribute.service.v1.AttributeScope) EntitiesRequestContext(org.hypertrace.gateway.service.entity.EntitiesRequestContext) EntitiesRequestAndResponseUtils.buildOrderByExpression(org.hypertrace.gateway.service.common.EntitiesRequestAndResponseUtils.buildOrderByExpression) OrderByExpression(org.hypertrace.gateway.service.v1.common.OrderByExpression) EntityQueryRequest(org.hypertrace.entity.query.service.v1.EntityQueryRequest) ResultSetChunk(org.hypertrace.entity.query.service.v1.ResultSetChunk) Test(org.junit.jupiter.api.Test)

Example 4 with AttributeScope

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

the class QueryServiceEntityFetcherTests method testGetEntities.

@Test
public void testGetEntities() {
    List<OrderByExpression> orderByExpressions = List.of(buildOrderByExpression(API_ID_ATTR));
    long startTime = 1L;
    long endTime = 10L;
    int limit = 10;
    int offset = 5;
    String tenantId = "TENANT_ID";
    Map<String, String> requestHeaders = Map.of("x-tenant-id", tenantId);
    AttributeScope entityType = AttributeScope.API;
    EntitiesRequest entitiesRequest = EntitiesRequest.newBuilder().setEntityType(entityType.name()).setStartTimeMillis(startTime).setEndTimeMillis(endTime).addSelection(buildExpression(API_NAME_ATTR)).addSelection(buildAggregateExpression(API_NUM_CALLS_ATTR, FunctionType.SUM, "Sum_numCalls", Collections.emptyList())).setFilter(Filter.newBuilder().setOperator(AND).addChildFilter(EntitiesRequestAndResponseUtils.getTimeRangeFilter("API.startTime", startTime, endTime)).addChildFilter(generateEQFilter(API_DISCOVERY_STATE_ATTR, "DISCOVERED"))).addAllOrderBy(orderByExpressions).setLimit(limit).setOffset(offset).build();
    EntitiesRequestContext entitiesRequestContext = new EntitiesRequestContext(tenantId, startTime, endTime, entityType.name(), "API.startTime", requestHeaders);
    QueryRequest expectedQueryRequest = QueryRequest.newBuilder().addSelection(createAttributeExpression(API_ID_ATTR)).addSelection(createQsAggregationExpression("SUM", API_NUM_CALLS_ATTR, "Sum_numCalls")).addSelection(createAttributeExpression(API_NAME_ATTR)).setFilter(createQsRequestFilter(API_START_TIME_ATTR, API_ID_ATTR, startTime, endTime, createStringFilter(API_DISCOVERY_STATE_ATTR, Operator.EQ, "DISCOVERED"))).addGroupBy(createAttributeExpression(API_ID_ATTR)).addGroupBy(createAttributeExpression(API_NAME_ATTR)).setOffset(offset).setLimit(QueryServiceClient.DEFAULT_QUERY_SERVICE_GROUP_BY_LIMIT).addAllOrderBy(QueryAndGatewayDtoConverter.convertToQueryOrderByExpressions(orderByExpressions)).build();
    List<ResultSetChunk> resultSetChunks = List.of(getResultSetChunk(List.of("API.id", "API.name", "Sum_numCalls"), new String[][] { { "apiId1", "api 1", "3" }, { "apiId2", "api 2", "5" } }));
    when(queryServiceClient.executeQuery(eq(expectedQueryRequest), eq(requestHeaders), eq(500))).thenReturn(resultSetChunks.iterator());
    EntityFetcherResponse response = queryServiceEntityFetcher.getEntities(entitiesRequestContext, entitiesRequest);
    assertEquals(2, response.size());
    Map<EntityKey, Builder> expectedEntityKeyBuilderResponseMap = new LinkedHashMap<>();
    expectedEntityKeyBuilderResponseMap.put(EntityKey.of("apiId1"), Entity.newBuilder().setId("apiId1").setEntityType("API").putAttribute("API.id", getStringValue("apiId1")).putAttribute("API.name", getStringValue("api 1")).putMetric("Sum_numCalls", getAggregatedMetricValue(FunctionType.SUM, 3)));
    expectedEntityKeyBuilderResponseMap.put(EntityKey.of("apiId2"), Entity.newBuilder().setId("apiId2").setEntityType("API").putAttribute("API.id", getStringValue("apiId2")).putAttribute("API.name", getStringValue("api 2")).putMetric("Sum_numCalls", getAggregatedMetricValue(FunctionType.SUM, 5)));
    compareEntityFetcherResponses(new EntityFetcherResponse(expectedEntityKeyBuilderResponseMap), response);
}
Also used : QueryRequest(org.hypertrace.core.query.service.api.QueryRequest) Builder(org.hypertrace.gateway.service.v1.entity.Entity.Builder) LinkedHashMap(java.util.LinkedHashMap) EntityKey(org.hypertrace.gateway.service.entity.EntityKey) EntitiesRequest(org.hypertrace.gateway.service.v1.entity.EntitiesRequest) AttributeScope(org.hypertrace.core.attribute.service.v1.AttributeScope) EntitiesRequestContext(org.hypertrace.gateway.service.entity.EntitiesRequestContext) EntitiesRequestAndResponseUtils.buildOrderByExpression(org.hypertrace.gateway.service.common.EntitiesRequestAndResponseUtils.buildOrderByExpression) OrderByExpression(org.hypertrace.gateway.service.v1.common.OrderByExpression) QueryServiceRequestAndResponseUtils.getResultSetChunk(org.hypertrace.gateway.service.common.QueryServiceRequestAndResponseUtils.getResultSetChunk) ResultSetChunk(org.hypertrace.core.query.service.api.ResultSetChunk) Test(org.junit.jupiter.api.Test)

Example 5 with AttributeScope

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

the class QueryServiceEntityFetcherTests method mockAttributeMetadataProvider.

private void mockAttributeMetadataProvider(String attributeScope) {
    AttributeMetadata idAttributeMetadata = AttributeMetadata.newBuilder().setId(API_ID_ATTR).setKey("id").setScopeString(attributeScope).setValueKind(AttributeKind.TYPE_STRING).build();
    AttributeMetadata startTimeAttributeMetadata = AttributeMetadata.newBuilder().setId(API_START_TIME_ATTR).setKey("startTime").setScopeString(attributeScope).setValueKind(AttributeKind.TYPE_TIMESTAMP).build();
    AttributeMetadata spaceIdAttributeMetadata = AttributeMetadata.newBuilder().setId(SPACE_IDS_ATTR).setKey("spaceIds").setScopeString(AttributeScope.EVENT.name()).setValueKind(AttributeKind.TYPE_STRING_ARRAY).build();
    when(attributeMetadataProvider.getAttributesMetadata(any(RequestContext.class), eq(attributeScope))).thenReturn(Map.of(API_ID_ATTR, idAttributeMetadata, API_NAME_ATTR, AttributeMetadata.newBuilder().setId(API_NAME_ATTR).setKey("name").setScopeString(attributeScope).setValueKind(AttributeKind.TYPE_STRING).build(), API_TYPE_ATTR, AttributeMetadata.newBuilder().setId(API_TYPE_ATTR).setKey("type").setScopeString(attributeScope).setValueKind(AttributeKind.TYPE_STRING).build(), API_PATTERN_ATTR, AttributeMetadata.newBuilder().setId(API_PATTERN_ATTR).setKey("urlPattern").setScopeString(attributeScope).setValueKind(AttributeKind.TYPE_STRING).build(), API_START_TIME_ATTR, startTimeAttributeMetadata, API_END_TIME_ATTR, AttributeMetadata.newBuilder().setId(API_END_TIME_ATTR).setKey("endTime").setScopeString(attributeScope).setValueKind(AttributeKind.TYPE_TIMESTAMP).build(), API_NUM_CALLS_ATTR, AttributeMetadata.newBuilder().setId(API_NUM_CALLS_ATTR).setKey("numCalls").setScopeString(attributeScope).setValueKind(AttributeKind.TYPE_INT64).build(), API_DURATION_ATTR, AttributeMetadata.newBuilder().setId(API_DURATION_ATTR).setKey("duration").setScopeString(attributeScope).setValueKind(AttributeKind.TYPE_DOUBLE).build(), API_DISCOVERY_STATE_ATTR, AttributeMetadata.newBuilder().setId(API_DISCOVERY_STATE_ATTR).setKey("apiDiscoveryState").setScopeString(attributeScope).setValueKind(AttributeKind.TYPE_STRING).build()));
    when(attributeMetadataProvider.getAttributeMetadata(any(RequestContext.class), eq(attributeScope), eq("id"))).thenReturn(Optional.of(idAttributeMetadata));
    when(attributeMetadataProvider.getAttributeMetadata(any(RequestContext.class), eq(attributeScope), eq("startTime"))).thenReturn(Optional.of(startTimeAttributeMetadata));
    when(attributeMetadataProvider.getAttributeMetadata(any(RequestContext.class), eq(AttributeScope.EVENT.name()), eq("spaceIds"))).thenReturn(Optional.of(spaceIdAttributeMetadata));
}
Also used : AttributeMetadata(org.hypertrace.core.attribute.service.v1.AttributeMetadata) RequestContext(org.hypertrace.gateway.service.common.RequestContext) EntitiesRequestContext(org.hypertrace.gateway.service.entity.EntitiesRequestContext)

Aggregations

EntitiesRequestContext (org.hypertrace.gateway.service.entity.EntitiesRequestContext)16 AttributeScope (org.hypertrace.core.attribute.service.v1.AttributeScope)14 EntitiesRequest (org.hypertrace.gateway.service.v1.entity.EntitiesRequest)14 Test (org.junit.jupiter.api.Test)14 EntitiesRequestAndResponseUtils.buildOrderByExpression (org.hypertrace.gateway.service.common.EntitiesRequestAndResponseUtils.buildOrderByExpression)13 OrderByExpression (org.hypertrace.gateway.service.v1.common.OrderByExpression)13 EntityKey (org.hypertrace.gateway.service.entity.EntityKey)10 Builder (org.hypertrace.gateway.service.v1.entity.Entity.Builder)10 QueryRequest (org.hypertrace.core.query.service.api.QueryRequest)6 ResultSetChunk (org.hypertrace.core.query.service.api.ResultSetChunk)6 EntitiesRequestAndResponseUtils.buildAggregateExpression (org.hypertrace.gateway.service.common.EntitiesRequestAndResponseUtils.buildAggregateExpression)6 EntitiesRequestAndResponseUtils.buildExpression (org.hypertrace.gateway.service.common.EntitiesRequestAndResponseUtils.buildExpression)6 QueryServiceRequestAndResponseUtils.getResultSetChunk (org.hypertrace.gateway.service.common.QueryServiceRequestAndResponseUtils.getResultSetChunk)6 EntityFetcherResponse (org.hypertrace.gateway.service.common.datafetcher.EntityFetcherResponse)6 EntityResponse (org.hypertrace.gateway.service.common.datafetcher.EntityResponse)6 Expression (org.hypertrace.gateway.service.v1.common.Expression)6 LinkedHashMap (java.util.LinkedHashMap)5 DataFetcherNode (org.hypertrace.gateway.service.entity.query.DataFetcherNode)5 EntitiesRequestAndResponseUtils.buildTimeAggregation (org.hypertrace.gateway.service.common.EntitiesRequestAndResponseUtils.buildTimeAggregation)4 TimeAggregation (org.hypertrace.gateway.service.v1.common.TimeAggregation)4