Search in sources :

Example 1 with PreparationDetailsGet

use of org.talend.dataprep.command.preparation.PreparationDetailsGet 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;
}
Also used : TDPException(org.talend.dataprep.exception.TDPException) Preparation(org.talend.dataprep.api.preparation.Preparation) PreparationDetailsGet(org.talend.dataprep.command.preparation.PreparationDetailsGet)

Example 2 with PreparationDetailsGet

use of org.talend.dataprep.command.preparation.PreparationDetailsGet in project data-prep by Talend.

the class PreparationExportStrategyTest method configurePreparation.

private void configurePreparation(Preparation preparation, String preparationId, String stepId) throws IOException {
    final StringWriter preparationAsString = new StringWriter();
    mapper.writerFor(Preparation.class).writeValue(preparationAsString, preparation);
    when(preparationDetailsGet.execute()).thenReturn(new ByteArrayInputStream(preparationAsString.toString().getBytes()));
    when(applicationContext.getBean(eq(PreparationDetailsGet.class), eq(preparationId), eq(stepId))).thenReturn(preparationDetailsGet);
}
Also used : StringWriter(java.io.StringWriter) ByteArrayInputStream(java.io.ByteArrayInputStream) Preparation(org.talend.dataprep.api.preparation.Preparation) PreparationDetailsGet(org.talend.dataprep.command.preparation.PreparationDetailsGet)

Aggregations

Preparation (org.talend.dataprep.api.preparation.Preparation)2 PreparationDetailsGet (org.talend.dataprep.command.preparation.PreparationDetailsGet)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 StringWriter (java.io.StringWriter)1 TDPException (org.talend.dataprep.exception.TDPException)1