use of io.restassured.response.ValidatableResponse in project molgenis by molgenis.
the class RestControllerV2APIIT method testGetI18nStrings.
@Test
public void testGetI18nStrings() {
ValidatableResponse response = given().log().all().header(X_MOLGENIS_TOKEN, testUserToken).get(API_V2 + "i18n").then().log().all();
validateGetI18nStrings(response);
}
use of io.restassured.response.ValidatableResponse in project molgenis by molgenis.
the class RestControllerV2APIIT method testRetrieveEntityExcludingCategoriesResultsInNoCategoricalOptions.
@Test
public void testRetrieveEntityExcludingCategoriesResultsInNoCategoricalOptions() {
ValidatableResponse response = given().log().all().header(X_MOLGENIS_TOKEN, testUserToken).param("includeCategories", newArrayList("false")).param("attrs", newArrayList("xcategorical_value")).get(API_V2 + "V2_API_TypeTestAPIV2/1").then().log().all();
response.statusCode(OKE);
response.body("_meta.attributes[0].categoricalOptions", Matchers.nullValue());
}
use of io.restassured.response.ValidatableResponse in project molgenis by molgenis.
the class RestControllerV2APIIT method testRetrieveEntityWithAttributeFilter.
@Test
public void testRetrieveEntityWithAttributeFilter() {
ValidatableResponse response = given().log().all().header(X_MOLGENIS_TOKEN, testUserToken).param("attrs", newArrayList("label")).get(API_V2 + "V2_API_TypeTestRefAPIV2/ref1").then().log().all();
validateRetrieveEntityWithAttributeFilter(response);
}
use of io.restassured.response.ValidatableResponse in project molgenis by molgenis.
the class RestControllerV2APIIT method testRetrieveEntity.
@Test
public void testRetrieveEntity() {
ValidatableResponse response = given().log().all().header(X_MOLGENIS_TOKEN, testUserToken).get(API_V2 + "V2_API_TypeTestRefAPIV2/ref1").then().log().all();
validateRetrieveEntityWithoutAttributeFilter(response);
}
use of io.restassured.response.ValidatableResponse in project molgenis by molgenis.
the class OneClickImporterControllerAPIIT method oneClickImportTest.
private void oneClickImportTest(String fileToImport) throws URISyntaxException, IOException {
URL resourceUrl = getResource(RestControllerV2APIIT.class, fileToImport);
File file = new File(new URI(resourceUrl.toString()).getPath());
// Post the file to be imported
ValidatableResponse response = given().log().all().header(X_MOLGENIS_TOKEN, testUserToken).multiPart(file).post(OneClickImporterController.URI + "/upload").then().log().all().statusCode(OKE);
// Verify the post returns a job url
String jobUrl = ((ValidatableResponseImpl) response).originalResponse().asString();
assertTrue(jobUrl.startsWith("/api/v2/sys_job_OneClickImportJobExecution/"));
String jobStatus = given().log().all().header(X_MOLGENIS_TOKEN, testUserToken).get(jobUrl).then().statusCode(OKE).extract().path("status");
List<String> validJobStats = Arrays.asList("PENDING", "RUNNING", "SUCCESS");
assertTrue(validJobStats.contains(jobStatus));
await().pollDelay(500, MILLISECONDS).atMost(3, MINUTES).until(() -> pollJobForStatus(jobUrl), not(is("PENDING")));
await().pollDelay(500, MILLISECONDS).atMost(10, SECONDS).until(() -> pollJobForStatus(jobUrl), is("SUCCESS"));
// Extract the id of the entity created by the import
ValidatableResponse completedJobResponse = given().log().all().header(X_MOLGENIS_TOKEN, testUserToken).get(jobUrl).then().statusCode(OKE);
JsonArray entityTypeId = new Gson().fromJson(completedJobResponse.extract().jsonPath().get("entityTypes").toString(), JsonArray.class);
String entityId = entityTypeId.get(0).getAsJsonObject().get("id").getAsString();
String packageName = completedJobResponse.extract().path("package");
String jobId = completedJobResponse.extract().path("identifier");
// Store to use during cleanup
importedEntities.add(entityId);
importPackages.add(packageName);
importJobIds.add(jobId);
// Get the entity value to check the import
ValidatableResponse entityResponse = given().log().all().header(X_MOLGENIS_TOKEN, testUserToken).get(API_V2 + entityId + "?attrs=~id,first_name,last_name,full_name,UMCG_employee,Age").then().log().all();
entityResponse.statusCode(OKE);
JSONAssert.assertEquals(Files.readFile(getClass().getResourceAsStream("users.json")), entityResponse.extract().body().asString(), false);
}
Aggregations