use of org.jumpmind.symmetric.io.data.transform.JavaColumnTransform in project symmetric-ds by JumpMind.
the class JavaColumnTransformTest method testSimple.
@Test
public void testSimple() throws Exception {
String javaCode = "return \"transValue\";";
TransformColumn column = new TransformColumn("sColumn", "tColumn", false, "java", javaCode);
TransformTable table = new TransformTable("sTable", "tTable", TransformPoint.LOAD, column);
Map<String, String> sourceKeyValues = new HashMap<String, String>();
Map<String, String> sourceValues = new HashMap<String, String>();
sourceValues.put("sColumn", "aNewValue");
Map<String, String> oldSourceValues = new HashMap<String, String>();
oldSourceValues.put("sColumn", "anOldValue");
TransformedData data = new TransformedData(table, DataEventType.INSERT, sourceKeyValues, oldSourceValues, sourceValues);
JavaColumnTransform transform = new JavaColumnTransform(extensionService);
String out = transform.transform(platform, context, column, data, sourceValues, "aNewValue", "anOldValue");
assertEquals("transValue", out);
}
use of org.jumpmind.symmetric.io.data.transform.JavaColumnTransform in project symmetric-ds by JumpMind.
the class JavaColumnTransformTest method testInnerClass.
@Test
public void testInnerClass() throws Exception {
String javaCode = "final DataContext ctx = context;" + "HashMap namedParams = new HashMap();" + "context.findTransaction().query(\"sql\", new ISqlRowMapper<Object>() {" + " public Object mapRow(Row row) {" + " ctx.put(\"a\", row.getString(\"b\"));" + " return null;" + " }" + "}, namedParams);" + "return \"transValue\";";
TransformColumn column = new TransformColumn("sColumn", "tColumn", false, "java", javaCode);
TransformTable table = new TransformTable("sTable", "tTable", TransformPoint.LOAD, column);
Map<String, String> sourceKeyValues = new HashMap<String, String>();
Map<String, String> sourceValues = new HashMap<String, String>();
sourceValues.put("sColumn", "aNewValue");
Map<String, String> oldSourceValues = new HashMap<String, String>();
oldSourceValues.put("sColumn", "anOldValue");
TransformedData data = new TransformedData(table, DataEventType.INSERT, sourceKeyValues, oldSourceValues, sourceValues);
JavaColumnTransform transform = new JavaColumnTransform(extensionService);
String out = transform.transform(platform, context, column, data, sourceValues, "aNewValue", "anOldValue");
assertEquals("transValue", out);
}
Aggregations