use of org.talend.dataprep.api.preparation.Preparation 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.preparation.Preparation in project data-prep by Talend.
the class PreparationRepositoryTest method findOneByDataset_should_return_a_preparation_that_use_dataset.
@Test
public void findOneByDataset_should_return_a_preparation_that_use_dataset() {
// given
final String dataSetId = "789b61f3128a9bc24a684";
final Preparation prep1 = new Preparation();
prep1.setDataSetId("other_dataset");
final Preparation prep2 = new Preparation();
prep2.setDataSetId(dataSetId);
getRepository().add(prep1);
getRepository().add(prep2);
// when
final boolean result = getRepository().exist(Preparation.class, eq("dataSetId", dataSetId));
// then
assertThat(result, is(true));
}
use of org.talend.dataprep.api.preparation.Preparation in project data-prep by Talend.
the class PreparationRepositoryTest method shouldListOnlyPreparationsForDatasets.
@Test
public void shouldListOnlyPreparationsForDatasets() {
List<Integer> ids = Arrays.asList(1, 2, 3);
// store preparations
final List<Preparation> preparations = //
ids.stream().map(//
i -> getPreparation(String.valueOf(i))).collect(Collectors.toList());
preparations.forEach(prep -> getRepository().add(prep));
// get preparation by name
final Preparation expected = preparations.get(1);
final Collection<Preparation> actual = getRepository().list(Preparation.class, eq("dataSetId", expected.getDataSetId())).collect(Collectors.toList());
assertEquals(1, actual.size());
assertTrue(actual.contains(expected));
}
use of org.talend.dataprep.api.preparation.Preparation in project data-prep by Talend.
the class FileSystemPreparationRepositoryTest method shouldRemove.
@Test
public void shouldRemove() {
final Preparation preparation = getPreparation("id#8486343");
repository.add(preparation);
repository.remove(preparation);
assertNull(repository.get(preparation.id(), Preparation.class));
}
use of org.talend.dataprep.api.preparation.Preparation in project data-prep by Talend.
the class FileSystemPreparationRepositoryTest method shouldOverwriteContent.
@Test
public void shouldOverwriteContent() {
Preparation expected = getPreparation("khdgf");
expected.setName("old name");
repository.add(expected);
expected.setName("new name");
repository.add(expected);
final Preparation actual = repository.get(expected.id(), Preparation.class);
assertEquals(expected, actual);
}
Aggregations