use of org.talend.dataprep.api.dataset.DataSetMetadata in project data-prep by Talend.
the class DataSetServiceTest method shouldCopy.
@Test
public void shouldCopy() throws Exception {
// given
String originalId = createCSVDataSet(this.getClass().getResourceAsStream(T_SHIRT_100_CSV), "original");
// when
final Response response = //
given().queryParam("copyName", //
"copy").when().expect().statusCode(200).log().ifError().post("/datasets/{id}/copy", originalId);
// then
assertEquals(200, response.getStatusCode());
final String copyId = response.asString();
final DataSetMetadata copy = dataSetMetadataRepository.get(copyId);
assertNotNull(copy);
assertEquals(9, copy.getRowMetadata().size());
}
use of org.talend.dataprep.api.dataset.DataSetMetadata in project data-prep by Talend.
the class DataSetServiceTest method getEmptyMetadata.
@Test
public void getEmptyMetadata() throws Exception {
DataSetMetadata metadata = dataSetMetadataRepository.get("9876");
assertNull(metadata);
int statusCode = when().get("/datasets/{id}/metadata", "9876").statusCode();
assertThat(statusCode, is(HttpStatus.NOT_FOUND.value()));
}
use of org.talend.dataprep.api.dataset.DataSetMetadata in project data-prep by Talend.
the class DataSetServiceTest method compatibleDatasetsListNameSort.
@Test
public void compatibleDatasetsListNameSort() throws Exception {
String dataSetId = createCSVDataSet(this.getClass().getResourceAsStream(TAGADA_CSV), "ds-16");
String dataSetId2 = createCSVDataSet(this.getClass().getResourceAsStream(TAGADA_CSV), "ds-15");
String dataSetId3 = createCSVDataSet(this.getClass().getResourceAsStream(TAGADA_CSV), "ds-14");
DataSetMetadata metadata1 = dataSetMetadataRepository.get(dataSetId);
metadata1.setName("CCCC");
dataSetMetadataRepository.save(metadata1);
DataSetMetadata metadata2 = dataSetMetadataRepository.get(dataSetId2);
metadata2.setName("BBBB");
dataSetMetadataRepository.save(metadata2);
DataSetMetadata metadata3 = dataSetMetadataRepository.get(dataSetId3);
metadata3.setName("AAAA");
dataSetMetadataRepository.save(metadata3);
// when
final String actual = when().get("/datasets/{id}/compatibledatasets?sort=name", dataSetId).asString();
// Ensure order by name (most recent first)
final Iterator<JsonNode> elements = mapper.readTree(actual).elements();
String[] expectedNames = new String[] { "BBBB", "AAAA" };
int i = 0;
while (elements.hasNext()) {
assertThat(elements.next().get("name").asText(), is(expectedNames[i++]));
}
}
use of org.talend.dataprep.api.dataset.DataSetMetadata in project data-prep by Talend.
the class DataSetServiceTest method listDateSort.
@Test
public void listDateSort() throws Exception {
when().get("/datasets?sort=creationDate").then().statusCode(OK.value()).body(equalTo("[]"));
// Adds 2 data set metadata to store
String id1 = UUID.randomUUID().toString();
final DataSetMetadata metadata1 = metadataBuilder.metadata().id(id1).name("AAAA").author("anonymous").created(20).formatFamilyId(new CSVFormatFamily().getBeanId()).build();
dataSetMetadataRepository.save(metadata1);
String id2 = UUID.randomUUID().toString();
final DataSetMetadata metadata2 = metadataBuilder.metadata().id(id2).name("BBBB").author("anonymous").created(0).formatFamilyId(new CSVFormatFamily().getBeanId()).build();
dataSetMetadataRepository.save(metadata2);
// Ensure order by date (most recent first)
String actual = when().get("/datasets?sort=creationDate").asString();
final Iterator<JsonNode> elements = mapper.readTree(actual).elements();
String[] expectedNames = new String[] { "AAAA", "BBBB" };
int i = 0;
while (elements.hasNext()) {
assertThat(elements.next().get("name").asText(), is(expectedNames[i++]));
}
}
use of org.talend.dataprep.api.dataset.DataSetMetadata in project data-prep by Talend.
the class DataSetServiceTest method test_TDP_2052.
@Test
public void test_TDP_2052() throws Exception {
// given
String dataSetId = UUID.randomUUID().toString();
DataSetMetadata dataSetMetadata = metadataBuilder.metadata().id(dataSetId).build();
dataSetMetadataRepository.save(dataSetMetadata);
given().body(IOUtils.toString(this.getClass().getResourceAsStream(TAGADA_CSV), UTF_8)).when().put("/datasets/{id}/raw?name=original", dataSetId).then().statusCode(OK.value());
String datasets = when().get("/datasets").asString();
List<DataSetMetadata> datasetsMetadata = mapper.readValue(datasets, new TypeReference<ArrayList<DataSetMetadata>>() {
});
final DataSetMetadata original = datasetsMetadata.get(0);
// when
given().body(IOUtils.toString(this.getClass().getResourceAsStream(TAGADA2_CSV), UTF_8)).when().put("/datasets/{id}/raw?name=", dataSetId).then().statusCode(OK.value());
// then
datasets = when().get("/datasets").asString();
datasetsMetadata = mapper.readValue(datasets, new TypeReference<ArrayList<DataSetMetadata>>() {
});
final DataSetMetadata copy = datasetsMetadata.get(0);
assertThat(copy.getId(), equalTo(original.getId()));
assertThat(copy.getName(), equalTo(original.getName()));
}
Aggregations