Search in sources :

Example 81 with Response

use of com.jayway.restassured.response.Response in project ddf by codice.

the class TestCatalog method testCswUpdateByFilterConstraintNoMetacardsFound.

@Test
public void testCswUpdateByFilterConstraintNoMetacardsFound() {
    Response response = ingestCswRecord();
    String updateRequest = getFileContent(CSW_REQUEST_RESOURCE_PATH + "/CswUpdateByFilterConstraintRequest");
    // Change the <Filter> property being searched for so no results will be found.
    updateRequest = updateRequest.replace("title", "subject");
    ValidatableResponse validatableResponse = given().header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_XML).body(updateRequest).post(CSW_PATH.getUrl()).then();
    validatableResponse.body(hasXPath("//TransactionResponse/TransactionSummary/totalDeleted", is("0")), hasXPath("//TransactionResponse/TransactionSummary/totalInserted", is("0")), hasXPath("//TransactionResponse/TransactionSummary/totalUpdated", is("0")));
    try {
        CatalogTestCommons.deleteMetacardUsingCswResponseId(response);
    } catch (IOException | XPathExpressionException e) {
        fail("Could not retrieve the ingested record's ID from the response.");
    }
}
Also used : CswTestCommons.getMetacardIdFromCswInsertResponse(org.codice.ddf.itests.common.csw.CswTestCommons.getMetacardIdFromCswInsertResponse) ValidatableResponse(com.jayway.restassured.response.ValidatableResponse) Response(com.jayway.restassured.response.Response) ValidatableResponse(com.jayway.restassured.response.ValidatableResponse) XPathExpressionException(javax.xml.xpath.XPathExpressionException) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) IOException(java.io.IOException) SkipUnstableTest(org.codice.ddf.itests.common.annotations.SkipUnstableTest) Test(org.junit.Test) AbstractIntegrationTest(org.codice.ddf.itests.common.AbstractIntegrationTest)

Example 82 with Response

use of com.jayway.restassured.response.Response in project ddf by codice.

the class TestCatalog method testCswUpdateByNewRecordNoMetacardFound.

@Test
public void testCswUpdateByNewRecordNoMetacardFound() throws IOException, XPathExpressionException {
    Response response = ingestCswRecord();
    try {
        ValidatableResponse validatableResponse = given().header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_XML).body(getFileContent(CSW_REQUEST_RESOURCE_PATH + "/CswUpdateRecordRequest")).post(CSW_PATH.getUrl()).then();
        validatableResponse.assertThat().statusCode(400);
    } finally {
        CatalogTestCommons.deleteMetacardUsingCswResponseId(response);
    }
}
Also used : CswTestCommons.getMetacardIdFromCswInsertResponse(org.codice.ddf.itests.common.csw.CswTestCommons.getMetacardIdFromCswInsertResponse) ValidatableResponse(com.jayway.restassured.response.ValidatableResponse) Response(com.jayway.restassured.response.Response) ValidatableResponse(com.jayway.restassured.response.ValidatableResponse) SkipUnstableTest(org.codice.ddf.itests.common.annotations.SkipUnstableTest) Test(org.junit.Test) AbstractIntegrationTest(org.codice.ddf.itests.common.AbstractIntegrationTest)

Example 83 with Response

use of com.jayway.restassured.response.Response in project ddf by codice.

the class TestCatalog method testGetRecordById.

@Test
public void testGetRecordById() throws IOException, XPathExpressionException {
    final Response firstResponse = ingestCswRecord();
    final Response secondResponse = ingestCswRecord();
    final String firstId = getMetacardIdFromCswInsertResponse(firstResponse);
    final String secondId = getMetacardIdFromCswInsertResponse(secondResponse);
    final String requestIds = firstId + "," + secondId;
    String cswUrlGetRecordsParmaters = "?service=CSW&version=2.0.2&request=GetRecordById&NAMESPACE=xmlns=" + "http://www.opengis.net/cat/csw/2.0.2&ElementSetName=full&" + "outputFormat=application/xml&outputSchema=http://www.opengis.net/cat/csw/2.0.2&" + "id=placeholder_id";
    // Request the records we just added.
    final String url = CSW_PATH.getUrl() + cswUrlGetRecordsParmaters.replace("placeholder_id", requestIds);
    final ValidatableResponse response = when().get(url).then().log().all();
    verifyGetRecordByIdResponse(response, firstId, secondId);
    deleteMetacard(firstId);
    deleteMetacard(secondId);
}
Also used : CswTestCommons.getMetacardIdFromCswInsertResponse(org.codice.ddf.itests.common.csw.CswTestCommons.getMetacardIdFromCswInsertResponse) ValidatableResponse(com.jayway.restassured.response.ValidatableResponse) Response(com.jayway.restassured.response.Response) ValidatableResponse(com.jayway.restassured.response.ValidatableResponse) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) SkipUnstableTest(org.codice.ddf.itests.common.annotations.SkipUnstableTest) Test(org.junit.Test) AbstractIntegrationTest(org.codice.ddf.itests.common.AbstractIntegrationTest)

Example 84 with Response

use of com.jayway.restassured.response.Response in project ddf by codice.

the class TestCatalogSearchUi method testCanShareByEmail.

@Test
public void testCanShareByEmail() {
    Map<String, Object> workspace = ImmutableMap.of(SecurityAttributes.ACCESS_INDIVIDUALS, ImmutableList.of("random@localhost.local"));
    Response res = expect(asAdmin().body(stringify(workspace)), 201).post(api());
    Map body = parse(res);
    String id = (String) body.get("id");
    assertNotNull(id);
    expect(asGuest(), 404).get(api() + "/" + id);
    expect(asUser("random", "password"), 200).get(api() + "/" + id);
}
Also used : Response(com.jayway.restassured.response.Response) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) AbstractIntegrationTest(org.codice.ddf.itests.common.AbstractIntegrationTest) Test(org.junit.Test)

Example 85 with Response

use of com.jayway.restassured.response.Response in project ddf by codice.

the class TestCatalogSearchUi method testAdminCanCreateWorkspace.

@Test
public void testAdminCanCreateWorkspace() {
    Map<String, String> workspace = ImmutableMap.of("title", "my workspace");
    Response res = expect(asAdmin().body(stringify(workspace)), 201).post(api());
    Map body = parse(res);
    String id = (String) body.get("id");
    assertNotNull(id);
}
Also used : Response(com.jayway.restassured.response.Response) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) AbstractIntegrationTest(org.codice.ddf.itests.common.AbstractIntegrationTest) 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