@Test public void testGetNotesLoincFromVuidNoMappingBecauseFieldsEmpty() { try { when(mockResultSet.next()).thenReturn(true).thenReturn(false); when(mockResultSet.getString(JLVNotesMap.SQL_FIELD_VA_NOTES_LOINC_NUM)).thenReturn(""); when(mockResultSet.getString(JLVNotesMap.SQL_FIELD_VA_NOTES_LOINC_TITLE)).thenReturn(""); List<JLVMappedCode> oMappedCodeList = testSubject.getNotesLoincFromVuid("123"); assertNull("The result should have been null", oMappedCodeList); verifyCloseMethodsCalled(); } catch (Exception e) { System.out.println("An unexpected exception occurred. Error: " + e.getMessage()); e.printStackTrace(); fail("An unexpected exception occurred. Error: " + e.getMessage()); } }
public List<JLVMappedCode> getNotesLoincFromVuid(String sVuid) throws TermLoadException { List<JLVMappedCode> oMappedCodes = null; if (NullChecker.isNotNullish(sVuid)) { PreparedStatement psSelectStatement = null; ResultSet oResults = null; try { psSelectStatement = this.oDBConnection.prepareStatement(SQL_SELECT_BY_VUID); psSelectStatement.setString(SQL_PARAM_VUID, sVuid); oResults = psSelectStatement.executeQuery(); boolean bHasResult = false; while (oResults.next()) { JLVMappedCode oTempMappedCode = new JLVMappedCode(); String sLoincCode = oResults.getString(SQL_FIELD_VA_NOTES_LOINC_NUM); if (NullChecker.isNotNullish(sLoincCode)) { oTempMappedCode.setCode(sLoincCode); bHasResult = true; } String sLoincText = oResults.getString(SQL_FIELD_VA_NOTES_LOINC_TITLE); if (NullChecker.isNotNullish(sLoincText)) { oTempMappedCode.setDisplayText(sLoincText); bHasResult = true; } if (bHasResult) { oTempMappedCode.setCodeSystem(CODE_SYSTEM_LOINC); if (oMappedCodes == null) oMappedCodes = new ArrayList<>(); oMappedCodes.add(oTempMappedCode); } } } catch (SQLException e) { throw new TermLoadException("Failed to read Notes information from the 'notes' 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 oMappedCodes; }
JLVNotesMap { public List<JLVMappedCode> getNotesLoincFromVuid(String sVuid) throws TermLoadException { List<JLVMappedCode> oMappedCodes = null; if (NullChecker.isNotNullish(sVuid)) { PreparedStatement psSelectStatement = null; ResultSet oResults = null; try { psSelectStatement = this.oDBConnection.prepareStatement(SQL_SELECT_BY_VUID); psSelectStatement.setString(SQL_PARAM_VUID, sVuid); oResults = psSelectStatement.executeQuery(); boolean bHasResult = false; while (oResults.next()) { JLVMappedCode oTempMappedCode = new JLVMappedCode(); String sLoincCode = oResults.getString(SQL_FIELD_VA_NOTES_LOINC_NUM); if (NullChecker.isNotNullish(sLoincCode)) { oTempMappedCode.setCode(sLoincCode); bHasResult = true; } String sLoincText = oResults.getString(SQL_FIELD_VA_NOTES_LOINC_TITLE); if (NullChecker.isNotNullish(sLoincText)) { oTempMappedCode.setDisplayText(sLoincText); bHasResult = true; } if (bHasResult) { oTempMappedCode.setCodeSystem(CODE_SYSTEM_LOINC); if (oMappedCodes == null) oMappedCodes = new ArrayList<>(); oMappedCodes.add(oTempMappedCode); } } } catch (SQLException e) { throw new TermLoadException("Failed to read Notes information from the 'notes' 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 oMappedCodes; } }
JLVNotesMap { public List<JLVMappedCode> getNotesLoincFromVuid(String sVuid) throws TermLoadException { List<JLVMappedCode> oMappedCodes = null; if (NullChecker.isNotNullish(sVuid)) { PreparedStatement psSelectStatement = null; ResultSet oResults = null; try { psSelectStatement = this.oDBConnection.prepareStatement(SQL_SELECT_BY_VUID); psSelectStatement.setString(SQL_PARAM_VUID, sVuid); oResults = psSelectStatement.executeQuery(); boolean bHasResult = false; while (oResults.next()) { JLVMappedCode oTempMappedCode = new JLVMappedCode(); String sLoincCode = oResults.getString(SQL_FIELD_VA_NOTES_LOINC_NUM); if (NullChecker.isNotNullish(sLoincCode)) { oTempMappedCode.setCode(sLoincCode); bHasResult = true; } String sLoincText = oResults.getString(SQL_FIELD_VA_NOTES_LOINC_TITLE); if (NullChecker.isNotNullish(sLoincText)) { oTempMappedCode.setDisplayText(sLoincText); bHasResult = true; } if (bHasResult) { oTempMappedCode.setCodeSystem(CODE_SYSTEM_LOINC); if (oMappedCodes == null) oMappedCodes = new ArrayList<>(); oMappedCodes.add(oTempMappedCode); } } } catch (SQLException e) { throw new TermLoadException("Failed to read Notes information from the 'notes' 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 oMappedCodes; } @SuppressWarnings("unused") private  JLVNotesMap();  JLVNotesMap(Connection oDBConnection); }
JLVNotesMap { public List<JLVMappedCode> getNotesLoincFromVuid(String sVuid) throws TermLoadException { List<JLVMappedCode> oMappedCodes = null; if (NullChecker.isNotNullish(sVuid)) { PreparedStatement psSelectStatement = null; ResultSet oResults = null; try { psSelectStatement = this.oDBConnection.prepareStatement(SQL_SELECT_BY_VUID); psSelectStatement.setString(SQL_PARAM_VUID, sVuid); oResults = psSelectStatement.executeQuery(); boolean bHasResult = false; while (oResults.next()) { JLVMappedCode oTempMappedCode = new JLVMappedCode(); String sLoincCode = oResults.getString(SQL_FIELD_VA_NOTES_LOINC_NUM); if (NullChecker.isNotNullish(sLoincCode)) { oTempMappedCode.setCode(sLoincCode); bHasResult = true; } String sLoincText = oResults.getString(SQL_FIELD_VA_NOTES_LOINC_TITLE); if (NullChecker.isNotNullish(sLoincText)) { oTempMappedCode.setDisplayText(sLoincText); bHasResult = true; } if (bHasResult) { oTempMappedCode.setCodeSystem(CODE_SYSTEM_LOINC); if (oMappedCodes == null) oMappedCodes = new ArrayList<>(); oMappedCodes.add(oTempMappedCode); } } } catch (SQLException e) { throw new TermLoadException("Failed to read Notes information from the 'notes' 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 oMappedCodes; } @SuppressWarnings("unused") private  JLVNotesMap();  JLVNotesMap(Connection oDBConnection); List<JLVMappedCode> getNotesLoincFromVuid(String sVuid); JLVMappedCode getNotesLoincFromDodNcid(String sDodNcid); }
JLVNotesMap { public List<JLVMappedCode> getNotesLoincFromVuid(String sVuid) throws TermLoadException { List<JLVMappedCode> oMappedCodes = null; if (NullChecker.isNotNullish(sVuid)) { PreparedStatement psSelectStatement = null; ResultSet oResults = null; try { psSelectStatement = this.oDBConnection.prepareStatement(SQL_SELECT_BY_VUID); psSelectStatement.setString(SQL_PARAM_VUID, sVuid); oResults = psSelectStatement.executeQuery(); boolean bHasResult = false; while (oResults.next()) { JLVMappedCode oTempMappedCode = new JLVMappedCode(); String sLoincCode = oResults.getString(SQL_FIELD_VA_NOTES_LOINC_NUM); if (NullChecker.isNotNullish(sLoincCode)) { oTempMappedCode.setCode(sLoincCode); bHasResult = true; } String sLoincText = oResults.getString(SQL_FIELD_VA_NOTES_LOINC_TITLE); if (NullChecker.isNotNullish(sLoincText)) { oTempMappedCode.setDisplayText(sLoincText); bHasResult = true; } if (bHasResult) { oTempMappedCode.setCodeSystem(CODE_SYSTEM_LOINC); if (oMappedCodes == null) oMappedCodes = new ArrayList<>(); oMappedCodes.add(oTempMappedCode); } } } catch (SQLException e) { throw new TermLoadException("Failed to read Notes information from the 'notes' 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 oMappedCodes; } @SuppressWarnings("unused") private  JLVNotesMap();  JLVNotesMap(Connection oDBConnection); List<JLVMappedCode> getNotesLoincFromVuid(String sVuid); JLVMappedCode getNotesLoincFromDodNcid(String sDodNcid); static final int SQL_PARAM_VUID; static final int SQL_PARAM_DOD_NCID; static final int SQL_FIELD_VA_NOTES_SOURCE_CODE; static final int SQL_FIELD_VA_NOTES_SOURCE_CODE_TEXT; static final int SQL_FIELD_VA_NOTES_MAP_PATH_WAY_ID; static final int SQL_FIELD_VA_NOTES_LOINC_NUM; static final int SQL_FIELD_VA_NOTES_LOINC_TITLE; static final int SQL_FIELD_DOD_NOTES_ID; static final int SQL_FIELD_DOD_NOTES_NCID; static final int SQL_FIELD_DOD_NOTES_LOINC; static final int SQL_FIELD_DOD_NOTES_MMM_NAME; static final String CODE_SYSTEM_LOINC; }