Search in sources :

Example 66 with ConceptId

use of ai.grakn.concept.ConceptId in project grakn by graknlabs.

the class ConceptControllerTest method whenCallingConceptEndpointAndRequestingJSON_ReturnJSON.

@Test
public void whenCallingConceptEndpointAndRequestingJSON_ReturnJSON() {
    ConceptId id;
    try (GraknTx tx = factory.tx(keyspace, GraknTxType.READ)) {
        id = tx.admin().getMetaConcept().getId();
    }
    given().accept(ContentType.JSON).pathParam("keyspace", keyspace.getValue()).pathParam("id", id.getValue()).when().get("/kb/{keyspace}/concept/{id}").then().statusCode(SC_OK).contentType(ContentType.JSON);
}
Also used : GraknTx(ai.grakn.GraknTx) ConceptId(ai.grakn.concept.ConceptId) Test(org.junit.Test)

Example 67 with ConceptId

use of ai.grakn.concept.ConceptId in project grakn by graknlabs.

the class ConceptControllerTest method whenCallingRelationshipsEndpoint_ReturnIdLinkToSelf.

@Test
public void whenCallingRelationshipsEndpoint_ReturnIdLinkToSelf() {
    ConceptId id;
    try (GraknTx tx = factory.tx(keyspace, GraknTxType.READ)) {
        id = tx.admin().getMetaConcept().instances().findAny().get().getId();
    }
    String relationshipsLink = "/kb/" + keyspace.getValue() + "/concept/" + id + "/relationships";
    RestAssured.when().get(relationshipsLink).then().statusCode(SC_OK).contentType(ContentType.JSON).body("@id", is(relationshipsLink));
}
Also used : GraknTx(ai.grakn.GraknTx) Matchers.containsString(org.hamcrest.Matchers.containsString) ConceptId(ai.grakn.concept.ConceptId) Test(org.junit.Test)

Example 68 with ConceptId

use of ai.grakn.concept.ConceptId in project grakn by graknlabs.

the class ConceptControllerTest method whenCallingKeysEndpoint_ReturnIdLinkToSelf.

@Test
public void whenCallingKeysEndpoint_ReturnIdLinkToSelf() {
    ConceptId id;
    try (GraknTx tx = factory.tx(keyspace, GraknTxType.READ)) {
        id = tx.admin().getMetaConcept().instances().findAny().get().getId();
    }
    String keysLink = "/kb/" + keyspace.getValue() + "/concept/" + id + "/relationships";
    RestAssured.when().get(keysLink).then().statusCode(SC_OK).contentType(ContentType.JSON).body("@id", is(keysLink));
}
Also used : GraknTx(ai.grakn.GraknTx) Matchers.containsString(org.hamcrest.Matchers.containsString) ConceptId(ai.grakn.concept.ConceptId) Test(org.junit.Test)

Example 69 with ConceptId

use of ai.grakn.concept.ConceptId in project grakn by graknlabs.

the class ConceptControllerTest method whenCallingAttributesEndpoint_ReturnIdLinkToSelf.

@Test
public void whenCallingAttributesEndpoint_ReturnIdLinkToSelf() {
    ConceptId id;
    try (GraknTx tx = factory.tx(keyspace, GraknTxType.READ)) {
        id = tx.admin().getMetaConcept().instances().findAny().get().getId();
    }
    String attributesLink = "/kb/" + keyspace.getValue() + "/concept/" + id + "/relationships";
    RestAssured.when().get(attributesLink).then().statusCode(SC_OK).contentType(ContentType.JSON).body("@id", is(attributesLink));
}
Also used : GraknTx(ai.grakn.GraknTx) Matchers.containsString(org.hamcrest.Matchers.containsString) ConceptId(ai.grakn.concept.ConceptId) Test(org.junit.Test)

Example 70 with ConceptId

use of ai.grakn.concept.ConceptId in project grakn by graknlabs.

the class GraqlControllerTest method testInsertQuery.

@Test
public void testInsertQuery() {
    Response resp = sendQuery("insert $x isa movie;");
    try {
        resp.then().statusCode(200);
        Assert.assertFalse(resp.jsonPath().getList(".").isEmpty());
    } finally {
        ConceptId id = ConceptId.of(resp.jsonPath().getList("x.id").get(0).toString());
        sampleKB.rollback();
        sampleKB.tx().graql().match(var("x").id(id)).delete("x").execute();
    }
}
Also used : Response(com.jayway.restassured.response.Response) 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