use of com.jayway.restassured.path.json.JsonPath in project data-prep by Talend.
the class PreparationAPITest method testPreparationsList_withFilterOnName.
@Test
public void testPreparationsList_withFilterOnName() throws Exception {
// given
String tagadaId = testClient.createDataset("dataset/dataset.csv", "tagada");
String preparationId = testClient.createPreparationFromDataset(tagadaId, "testPreparation", home.getId());
// when : short format
final JsonPath shortFormat = when().get("/api/preparations/?format=short&name={name}", "testPreparation").jsonPath();
// then
final List<String> values = shortFormat.getList("id");
assertThat(values.get(0), is(preparationId));
}
use of com.jayway.restassured.path.json.JsonPath in project data-prep by Talend.
the class PreparationAPITest method testPreparationsList.
@Test
public void testPreparationsList() throws Exception {
// given
String tagadaId = testClient.createDataset("dataset/dataset.csv", "tagada");
String preparationId = testClient.createPreparationFromDataset(tagadaId, "testPreparation", home.getId());
// when : short format
final JsonPath shortFormat = when().get("/api/preparations/?format=short").jsonPath();
// then
final List<String> values = shortFormat.getList("id");
assertThat(values.get(0), is(preparationId));
// when : long format
Response response1 = when().get("/api/preparations/?format=long");
// then
List<PreparationListItemDTO> preparations = mapper.readerFor(PreparationListItemDTO.class).<PreparationListItemDTO>readValues(response1.asInputStream()).readAll();
assertEquals(1, preparations.size());
PreparationListItemDTO userPreparation = preparations.iterator().next();
assertThat(userPreparation.getDataSet().getDataSetName(), is("tagada"));
assertThat(userPreparation.getId(), is(preparationId));
// when : summary format
Response response = when().get("/api/preparations/?format=summary");
// then
List<PreparationListItemDTO> preparationSummaries = mapper.readerFor(PreparationListItemDTO.class).<PreparationListItemDTO>readValues(response.asInputStream()).readAll();
assertEquals(1, preparationSummaries.size());
PreparationListItemDTO preparationSummary = preparationSummaries.iterator().next();
assertThat(preparationSummary.getId(), is(preparationId));
assertThat(preparationSummary.getName(), is("testPreparation"));
assertThat(preparationSummary.getLastModificationDate(), is(notNullValue()));
}
use of com.jayway.restassured.path.json.JsonPath in project data-prep by Talend.
the class PreparationAPITest method testPreparationGet.
@Test
public void testPreparationGet() throws Exception {
// when
final String datasetId = testClient.createDataset("dataset/dataset.csv", "great dataset");
final String preparationId = testClient.createPreparationFromDataset(datasetId, "1234", home.getId());
// then
final JsonPath longFormat = given().get("/api/preparations/{id}/details", preparationId).jsonPath();
assertThat(longFormat.getString("dataSetId"), is(datasetId));
assertThat(longFormat.getString("author"), is(security.getUserId()));
assertThat(longFormat.getString("id"), is(preparationId));
assertThat(longFormat.getList("actions").size(), is(0));
assertThat(longFormat.getString("allowFullRun"), is("false"));
// make sure the "steps" node is a string array
final List<String> steps = longFormat.getList("steps");
assertThat(steps.size(), is(1));
}
use of com.jayway.restassured.path.json.JsonPath in project data-prep by Talend.
the class PreparationAPITest method testPreparationsList_withFilterOnFolderPath.
@Test
public void testPreparationsList_withFilterOnFolderPath() throws Exception {
// given
String tagadaId = testClient.createDataset("dataset/dataset.csv", "tagada");
String preparationName = "tagadaPreparation";
String preparationId = testClient.createPreparationFromDataset(tagadaId, preparationName, home.getId());
// when : short format
final Response shouldNotBeEmpty = when().get("/api/preparations/?format=short&folder_path={folder_path}", "/");
// then
List<PreparationDTO> result = //
mapper.readerFor(//
PreparationDTO.class).<PreparationDTO>readValues(//
shouldNotBeEmpty.asInputStream()).readAll();
assertThat(result.get(0).getId(), is(preparationId));
// when
final JsonPath shouldBeEmpty = when().get("/api/preparations/?format=short&folder_path={folder_path}", "/toto").jsonPath();
// then
assertThat(shouldBeEmpty.<String>getList("id"), is(empty()));
}
use of com.jayway.restassured.path.json.JsonPath in project data-prep by Talend.
the class DatasetStep method thenTheDataSetIsCreatedWithColumns.
@Then("^I check that the dataSet \"(.*)\" is created with the following columns :$")
public void thenTheDataSetIsCreatedWithColumns(String datasetName, List<String> columns) throws IOException {
Response response = api.getDataSetMetaData(context.getDatasetId(suffixName(datasetName)));
response.then().statusCode(OK.value());
final JsonPath jsonPath = response.body().jsonPath();
final List<String> actual = jsonPath.getList("columns.name", String.class);
checkColumnNames(datasetName, columns, actual);
}
Aggregations