use of io.atlasmap.v2.StartsWith in project atlasmap by atlasmap.
the class DefaultAtlasFieldActionService method detectFieldActionParameters.
protected Properties detectFieldActionParameters(String actionClassName) throws ClassNotFoundException {
Class<?> actionClazz = Class.forName(actionClassName);
Properties props = null;
for (Method method : actionClazz.getMethods()) {
// Find setters to avoid the get / is confusion
if (method.getParameterCount() == 1 && method.getName().startsWith("set")) {
// We have a parameter
if (props == null) {
props = new Properties();
}
Property prop = null;
for (Parameter param : method.getParameters()) {
prop = new Property();
prop.setName(camelize(method.getName().substring("set".length())));
prop.setFieldType(getConversionService().fieldTypeFromClass(param.getType()));
props.getProperty().add(prop);
}
}
}
return props;
}
use of io.atlasmap.v2.StartsWith in project atlasmap by atlasmap.
the class StringComplexFieldActionsTest method testStartsWith.
@Test
public void testStartsWith() {
StartsWith action = new StartsWith();
action.setString("");
assertFalse(StringComplexFieldActions.startsWith(action, null));
assertTrue(StringComplexFieldActions.startsWith(action, ""));
assertTrue(StringComplexFieldActions.startsWith(action, "foo"));
action.setString("foo");
assertFalse(StringComplexFieldActions.startsWith(action, null));
assertFalse(StringComplexFieldActions.startsWith(action, ""));
assertTrue(StringComplexFieldActions.startsWith(action, "foo"));
assertTrue(StringComplexFieldActions.startsWith(action, "foobar"));
assertFalse(StringComplexFieldActions.startsWith(action, "barfoo"));
}
use of io.atlasmap.v2.StartsWith in project atlasmap by atlasmap.
the class BaseModuleValidationService method validateMapping.
@Override
public List<Validation> validateMapping(AtlasMapping mapping) {
List<Validation> validations = new ArrayList<>();
if (getMode() == AtlasModuleMode.UNSET) {
Validation validation = new Validation();
validation.setMessage(String.format("No mode specified for %s/%s, skipping module validations", this.getModuleDetail().name(), this.getClass().getSimpleName()));
}
if (mapping != null && mapping.getMappings() != null && mapping.getMappings().getMapping() != null && !mapping.getMappings().getMapping().isEmpty()) {
validateMappingEntries(mapping.getMappings().getMapping(), validations);
}
boolean found = false;
for (DataSource ds : mapping.getDataSource()) {
if (ds.getUri() != null && ds.getUri().startsWith(getModuleDetail().uri())) {
found = true;
break;
}
}
if (!found) {
Validation validation = new Validation();
validation.setScope(ValidationScope.DATA_SOURCE);
validation.setMessage(String.format("No DataSource with '%s' uri specified", getModuleDetail().uri()));
validation.setStatus(ValidationStatus.ERROR);
validations.add(validation);
}
return validations;
}
Aggregations