use of ai.grakn.grpc.TxGrpcCommunicator in project grakn by graknlabs.
the class GrpcServerTest method whenExecutingAQueryRemotely_TheQueryIsParsedAndExecuted.
@Test
public void whenExecutingAQueryRemotely_TheQueryIsParsedAndExecuted() {
try (TxGrpcCommunicator tx = TxGrpcCommunicator.create(stub)) {
tx.send(openRequest(MYKS, GraknTxType.WRITE));
tx.send(execQueryRequest(QUERY, null));
}
ai.grakn.graql.Query<?> query = tx.graql().parse(QUERY);
verify(query).results(any());
}
use of ai.grakn.grpc.TxGrpcCommunicator in project grakn by graknlabs.
the class GrpcServerTest method whenExecutingQueryWithInferenceOn_InferenceIsTurnedOn.
@Test
public void whenExecutingQueryWithInferenceOn_InferenceIsTurnedOn() throws InterruptedException {
try (TxGrpcCommunicator tx = TxGrpcCommunicator.create(stub)) {
tx.send(openRequest(MYKS, GraknTxType.WRITE));
tx.send(execQueryRequest(QUERY, true));
IteratorId iterator = tx.receive().ok().getIteratorId();
tx.send(nextRequest(iterator));
tx.send(stopRequest(iterator));
}
verify(tx.graql()).infer(true);
}
use of ai.grakn.grpc.TxGrpcCommunicator in project grakn by graknlabs.
the class GrpcServerTest method whenExecutingAQueryBeforeOpeningTx_Throw.
@Test
public void whenExecutingAQueryBeforeOpeningTx_Throw() throws Throwable {
try (TxGrpcCommunicator tx = TxGrpcCommunicator.create(stub)) {
tx.send(execQueryRequest(QUERY, null));
exception.expect(hasStatus(Status.FAILED_PRECONDITION));
throw tx.receive().error();
}
}
use of ai.grakn.grpc.TxGrpcCommunicator in project grakn by graknlabs.
the class GrpcServerTest method whenSendingAnotherQueryDuringQueryExecution_ReturnResultsForBothQueries.
@Test
public void whenSendingAnotherQueryDuringQueryExecution_ReturnResultsForBothQueries() throws Throwable {
try (TxGrpcCommunicator tx = TxGrpcCommunicator.create(stub)) {
tx.send(openRequest(MYKS, GraknTxType.WRITE));
tx.receive();
tx.send(execQueryRequest(QUERY, null));
IteratorId iterator1 = tx.receive().ok().getIteratorId();
tx.send(execQueryRequest(QUERY, null));
IteratorId iterator2 = tx.receive().ok().getIteratorId();
tx.send(nextRequest(iterator1));
tx.receive().ok();
tx.send(nextRequest(iterator2));
tx.receive().ok();
tx.send(stopRequest(iterator1));
tx.receive().ok();
tx.send(stopRequest(iterator2));
tx.receive().ok();
}
}
use of ai.grakn.grpc.TxGrpcCommunicator in project grakn by graknlabs.
the class GrpcServerTest method whenGettingALabel_TheLabelIsReturned.
@Test
public void whenGettingALabel_TheLabelIsReturned() throws InterruptedException {
ConceptId id = ConceptId.of("V123456");
Label label = Label.of("Dunstan");
Concept concept = mock(Concept.class, RETURNS_DEEP_STUBS);
when(tx.getConcept(id)).thenReturn(concept);
when(concept.isSchemaConcept()).thenReturn(true);
when(concept.asSchemaConcept().getLabel()).thenReturn(label);
try (TxGrpcCommunicator tx = TxGrpcCommunicator.create(stub)) {
tx.send(openRequest(MYKS, GraknTxType.READ));
tx.receive().ok();
tx.send(GrpcUtil.runConceptMethodRequest(id, ConceptMethods.GET_LABEL));
assertEquals(label, ConceptMethods.GET_LABEL.get(conceptConverter, client, tx.receive().ok()));
}
}
Aggregations