@Test public void testGetImmunizationCvxFromCptSQLExceptionOnPreparedStatementClose() { try { when(mockResultSet.next()).thenReturn(false); Mockito.doThrow(new SQLException()).when(mockPreparedStatement).close(); @SuppressWarnings("unused") JLVMappedCode oMappedCode = testSubject.getImmunizationCvxFromCpt("123"); fail("There should have been a TermLoadException thrown."); } catch (TermLoadException e) { try { verifyCloseMethodsCalled(); } catch (Exception e2) { System.out.println("An unexpected exception occurred. Error: " + e2.getMessage()); e2.printStackTrace(); fail("An unexpected exception occurred. Error: " + e2.getMessage()); } } catch (Exception e) { System.out.println("An unexpected exception occurred. Error: " + e.getMessage()); e.printStackTrace(); fail("An unexpected exception occurred. Error: " + e.getMessage()); } }
public JLVMappedCode getImmunizationCvxFromCpt(String sCpt) throws TermLoadException { JLVMappedCode oMappedCode = null; if (NullChecker.isNotNullish(sCpt)) { PreparedStatement psSelectStatement = null; ResultSet oResults = null; try { psSelectStatement = this.oDBConnection.prepareStatement(SQL_SELECT); psSelectStatement.setString(SQL_PARAM_CPT_CODE, sCpt); oResults = psSelectStatement.executeQuery(); boolean bHasResult = false; if (oResults.next()) { JLVMappedCode oTempMappedCode = new JLVMappedCode(); String sCvx = oResults.getString(SQL_FIELD_CVX_CODE); if (NullChecker.isNotNullish(sCvx)) { oTempMappedCode.setCode(sCvx); bHasResult = true; } String sCvxText = oResults.getString(SQL_FIELD_FULL_DESCRIPTION); if (NullChecker.isNotNullish(sCvxText)) { oTempMappedCode.setDisplayText(sCvxText); bHasResult = true; } if (bHasResult) { oTempMappedCode.setCodeSystem(CODE_SYSTEM_CVX); oMappedCode = oTempMappedCode; } } } catch (SQLException e) { throw new TermLoadException("Failed to read Immunization information from the 'cpt_cvx' table. Error: " + e.getMessage(), e); } finally { TermLoadException exceptionToThrow = null; if (oResults != null) { try { oResults.close(); oResults = null; } catch (SQLException e) { String sErrorMessage = "Failed to close the result set. Error: " + e.getMessage(); LOG.error(sErrorMessage, e); exceptionToThrow = new TermLoadException(sErrorMessage, e); } } if (psSelectStatement != null) { try { psSelectStatement.close(); psSelectStatement = null; } catch (SQLException e) { String sErrorMessage = "Failed to close the prepared statement. Error: " + e.getMessage(); LOG.error(sErrorMessage, e); exceptionToThrow = new TermLoadException(sErrorMessage, e); } } if (exceptionToThrow != null) { throw exceptionToThrow; } } } return oMappedCode; }
JLVImmunizationsMap { public JLVMappedCode getImmunizationCvxFromCpt(String sCpt) throws TermLoadException { JLVMappedCode oMappedCode = null; if (NullChecker.isNotNullish(sCpt)) { PreparedStatement psSelectStatement = null; ResultSet oResults = null; try { psSelectStatement = this.oDBConnection.prepareStatement(SQL_SELECT); psSelectStatement.setString(SQL_PARAM_CPT_CODE, sCpt); oResults = psSelectStatement.executeQuery(); boolean bHasResult = false; if (oResults.next()) { JLVMappedCode oTempMappedCode = new JLVMappedCode(); String sCvx = oResults.getString(SQL_FIELD_CVX_CODE); if (NullChecker.isNotNullish(sCvx)) { oTempMappedCode.setCode(sCvx); bHasResult = true; } String sCvxText = oResults.getString(SQL_FIELD_FULL_DESCRIPTION); if (NullChecker.isNotNullish(sCvxText)) { oTempMappedCode.setDisplayText(sCvxText); bHasResult = true; } if (bHasResult) { oTempMappedCode.setCodeSystem(CODE_SYSTEM_CVX); oMappedCode = oTempMappedCode; } } } catch (SQLException e) { throw new TermLoadException("Failed to read Immunization information from the 'cpt_cvx' table. Error: " + e.getMessage(), e); } finally { TermLoadException exceptionToThrow = null; if (oResults != null) { try { oResults.close(); oResults = null; } catch (SQLException e) { String sErrorMessage = "Failed to close the result set. Error: " + e.getMessage(); LOG.error(sErrorMessage, e); exceptionToThrow = new TermLoadException(sErrorMessage, e); } } if (psSelectStatement != null) { try { psSelectStatement.close(); psSelectStatement = null; } catch (SQLException e) { String sErrorMessage = "Failed to close the prepared statement. Error: " + e.getMessage(); LOG.error(sErrorMessage, e); exceptionToThrow = new TermLoadException(sErrorMessage, e); } } if (exceptionToThrow != null) { throw exceptionToThrow; } } } return oMappedCode; } }
JLVImmunizationsMap { public JLVMappedCode getImmunizationCvxFromCpt(String sCpt) throws TermLoadException { JLVMappedCode oMappedCode = null; if (NullChecker.isNotNullish(sCpt)) { PreparedStatement psSelectStatement = null; ResultSet oResults = null; try { psSelectStatement = this.oDBConnection.prepareStatement(SQL_SELECT); psSelectStatement.setString(SQL_PARAM_CPT_CODE, sCpt); oResults = psSelectStatement.executeQuery(); boolean bHasResult = false; if (oResults.next()) { JLVMappedCode oTempMappedCode = new JLVMappedCode(); String sCvx = oResults.getString(SQL_FIELD_CVX_CODE); if (NullChecker.isNotNullish(sCvx)) { oTempMappedCode.setCode(sCvx); bHasResult = true; } String sCvxText = oResults.getString(SQL_FIELD_FULL_DESCRIPTION); if (NullChecker.isNotNullish(sCvxText)) { oTempMappedCode.setDisplayText(sCvxText); bHasResult = true; } if (bHasResult) { oTempMappedCode.setCodeSystem(CODE_SYSTEM_CVX); oMappedCode = oTempMappedCode; } } } catch (SQLException e) { throw new TermLoadException("Failed to read Immunization information from the 'cpt_cvx' table. Error: " + e.getMessage(), e); } finally { TermLoadException exceptionToThrow = null; if (oResults != null) { try { oResults.close(); oResults = null; } catch (SQLException e) { String sErrorMessage = "Failed to close the result set. Error: " + e.getMessage(); LOG.error(sErrorMessage, e); exceptionToThrow = new TermLoadException(sErrorMessage, e); } } if (psSelectStatement != null) { try { psSelectStatement.close(); psSelectStatement = null; } catch (SQLException e) { String sErrorMessage = "Failed to close the prepared statement. Error: " + e.getMessage(); LOG.error(sErrorMessage, e); exceptionToThrow = new TermLoadException(sErrorMessage, e); } } if (exceptionToThrow != null) { throw exceptionToThrow; } } } return oMappedCode; } @SuppressWarnings("unused") private  JLVImmunizationsMap();  JLVImmunizationsMap(Connection oDBConnection); }
JLVImmunizationsMap { public JLVMappedCode getImmunizationCvxFromCpt(String sCpt) throws TermLoadException { JLVMappedCode oMappedCode = null; if (NullChecker.isNotNullish(sCpt)) { PreparedStatement psSelectStatement = null; ResultSet oResults = null; try { psSelectStatement = this.oDBConnection.prepareStatement(SQL_SELECT); psSelectStatement.setString(SQL_PARAM_CPT_CODE, sCpt); oResults = psSelectStatement.executeQuery(); boolean bHasResult = false; if (oResults.next()) { JLVMappedCode oTempMappedCode = new JLVMappedCode(); String sCvx = oResults.getString(SQL_FIELD_CVX_CODE); if (NullChecker.isNotNullish(sCvx)) { oTempMappedCode.setCode(sCvx); bHasResult = true; } String sCvxText = oResults.getString(SQL_FIELD_FULL_DESCRIPTION); if (NullChecker.isNotNullish(sCvxText)) { oTempMappedCode.setDisplayText(sCvxText); bHasResult = true; } if (bHasResult) { oTempMappedCode.setCodeSystem(CODE_SYSTEM_CVX); oMappedCode = oTempMappedCode; } } } catch (SQLException e) { throw new TermLoadException("Failed to read Immunization information from the 'cpt_cvx' table. Error: " + e.getMessage(), e); } finally { TermLoadException exceptionToThrow = null; if (oResults != null) { try { oResults.close(); oResults = null; } catch (SQLException e) { String sErrorMessage = "Failed to close the result set. Error: " + e.getMessage(); LOG.error(sErrorMessage, e); exceptionToThrow = new TermLoadException(sErrorMessage, e); } } if (psSelectStatement != null) { try { psSelectStatement.close(); psSelectStatement = null; } catch (SQLException e) { String sErrorMessage = "Failed to close the prepared statement. Error: " + e.getMessage(); LOG.error(sErrorMessage, e); exceptionToThrow = new TermLoadException(sErrorMessage, e); } } if (exceptionToThrow != null) { throw exceptionToThrow; } } } return oMappedCode; } @SuppressWarnings("unused") private  JLVImmunizationsMap();  JLVImmunizationsMap(Connection oDBConnection); JLVMappedCode getImmunizationCvxFromCpt(String sCpt); }
JLVImmunizationsMap { public JLVMappedCode getImmunizationCvxFromCpt(String sCpt) throws TermLoadException { JLVMappedCode oMappedCode = null; if (NullChecker.isNotNullish(sCpt)) { PreparedStatement psSelectStatement = null; ResultSet oResults = null; try { psSelectStatement = this.oDBConnection.prepareStatement(SQL_SELECT); psSelectStatement.setString(SQL_PARAM_CPT_CODE, sCpt); oResults = psSelectStatement.executeQuery(); boolean bHasResult = false; if (oResults.next()) { JLVMappedCode oTempMappedCode = new JLVMappedCode(); String sCvx = oResults.getString(SQL_FIELD_CVX_CODE); if (NullChecker.isNotNullish(sCvx)) { oTempMappedCode.setCode(sCvx); bHasResult = true; } String sCvxText = oResults.getString(SQL_FIELD_FULL_DESCRIPTION); if (NullChecker.isNotNullish(sCvxText)) { oTempMappedCode.setDisplayText(sCvxText); bHasResult = true; } if (bHasResult) { oTempMappedCode.setCodeSystem(CODE_SYSTEM_CVX); oMappedCode = oTempMappedCode; } } } catch (SQLException e) { throw new TermLoadException("Failed to read Immunization information from the 'cpt_cvx' table. Error: " + e.getMessage(), e); } finally { TermLoadException exceptionToThrow = null; if (oResults != null) { try { oResults.close(); oResults = null; } catch (SQLException e) { String sErrorMessage = "Failed to close the result set. Error: " + e.getMessage(); LOG.error(sErrorMessage, e); exceptionToThrow = new TermLoadException(sErrorMessage, e); } } if (psSelectStatement != null) { try { psSelectStatement.close(); psSelectStatement = null; } catch (SQLException e) { String sErrorMessage = "Failed to close the prepared statement. Error: " + e.getMessage(); LOG.error(sErrorMessage, e); exceptionToThrow = new TermLoadException(sErrorMessage, e); } } if (exceptionToThrow != null) { throw exceptionToThrow; } } } return oMappedCode; } @SuppressWarnings("unused") private  JLVImmunizationsMap();  JLVImmunizationsMap(Connection oDBConnection); JLVMappedCode getImmunizationCvxFromCpt(String sCpt); static final int SQL_PARAM_CPT_CODE; static final int SQL_FIELD_ID; static final int SQL_FIELD_CVX_CODE; static final int SQL_FIELD_CVX_SHORT_DESCRIPTION; static final int SQL_FIELD_FULL_DESCRIPTION; static final String CODE_SYSTEM_CVX; }