public void testSQLActionParser() {
assertActionCount(5);
assertActionClassAndName(ExecuteSQLQueryAction.class, "sqlQuery:testDataSource");
// 1st action
ExecuteSQLQueryAction action = getNextTestActionFromTest();
Assert.assertNotNull(action.getDataSource());
Assert.assertNull(action.getSqlResourcePath());
Assert.assertEquals(action.getStatements().size(), 2);
Assert.assertEquals(action.getStatements().get(0), "select A, B, C from D where E='${id}'");
Assert.assertEquals(action.getStatements().get(1), "select COUNT(F) as cnt_f from G");
Assert.assertEquals(action.getControlResultSet().size(), 4);
Assert.assertEquals(action.getControlResultSet().get("A").size(), 1);
Assert.assertEquals(action.getControlResultSet().get("A").get(0), "a");
Assert.assertEquals(action.getControlResultSet().get("B").size(), 1);
Assert.assertEquals(action.getControlResultSet().get("B").get(0), "b");
Assert.assertEquals(action.getControlResultSet().get("C").size(), 1);
Assert.assertEquals(action.getControlResultSet().get("C").get(0), "NULL");
Assert.assertEquals(action.getControlResultSet().get("CNT_F").get(0), "${count}");
Assert.assertNull(action.getScriptValidationContext());
Assert.assertEquals(action.getExtractVariables().size(), 0);
// 2nd action
action = getNextTestActionFromTest();
Assert.assertNotNull(action.getDataSource());
Assert.assertNotNull(action.getSqlResourcePath());
Assert.assertEquals(action.getSqlResourcePath(), "classpath:com/consol/citrus/actions/test-sql-query-statements.sql");
Assert.assertEquals(action.getStatements().size(), 0);
Assert.assertEquals(action.getControlResultSet().size(), 1);
Assert.assertEquals(action.getControlResultSet().get("foo").get(0), "1");
Assert.assertNull(action.getScriptValidationContext());
Assert.assertEquals(action.getExtractVariables().size(), 0);
// 3rd action
action = getNextTestActionFromTest();
Assert.assertNotNull(action.getDataSource());
Assert.assertNull(action.getSqlResourcePath());
Assert.assertEquals(action.getStatements().size(), 1);
Assert.assertEquals(action.getStatements().get(0), "select A as A_COLUMN, B as B_COLUMN from C");
Assert.assertEquals(action.getControlResultSet().size(), 2);
Assert.assertEquals(action.getControlResultSet().get("A_COLUMN").size(), 2);
Assert.assertEquals(action.getControlResultSet().get("A_COLUMN").get(0), "a");
Assert.assertEquals(action.getControlResultSet().get("A_COLUMN").get(1), "@ignore@");
Assert.assertEquals(action.getControlResultSet().get("B_COLUMN").size(), 2);
Assert.assertEquals(action.getControlResultSet().get("B_COLUMN").get(0), "b");
Assert.assertEquals(action.getControlResultSet().get("B_COLUMN").get(1), "NULL");
Assert.assertNull(action.getScriptValidationContext());
Assert.assertEquals(action.getExtractVariables().size(), 2);
Assert.assertEquals(action.getExtractVariables().get("A_COLUMN"), "a_values");
Assert.assertEquals(action.getExtractVariables().get("B_COLUMN"), "b_values");
// 4th action
action = getNextTestActionFromTest();
Assert.assertNotNull(action.getDataSource());
Assert.assertNull(action.getSqlResourcePath());
Assert.assertEquals(action.getStatements().size(), 1);
Assert.assertEquals(action.getStatements().get(0), "select A as A_COLUMN, B as B_COLUMN from C");
Assert.assertEquals(action.getControlResultSet().size(), 0);
Assert.assertEquals(action.getExtractVariables().size(), 0);
Assert.assertNotNull(action.getScriptValidationContext());
Assert.assertNull(action.getScriptValidationContext().getValidationScriptResourcePath());
Assert.assertEquals(action.getScriptValidationContext().getValidationScript().trim(), "assert rows.size == 2");
// 5th action
action = getNextTestActionFromTest();
Assert.assertNotNull(action.getDataSource());
Assert.assertNull(action.getSqlResourcePath());
Assert.assertEquals(action.getStatements().size(), 1);
Assert.assertEquals(action.getStatements().get(0), "select A as A_COLUMN, B as B_COLUMN from C");
Assert.assertEquals(action.getControlResultSet().size(), 0);
Assert.assertEquals(action.getExtractVariables().size(), 0);
Assert.assertNotNull(action.getScriptValidationContext());
Assert.assertNotNull(action.getScriptValidationContext().getValidationScriptResourcePath());
Assert.assertEquals(action.getScriptValidationContext().getValidationScriptResourcePath(), "classpath:com/consol/citrus/script/example.groovy");
Assert.assertEquals(action.getScriptValidationContext().getValidationScript(), "");
}