use of ai.grakn.client.GraknClientException in project grakn by graknlabs.
the class GraknClientFake method whenQueriesFail_TheBatchExecutorClientStillCompletes.
@Test
public void whenQueriesFail_TheBatchExecutorClientStillCompletes() throws GraknClientException {
Keyspace keyspace = Keyspace.of("yes");
GraknClientFake graknClient = new GraknClientFake();
graknClient.shouldThrow(new GraknClientException("UH OH"));
// Make sure there are more queries to execute than are allowed to run at once
int maxQueries = 10;
int numQueries = 100;
BatchExecutorClient.Builder clientBuilder = BatchExecutorClient.newBuilder().taskClient(graknClient).maxQueries(maxQueries);
Set<Query<?>> queriesToExecute = IntStream.range(0, numQueries).mapToObj(this::createInsertQuery).collect(toImmutableSet());
try (BatchExecutorClient client = clientBuilder.build()) {
for (Query<?> query : queriesToExecute) {
// If we don't subscribe, the query won't execute
client.add(query, keyspace).subscribe(a -> {
});
}
}
assertThat(graknClient.queriesExecuted(), containsInAnyOrder(queriesToExecute.toArray()));
}
Aggregations