use of io.atlasmap.v2.Trim in project atlasmap by atlasmap.
the class DefaultAtlasFieldActionsServiceTest method testProcessActionWithActionActionDetailObject.
@Test
public void testProcessActionWithActionActionDetailObject() throws AtlasException {
ActionProcessor processor = null;
Object sourceObject = "String";
Action action = new Trim();
processor = fieldActionsService.findActionProcessor(action, FieldType.STRING);
assertEquals(sourceObject, processor.process(action, sourceObject));
action = new GenerateUUID();
processor = fieldActionsService.findActionProcessor(action, FieldType.NONE);
assertNotNull(processor.process(action, sourceObject));
}
use of io.atlasmap.v2.Trim in project atlasmap by atlasmap.
the class AtlasBaseActionsTest method testActions.
@Test
public void testActions() throws Exception {
List<ActionDetail> actions = DefaultAtlasContextFactory.getInstance().getFieldActionService().listActionDetails();
for (ActionDetail d : actions) {
System.out.println(d.getName());
}
this.runActionTest(new Uppercase(), "fname", "FNAME", String.class);
this.runActionTest(new Lowercase(), "fnAme", "fname", String.class);
this.runActionTest(new Trim(), " fname ", "fname", String.class);
this.runActionTest(new TrimLeft(), " fname ", "fname ", String.class);
this.runActionTest(new TrimRight(), " fname ", " fname", String.class);
this.runActionTest(new Capitalize(), "fname", "Fname", String.class);
this.runActionTest(new SeparateByDash(), "f:name", "f-name", String.class);
this.runActionTest(new SeparateByUnderscore(), "f-na_me", "f_na_me", String.class);
SubString s = new SubString();
s.setStartIndex(0);
s.setEndIndex(3);
this.runActionTest(s, "12345", "123", String.class);
SubStringAfter s1 = new SubStringAfter();
s1.setStartIndex(3);
s1.setEndIndex(null);
s1.setMatch("foo");
this.runActionTest(s1, "foobarblah", "blah", String.class);
SubStringBefore s2 = new SubStringBefore();
s2.setStartIndex(3);
s2.setEndIndex(null);
s2.setMatch("blah");
this.runActionTest(s2, "foobarblah", "bar", String.class);
PadStringRight ps = new PadStringRight();
ps.setPadCharacter("X");
ps.setPadCount(5);
this.runActionTest(ps, "fname", "fnameXXXXX", String.class);
PadStringLeft pl = new PadStringLeft();
pl.setPadCharacter("X");
pl.setPadCount(5);
this.runActionTest(pl, "fname", "XXXXXfname", String.class);
String result = (String) runActionTest(new GenerateUUID(), "fname", null, String.class);
assertTrue(Pattern.compile("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}").matcher(result).matches());
}
use of io.atlasmap.v2.Trim in project atlasmap by atlasmap.
the class BaseMarshallerTest method generateActions.
private void generateActions(JsonField inputField) {
ArrayList<Action> actions = new ArrayList<Action>();
actions.add(new Camelize());
actions.add(new Capitalize());
actions.add(new Length());
actions.add(new Lowercase());
actions.add(new SeparateByDash());
actions.add(new SeparateByUnderscore());
actions.add(new Trim());
actions.add(new TrimLeft());
actions.add(new TrimRight());
actions.add(new Uppercase());
inputField.setActions(actions);
}
use of io.atlasmap.v2.Trim in project atlasmap by atlasmap.
the class DefaultAtlasFieldActionsServiceTest method testProcessActionsActionsField.
@Test
public void testProcessActionsActionsField() throws AtlasException {
SimpleField field = new SimpleField();
field.setFieldType(FieldType.COMPLEX);
field.setActions(null);
fieldActionsService.processActions(mock(AtlasInternalSession.class), field);
field.setValue(null);
field.setFieldType(FieldType.INTEGER);
fieldActionsService.processActions(mock(AtlasInternalSession.class), field);
field.setValue(Integer.valueOf(0));
field.setFieldType(FieldType.INTEGER);
fieldActionsService.processActions(mock(AtlasInternalSession.class), field);
field.setActions(new ArrayList<Action>());
fieldActionsService.processActions(mock(AtlasInternalSession.class), field);
field.setActions(new ArrayList<Action>());
fieldActionsService.processActions(mock(AtlasInternalSession.class), field);
field.getActions().add(new Trim());
field.setValue("testString");
field.setFieldType(FieldType.STRING);
fieldActionsService.processActions(mock(AtlasInternalSession.class), field);
field.setValue(Integer.valueOf(8));
field.setFieldType(FieldType.NUMBER);
fieldActionsService.processActions(mock(AtlasInternalSession.class), field);
}
use of io.atlasmap.v2.Trim in project atlasmap by atlasmap.
the class BaseMarshallerTest method generatePropertyReferenceMapping.
protected AtlasMapping generatePropertyReferenceMapping() {
AtlasMapping mapping = generateAtlasMapping();
PropertyField inputField = new PropertyField();
inputField.setName("foo");
ArrayList<Action> actions = new ArrayList<Action>();
actions.add(new Trim());
populateFieldComplexObject(inputField, actions, CollectionType.ARRAY, FieldStatus.SUPPORTED, FieldType.INTEGER);
populateFieldSimpleObject(inputField, 3, "docid", "/path", false, "bar");
Mapping fm = (Mapping) mapping.getMappings().getMapping().get(0);
fm.getInputField().add(inputField);
fm.getOutputField().add(inputField);
populateMapping(fm, MappingType.MAP, "MapPropertyFieldAlias", ",", ",");
populateMappingString(fm, "description", "id", "lookupTableName", "strategy", "strategyClassName");
generateProperties(mapping);
return mapping;
}
Aggregations