Search in sources :

Example 26 with Folder

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());
}
Also used : Response(com.jayway.restassured.response.Response) Folder(org.talend.dataprep.api.folder.Folder) BasePreparationTest(org.talend.dataprep.preparation.BasePreparationTest) Test(org.junit.Test)

Example 27 with Folder

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));
}
Also used : Response(com.jayway.restassured.response.Response) Folder(org.talend.dataprep.api.folder.Folder) BasePreparationTest(org.talend.dataprep.preparation.BasePreparationTest) Test(org.junit.Test)

Example 28 with Folder

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));
}
Also used : Response(com.jayway.restassured.response.Response) Folder(org.talend.dataprep.api.folder.Folder) BasePreparationTest(org.talend.dataprep.preparation.BasePreparationTest) Test(org.junit.Test)

Example 29 with Folder

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());
}
Also used : Response(com.jayway.restassured.response.Response) Folder(org.talend.dataprep.api.folder.Folder) BasePreparationTest(org.talend.dataprep.preparation.BasePreparationTest) Test(org.junit.Test)

Example 30 with Folder

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());
}
Also used : Preparation(org.talend.dataprep.api.preparation.Preparation) RowMetadata(org.talend.dataprep.api.dataset.RowMetadata) Folder(org.talend.dataprep.api.folder.Folder)

Aggregations

Folder (org.talend.dataprep.api.folder.Folder)69 Test (org.junit.Test)36 Response (com.jayway.restassured.response.Response)25 BasePreparationTest (org.talend.dataprep.preparation.BasePreparationTest)21 ServiceBaseTest (org.talend.ServiceBaseTest)17 FolderEntry (org.talend.dataprep.api.folder.FolderEntry)16 TDPException (org.talend.dataprep.exception.TDPException)9 Collectors.toList (java.util.stream.Collectors.toList)7 List (java.util.List)6 Preparation (org.talend.dataprep.api.preparation.Preparation)6 DataSetMetadata (org.talend.dataprep.api.dataset.DataSetMetadata)5 RowMetadata (org.talend.dataprep.api.dataset.RowMetadata)5 FolderInfo (org.talend.dataprep.api.folder.FolderInfo)5 EnrichedPreparation (org.talend.dataprep.api.service.api.EnrichedPreparation)5 Stream (java.util.stream.Stream)4 Autowired (org.springframework.beans.factory.annotation.Autowired)4 PREPARATION (org.talend.dataprep.api.folder.FolderContentType.PREPARATION)4 ApiOperation (io.swagger.annotations.ApiOperation)3 IOException (java.io.IOException)3 InputStream (java.io.InputStream)3