use of ai.grakn.grpc.TxGrpcCommunicator in project grakn by graknlabs.
the class GrpcServerTest method whenExecutingQueryWithoutInferenceSet_InferenceIsNotSet.
@Test
public void whenExecutingQueryWithoutInferenceSet_InferenceIsNotSet() throws InterruptedException {
try (TxGrpcCommunicator tx = TxGrpcCommunicator.create(stub)) {
tx.send(openRequest(MYKS, GraknTxType.WRITE));
tx.send(execQueryRequest(QUERY, null));
IteratorId iterator = tx.receive().ok().getIteratorId();
tx.send(nextRequest(iterator));
tx.send(stopRequest(iterator));
}
verify(tx.graql(), times(0)).infer(anyBoolean());
}
use of ai.grakn.grpc.TxGrpcCommunicator in project grakn by graknlabs.
the class GrpcServerTest method whenOpeningATransactionRemotelyWithAnInvalidKeyspace_Throw.
@Test
public void whenOpeningATransactionRemotelyWithAnInvalidKeyspace_Throw() throws Throwable {
GrpcGrakn.Keyspace keyspace = GrpcGrakn.Keyspace.newBuilder().setValue("not!@akeyspace").build();
Open open = Open.newBuilder().setKeyspace(keyspace).setTxType(TxType.Write).build();
try (TxGrpcCommunicator tx = TxGrpcCommunicator.create(stub)) {
tx.send(TxRequest.newBuilder().setOpen(open).build());
exception.expect(hasStatus(Status.UNKNOWN.withDescription(GraknTxOperationException.invalidKeyspace("not!@akeyspace").getMessage())));
exception.expect(hasMetadata(ErrorType.KEY, ErrorType.GRAKN_TX_OPERATION_EXCEPTION));
throw tx.receive().error();
}
}
use of ai.grakn.grpc.TxGrpcCommunicator in project grakn by graknlabs.
the class GrpcServerTest method whenGettingAConcept_ReturnTheConcept.
@Test
public void whenGettingAConcept_ReturnTheConcept() throws InterruptedException {
ConceptId id = ConceptId.of("V123456");
Concept concept = mock(Concept.class, RETURNS_DEEP_STUBS);
when(concept.getId()).thenReturn(id);
when(concept.isRelationship()).thenReturn(true);
when(tx.getConcept(id)).thenReturn(concept);
try (TxGrpcCommunicator tx = TxGrpcCommunicator.create(stub)) {
tx.send(openRequest(MYKS, GraknTxType.READ));
tx.receive().ok();
tx.send(GrpcUtil.getConceptRequest(id));
GrpcConcept.OptionalConcept response = tx.receive().ok().getOptionalConcept();
assertEquals(id.getValue(), response.getPresent().getId().getValue());
assertEquals(BaseType.Relationship, response.getPresent().getBaseType());
}
}
use of ai.grakn.grpc.TxGrpcCommunicator in project grakn by graknlabs.
the class GrpcServerTest method whenGettingIsInferredProperty_IsInferredIsReturned.
@Test
public void whenGettingIsInferredProperty_IsInferredIsReturned() throws InterruptedException {
ConceptId id = ConceptId.of("V123456");
Concept concept = mock(Concept.class, RETURNS_DEEP_STUBS);
when(tx.getConcept(id)).thenReturn(concept);
when(concept.isThing()).thenReturn(true);
when(concept.asThing().isInferred()).thenReturn(false);
try (TxGrpcCommunicator tx = TxGrpcCommunicator.create(stub)) {
tx.send(openRequest(MYKS, GraknTxType.READ));
tx.receive().ok();
tx.send(GrpcUtil.runConceptMethodRequest(id, ConceptMethods.IS_INFERRED));
assertFalse(ConceptMethods.IS_INFERRED.get(conceptConverter, client, tx.receive().ok()));
}
}
use of ai.grakn.grpc.TxGrpcCommunicator in project grakn by graknlabs.
the class GrpcServerTest method whenCommittingFails_Throw.
@Test
public void whenCommittingFails_Throw() throws Throwable {
doThrow(EXCEPTION).when(tx).commitSubmitNoLogs();
try (TxGrpcCommunicator tx = TxGrpcCommunicator.create(stub)) {
tx.send(openRequest(MYKS, GraknTxType.WRITE));
tx.receive();
tx.send(commitRequest());
exception.expect(hasStatus(Status.UNKNOWN.withDescription(EXCEPTION_MESSAGE)));
throw tx.receive().error();
}
}
Aggregations