Search in sources :

Example 36 with Preparation

use of org.talend.dataprep.api.preparation.Preparation in project data-prep by Talend.

the class PreparationExportStrategyTest method shouldUsedVersionedPreparation.

@Test
public void shouldUsedVersionedPreparation() throws IOException {
    // Given
    final ExportParameters parameters = new ExportParameters();
    parameters.setExportType("JSON");
    parameters.setPreparationId("prep-1234");
    parameters.setStepId("step-1234");
    final Preparation preparation = new Preparation();
    preparation.setId("prep-1234");
    preparation.setHeadId("step-1234");
    configurePreparation(preparation, "prep-1234", "step-1234");
    // When
    final StreamingResponseBody body = strategy.execute(parameters);
    body.writeTo(new NullOutputStream());
    // Then
    final ArgumentCaptor<Configuration> captor = ArgumentCaptor.forClass(Configuration.class);
    verify(transformer).buildExecutable(any(), captor.capture());
    assertEquals("prep-1234", captor.getValue().getPreparationId());
    assertEquals("step-1234", captor.getValue().getPreparation().getHeadId());
}
Also used : StreamingResponseBody(org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody) Configuration(org.talend.dataprep.transformation.api.transformer.configuration.Configuration) ExportParameters(org.talend.dataprep.api.export.ExportParameters) Preparation(org.talend.dataprep.api.preparation.Preparation) NullOutputStream(org.apache.commons.io.output.NullOutputStream) Test(org.junit.Test)

Example 37 with Preparation

use of org.talend.dataprep.api.preparation.Preparation in project data-prep by Talend.

the class PreparationDatasetRowUpdaterTest method updatePreparations.

@Test
public void updatePreparations() throws Exception {
    // given
    String datasetId = "dataset id";
    Preparation prep = new Preparation("prepId", "123456");
    prep.setDataSetId(datasetId);
    final List<Preparation> preparations = singletonList(prep);
    when(preparationRepository.list(Preparation.class)).thenReturn(preparations.stream());
    DataSetMetadata datasetMetadata = new DataSetMetadata();
    datasetMetadata.setRowMetadata(new RowMetadata());
    when(dataSetMetadataRepository.get(datasetId)).thenReturn(datasetMetadata);
    // when
    updater.updatePreparations();
    // then
    verify(preparationRepository, times(1)).list(Preparation.class);
    verify(preparationRepository, times(1)).add(prep);
    verify(dataSetMetadataRepository, only()).get(datasetId);
}
Also used : Preparation(org.talend.dataprep.api.preparation.Preparation) RowMetadata(org.talend.dataprep.api.dataset.RowMetadata) DataSetMetadata(org.talend.dataprep.api.dataset.DataSetMetadata) Test(org.junit.Test)

Example 38 with Preparation

use of org.talend.dataprep.api.preparation.Preparation in project data-prep by Talend.

the class PreparationExportStrategyTest method shouldUsedHeadPreparation.

@Test
public void shouldUsedHeadPreparation() throws IOException {
    // Given
    final ExportParameters parameters = new ExportParameters();
    parameters.setExportType("JSON");
    parameters.setPreparationId("prep-1234");
    parameters.setStepId("head");
    final Preparation preparation = new Preparation();
    preparation.setId("prep-1234");
    preparation.setHeadId("head");
    configurePreparation(preparation, "prep-1234", "head");
    // When
    final StreamingResponseBody body = strategy.execute(parameters);
    body.writeTo(new NullOutputStream());
    // Then
    final ArgumentCaptor<Configuration> captor = ArgumentCaptor.forClass(Configuration.class);
    verify(transformer).buildExecutable(any(), captor.capture());
    assertEquals("prep-1234", captor.getValue().getPreparationId());
    assertEquals("head", captor.getValue().getPreparation().getHeadId());
}
Also used : StreamingResponseBody(org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody) Configuration(org.talend.dataprep.transformation.api.transformer.configuration.Configuration) ExportParameters(org.talend.dataprep.api.export.ExportParameters) Preparation(org.talend.dataprep.api.preparation.Preparation) NullOutputStream(org.apache.commons.io.output.NullOutputStream) Test(org.junit.Test)

Example 39 with Preparation

use of org.talend.dataprep.api.preparation.Preparation in project data-prep by Talend.

the class AddAllPreparationsToHomeTest method shouldAddAllPreparationsToHome.

@Test
public void shouldAddAllPreparationsToHome() throws Exception {
    // given
    final String homeFolderId = folderRepository.getHome().getId();
    // when
    task.run();
    // then
    final Stream<Preparation> preparations = preparationRepository.list(Preparation.class);
    preparations.forEach(p -> {
        final Folder folder = folderRepository.locateEntry(p.getId(), PREPARATION);
        assertEquals(homeFolderId, folder.getId());
    });
}
Also used : Preparation(org.talend.dataprep.api.preparation.Preparation) Folder(org.talend.dataprep.api.folder.Folder) Test(org.junit.Test)

Example 40 with Preparation

use of org.talend.dataprep.api.preparation.Preparation in project data-prep by Talend.

the class PrepHasStepCondition method apply.

@Override
public boolean apply(Object... args) {
    // check pre-condition
    Validate.notNull(args);
    Validate.isTrue(args.length == 2);
    Validate.isInstanceOf(String.class, args[0]);
    Validate.isInstanceOf(String.class, args[1]);
    String preparationId = (String) args[0];
    String headId = (String) args[1];
    Preparation prep = exportParametersUtil.getPreparation(preparationId, headId);
    return prep.getSteps().size() > 1;
}
Also used : Preparation(org.talend.dataprep.api.preparation.Preparation)

Aggregations

Preparation (org.talend.dataprep.api.preparation.Preparation)65 Test (org.junit.Test)44 Step (org.talend.dataprep.api.preparation.Step)18 List (java.util.List)14 ServiceBaseTest (org.talend.ServiceBaseTest)11 ArrayList (java.util.ArrayList)10 Action (org.talend.dataprep.api.preparation.Action)10 PreparationActions (org.talend.dataprep.api.preparation.PreparationActions)10 Response (com.jayway.restassured.response.Response)9 Arrays (java.util.Arrays)8 DataSetMetadata (org.talend.dataprep.api.dataset.DataSetMetadata)8 ExportParameters (org.talend.dataprep.api.export.ExportParameters)8 UserPreparation (org.talend.dataprep.preparation.service.UserPreparation)8 TransformationCacheKey (org.talend.dataprep.cache.TransformationCacheKey)7 PreparationRepository (org.talend.dataprep.preparation.store.PreparationRepository)7 RowMetadata (org.talend.dataprep.api.dataset.RowMetadata)6 Folder (org.talend.dataprep.api.folder.Folder)6 TDPException (org.talend.dataprep.exception.TDPException)6 PersistentStep (org.talend.dataprep.preparation.store.PersistentStep)6 PreparationRepositoryTest (org.talend.dataprep.preparation.store.PreparationRepositoryTest)6