/** * Validates parameters specified in the given statement. * * @param jdbcStatement statement to validate * @param jdbcStatementIndex the index number of the statement in the list */ private void validateJdbcStatement(JdbcStatement jdbcStatement, int jdbcStatementIndex) { Assert.notNull(jdbcStatement, "JDBC statement [" + jdbcStatementIndex + "] is required"); Assert.notNull(jdbcStatement.getType(), "JDBC statement [" + jdbcStatementIndex + "] type is required"); validateSqlStatement(jdbcStatement.getSql(), jdbcStatementIndex); }
/** * Validates parameters specified in the given statement. * * @param jdbcStatement statement to validate * @param jdbcStatementIndex the index number of the statement in the list */ private void validateJdbcStatement(JdbcStatement jdbcStatement, int jdbcStatementIndex) { Assert.notNull(jdbcStatement, "JDBC statement [" + jdbcStatementIndex + "] is required"); Assert.notNull(jdbcStatement.getType(), "JDBC statement [" + jdbcStatementIndex + "] type is required"); validateSqlStatement(jdbcStatement.getSql(), jdbcStatementIndex); }
/** * Creates and returns a {@link JdbcStatement} at a state which has not yet been executed based on the given request. * <p/> * The status will be set to {@link JdbcStatementStatus#SKIPPED} and result null. * * @param requestJdbcStatement the requested JDBC statement * * @return a new {@link JdbcStatement} */ private JdbcStatement createDefaultResponseJdbcStatement(JdbcStatement requestJdbcStatement) { JdbcStatement responseJdbcStatement = new JdbcStatement(); responseJdbcStatement.setType(requestJdbcStatement.getType()); responseJdbcStatement.setSql(requestJdbcStatement.getSql()); responseJdbcStatement.setContinueOnError(requestJdbcStatement.isContinueOnError()); responseJdbcStatement.setStatus(JdbcStatementStatus.SKIPPED); return responseJdbcStatement; }
/** * Creates and returns a {@link JdbcStatement} at a state which has not yet been executed based on the given request. * <p/> * The status will be set to {@link JdbcStatementStatus#SKIPPED} and result null. * * @param requestJdbcStatement the requested JDBC statement * * @return a new {@link JdbcStatement} */ private JdbcStatement createDefaultResponseJdbcStatement(JdbcStatement requestJdbcStatement) { JdbcStatement responseJdbcStatement = new JdbcStatement(); responseJdbcStatement.setType(requestJdbcStatement.getType()); responseJdbcStatement.setSql(requestJdbcStatement.getSql()); responseJdbcStatement.setContinueOnError(requestJdbcStatement.isContinueOnError()); responseJdbcStatement.setStatus(JdbcStatementStatus.SKIPPED); return responseJdbcStatement; }
/** * 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()); } }
/** * Test case where user specifies a QUERY statement type, but there are SQL errors. The status should be ERROR and no result set should exist in the * result. */ @Test public void testExecuteJdbcStatementTypeQueryError() { // Get test request JdbcExecutionRequest jdbcExecutionRequest = jdbcServiceTestHelper.createDefaultQueryJdbcExecutionRequest(); JdbcStatement expectedJdbcStatement = jdbcExecutionRequest.getStatements().get(0); expectedJdbcStatement.setSql(MockJdbcOperations.CASE_2_SQL); JdbcExecutionResponse jdbcExecutionResponse = jdbcService.executeJdbc(jdbcExecutionRequest); Assert.assertEquals("JDBC statements size", 1, jdbcExecutionResponse.getStatements().size()); JdbcStatement actualJdbcStatement = jdbcExecutionResponse.getStatements().get(0); Assert.assertNotNull("JDBC statement error message", actualJdbcStatement.getErrorMessage()); Assert.assertEquals("JDBC statement error message", "java.sql.SQLException: test DataIntegrityViolationException cause", actualJdbcStatement.getErrorMessage()); Assert.assertNull("JDBC statement result", actualJdbcStatement.getResult()); Assert.assertEquals("JDBC statement status", JdbcStatementStatus.ERROR, actualJdbcStatement.getStatus()); Assert.assertEquals("JDBC statement type", expectedJdbcStatement.getType(), actualJdbcStatement.getType()); Assert.assertNull("JDBC statement result set", actualJdbcStatement.getResultSet()); }
public StringBuilder appendFields(ObjectLocator locator, StringBuilder buffer, ToStringStrategy2 strategy) { theType = this.getType(); strategy.appendField(locator, this, "type", buffer, theType, (this.type!= null));
public StringBuilder appendFields(ObjectLocator locator, StringBuilder buffer, ToStringStrategy2 strategy) { theType = this.getType(); strategy.appendField(locator, this, "type", buffer, theType, (this.type!= null));
public StringBuilder appendFields(ObjectLocator locator, StringBuilder buffer, ToStringStrategy2 strategy) { theType = this.getType(); strategy.appendField(locator, this, "type", buffer, theType, (this.type!= null));
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());
JdbcStatement originalJdbcStatement = jdbcExecutionRequest.getStatements().get(0); JdbcStatement expectedJdbcStatement = new JdbcStatement(); expectedJdbcStatement.setType(originalJdbcStatement.getType()); expectedJdbcStatement.setSql(originalJdbcStatement.getSql()); expectedJdbcStatement.setStatus(JdbcStatementStatus.SUCCESS);
theType = this.getType(); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "type", theType), currentHashCode, theType, (this.type!= null));
theType = this.getType(); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "type", theType), currentHashCode, theType, (this.type!= null));
theType = this.getType(); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "type", theType), currentHashCode, theType, (this.type!= null));
if (typeShouldBeCopiedAndSet == Boolean.TRUE) { JdbcStatementType sourceType; sourceType = this.getType(); JdbcStatementType copyType = ((JdbcStatementType) strategy.copy(LocatorUtils.property(locator, "type", sourceType), sourceType, (this.type!= null))); copy.setType(copyType);