Search in sources :

Example 26 with JdbcExecutionRequest

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());
    }
}
Also used : JdbcExecutionRequest(org.finra.herd.model.api.xml.JdbcExecutionRequest) Test(org.junit.Test)

Example 27 with JdbcExecutionRequest

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;
}
Also used : JdbcStatement(org.finra.herd.model.api.xml.JdbcStatement) JdbcConnection(org.finra.herd.model.api.xml.JdbcConnection) JdbcExecutionRequest(org.finra.herd.model.api.xml.JdbcExecutionRequest)

Example 28 with 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;
}
Also used : JdbcStatement(org.finra.herd.model.api.xml.JdbcStatement) JdbcConnection(org.finra.herd.model.api.xml.JdbcConnection) JdbcExecutionRequest(org.finra.herd.model.api.xml.JdbcExecutionRequest)

Example 29 with 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);
}
Also used : HashMap(java.util.HashMap) FieldExtension(org.activiti.bpmn.model.FieldExtension) ArrayList(java.util.ArrayList) Parameter(org.finra.herd.model.api.xml.Parameter) JdbcExecutionRequest(org.finra.herd.model.api.xml.JdbcExecutionRequest) JdbcExecutionResponse(org.finra.herd.model.api.xml.JdbcExecutionResponse) Test(org.junit.Test)

Example 30 with JdbcExecutionRequest

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);
    });
}
Also used : HashMap(java.util.HashMap) FieldExtension(org.activiti.bpmn.model.FieldExtension) ArrayList(java.util.ArrayList) Parameter(org.finra.herd.model.api.xml.Parameter) JdbcExecutionRequest(org.finra.herd.model.api.xml.JdbcExecutionRequest) Test(org.junit.Test)

Aggregations

JdbcExecutionRequest (org.finra.herd.model.api.xml.JdbcExecutionRequest)32 Test (org.junit.Test)28 JdbcExecutionResponse (org.finra.herd.model.api.xml.JdbcExecutionResponse)12 JdbcStatement (org.finra.herd.model.api.xml.JdbcStatement)10 HashMap (java.util.HashMap)6 S3PropertiesLocation (org.finra.herd.model.api.xml.S3PropertiesLocation)6 ArrayList (java.util.ArrayList)4 Parameter (org.finra.herd.model.api.xml.Parameter)4 FieldExtension (org.activiti.bpmn.model.FieldExtension)3 JdbcConnection (org.finra.herd.model.api.xml.JdbcConnection)2 JdbcStatementResultSetRow (org.finra.herd.model.api.xml.JdbcStatementResultSetRow)1 Job (org.finra.herd.model.api.xml.Job)1 JobCreateRequest (org.finra.herd.model.api.xml.JobCreateRequest)1 Transactional (org.springframework.transaction.annotation.Transactional)1