use of ai.grakn.concept.ConceptId 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.ConceptId 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));
}
}
use of ai.grakn.concept.ConceptId in project grakn by graknlabs.
the class RemoteGraknTxTest method whenGettingNonExistentConceptViaID_ReturnNull.
@Test
public void whenGettingNonExistentConceptViaID_ReturnNull() {
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());
server.setResponse(GrpcUtil.getConceptRequest(id), GrpcUtil.optionalConceptResponse(Optional.empty()));
assertNull(tx.getConcept(id));
}
}
use of ai.grakn.concept.ConceptId in project grakn by graknlabs.
the class RemoteGraknTxTest method whenPuttingAttributeType_EnsureCorrectRequestIsSent.
@Test
public void whenPuttingAttributeType_EnsureCorrectRequestIsSent() {
ConceptId id = ConceptId.of(V123.getValue());
Label label = Label.of("foo");
AttributeType.DataType<?> dataType = AttributeType.DataType.STRING;
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.putAttributeTypeRequest(label, dataType), GrpcUtil.conceptResponse(concept));
assertEquals(concept, tx.putAttributeType(label, dataType));
}
}
use of ai.grakn.concept.ConceptId in project grakn by graknlabs.
the class RemoteGraknTxTest method whenPuttingRule_EnsureCorrectRequestIsSent.
@Test
public void whenPuttingRule_EnsureCorrectRequestIsSent() {
ConceptId id = ConceptId.of(V123.getValue());
Label label = Label.of("foo");
Pattern when = var("x").isa("person");
Pattern then = var("y").isa("person");
try (RemoteGraknTx tx = RemoteGraknTx.create(session, GrpcUtil.openRequest(KEYSPACE, GraknTxType.READ))) {
// The open request
verify(server.requests()).onNext(any());
Concept concept = RemoteConcepts.createRule(tx, id);
server.setResponse(GrpcUtil.putRuleRequest(label, when, then), GrpcUtil.conceptResponse(concept));
assertEquals(concept, tx.putRule(label, when, then));
}
}
Aggregations