use of org.talend.dataprep.api.folder.Folder in project data-prep by Talend.
the class PreparationControllerTest method shouldCopy.
@Test
public void shouldCopy() throws Exception {
// given
final Folder fromFolder = folderRepository.addFolder(home.getId(), "from");
final Folder toFolder = folderRepository.addFolder(home.getId(), "to");
final String originalId = clientTest.createPreparation(createTestPreparation("test_name", "1234"), fromFolder.getId()).getId();
// Change the author, to make it different from system user.
repository.get(originalId, Preparation.class).setAuthor("tagada");
// when
final Response response = //
given().queryParam("name", //
"the new preparation").queryParam("destination", //
toFolder.getId()).when().expect().statusCode(200).log().ifError().post("/preparations/{id}/copy", originalId);
final String copyId = response.asString();
// then
assertThat(response.getStatusCode(), is(200));
assertThatPreparationIsFirstInsideFolder(copyId, toFolder.getId());
assertEquals("the new preparation", repository.get(copyId, Preparation.class).getName());
// Assert that the author is the system user, and not the original author of the prep:
assertEquals(System.getProperty("user.name"), repository.get(copyId, Preparation.class).getAuthor());
// row metadata its nullity after copy caused https://jira.talendforge.org/browse/TDP-3379
assertNotNull(repository.get(copyId, Preparation.class).getRowMetadata());
}
use of org.talend.dataprep.api.folder.Folder in project data-prep by Talend.
the class PreparationControllerTest method cannotMovePreparationIfTargetPathAndNameExists.
@Test
public void cannotMovePreparationIfTargetPathAndNameExists() throws Exception {
// given
final Folder fromFolder = folderRepository.addFolder(home.getId(), "from");
final Folder toFolder = folderRepository.addFolder(home.getId(), "to");
final String name = "super preparation";
final String preparationId = clientTest.createPreparation(createTestPreparation("another preparation", "7535"), fromFolder.getId()).getId();
clientTest.createPreparation(createTestPreparation(name, "7384"), toFolder.getId());
// when
final Response response = //
given().queryParam("folder", //
fromFolder.getId()).queryParam("destination", //
toFolder.getId()).queryParam("newName", //
name).when().expect().statusCode(409).log().ifError().put("/preparations/{id}/move", preparationId);
// then
assertThat(response.getStatusCode(), is(409));
}
use of org.talend.dataprep.api.folder.Folder in project data-prep by Talend.
the class PreparationControllerTest method cannotMovePreparationThatDoesntExist.
@Test
public void cannotMovePreparationThatDoesntExist() throws Exception {
// given
final Folder fromFolder = folderRepository.addFolder(home.getId(), "from");
final Folder toFolder = folderRepository.addFolder(home.getId(), "to");
// when
final Response response = //
given().queryParam("newName", //
"moved preparation").queryParam("folder", //
fromFolder.getId()).queryParam("destination", //
toFolder.getId()).when().expect().statusCode(404).log().ifError().put("/preparations/{id}/move", "ABC123XYZ");
// then
assertThat(response.getStatusCode(), is(404));
}
use of org.talend.dataprep.api.folder.Folder in project data-prep by Talend.
the class PreparationControllerTest method shouldMoveWithDefaultParameters.
@Test
public void shouldMoveWithDefaultParameters() throws Exception {
// given
final Folder fromFolder = folderRepository.addFolder(home.getId(), "from");
final Folder toFolder = folderRepository.addFolder(home.getId(), "to");
final String originalId = clientTest.createPreparation(createTestPreparation("yap", "7535"), fromFolder.getId()).getId();
// when
final Response response = //
given().queryParam("folder", //
fromFolder.getId()).queryParam("destination", //
toFolder.getId()).when().expect().statusCode(200).log().ifError().put("/preparations/{id}/move", originalId);
// then
assertThat(response.getStatusCode(), is(200));
assertThatPreparationIsFirstInsideFolder(originalId, toFolder.getId());
assertEquals("yap", repository.get(originalId, Preparation.class).getName());
}
use of org.talend.dataprep.api.folder.Folder in project data-prep by Talend.
the class PreparationServiceTest method init.
private void init() throws IOException {
createFolder(home.getId(), "foo");
final Folder foo = getFolder(home.getId(), "foo");
createFolder(home.getId(), "Folder Cr((eate Email A!ddressrrrbb[zzzz (copie-é'(-è_çà)+&.csv");
final Folder specialChar = getFolder(home.getId(), "Folder Cr((eate Email A!ddressrrrbb[zzzz (copie-é'(-è_çà)+&.csv");
Preparation preparation = new Preparation();
preparation.setName("prep_name_foo");
preparation.setDataSetId("1234");
preparation.setRowMetadata(new RowMetadata());
clientTest.createPreparation(preparation, foo.getId());
preparation.setName("prep_name_home");
clientTest.createPreparation(preparation, home.getId());
preparation.setName("Cr((eate Email A!ddressrrrbb[zzzz (copie-é'(-è_çà)+&.csv");
clientTest.createPreparation(preparation, foo.getId());
preparation.setName("Cr((eate Email A!ddressrrrbb[zzzz (copie-é'(-è_çà)+&.csv");
clientTest.createPreparation(preparation, specialChar.getId());
}
Aggregations