Search in sources :

Example 1 with JavaColumnTransform

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);
}
Also used : JavaColumnTransform(org.jumpmind.symmetric.io.data.transform.JavaColumnTransform) HashMap(java.util.HashMap) TransformedData(org.jumpmind.symmetric.io.data.transform.TransformedData) TransformTable(org.jumpmind.symmetric.io.data.transform.TransformTable) TransformColumn(org.jumpmind.symmetric.io.data.transform.TransformColumn) Test(org.junit.Test)

Example 2 with JavaColumnTransform

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);
}
Also used : JavaColumnTransform(org.jumpmind.symmetric.io.data.transform.JavaColumnTransform) HashMap(java.util.HashMap) TransformedData(org.jumpmind.symmetric.io.data.transform.TransformedData) TransformTable(org.jumpmind.symmetric.io.data.transform.TransformTable) TransformColumn(org.jumpmind.symmetric.io.data.transform.TransformColumn) Test(org.junit.Test)

Aggregations

HashMap (java.util.HashMap)2 JavaColumnTransform (org.jumpmind.symmetric.io.data.transform.JavaColumnTransform)2 TransformColumn (org.jumpmind.symmetric.io.data.transform.TransformColumn)2 TransformTable (org.jumpmind.symmetric.io.data.transform.TransformTable)2 TransformedData (org.jumpmind.symmetric.io.data.transform.TransformedData)2 Test (org.junit.Test)2