Search in sources :

Example 86 with Response

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

the class TestCatalogSearchUi method testGuestCantViewUnsharedWorkspace.

@Test
public void testGuestCantViewUnsharedWorkspace() {
    Map<String, Object> workspace = Collections.emptyMap();
    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);
}
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 87 with Response

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

the class TestRegistry method createRegistryEntry.

private String createRegistryEntry(String id, String regId) throws Exception {
    Response response = given().auth().preemptive().basic(ADMIN, ADMIN).body(getCswRegistryInsert(id, regId)).header("Content-Type", "text/xml").expect().log().all().statusCode(200).when().post(CSW_PATH.getUrl());
    ValidatableResponse validatableResponse = response.then();
    validatableResponse.body(hasXPath("//TransactionResponse/TransactionSummary/totalInserted", CoreMatchers.is("1")), hasXPath("//TransactionResponse/TransactionSummary/totalUpdated", CoreMatchers.is("0")), hasXPath("//TransactionResponse/TransactionSummary/totalDeleted", CoreMatchers.is("0")));
    String idPath = "//*[local-name()='identifier']/text()";
    String mcardId = XmlSearch.evaluate(idPath, response.getBody().asString());
    boolean foundMetacard = false;
    long startTime = System.currentTimeMillis();
    long metacardLookupTimeout = TimeUnit.MINUTES.toMillis(20);
    while (!foundMetacard) {
        LOGGER.info("Waiting for metacard to be created");
        List entries = SECURITY.runAsAdminWithException(() -> {
            FederationAdminService federationAdminServiceImpl = getServiceManager().getService(FederationAdminService.class);
            return federationAdminServiceImpl.getRegistryMetacardsByRegistryIds(Collections.singletonList(regId));
        });
        if (!entries.isEmpty()) {
            foundMetacard = true;
        } else if (System.currentTimeMillis() - startTime > metacardLookupTimeout) {
            fail("Registry Metacard was not created in the allowed time");
        }
        Thread.sleep(SLEEP_TIME);
    }
    return mcardId;
}
Also used : Response(com.jayway.restassured.response.Response) ValidatableResponse(com.jayway.restassured.response.ValidatableResponse) ValidatableResponse(com.jayway.restassured.response.ValidatableResponse) FederationAdminService(org.codice.ddf.registry.federationadmin.service.internal.FederationAdminService) ArrayList(java.util.ArrayList) List(java.util.List)

Example 88 with Response

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

the class TestRegistry method testCswRegistryUpdate.

@Test
public void testCswRegistryUpdate() throws Exception {
    String regID = "urn:uuid:2014ca7f59ac46f495e32b4a67a51285";
    String mcardId = "2014ca7f59ac46f495e32b4a67a51285";
    String id = createRegistryEntry(mcardId, regID);
    Response response = given().auth().preemptive().basic(ADMIN, ADMIN).body(getCswRegistryUpdate(id, "New Node Name", "2018-02-26T17:16:34.996Z", regID)).header("Content-Type", "text/xml").expect().log().all().statusCode(200).when().post(CSW_PATH.getUrl());
    ValidatableResponse validatableResponse = response.then();
    validatableResponse.body(hasXPath("//TransactionResponse/TransactionSummary/totalInserted", CoreMatchers.is("0")), hasXPath("//TransactionResponse/TransactionSummary/totalUpdated", CoreMatchers.is("1")), hasXPath("//TransactionResponse/TransactionSummary/totalDeleted", CoreMatchers.is("0")));
}
Also used : Response(com.jayway.restassured.response.Response) ValidatableResponse(com.jayway.restassured.response.ValidatableResponse) ValidatableResponse(com.jayway.restassured.response.ValidatableResponse) AbstractIntegrationTest(org.codice.ddf.itests.common.AbstractIntegrationTest) Test(org.junit.Test)

Example 89 with Response

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

the class TestRegistry method testCswRegistryDelete.

@Test
public void testCswRegistryDelete() throws Exception {
    String regID = "urn:uuid:2014ca7f59ac46f495e32b4a67a51281";
    String mcardId = "2014ca7f59ac46f495e32b4a67a51281";
    createRegistryEntry(mcardId, regID);
    Response response = given().auth().preemptive().basic(ADMIN, ADMIN).body(getFileContent(CSW_REQUEST_RESOURCE_PATH + "/CswRegistryDeleteRequest", ImmutableMap.of("id", mcardId))).header("Content-Type", "text/xml").expect().log().all().statusCode(200).when().post(CSW_PATH.getUrl());
    ValidatableResponse validatableResponse = response.then();
    validatableResponse.body(hasXPath("//TransactionResponse/TransactionSummary/totalInserted", CoreMatchers.is("0")), hasXPath("//TransactionResponse/TransactionSummary/totalUpdated", CoreMatchers.is("0")), hasXPath("//TransactionResponse/TransactionSummary/totalDeleted", CoreMatchers.is("1")));
}
Also used : Response(com.jayway.restassured.response.Response) ValidatableResponse(com.jayway.restassured.response.ValidatableResponse) ValidatableResponse(com.jayway.restassured.response.ValidatableResponse) AbstractIntegrationTest(org.codice.ddf.itests.common.AbstractIntegrationTest) Test(org.junit.Test)

Example 90 with Response

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

the class TestFtp method verifyIngest.

private void verifyIngest(int expectedResults, String expectedTitle) {
    // verify FTP PUT resulted in ingest, catalogued data
    expect(String.format("Failed to verify FTP ingest expectedResult(s) of %d and expectedTitle of %s", expectedResults, expectedTitle)).within(VERIFY_INGEST_TIMEOUT_SEC, TimeUnit.SECONDS).until(() -> {
        final Response response = executeOpenSearch("xml", "q=*", "count=100");
        int numOfResults = response.xmlPath().getList("metacards.metacard").size();
        String title = response.xmlPath().get("metacards.metacard.string.findAll { it.@name == 'title' }.value");
        boolean success = numOfResults == expectedResults && title.equals(expectedTitle);
        return success;
    });
}
Also used : Response(com.jayway.restassured.response.Response)

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