@Test public void testGetAllergyUMLSCuiFromDodNcidSQLExceptionOnResultSetClose() { try { when(mockResultSet.next()).thenReturn(false); Mockito.doThrow(new SQLException()).when(mockResultSet).close(); @SuppressWarnings("unused") JLVMappedCode oMappedCode = testSubject.getAllergyUMLSCuiFromDodNcid("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 getAllergyUMLSCuiFromDodNcid(String sDodNcid) throws TermLoadException { JLVMappedCode oMappedCode = null; if (NullChecker.isNotNullish(sDodNcid)) { PreparedStatement psSelectStatement = null; ResultSet oResults = null; try { psSelectStatement = this.oDBConnection.prepareStatement(SQL_SELECT_BY_DOD_NCID); psSelectStatement.setString(SQL_PARAM_DOD_NCID, sDodNcid); oResults = psSelectStatement.executeQuery(); boolean bHasResult = false; if (oResults.next()) { JLVMappedCode oTempMappedCode = new JLVMappedCode(); String sUmlsCode = oResults.getString(SQL_FIELD_DOD_ALLERGIES_UMLS_CUI); if (NullChecker.isNotNullish(sUmlsCode)) { oTempMappedCode.setCode(sUmlsCode); bHasResult = true; } String sUmlsText = oResults.getString(SQL_FIELD_REACTANTS_UMLS_TEXT); if (NullChecker.isNotNullish(sUmlsText)) { oTempMappedCode.setDisplayText(sUmlsText); bHasResult = true; } if (bHasResult) { oTempMappedCode.setCodeSystem(CODE_SYSTEM_UMLS_CUI); oMappedCode = oTempMappedCode; } } } catch (SQLException e) { throw new TermLoadException("Failed to read Allergy information from the 'dod_allergies' and 'reactants' 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; }
JLVDodAllergiesMap { public JLVMappedCode getAllergyUMLSCuiFromDodNcid(String sDodNcid) throws TermLoadException { JLVMappedCode oMappedCode = null; if (NullChecker.isNotNullish(sDodNcid)) { PreparedStatement psSelectStatement = null; ResultSet oResults = null; try { psSelectStatement = this.oDBConnection.prepareStatement(SQL_SELECT_BY_DOD_NCID); psSelectStatement.setString(SQL_PARAM_DOD_NCID, sDodNcid); oResults = psSelectStatement.executeQuery(); boolean bHasResult = false; if (oResults.next()) { JLVMappedCode oTempMappedCode = new JLVMappedCode(); String sUmlsCode = oResults.getString(SQL_FIELD_DOD_ALLERGIES_UMLS_CUI); if (NullChecker.isNotNullish(sUmlsCode)) { oTempMappedCode.setCode(sUmlsCode); bHasResult = true; } String sUmlsText = oResults.getString(SQL_FIELD_REACTANTS_UMLS_TEXT); if (NullChecker.isNotNullish(sUmlsText)) { oTempMappedCode.setDisplayText(sUmlsText); bHasResult = true; } if (bHasResult) { oTempMappedCode.setCodeSystem(CODE_SYSTEM_UMLS_CUI); oMappedCode = oTempMappedCode; } } } catch (SQLException e) { throw new TermLoadException("Failed to read Allergy information from the 'dod_allergies' and 'reactants' 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; } }
JLVDodAllergiesMap { public JLVMappedCode getAllergyUMLSCuiFromDodNcid(String sDodNcid) throws TermLoadException { JLVMappedCode oMappedCode = null; if (NullChecker.isNotNullish(sDodNcid)) { PreparedStatement psSelectStatement = null; ResultSet oResults = null; try { psSelectStatement = this.oDBConnection.prepareStatement(SQL_SELECT_BY_DOD_NCID); psSelectStatement.setString(SQL_PARAM_DOD_NCID, sDodNcid); oResults = psSelectStatement.executeQuery(); boolean bHasResult = false; if (oResults.next()) { JLVMappedCode oTempMappedCode = new JLVMappedCode(); String sUmlsCode = oResults.getString(SQL_FIELD_DOD_ALLERGIES_UMLS_CUI); if (NullChecker.isNotNullish(sUmlsCode)) { oTempMappedCode.setCode(sUmlsCode); bHasResult = true; } String sUmlsText = oResults.getString(SQL_FIELD_REACTANTS_UMLS_TEXT); if (NullChecker.isNotNullish(sUmlsText)) { oTempMappedCode.setDisplayText(sUmlsText); bHasResult = true; } if (bHasResult) { oTempMappedCode.setCodeSystem(CODE_SYSTEM_UMLS_CUI); oMappedCode = oTempMappedCode; } } } catch (SQLException e) { throw new TermLoadException("Failed to read Allergy information from the 'dod_allergies' and 'reactants' 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  JLVDodAllergiesMap();  JLVDodAllergiesMap(Connection oDBConnection); }
JLVDodAllergiesMap { public JLVMappedCode getAllergyUMLSCuiFromDodNcid(String sDodNcid) throws TermLoadException { JLVMappedCode oMappedCode = null; if (NullChecker.isNotNullish(sDodNcid)) { PreparedStatement psSelectStatement = null; ResultSet oResults = null; try { psSelectStatement = this.oDBConnection.prepareStatement(SQL_SELECT_BY_DOD_NCID); psSelectStatement.setString(SQL_PARAM_DOD_NCID, sDodNcid); oResults = psSelectStatement.executeQuery(); boolean bHasResult = false; if (oResults.next()) { JLVMappedCode oTempMappedCode = new JLVMappedCode(); String sUmlsCode = oResults.getString(SQL_FIELD_DOD_ALLERGIES_UMLS_CUI); if (NullChecker.isNotNullish(sUmlsCode)) { oTempMappedCode.setCode(sUmlsCode); bHasResult = true; } String sUmlsText = oResults.getString(SQL_FIELD_REACTANTS_UMLS_TEXT); if (NullChecker.isNotNullish(sUmlsText)) { oTempMappedCode.setDisplayText(sUmlsText); bHasResult = true; } if (bHasResult) { oTempMappedCode.setCodeSystem(CODE_SYSTEM_UMLS_CUI); oMappedCode = oTempMappedCode; } } } catch (SQLException e) { throw new TermLoadException("Failed to read Allergy information from the 'dod_allergies' and 'reactants' 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  JLVDodAllergiesMap();  JLVDodAllergiesMap(Connection oDBConnection); JLVMappedCode getAllergyUMLSCuiFromChcsIen(String sChcsIen); JLVMappedCode getAllergyUMLSCuiFromDodNcid(String sDodNcid); }
JLVDodAllergiesMap { public JLVMappedCode getAllergyUMLSCuiFromDodNcid(String sDodNcid) throws TermLoadException { JLVMappedCode oMappedCode = null; if (NullChecker.isNotNullish(sDodNcid)) { PreparedStatement psSelectStatement = null; ResultSet oResults = null; try { psSelectStatement = this.oDBConnection.prepareStatement(SQL_SELECT_BY_DOD_NCID); psSelectStatement.setString(SQL_PARAM_DOD_NCID, sDodNcid); oResults = psSelectStatement.executeQuery(); boolean bHasResult = false; if (oResults.next()) { JLVMappedCode oTempMappedCode = new JLVMappedCode(); String sUmlsCode = oResults.getString(SQL_FIELD_DOD_ALLERGIES_UMLS_CUI); if (NullChecker.isNotNullish(sUmlsCode)) { oTempMappedCode.setCode(sUmlsCode); bHasResult = true; } String sUmlsText = oResults.getString(SQL_FIELD_REACTANTS_UMLS_TEXT); if (NullChecker.isNotNullish(sUmlsText)) { oTempMappedCode.setDisplayText(sUmlsText); bHasResult = true; } if (bHasResult) { oTempMappedCode.setCodeSystem(CODE_SYSTEM_UMLS_CUI); oMappedCode = oTempMappedCode; } } } catch (SQLException e) { throw new TermLoadException("Failed to read Allergy information from the 'dod_allergies' and 'reactants' 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  JLVDodAllergiesMap();  JLVDodAllergiesMap(Connection oDBConnection); JLVMappedCode getAllergyUMLSCuiFromChcsIen(String sChcsIen); JLVMappedCode getAllergyUMLSCuiFromDodNcid(String sDodNcid); static final int SQL_PARAM_CHCS_IEN; static final int SQL_PARAM_DOD_NCID; static final int SQL_FIELD_DOD_ALLERGIES_CHCS_ALLERGY_IEN; static final int SQL_FIELD_DOD_ALLERGIES_CHCS_DOD_NCID; static final int SQL_FIELD_DOD_ALLERGIES_CHCS_NAME; static final int SQL_FIELD_DOD_ALLERGIES_DOD_NAME; static final int SQL_FIELD_DOD_ALLERGIES_UMLS_CUI; static final int SQL_FIELD_REACTANTS_UMLS_CODE; static final int SQL_FIELD_REACTANTS_UMLS_TEXT; static final String CODE_SYSTEM_UMLS_CUI; }