use of org.talend.dataprep.api.preparation.Preparation 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());
}
use of org.talend.dataprep.api.preparation.Preparation in project data-prep by Talend.
the class PreparationClientTest method addStep.
/**
* Append an action to a preparation.
*
* @param preparationId The preparation id.
* @param stepContent The step content json.
* @return The created stepContent id.
*/
public String addStep(final String preparationId, final String stepContent) throws IOException {
final Response post = //
given().body(stepContent).contentType(//
JSON).when().post("/preparations/{id}/actions", preparationId);
assertEquals("fail to add step : " + post.statusLine(), 200, post.statusCode());
final Preparation preparation = preparationRepository.get(preparationId, Preparation.class);
return preparation.getHeadId();
}
use of org.talend.dataprep.api.preparation.Preparation in project data-prep by Talend.
the class TransformationService method getPreparation.
/**
* Get the preparation from the preparation service.
*
* @param preparationId the wanted preparation id.
* @return the preparation from the preparation service.
*/
private Preparation getPreparation(@ApiParam(value = "The preparation id") @PathVariable String preparationId) {
final Preparation preparation;
try {
final PreparationDetailsGet details = applicationContext.getBean(PreparationDetailsGet.class, preparationId);
preparation = mapper.readerFor(Preparation.class).readValue(details.execute());
} catch (IOException e) {
throw new TDPException(PREPARATION_DOES_NOT_EXIST, e, build().put("id", preparationId));
}
return preparation;
}
use of org.talend.dataprep.api.preparation.Preparation in project data-prep by Talend.
the class TransformationServiceTest method testCache.
@Test
public void testCache() throws Exception {
// given
String dsId = createDataset("input_dataset.csv", "uppercase", "text/csv");
String prepId = createEmptyPreparationFromDataset(dsId, "uppercase prep");
applyActionFromFile(prepId, "uppercase_action.json");
final Preparation preparation = getPreparation(prepId);
final String headId = preparation.getHeadId();
final TransformationCacheKey key = //
cacheKeyGenerator.generateContentKey(//
dsId, //
preparation.getId(), //
headId, //
JSON, //
HEAD, // no filter
"");
assertFalse(contentCache.has(key));
// when
//
given().expect().statusCode(200).log().ifError().when().get("/apply/preparation/{prepId}/dataset/{datasetId}/{format}", prepId, dsId, //
"JSON").asString();
// then
assertTrue(contentCache.has(key));
// just to pass through the cache
final Response response = //
given().expect().statusCode(200).log().ifError().when().get("/apply/preparation/{prepId}/dataset/{datasetId}/{format}", prepId, dsId, "JSON");
Assert.assertThat(response.getStatusCode(), is(200));
}
use of org.talend.dataprep.api.preparation.Preparation in project data-prep by Talend.
the class OptimizedExportStrategyTest method testAcceptOK.
@Test
public void testAcceptOK() throws Exception {
// Given
final String datasetId = "1234";
final String format = "";
final String preparation = createEmptyPreparationFromDataset(datasetId, "test");
applyAction(preparation, "[{}]");
applyAction(preparation, "[{}]");
final Preparation preparationDetails = getPreparation(preparation);
for (Step step : preparationDetails.getSteps()) {
try (OutputStream content = contentCache.put(cacheKeyGenerator.generateMetadataKey(preparation, step.id(), HEAD), ContentCache.TimeToLive.DEFAULT)) {
content.write("{}".getBytes());
content.flush();
}
final TransformationCacheKey key = //
cacheKeyGenerator.generateContentKey(//
datasetId, //
preparation, //
step.id(), //
format, //
HEAD, //
"");
try (OutputStream content = contentCache.put(key, ContentCache.TimeToLive.DEFAULT)) {
content.write("{}".getBytes());
content.flush();
}
}
ExportParameters exportParameters = new ExportParameters();
exportParameters.setPreparationId(preparation);
exportParameters.setDatasetId(datasetId);
exportParameters.setExportType(format);
exportParameters.setFrom(HEAD);
// Then
assertTrue(optimizedExportStrategy.accept(exportParameters));
}
Aggregations