Search in sources :

Example 6 with Concept

use of ai.grakn.engine.controller.response.Concept in project grakn by graknlabs.

the class ConceptControllerTest method assertConceptsReturned.

private static void assertConceptsReturned(String path, Class<? extends Concept[]> clazz, String key, Concept... concepts) {
    String request = REST.resolveTemplate(path, keyspace.getValue());
    Response response = RestAssured.when().get(request);
    assertEquals(SC_OK, response.statusCode());
    Concept[] conceptsFound = response.jsonPath().getObject(key, clazz);
    assertThat(Arrays.asList(conceptsFound), hasItems(concepts));
}
Also used : Response(com.jayway.restassured.response.Response) Concept(ai.grakn.engine.controller.response.Concept) Matchers.containsString(org.hamcrest.Matchers.containsString)

Example 7 with Concept

use of ai.grakn.engine.controller.response.Concept in project grakn by graknlabs.

the class GraqlControllerTest method whenRunningInsertQuery_JsonResponseCanBeMappedToJavaObject.

@Test
public void whenRunningInsertQuery_JsonResponseCanBeMappedToJavaObject() {
    Concept expectedConcept = ConceptBuilder.build(sampleKB.tx().getEntityType("movie"));
    Json json = Json.read(sendQuery("insert $x label movie;", APPLICATION_JSON).body().asString()).asJsonList().iterator().next().at("x");
    Concept concept = JsonConceptBuilder.build(json);
    assertEquals(expectedConcept, concept);
}
Also used : Concept(ai.grakn.engine.controller.response.Concept) Json(mjson.Json) Test(org.junit.Test)

Aggregations

Concept (ai.grakn.engine.controller.response.Concept)7 Test (org.junit.Test)3 GraknTx (ai.grakn.GraknTx)2 Role (ai.grakn.engine.controller.response.Role)2 Rule (ai.grakn.engine.controller.response.Rule)2 Timer (com.codahale.metrics.Timer)2 Json (mjson.Json)2 Matchers.containsString (org.hamcrest.Matchers.containsString)2 Keyspace (ai.grakn.Keyspace)1 Attribute (ai.grakn.engine.controller.response.Attribute)1 AttributeType (ai.grakn.engine.controller.response.AttributeType)1 ConceptBuilder (ai.grakn.engine.controller.response.ConceptBuilder)1 Entity (ai.grakn.engine.controller.response.Entity)1 EntityType (ai.grakn.engine.controller.response.EntityType)1 ListResource (ai.grakn.engine.controller.response.ListResource)1 MetaConcept (ai.grakn.engine.controller.response.MetaConcept)1 Relationship (ai.grakn.engine.controller.response.Relationship)1 RelationshipType (ai.grakn.engine.controller.response.RelationshipType)1 Schema (ai.grakn.util.Schema)1 Response (com.jayway.restassured.response.Response)1