use of org.talend.dataprep.api.preparation.Action in project data-prep by Talend.
the class PreparationTest method stepsWithAppend.
@Test
public void stepsWithAppend() {
final String version = versionService.version().getVersionId();
final List<Action> actions = getSimpleAction("uppercase", "column_name", "lastname");
final PreparationActions newContent1 = PreparationActions.ROOT_ACTIONS.append(actions);
repository.add(newContent1);
final PreparationActions newContent2 = newContent1.append(actions);
repository.add(newContent2);
// Steps
final Step s1 = new Step(Step.ROOT_STEP.id(), newContent1.id(), version);
repository.add(s1);
final Step s2 = new Step(s1.id(), newContent2.id(), version);
repository.add(s2);
// Preparation
final Preparation preparation = new Preparation("#54258728", "1234", s2.id(), version);
preparation.setCreationDate(0L);
repository.add(preparation);
assertThat(preparation.id(), Is.is("#54258728"));
}
use of org.talend.dataprep.api.preparation.Action in project data-prep by Talend.
the class PreparationTest method initialStep.
@Test
public void initialStep() {
final String version = versionService.version().getVersionId();
final List<Action> actions = getSimpleAction("uppercase", "column_name", "lastname");
final PreparationActions newContent = new PreparationActions(actions, version);
repository.add(newContent);
final Step s = new Step(Step.ROOT_STEP.id(), newContent.id(), version);
repository.add(s);
Preparation preparation = new Preparation("#48368", "1234", s.id(), version);
preparation.setCreationDate(0L);
repository.add(preparation);
assertThat(preparation.id(), Is.is("#48368"));
}
use of org.talend.dataprep.api.preparation.Action in project data-prep by Talend.
the class PreparationTest method getSimpleAction.
public static List<Action> getSimpleAction(final String actionName, final String paramKey, final String paramValue) {
final Action action = new Action();
action.setName(actionName);
action.getParameters().put(paramKey, paramValue);
final List<Action> actions = new ArrayList<>();
actions.add(action);
return actions;
}
use of org.talend.dataprep.api.preparation.Action in project data-prep by Talend.
the class ActionMetadataTestUtils method parseParameters.
/**
* Parse the given input stream into a parameter map.
*
* @param input the parameters input stream.
* @return the parsed parameters.
* @throws IOException if an error occurs.
*/
public static Map<String, String> parseParameters(InputStream input) throws IOException {
ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new MixedContentMapModule());
mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
List<Action> parsedAction = ((Actions) mapper.reader(Actions.class).readValue(input)).getActions();
return parsedAction.get(0).getParameters();
}
use of org.talend.dataprep.api.preparation.Action in project data-prep by Talend.
the class ActionNewColumnToggleCommonTest method shouldNotUpdateSteps.
@Test
public void shouldNotUpdateSteps() {
// given
final PreparationRepository repository = mock(PreparationRepository.class);
final PreparationActions actions = mock(PreparationActions.class);
final PersistentStep step = mock(PersistentStep.class);
final Action action = mock(Action.class);
List<Action> actionsList = new ArrayList<>();
actionsList.add(action);
when(step.id()).thenReturn("step-1");
when(actions.getActions()).thenReturn(actionsList);
when(action.getName()).thenReturn("action");
when(repository.list(eq(PreparationActions.class))).thenReturn(Stream.of(actions));
// Twice "action-1" to pass root preparation action filter.
// same id
when(actions.id()).thenReturn("actions-1", "actions-1", "actions-1");
when(repository.list(eq(PersistentStep.class), any())).thenReturn(Stream.of(step));
// when
ActionNewColumnToggleCommon.upgradeActions(repository);
// then
verify(repository, times(1)).add(eq(actions));
verify(repository, never()).add(eq(step));
verify(step, never()).setContent(any());
}
Aggregations