Search in sources :

Example 6 with ConceptId

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));
    }
}
Also used : GrpcConcept(ai.grakn.rpc.generated.GrpcConcept) Concept(ai.grakn.concept.Concept) Label(ai.grakn.concept.Label) ConceptId(ai.grakn.concept.ConceptId) Test(org.junit.Test)

Example 7 with ConceptId

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));
    }
}
Also used : GrpcConcept(ai.grakn.rpc.generated.GrpcConcept) Concept(ai.grakn.concept.Concept) Label(ai.grakn.concept.Label) ConceptId(ai.grakn.concept.ConceptId) Test(org.junit.Test)

Example 8 with ConceptId

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));
    }
}
Also used : ConceptId(ai.grakn.concept.ConceptId) Test(org.junit.Test)

Example 9 with ConceptId

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));
    }
}
Also used : GrpcConcept(ai.grakn.rpc.generated.GrpcConcept) Concept(ai.grakn.concept.Concept) AttributeType(ai.grakn.concept.AttributeType) Label(ai.grakn.concept.Label) ConceptId(ai.grakn.concept.ConceptId) Test(org.junit.Test)

Example 10 with ConceptId

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));
    }
}
Also used : GrpcConcept(ai.grakn.rpc.generated.GrpcConcept) Concept(ai.grakn.concept.Concept) Pattern(ai.grakn.graql.Pattern) Label(ai.grakn.concept.Label) ConceptId(ai.grakn.concept.ConceptId) Test(org.junit.Test)

Aggregations

ConceptId (ai.grakn.concept.ConceptId)80 Test (org.junit.Test)55 Concept (ai.grakn.concept.Concept)23 Role (ai.grakn.concept.Role)22 RelationshipType (ai.grakn.concept.RelationshipType)19 GraknTx (ai.grakn.GraknTx)18 EntityType (ai.grakn.concept.EntityType)18 Label (ai.grakn.concept.Label)16 GrpcConcept (ai.grakn.rpc.generated.GrpcConcept)14 Var (ai.grakn.graql.Var)12 List (java.util.List)12 Entity (ai.grakn.concept.Entity)10 AttributeType (ai.grakn.concept.AttributeType)9 HashSet (java.util.HashSet)9 Set (java.util.Set)9 Assert.assertEquals (org.junit.Assert.assertEquals)9 ClassRule (org.junit.ClassRule)9 GraknTxType (ai.grakn.GraknTxType)8 Keyspace (ai.grakn.Keyspace)8 IdPredicate (ai.grakn.graql.internal.reasoner.atom.predicate.IdPredicate)8