use of org.talend.dataprep.api.preparation.Preparation in project data-prep by Talend.
the class FileSystemPreparationRepositoryTest method shouldListOnlyPreparationsExactlyMatchingGivenName.
@Test
public void shouldListOnlyPreparationsExactlyMatchingGivenName() {
final List<Integer> ids = Arrays.asList(1, 12, 3);
// store preparations
final List<Preparation> preparations = //
ids.stream().map(//
i -> getPreparation(String.valueOf(i))).collect(Collectors.toList());
preparations.forEach(prep -> repository.add(prep));
// and some steps to add some noise
//
ids.stream().map(i -> new Step(Step.ROOT_STEP.id(), "step" + i, versionService.version().getVersionId())).forEach(step -> repository.add(step));
// get some preparation by dataset id
final Preparation expected = preparations.get(0);
final Collection<Preparation> actual = repository.list(Preparation.class, eq("name", "prep-1")).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 getPreparation.
/**
* @param datasetId the preparation id.
* @return a preparation with a root step an a the given dataset id.
*/
@Override
protected Preparation getPreparation(String datasetId) {
Preparation preparation = new Preparation(UUID.randomUUID().toString(), datasetId, Step.ROOT_STEP.id(), versionService.version().getVersionId());
preparation.setName("prep-" + datasetId);
return preparation;
}
use of org.talend.dataprep.api.preparation.Preparation in project data-prep by Talend.
the class FileSystemPreparationRepositoryTest method shouldListOnlyPreparationsContainingGivenName.
@Test
public void shouldListOnlyPreparationsContainingGivenName() {
final List<Integer> ids = Arrays.asList(1, 12, 3);
// store preparations
final List<Preparation> preparations = //
ids.stream().map(//
i -> getPreparation(String.valueOf(i))).collect(Collectors.toList());
preparations.forEach(prep -> repository.add(prep));
// and some steps to add some noise
//
ids.stream().map(i -> new Step(Step.ROOT_STEP.id(), "step" + i, versionService.version().getVersionId())).forEach(step -> repository.add(step));
// get some preparation by dataset id
final Preparation expected1 = preparations.get(0);
final Preparation expected2 = preparations.get(1);
final Collection<Preparation> actual = repository.list(Preparation.class, contains("name", "1")).collect(Collectors.toList());
assertEquals(2, actual.size());
assertTrue(actual.contains(expected1));
assertTrue(actual.contains(expected2));
}
use of org.talend.dataprep.api.preparation.Preparation in project data-prep by Talend.
the class InMemoryPreparationRepositoryTest method getByDataSetTest.
/**
* Test the getByDataSet method.
*/
@Test
public void getByDataSetTest() {
// populate repository with noise (steps and preparations to be ignored)
repository.add(getStep("s1"));
repository.add(getStep("s2"));
repository.add(getStep("s3"));
repository.add(getStep("s4"));
repository.add(getStep("s5"));
repository.add(getPreparation("p1"));
repository.add(getPreparation("p2"));
repository.add(getPreparation("p3"));
repository.add(getPreparation("p4"));
repository.add(getPreparation("p5"));
// add relevant data
String dataSetId = "wantedId";
Collection<Preparation> expected = Arrays.asList(getPreparation(dataSetId, "10"), getPreparation(dataSetId, "11"), getPreparation(dataSetId, "12"));
for (Preparation preparation : expected) {
repository.add(preparation);
}
// run the test
Collection<Preparation> actual = getRepository().list(Preparation.class, eq("dataSetId", dataSetId)).collect(Collectors.toList());
// check the result
Assert.assertEquals(3, actual.size());
for (Preparation preparation : expected) {
Assert.assertTrue(actual.contains(preparation));
}
}
use of org.talend.dataprep.api.preparation.Preparation in project data-prep by Talend.
the class FolderServiceTest method searchFolderShouldUpdateNbPreparationsFound.
@Test
public void searchFolderShouldUpdateNbPreparationsFound() throws Exception {
// given
createFolder(home.getId(), "foo");
final Folder foo = getFolder(home.getId(), "foo");
Preparation preparation = new Preparation();
preparation.setName("test_name");
preparation.setDataSetId("1234");
preparation.setRowMetadata(new RowMetadata());
clientTest.createPreparation(preparation, foo.getId());
// when
final Response response = //
given().queryParam("name", //
"foo").expect().statusCode(200).log().ifError().when().get("/folders/search");
// then
final List<Folder> folders = mapper.readValue(response.asString(), new TypeReference<List<Folder>>() {
});
assertThat(folders, hasSize(1));
final Folder folder = folders.get(0);
assertThat(folder.getName(), is("foo"));
assertEquals(1, folder.getNbPreparations());
}
Aggregations