use of org.talend.dataprep.api.folder.Folder in project data-prep by Talend.
the class PreparationAPITest method shouldCreatePreparationInDefaultFolder.
// ------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------CONTENT------------------------------------------------------
// -------------------------------------------------------------------------------------------------------------------
@Test
public void shouldCreatePreparationInDefaultFolder() throws Exception {
// given
Folder home = folderRepository.getHome();
List<FolderEntry> entries = getEntries(home.getId());
assertTrue(entries.isEmpty());
// when
final String preparationId = testClient.createPreparationFromFile("dataset/dataset.csv", "testCreatePreparation", home.getId());
// then
entries = getEntries(home.getId());
assertThat(entries.size(), is(1));
final FolderEntry entry = entries.get(0);
assertThat(entry.getContentId(), is(preparationId));
assertThat(entry.getContentType(), is(PREPARATION));
}
use of org.talend.dataprep.api.folder.Folder in project data-prep by Talend.
the class PreparationAPITest method shouldCopyPreparation.
@Test
public void shouldCopyPreparation() throws Exception {
// given
Folder destination = folderRepository.addFolder(home.getId(), "/destination");
Folder origin = folderRepository.addFolder(home.getId(), "/from");
final String preparationId = testClient.createPreparationFromFile("dataset/dataset.csv", "super preparation", origin.getId());
// when
String newPreparationName = "NEW super preparation";
final Response response = //
given().queryParam("destination", //
destination.getId()).queryParam("newName", //
newPreparationName).when().expect().statusCode(200).log().ifError().post("api/preparations/{id}/copy", preparationId);
// then
assertEquals(200, response.getStatusCode());
String copyId = response.asString();
// check the folder entry
final List<FolderEntry> entries = getEntries(destination.getId());
assertThat(entries.size(), greaterThan(0));
final FolderEntry entry = entries.get(0);
assertEquals(entry.getContentId(), copyId);
// check the name
final Preparation actual = preparationRepository.get(copyId, Preparation.class);
assertEquals(newPreparationName, actual.getName());
}
use of org.talend.dataprep.api.folder.Folder in project data-prep by Talend.
the class PreparationAPITest method shouldNotAcceptPreparationWithoutRowMetadata.
@Test
public void shouldNotAcceptPreparationWithoutRowMetadata() throws Exception {
// given
Folder home = folderRepository.getHome();
final List<FolderEntry> entries = getEntries(home.getId());
assertThat(entries.size(), is(0));
String dataSetId = testClient.createDataset("dataset/dataset.csv", "testCreatePreparation");
final Response response = //
given().contentType(//
ContentType.JSON).body("{ \"name\": \"" + "my_preparation" + "\", \"dataSetId\": \"" + dataSetId + "\"}").queryParam("folder", //
home.getId()).when().expect().statusCode(200).log().ifError().post("/api/preparations");
}
use of org.talend.dataprep.api.folder.Folder in project data-prep by Talend.
the class APIPreparationConversionsTest method getFolder.
private Folder getFolder(String name) {
final Folder folder = new Folder();
folder.setId(UUID.randomUUID().toString());
folder.setName(name);
return folder;
}
use of org.talend.dataprep.api.folder.Folder in project data-prep by Talend.
the class APIPreparationConversionsTest method shouldEnrichPreparationWithDataset.
@Test
public void shouldEnrichPreparationWithDataset() {
// given
DataSetMetadata metadata = getDataSetMetadata("super dataset", 1001L);
setupHystrixCommand(DataSetGetMetadata.class, metadata);
final PreparationMessage preparation = getPreparationMessage(metadata.getId());
Folder folder = getFolder("F-753854");
setupHystrixCommand(LocatePreparation.class, folder);
// when
final EnrichedPreparation actual = conversionService.convert(preparation, EnrichedPreparation.class);
// then
assertEquals(metadata.getId(), actual.getSummary().getDataSetId());
assertEquals(metadata.getName(), actual.getSummary().getDataSetName());
assertEquals(metadata.getContent().getNbRecords(), actual.getSummary().getDataSetNbRow());
final List<String> expectedSteps = preparation.getSteps().stream().map(Step::getId).collect(Collectors.toList());
final List<String> actualSteps = actual.getSteps();
assertNotNull(actualSteps);
assertEquals(expectedSteps.size(), expectedSteps.size());
expectedSteps.forEach(s -> assertTrue(actualSteps.contains(s)));
assertEquals(folder, actual.getFolder());
}
Aggregations