use of org.hypertrace.core.query.service.client.QueryServiceClient in project gateway-service by hypertrace.
the class AbstractServiceTest method createMockQueryServiceClient.
private QueryServiceClient createMockQueryServiceClient(String fileName) throws IOException {
QueryServiceClient queryServiceClient = mock(QueryServiceClient.class);
Map<QueryRequest, ResultSetChunk> queryRequestResultSetChunkMap = readExpectedQueryServiceRequestAndResponse(fileName);
when(queryServiceClient.executeQuery(any(QueryRequest.class), any(HashMap.class), any(Integer.class))).thenAnswer((Answer<Iterator<ResultSetChunk>>) invocation -> {
QueryRequest queryRequest = (QueryRequest) invocation.getArguments()[0];
ResultSetChunk resultSetChunk = queryRequestResultSetChunkMap.get(queryRequest);
if (resultSetChunk == null) {
Assertions.fail("Unexpected QueryRequest object:\n" + JsonFormat.printer().print(queryRequest));
}
return List.of(resultSetChunk).iterator();
});
return queryServiceClient;
}
use of org.hypertrace.core.query.service.client.QueryServiceClient in project gateway-service by hypertrace.
the class AbstractServiceTest method runTest.
@ParameterizedTest
@MethodSource("data")
public void runTest(String fileName) throws IOException {
QueryServiceClient queryServiceClient = createMockQueryServiceClient(fileName);
TGatewayServiceRequestType testRequest = readGatewayServiceRequest(fileName);
TGatewayServiceResponseType actualResponse = executeApi(testRequest, queryServiceClient, attributeMetadataProvider, scopeFilterConfigs);
TGatewayServiceResponseType expectedResponse = readGatewayServiceResponse(fileName);
Assertions.assertEquals(expectedResponse, actualResponse);
}
Aggregations