Search in sources :

Example 1 with Open

use of ai.grakn.rpc.generated.GrpcGrakn.Open in project grakn by graknlabs.

the class GrpcServerTest method whenSendingDeleteRequest_CallDeleteOnEmbeddedTx.

@Test
public void whenSendingDeleteRequest_CallDeleteOnEmbeddedTx() {
    Open open = Open.newBuilder().setKeyspace(convert(MYKS)).setTxType(TxType.Write).build();
    blockingStub.delete(deleteRequest(open));
    verify(tx).delete();
}
Also used : Open(ai.grakn.rpc.generated.GrpcGrakn.Open) Test(org.junit.Test)

Example 2 with Open

use of ai.grakn.rpc.generated.GrpcGrakn.Open in project grakn by graknlabs.

the class GrpcServerTest method whenSendingDeleteRequestWithInvalidKeyspace_CallDeleteOnEmbeddedTx.

@Test
public void whenSendingDeleteRequestWithInvalidKeyspace_CallDeleteOnEmbeddedTx() {
    GrpcGrakn.Keyspace keyspace = GrpcGrakn.Keyspace.newBuilder().setValue("not!@akeyspace").build();
    Open open = Open.newBuilder().setKeyspace(keyspace).setTxType(TxType.Write).build();
    String message = GraknTxOperationException.invalidKeyspace("not!@akeyspace").getMessage();
    exception.expect(hasStatus(Status.UNKNOWN.withDescription(message)));
    exception.expect(hasMetadata(ErrorType.KEY, ErrorType.GRAKN_TX_OPERATION_EXCEPTION));
    blockingStub.delete(deleteRequest(open));
}
Also used : GrpcGrakn(ai.grakn.rpc.generated.GrpcGrakn) Open(ai.grakn.rpc.generated.GrpcGrakn.Open) Test(org.junit.Test)

Example 3 with Open

use of ai.grakn.rpc.generated.GrpcGrakn.Open 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();
    }
}
Also used : GrpcGrakn(ai.grakn.rpc.generated.GrpcGrakn) TxGrpcCommunicator(ai.grakn.grpc.TxGrpcCommunicator) Open(ai.grakn.rpc.generated.GrpcGrakn.Open) Test(org.junit.Test)

Aggregations

Open (ai.grakn.rpc.generated.GrpcGrakn.Open)3 Test (org.junit.Test)3 GrpcGrakn (ai.grakn.rpc.generated.GrpcGrakn)2 TxGrpcCommunicator (ai.grakn.grpc.TxGrpcCommunicator)1