use of org.talend.dataprep.api.folder.FolderEntry in project data-prep by Talend.
the class FileSystemUtils method readEntryFromStream.
private static FolderEntry readEntryFromStream(InputStream inputStream) throws IOException {
// use java Properties to save the files
Properties properties = new Properties();
properties.load(inputStream);
FolderEntry folderEntry = new FolderEntry();
folderEntry.setContentId(properties.getProperty(CONTENT_ID));
folderEntry.setContentType(FolderContentType.fromName(properties.getProperty(CONTENT_TYPE)));
folderEntry.setFolderId(properties.getProperty(FOLDER_ID));
return folderEntry;
}
use of org.talend.dataprep.api.folder.FolderEntry in project data-prep by Talend.
the class FolderAPITest method should_return_conflict_on_non_empty_folder_remove.
@Test
public void should_return_conflict_on_non_empty_folder_remove() throws IOException {
// given
createFolder("beer", home.getId());
final Folder beer = getFolder(home.getId(), "beer");
final FolderEntry folderEntry = new FolderEntry(DATASET, "6f8a54051bc454");
createFolderEntry(folderEntry, beer.getId());
// when
final Response response = removeFolder(beer.getId());
// then
assertThat(response.getStatusCode(), is(409));
final String content = response.asString();
assertTrue(StringUtils.isNoneBlank(content));
assertTrue(content.contains(FolderErrorCodes.FOLDER_NOT_EMPTY.name()));
final List<Folder> folders = getFolderChildren(home.getId());
assertThat(folders, hasSize(1));
}
use of org.talend.dataprep.api.folder.FolderEntry in project data-prep by Talend.
the class PreparationAPITest method shouldCreatePreparationInSpecificFolder.
@Test
public void shouldCreatePreparationInSpecificFolder() throws Exception {
// given
final String path = "/folder-1/sub-folder-2";
Folder folder = folderRepository.addFolder(folderRepository.getHome().getId(), path);
List<FolderEntry> entries = getEntries(folder.getId());
assertThat(entries.size(), is(0));
// when
final String preparationId = testClient.createPreparationFromFile("dataset/dataset.csv", "testCreatePreparation", folder.getId());
// then
entries = getEntries(folder.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.FolderEntry in project data-prep by Talend.
the class PreparationAPITest method shouldMovePreparation.
@Test
public void shouldMovePreparation() throws Exception {
// given
final Folder source = folderRepository.addFolder(home.getId(), "source");
final String id = testClient.createPreparationFromFile("dataset/dataset.csv", "great_preparation", source.getId());
final Folder destination = folderRepository.addFolder(home.getId(), "destination");
// when
final Response response = //
given().queryParam("folder", //
source.getId()).queryParam("destination", //
destination.getId()).queryParam("newName", //
"NEW great preparation").when().expect().statusCode(200).log().ifError().put("api/preparations/{id}/move", id);
// then
assertEquals(200, response.getStatusCode());
// 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(), id);
// check the name
final Preparation actual = preparationRepository.get(id, Preparation.class);
assertEquals("NEW great preparation", actual.getName());
}
use of org.talend.dataprep.api.folder.FolderEntry in project data-prep by Talend.
the class AbstractFolderTest method shouldLocateEntry.
@Test
public void shouldLocateEntry() throws Exception {
// given (root & 2 entries)
final Folder root = getFolderRepository().getHome();
final FolderEntry littleCreatures = new FolderEntry(DATASET, "littleCreatures");
getFolderRepository().addFolderEntry(littleCreatures, root.getId());
final FolderEntry bordeaux = new FolderEntry(PREPARATION, "bordeaux");
getFolderRepository().addFolderEntry(bordeaux, root.getId());
// given (foo & 2 entries)
final Folder foo = getFolderRepository().addFolder(homeFolderId, "foo");
final FolderEntry cars = new FolderEntry(DATASET, "cars");
getFolderRepository().addFolderEntry(cars, foo.getId());
final FolderEntry boats = new FolderEntry(PREPARATION, "boats");
getFolderRepository().addFolderEntry(boats, foo.getId());
// add some noise
getFolderRepository().addFolder(foo.getId(), "bar");
getFolderRepository().addFolder(homeFolderId, "hello");
// then
assertNull(getFolderRepository().locateEntry(pathToId("not to be found"), PREPARATION));
assertEquals(root.getId(), getFolderRepository().locateEntry(bordeaux.getContentId(), bordeaux.getContentType()).getId());
assertEquals(root.getId(), getFolderRepository().locateEntry(littleCreatures.getContentId(), littleCreatures.getContentType()).getId());
assertEquals(foo.getId(), getFolderRepository().locateEntry(cars.getContentId(), cars.getContentType()).getId());
assertEquals(foo.getId(), getFolderRepository().locateEntry(boats.getContentId(), boats.getContentType()).getId());
}
Aggregations