use of org.finra.herd.model.api.xml.JdbcExecutionRequest in project herd by FINRAOS.
the class JdbcServiceTest method testExecuteJdbcParamValidationStatementsNull.
/**
* Parameter validation, request statement list is null
*/
@Test
public void testExecuteJdbcParamValidationStatementsNull() {
JdbcExecutionRequest jdbcExecutionRequest = jdbcServiceTestHelper.createDefaultUpdateJdbcExecutionRequest();
jdbcExecutionRequest.setStatements(null);
try {
// Execute
jdbcService.executeJdbc(jdbcExecutionRequest);
Assert.fail("expected an IllegalArgumentException, but no exception was thrown");
} catch (Exception e) {
Assert.assertEquals("thrown exception type", IllegalArgumentException.class, e.getClass());
Assert.assertEquals("thrown exception message", "JDBC statements are required", e.getMessage());
}
}
use of org.finra.herd.model.api.xml.JdbcExecutionRequest in project herd by FINRAOS.
the class JdbcServiceTestHelper method createDefaultUpdateJdbcExecutionRequest.
/**
* Creates a default JDBC execution request which is guaranteed to work. The request contains a single statement of UPDATE type.
*
* @return a valid JDBC request
*/
public JdbcExecutionRequest createDefaultUpdateJdbcExecutionRequest() {
JdbcConnection jdbcConnection = createDefaultJdbcConnection();
List<JdbcStatement> jdbcStatements = createDefaultUpdateJdbcStatements();
JdbcExecutionRequest jdbcExecutionRequest = createJdbcExecutionRequest(jdbcConnection, jdbcStatements);
return jdbcExecutionRequest;
}
use of org.finra.herd.model.api.xml.JdbcExecutionRequest in project herd by FINRAOS.
the class JdbcServiceTestHelper method createDefaultQueryJdbcExecutionRequest.
/**
* Creates a default JDBC execution request which is guaranteed to work. The request contains a single statement of QUERY type.
*
* @return a valid JDBC request
*/
public JdbcExecutionRequest createDefaultQueryJdbcExecutionRequest() {
JdbcConnection jdbcConnection = createDefaultJdbcConnection();
List<JdbcStatement> jdbcStatements = createDefaultQueryJdbcStatements();
JdbcExecutionRequest jdbcExecutionRequest = createJdbcExecutionRequest(jdbcConnection, jdbcStatements);
return jdbcExecutionRequest;
}
use of org.finra.herd.model.api.xml.JdbcExecutionRequest 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.JdbcExecutionRequest in project herd by FINRAOS.
the class ExecuteJdbcTest method testExecuteJdbcErrorValidation.
@Test
public void testExecuteJdbcErrorValidation() throws Exception {
JdbcExecutionRequest jdbcExecutionRequest = jdbcServiceTestHelper.createDefaultUpdateJdbcExecutionRequest();
jdbcExecutionRequest.setConnection(null);
List<FieldExtension> fieldExtensionList = new ArrayList<>();
List<Parameter> parameters = new ArrayList<>();
populateParameters(jdbcExecutionRequest, fieldExtensionList, parameters);
Map<String, Object> variableValuesToValidate = new HashMap<>();
variableValuesToValidate.put(BaseJavaDelegate.VARIABLE_JSON_RESPONSE, VARIABLE_VALUE_IS_NULL);
variableValuesToValidate.put(ActivitiRuntimeHelper.VARIABLE_ERROR_MESSAGE, "JDBC connection is required");
executeWithoutLogging(ActivitiRuntimeHelper.class, () -> {
testActivitiServiceTaskFailure(JAVA_DELEGATE_CLASS_NAME, fieldExtensionList, parameters, variableValuesToValidate);
});
}
Aggregations