use of org.talend.dataprep.api.preparation.Preparation in project data-prep by Talend.
the class SearchAPITest method shouldReturnMatchingPreparationsWithSpaceWhenPerformingInventory.
@Test
public void shouldReturnMatchingPreparationsWithSpaceWhenPerformingInventory() throws IOException {
// given
final String preparationId = testClient.createPreparationFromFile("t-shirt_100.csv", "testInventory OfPreparations", folderRepository.getHome().getId());
// when
final Response response = //
given().queryParam("name", //
"Inventory ").expect().statusCode(200).log().ifError().get("/api/search");
// then
assertEquals(200, response.getStatusCode());
JsonNode rootNode = mapper.readTree(response.asInputStream());
JsonNode preparations = rootNode.get("preparations");
List<Preparation> preparationList = mapper.readValue(preparations.toString(), new TypeReference<List<Preparation>>() {
});
assertThat(preparationList.size(), is(1));
assertEquals("testInventory OfPreparations", preparationList.get(0).getName());
assertEquals(preparationId, preparationList.get(0).id());
}
use of org.talend.dataprep.api.preparation.Preparation in project data-prep by Talend.
the class SearchAPITest method shouldReturnMatchingPreparationsWhenPerformingInventory.
@Test
public void shouldReturnMatchingPreparationsWhenPerformingInventory() throws IOException {
// given
final String preparationId = testClient.createPreparationFromFile("t-shirt_100.csv", "testInventoryOfPreparations", folderRepository.getHome().getId());
// when
final Response response = //
given().queryParam("name", //
"Inventory").expect().statusCode(200).log().ifError().get("/api/search");
// then
assertEquals(200, response.getStatusCode());
JsonNode rootNode = mapper.readTree(response.asInputStream());
JsonNode preparations = rootNode.get("preparations");
List<Preparation> preparationList = mapper.readValue(preparations.toString(), new TypeReference<List<Preparation>>() {
});
assertThat(preparationList.size(), is(1));
assertEquals("testInventoryOfPreparations", preparationList.get(0).getName());
assertEquals(preparationId, preparationList.get(0).id());
}
use of org.talend.dataprep.api.preparation.Preparation in project data-prep by Talend.
the class TransformAPITest method testShouldEvictPreparationCacheOnDataSetUpdate.
@Test
public void testShouldEvictPreparationCacheOnDataSetUpdate() throws Exception {
// given
final String preparationId = testClient.createPreparationFromFile("dataset/dataset_TDP-2165.csv", "testDataset", home.getId());
testClient.applyAction(preparationId, IOUtils.toString(this.getClass().getResourceAsStream("transformation/TDP-2165.json"), UTF_8));
testClient.getPreparation(preparationId);
final Preparation preparation = preparationRepository.get(preparationId, Preparation.class);
final TransformationCacheKey transformationCacheKey = //
cacheKeyGenerator.generateContentKey(//
preparation.getDataSetId(), //
preparationId, //
preparation.getHeadId(), //
"JSON", //
HEAD, // no filter
"");
assertTrue(contentCache.has(transformationCacheKey));
// when
context.publishEvent(new DatasetUpdatedEvent(dataSetMetadataRepository.get(preparation.getDataSetId())));
// then
assertFalse(contentCache.has(transformationCacheKey));
}
use of org.talend.dataprep.api.preparation.Preparation in project data-prep by Talend.
the class PreparationRepositoryTest method findOneByDataset_should_return_null_when_no_preparation_use_dataset.
@Test
public void findOneByDataset_should_return_null_when_no_preparation_use_dataset() {
// given
final String dataSetId = "789b61f3128a9bc24a684";
final Preparation prep1 = new Preparation();
prep1.setDataSetId("other_dataset");
final Preparation prep2 = new Preparation();
prep2.setDataSetId("other_dataset");
getRepository().add(prep1);
getRepository().add(prep2);
// when
final boolean result = getRepository().exist(Preparation.class, eq("dataSetId", dataSetId));
// then
assertThat(result, is(false));
}
use of org.talend.dataprep.api.preparation.Preparation in project data-prep by Talend.
the class FileSystemPreparationRepositoryTest method shouldGetPreparationThatWasAdded.
@Test
public void shouldGetPreparationThatWasAdded() throws JsonProcessingException {
// given
Preparation expected = getPreparation("7561486");
repository.add(expected);
// when
final Preparation actual = repository.get(expected.id(), Preparation.class);
// then
assertEquals(expected, actual);
}
Aggregations