use of ai.grakn.concept.Concept in project grakn by graknlabs.
the class TxObserver method getConcept.
private void getConcept(GrpcConcept.ConceptId conceptId) {
Optional<Concept> concept = Optional.ofNullable(tx().getConcept(GrpcUtil.convert(conceptId)));
TxResponse response = TxResponse.newBuilder().setOptionalConcept(GrpcUtil.convertOptionalConcept(concept)).build();
responseObserver.onNext(response);
}
use of ai.grakn.concept.Concept in project grakn by graknlabs.
the class TxObserver method getSchemaConcept.
private void getSchemaConcept(GrpcConcept.Label label) {
Optional<Concept> concept = Optional.ofNullable(tx().getSchemaConcept(GrpcUtil.convert(label)));
TxResponse response = TxResponse.newBuilder().setOptionalConcept(GrpcUtil.convertOptionalConcept(concept)).build();
responseObserver.onNext(response);
}
use of ai.grakn.concept.Concept in project grakn by graknlabs.
the class RemoteGraknTxTest method whenPuttingRole_EnsureCorrectRequestIsSent.
@Test
public void whenPuttingRole_EnsureCorrectRequestIsSent() {
ConceptId id = ConceptId.of(V123.getValue());
Label label = Label.of("foo");
try (RemoteGraknTx tx = RemoteGraknTx.create(session, GrpcUtil.openRequest(KEYSPACE, GraknTxType.READ))) {
// The open request
verify(server.requests()).onNext(any());
Concept concept = RemoteConcepts.createRole(tx, id);
server.setResponse(GrpcUtil.putRoleRequest(label), GrpcUtil.conceptResponse(concept));
assertEquals(concept, tx.putRole(label));
}
}
use of ai.grakn.concept.Concept in project grakn by graknlabs.
the class RemoteGraknTxTest method whenGettingSchemaConceptViaLabel_EnsureCorrectRequestIsSent.
@Test
public void whenGettingSchemaConceptViaLabel_EnsureCorrectRequestIsSent() {
Label label = Label.of("foo");
ConceptId id = ConceptId.of(V123.getValue());
try (RemoteGraknTx tx = RemoteGraknTx.create(session, GrpcUtil.openRequest(KEYSPACE, GraknTxType.READ))) {
// The open request
verify(server.requests()).onNext(any());
Concept concept = RemoteConcepts.createAttributeType(tx, id);
server.setResponse(GrpcUtil.getSchemaConceptRequest(label), GrpcUtil.optionalConceptResponse(Optional.of(concept)));
assertEquals(concept, tx.getSchemaConcept(label));
}
}
use of ai.grakn.concept.Concept in project grakn by graknlabs.
the class RemoteGraknTxTest method whenPuttingRelationshipType_EnsureCorrectRequestIsSent.
@Test
public void whenPuttingRelationshipType_EnsureCorrectRequestIsSent() {
ConceptId id = ConceptId.of(V123.getValue());
Label label = Label.of("foo");
try (RemoteGraknTx tx = RemoteGraknTx.create(session, GrpcUtil.openRequest(KEYSPACE, GraknTxType.READ))) {
// The open request
verify(server.requests()).onNext(any());
Concept concept = RemoteConcepts.createRelationshipType(tx, id);
server.setResponse(GrpcUtil.putRelationshipTypeRequest(label), GrpcUtil.conceptResponse(concept));
assertEquals(concept, tx.putRelationshipType(label));
}
}
Aggregations