use of io.atlasmap.v2.Action in project atlasmap by atlasmap.
the class DefaultAtlasFieldActionsServiceTest method testProcessActionsActionsField.
@Test
public void testProcessActionsActionsField() throws AtlasException {
Actions actions = null;
SimpleField field = new SimpleField();
field.setFieldType(FieldType.COMPLEX);
fieldActionsService.processActions(actions, field);
field.setValue(null);
field.setFieldType(FieldType.INTEGER);
fieldActionsService.processActions(actions, field);
field.setValue(new Integer(0));
field.setFieldType(FieldType.INTEGER);
fieldActionsService.processActions(actions, field);
@SuppressWarnings("serial")
class MockActions extends Actions {
@Override
public List<Action> getActions() {
return null;
}
}
fieldActionsService.processActions(new MockActions(), field);
actions = new Actions();
fieldActionsService.processActions(actions, field);
actions.getActions().add(new Trim());
field.setValue("testString");
field.setFieldType(FieldType.STRING);
fieldActionsService.processActions(actions, field);
field.setValue(new Integer(8));
field.setFieldType(FieldType.NUMBER);
fieldActionsService.processActions(actions, field);
}
use of io.atlasmap.v2.Action in project atlasmap by atlasmap.
the class DefaultAtlasFieldActionsServiceTest method testProcessActionWithActionActionDetailObjectAtlasException.
@Test(expected = AtlasException.class)
public void testProcessActionWithActionActionDetailObjectAtlasException() throws AtlasException {
Action action = new AbsoluteValue();
Object sourceObject = new Integer("1");
ActionDetail actionDetail = new ActionDetail();
actionDetail.setClassName("io.atlasmap.actions.NumberFieldActions");
actionDetail.setSourceType(FieldType.INTEGER);
actionDetail.setMethod("absoluteValue");
fieldActionsService.processAction(action, actionDetail, sourceObject);
}
use of io.atlasmap.v2.Action in project atlasmap by atlasmap.
the class NumberFieldActions method convertVolumeUnit.
@AtlasFieldActionInfo(name = "ConvertVolumeUnit", sourceType = FieldType.NUMBER, targetType = FieldType.NUMBER, sourceCollectionType = CollectionType.NONE, targetCollectionType = CollectionType.NONE)
public static Number convertVolumeUnit(Action action, Number input) {
if (input == null) {
return 0;
}
if (action == null || !(action instanceof ConvertVolumeUnit) || ((ConvertVolumeUnit) action).getFromUnit() == null || ((ConvertVolumeUnit) action).getToUnit() == null) {
throw new IllegalArgumentException("ConvertVolumeUnit must be specfied with fromUnit and toUnit");
}
VolumeUnitType fromUnit = ((ConvertVolumeUnit) action).getFromUnit();
VolumeUnitType toUnit = ((ConvertVolumeUnit) action).getToUnit();
double rate = volumeConvertionTable.get(fromUnit).get(toUnit);
return doMultiply(input, rate);
}
use of io.atlasmap.v2.Action in project atlasmap by atlasmap.
the class NumberFieldActions method convertMassUnit.
@AtlasFieldActionInfo(name = "ConvertMassUnit", sourceType = FieldType.NUMBER, targetType = FieldType.NUMBER, sourceCollectionType = CollectionType.NONE, targetCollectionType = CollectionType.NONE)
public static Number convertMassUnit(Action action, Number input) {
if (input == null) {
return 0;
}
if (action == null || !(action instanceof ConvertMassUnit) || ((ConvertMassUnit) action).getFromUnit() == null || ((ConvertMassUnit) action).getToUnit() == null) {
throw new IllegalArgumentException("ConvertMassUnit must be specfied with fromUnit and toUnit");
}
MassUnitType fromUnit = ((ConvertMassUnit) action).getFromUnit();
MassUnitType toUnit = ((ConvertMassUnit) action).getToUnit();
double rate = massConvertionTable.get(fromUnit).get(toUnit);
return doMultiply(input, rate);
}
use of io.atlasmap.v2.Action in project atlasmap by atlasmap.
the class NumberFieldActions method convertDistanceUnit.
@AtlasFieldActionInfo(name = "ConvertDistanceUnit", sourceType = FieldType.NUMBER, targetType = FieldType.NUMBER, sourceCollectionType = CollectionType.NONE, targetCollectionType = CollectionType.NONE)
public static Number convertDistanceUnit(Action action, Number input) {
if (input == null) {
return 0;
}
if (action == null || !(action instanceof ConvertDistanceUnit) || ((ConvertDistanceUnit) action).getFromUnit() == null || ((ConvertDistanceUnit) action).getToUnit() == null) {
throw new IllegalArgumentException("ConvertDistanceUnit must be specfied with fromUnit and toUnit");
}
DistanceUnitType fromUnit = ((ConvertDistanceUnit) action).getFromUnit();
DistanceUnitType toUnit = ((ConvertDistanceUnit) action).getToUnit();
double rate = distanceConvertionTable.get(fromUnit).get(toUnit);
return doMultiply(input, rate);
}
Aggregations