Search in sources :

Example 91 with Response

use of com.jayway.restassured.response.Response in project grakn by graknlabs.

the class ConceptControllerTest method whenGettingTypesInstances_EnsureInstancesAreReturned.

@Test
public void whenGettingTypesInstances_EnsureInstancesAreReturned() throws JsonProcessingException {
    // TODO: Same as below get jackson to deserialise via a child constructor
    String request = entityTypeWrapper.instances().id();
    Response response = RestAssured.when().get(request);
    assertEquals(SC_OK, response.getStatusCode());
    // Hacky way to check if instance is embedded
    String instance = new ObjectMapper().writeValueAsString(entityWrapper);
    response.then().body(containsString(instance));
}
Also used : Response(com.jayway.restassured.response.Response) Matchers.containsString(org.hamcrest.Matchers.containsString) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 92 with Response

use of com.jayway.restassured.response.Response in project grakn by graknlabs.

the class ConceptControllerTest method whenGettingKeysOfType_EnsureAttributesAreReturned.

@Test
public void whenGettingKeysOfType_EnsureAttributesAreReturned() throws IOException {
    Response response = RestAssured.when().get(entityTypeWrapper.keys().id());
    assertEquals(SC_OK, response.getStatusCode());
    AttributeType[] keys = response.jsonPath().getObject("keys", AttributeType[].class);
    assertThat(keys, arrayContainingInAnyOrder(attributeTypeKeyWrapper));
}
Also used : Response(com.jayway.restassured.response.Response) AttributeType(ai.grakn.engine.controller.response.AttributeType) Test(org.junit.Test)

Example 93 with Response

use of com.jayway.restassured.response.Response in project grakn by graknlabs.

the class ConceptControllerTest method whenGettingSubsOfSchemaConcept_EnsureSubsAreReturned.

@Test
public void whenGettingSubsOfSchemaConcept_EnsureSubsAreReturned() throws IOException {
    Response response = RestAssured.when().get(entityTypeWrapper.subs().id());
    assertEquals(SC_OK, response.getStatusCode());
    EntityType[] subs = response.jsonPath().getObject("subs", EntityType[].class);
    assertThat(subs, arrayContainingInAnyOrder(entityTypeWrapper, entityTypeSubWrapper));
}
Also used : Response(com.jayway.restassured.response.Response) EntityType(ai.grakn.engine.controller.response.EntityType) Test(org.junit.Test)

Example 94 with Response

use of com.jayway.restassured.response.Response in project grakn by graknlabs.

the class GraqlControllerInsertTest method POSTGraqlInsertWithJsonType_ResponseIsCorrectJson.

@Test
public void POSTGraqlInsertWithJsonType_ResponseIsCorrectJson() {
    when(printer.graqlString(any())).thenReturn(Json.array().toString());
    Response response = sendRequest("insert $x isa person;");
    assertThat(jsonResponse(response).asJsonList().size(), equalTo(0));
}
Also used : Response(com.jayway.restassured.response.Response) GraqlControllerReadOnlyTest.jsonResponse(ai.grakn.engine.controller.GraqlControllerReadOnlyTest.jsonResponse) Test(org.junit.Test)

Example 95 with Response

use of com.jayway.restassured.response.Response in project grakn by graknlabs.

the class GraqlControllerInsertTest method POSTGraqlDefineNotValid_ResponseStatusCodeIs422.

@Test
public void POSTGraqlDefineNotValid_ResponseStatusCodeIs422() {
    GraknTxOperationException exception = GraknTxOperationException.invalidCasting(Object.class, Object.class);
    when(tx.graql().parser().parseQuery("define person plays movie;").execute()).thenThrow(exception);
    Response response = sendRequest("define person plays movie;");
    assertThat(response.statusCode(), equalTo(422));
}
Also used : Response(com.jayway.restassured.response.Response) GraqlControllerReadOnlyTest.jsonResponse(ai.grakn.engine.controller.GraqlControllerReadOnlyTest.jsonResponse) GraknTxOperationException(ai.grakn.exception.GraknTxOperationException) Test(org.junit.Test)

Aggregations

Response (com.jayway.restassured.response.Response)214 Test (org.testng.annotations.Test)129 Test (org.junit.Test)73 WorkspaceImpl (org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl)35 AbstractIntegrationTest (org.codice.ddf.itests.common.AbstractIntegrationTest)31 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)27 Matchers.anyString (org.mockito.Matchers.anyString)21 ValidatableResponse (com.jayway.restassured.response.ValidatableResponse)19 CswTestCommons.getMetacardIdFromCswInsertResponse (org.codice.ddf.itests.common.csw.CswTestCommons.getMetacardIdFromCswInsertResponse)15 IOException (java.io.IOException)14 SkipUnstableTest (org.codice.ddf.itests.common.annotations.SkipUnstableTest)14 XPathExpressionException (javax.xml.xpath.XPathExpressionException)12 ImmutableMap (com.google.common.collect.ImmutableMap)11 Map (java.util.Map)11 Factory (org.eclipse.che.api.core.model.factory.Factory)11 FactoryDto (org.eclipse.che.api.factory.shared.dto.FactoryDto)11 UserImpl (org.eclipse.che.api.user.server.model.impl.UserImpl)11 DtoFactory (org.eclipse.che.dto.server.DtoFactory)11 Matchers.containsString (org.hamcrest.Matchers.containsString)10 WorkspaceDto (org.eclipse.che.api.workspace.shared.dto.WorkspaceDto)9