use of org.finra.herd.model.api.xml.JdbcExecutionResponse in project herd by FINRAOS.
the class JdbcServiceTest method testExecuteJdbcStatementSuccess.
/**
* Use case where a single successful statement is executed.
*/
@Test
public void testExecuteJdbcStatementSuccess() {
// Get test request
JdbcExecutionRequest jdbcExecutionRequest = jdbcServiceTestHelper.createDefaultUpdateJdbcExecutionRequest();
// Execute
JdbcExecutionResponse jdbcExecutionResponse = jdbcService.executeJdbc(jdbcExecutionRequest);
// Assert results
Assert.assertNull("JDBC connection is not null", jdbcExecutionResponse.getConnection());
Assert.assertEquals("JDBC statements size", jdbcExecutionRequest.getStatements().size(), jdbcExecutionResponse.getStatements().size());
{
JdbcStatement expectedJdbcStatement = jdbcExecutionRequest.getStatements().get(0);
JdbcStatement actualJdbcStatement = jdbcExecutionResponse.getStatements().get(0);
Assert.assertEquals("JDBC statement [0] type", expectedJdbcStatement.getType(), actualJdbcStatement.getType());
Assert.assertEquals("JDBC statement [0] sql", expectedJdbcStatement.getSql(), actualJdbcStatement.getSql());
Assert.assertEquals("JDBC statement [0] status", JdbcStatementStatus.SUCCESS, actualJdbcStatement.getStatus());
Assert.assertEquals("JDBC statement [0] result", "1", actualJdbcStatement.getResult());
}
}
use of org.finra.herd.model.api.xml.JdbcExecutionResponse in project herd by FINRAOS.
the class JdbcServiceTest method testExecuteJdbcStatementTypeQuerySuccess.
/**
* Test case where user specifies a QUERY statement type. A proper result set should be created.
*/
@Test
public void testExecuteJdbcStatementTypeQuerySuccess() {
// Get test request
JdbcExecutionRequest jdbcExecutionRequest = jdbcServiceTestHelper.createDefaultQueryJdbcExecutionRequest();
JdbcStatement expectedJdbcStatement = jdbcExecutionRequest.getStatements().get(0);
JdbcExecutionResponse jdbcExecutionResponse = jdbcService.executeJdbc(jdbcExecutionRequest);
Assert.assertEquals("JDBC statements size", 1, jdbcExecutionResponse.getStatements().size());
JdbcStatement actualJdbcStatement = jdbcExecutionResponse.getStatements().get(0);
Assert.assertNull("JDBC statement error message is not null", actualJdbcStatement.getErrorMessage());
Assert.assertNull("JDBC statement result not is null", actualJdbcStatement.getResult());
Assert.assertEquals("JDBC statement SQL", expectedJdbcStatement.getSql(), actualJdbcStatement.getSql());
Assert.assertEquals("JDBC statement status", JdbcStatementStatus.SUCCESS, actualJdbcStatement.getStatus());
Assert.assertEquals("JDBC statement type", expectedJdbcStatement.getType(), actualJdbcStatement.getType());
Assert.assertNotNull("JDBC statement result set is null", actualJdbcStatement.getResultSet());
Assert.assertNotNull("JDBC statement result set column names is null", actualJdbcStatement.getResultSet().getColumnNames());
Assert.assertEquals("JDBC statement result set column names", Arrays.asList("COL1", "COL2", "COL3"), actualJdbcStatement.getResultSet().getColumnNames());
Assert.assertNotNull("JDBC statement result set rows is null", actualJdbcStatement.getResultSet().getRows());
Assert.assertEquals("JDBC statement result set rows size", 2, actualJdbcStatement.getResultSet().getRows().size());
{
JdbcStatementResultSetRow row = actualJdbcStatement.getResultSet().getRows().get(0);
Assert.assertNotNull("JDBC statement row [0] columns is null", row.getColumns());
Assert.assertEquals("JDBC statement row [0] columns", Arrays.asList("A", "B", "C"), row.getColumns());
}
{
JdbcStatementResultSetRow row = actualJdbcStatement.getResultSet().getRows().get(1);
Assert.assertNotNull("JDBC statement row [1] columns is null", row.getColumns());
Assert.assertEquals("JDBC statement row [1] columns", Arrays.asList("D", "E", "F"), row.getColumns());
}
}
use of org.finra.herd.model.api.xml.JdbcExecutionResponse in project herd by FINRAOS.
the class ExecuteJdbcTest method testExecuteJdbcSuccess.
@Test
public void testExecuteJdbcSuccess() throws Exception {
JdbcExecutionRequest jdbcExecutionRequest = jdbcServiceTestHelper.createDefaultUpdateJdbcExecutionRequest();
List<FieldExtension> fieldExtensionList = new ArrayList<>();
List<Parameter> parameters = new ArrayList<>();
populateParameters(jdbcExecutionRequest, fieldExtensionList, parameters);
JdbcExecutionResponse expectedJdbcExecutionResponse = new JdbcExecutionResponse();
expectedJdbcExecutionResponse.setStatements(jdbcExecutionRequest.getStatements());
expectedJdbcExecutionResponse.getStatements().get(0).setStatus(JdbcStatementStatus.SUCCESS);
expectedJdbcExecutionResponse.getStatements().get(0).setResult("1");
String expectedJdbcExecutionResponseJson = jsonHelper.objectToJson(expectedJdbcExecutionResponse);
Map<String, Object> variableValuesToValidate = new HashMap<>();
variableValuesToValidate.put(BaseJavaDelegate.VARIABLE_JSON_RESPONSE, expectedJdbcExecutionResponseJson);
testActivitiServiceTaskSuccess(JAVA_DELEGATE_CLASS_NAME, fieldExtensionList, parameters, variableValuesToValidate);
}
use of org.finra.herd.model.api.xml.JdbcExecutionResponse in project herd by FINRAOS.
the class ExecuteJdbcTest method testExecuteJdbcErrorStatement.
@Test
public void testExecuteJdbcErrorStatement() throws Exception {
JdbcExecutionRequest jdbcExecutionRequest = jdbcServiceTestHelper.createDefaultUpdateJdbcExecutionRequest();
jdbcExecutionRequest.getStatements().get(0).setSql(MockJdbcOperations.CASE_2_SQL);
List<FieldExtension> fieldExtensionList = new ArrayList<>();
List<Parameter> parameters = new ArrayList<>();
populateParameters(jdbcExecutionRequest, fieldExtensionList, parameters);
JdbcExecutionResponse expectedJdbcExecutionResponse = new JdbcExecutionResponse();
expectedJdbcExecutionResponse.setStatements(jdbcExecutionRequest.getStatements());
expectedJdbcExecutionResponse.getStatements().get(0).setStatus(JdbcStatementStatus.ERROR);
expectedJdbcExecutionResponse.getStatements().get(0).setErrorMessage("java.sql.SQLException: test DataIntegrityViolationException cause");
String expectedJdbcExecutionResponseString = jsonHelper.objectToJson(expectedJdbcExecutionResponse);
Map<String, Object> variableValuesToValidate = new HashMap<>();
variableValuesToValidate.put(BaseJavaDelegate.VARIABLE_JSON_RESPONSE, expectedJdbcExecutionResponseString);
variableValuesToValidate.put(ActivitiRuntimeHelper.VARIABLE_ERROR_MESSAGE, "There are failed executions. See JSON response for details.");
executeWithoutLogging(ActivitiRuntimeHelper.class, () -> {
testActivitiServiceTaskFailure(JAVA_DELEGATE_CLASS_NAME, fieldExtensionList, parameters, variableValuesToValidate);
});
}
Aggregations