Search in sources :

Example 71 with Response

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

the class ServiceManagerImpl method waitForHttpEndpoint.

@Override
public void waitForHttpEndpoint(String path) throws InterruptedException {
    LOGGER.info("Waiting for {}", path);
    long timeoutLimit = System.currentTimeMillis() + HTTP_ENDPOINT_TIMEOUT;
    boolean available = false;
    while (!available) {
        Response response = get(path);
        available = response.getStatusCode() == 200 && response.getBody().print().length() > 0;
        if (!available) {
            if (System.currentTimeMillis() > timeoutLimit) {
                printInactiveBundles();
                fail(String.format("%s did not start within %d minutes.", path, TimeUnit.MILLISECONDS.toMinutes(HTTP_ENDPOINT_TIMEOUT)));
            }
            Thread.sleep(100);
        }
    }
    LOGGER.info("{} ready.", path);
}
Also used : Response(com.jayway.restassured.response.Response)

Example 72 with Response

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

the class TestCatalog method testCswUpdateRemoveAttributesByCqlConstraint.

@Test
public void testCswUpdateRemoveAttributesByCqlConstraint() {
    Response response = ingestCswRecord();
    String id;
    try {
        id = getMetacardIdFromCswInsertResponse(response);
    } catch (IOException | XPathExpressionException e) {
        fail("Could not retrieve the ingested record's ID from the response.");
        return;
    }
    String url = REST_PATH.getUrl() + id;
    when().get(url).then().log().all().assertThat().body(hasXPath("//metacard/dateTime[@name='modified']"), hasXPath("//metacard/string[@name='title']"), hasXPath("//metacard/geometry[@name='location']"));
    ValidatableResponse validatableResponse = given().header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_XML).body(getFileContent(CSW_REQUEST_RESOURCE_PATH + "/CswUpdateRemoveAttributesByCqlConstraintRequest")).post(CSW_PATH.getUrl()).then();
    validatableResponse.body(hasXPath("//TransactionResponse/TransactionSummary/totalDeleted", is("0")), hasXPath("//TransactionResponse/TransactionSummary/totalInserted", is("0")), hasXPath("//TransactionResponse/TransactionSummary/totalUpdated", is("1")));
    when().get(url).then().log().all().assertThat().body(not(hasXPath("//metacard/string[@name='title']")), not(hasXPath("//metacard/geometry[@name='location']")), // Check that an attribute that was not updated was not changed.
    hasXPath("//metacard/dateTime[@name='modified']"), hasXPath("//metacard/string[@name='topic.category']/value", is("Hydrography--Dictionaries")));
    deleteMetacard(id);
}
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 73 with Response

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

the class TestCatalog method testCswGetRecordsWithHitsResultType.

@Test
public void testCswGetRecordsWithHitsResultType() {
    Response response = ingestCswRecord();
    String query = getCswQuery("AnyText", "*", "application/xml", "http://www.opengis.net/cat/csw/2.0.2");
    String id;
    try {
        id = getMetacardIdFromCswInsertResponse(response);
    } catch (IOException | XPathExpressionException e) {
        fail("Could not retrieve the ingested record's ID from the response.");
        return;
    }
    //test with resultType="results" first
    ValidatableResponse validatableResponse = given().header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_XML).body(query).post(CSW_PATH.getUrl()).then();
    validatableResponse.body(hasXPath("/GetRecordsResponse/SearchResults/Record"));
    //test with resultType="hits"
    query = query.replace("results", "hits");
    validatableResponse = given().header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_XML).body(query).post(CSW_PATH.getUrl()).then();
    //assert that no records have been returned
    validatableResponse.body(not(hasXPath("//Record")));
    //testing with resultType='validate' is not
    //possible due to DDF-1537, this test will need
    //to be updated to test this once it is fixed.
    deleteMetacard(id);
}
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 74 with Response

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

the class TestCatalogSearchUi method testCanShareByGroup.

@Test
public void testCanShareByGroup() {
    Map<String, Object> workspace = ImmutableMap.of(SecurityAttributes.ACCESS_GROUPS, ImmutableList.of("guest"));
    Response res = expect(asAdmin().body(stringify(workspace)), 201).post(api());
    Map body = parse(res);
    String id = (String) body.get("id");
    assertNotNull(id);
    expect(asGuest(), 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 75 with Response

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

the class TestCatalogSearchUi method testWorkspaceSavedItems.

@Test
public void testWorkspaceSavedItems() {
    List<String> metacards = ImmutableList.of("item1", "item2");
    Map<String, Object> workspace = ImmutableMap.of(WORKSPACE_METACARDS, metacards);
    Response res = expect(asAdmin().body(stringify(workspace)), 201).post(api());
    Map body = parse(res);
    String id = (String) body.get("id");
    assertNotNull(id);
    assertThat(body.get(WORKSPACE_METACARDS), is(metacards));
}
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