Search in sources :

Example 1 with GraknClientException

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()));
}
Also used : InsertQuery(ai.grakn.graql.InsertQuery) Query(ai.grakn.graql.Query) Keyspace(ai.grakn.Keyspace) BatchExecutorClient(ai.grakn.client.BatchExecutorClient) GraknClientException(ai.grakn.client.GraknClientException) Test(org.junit.Test)

Aggregations

Keyspace (ai.grakn.Keyspace)1 BatchExecutorClient (ai.grakn.client.BatchExecutorClient)1 GraknClientException (ai.grakn.client.GraknClientException)1 InsertQuery (ai.grakn.graql.InsertQuery)1 Query (ai.grakn.graql.Query)1 Test (org.junit.Test)1