@Test void testGetAllConfigValues_exception() throws SQLException { repository.selectAll = mock(PreparedStatement.class); when(repository.selectAll.executeQuery()).thenThrow(SQLException.class); assertEquals(0, repository.getAllConfigValues().size()); }
public Map<String, String> getAllConfigValues() { Map<String, String> result = new HashMap<>(); if (selectAll != null) { try { ResultSet rs = selectAll.executeQuery(); while (rs.next()) { result.put(rs.getString(1), rs.getString(2)); } } catch (SQLException e) { log.log(Level.FINE, () -> "query for config values failed:}" + e.getMessage()); } } return result; }
Repository { public Map<String, String> getAllConfigValues() { Map<String, String> result = new HashMap<>(); if (selectAll != null) { try { ResultSet rs = selectAll.executeQuery(); while (rs.next()) { result.put(rs.getString(1), rs.getString(2)); } } catch (SQLException e) { log.log(Level.FINE, () -> "query for config values failed:}" + e.getMessage()); } } return result; } }
Repository { public Map<String, String> getAllConfigValues() { Map<String, String> result = new HashMap<>(); if (selectAll != null) { try { ResultSet rs = selectAll.executeQuery(); while (rs.next()) { result.put(rs.getString(1), rs.getString(2)); } } catch (SQLException e) { log.log(Level.FINE, () -> "query for config values failed:}" + e.getMessage()); } } return result; } Repository(Config config); }
Repository { public Map<String, String> getAllConfigValues() { Map<String, String> result = new HashMap<>(); if (selectAll != null) { try { ResultSet rs = selectAll.executeQuery(); while (rs.next()) { result.put(rs.getString(1), rs.getString(2)); } } catch (SQLException e) { log.log(Level.FINE, () -> "query for config values failed:}" + e.getMessage()); } } return result; } Repository(Config config); Map<String, String> getAllConfigValues(); String getConfigValue(String key); }
Repository { public Map<String, String> getAllConfigValues() { Map<String, String> result = new HashMap<>(); if (selectAll != null) { try { ResultSet rs = selectAll.executeQuery(); while (rs.next()) { result.put(rs.getString(1), rs.getString(2)); } } catch (SQLException e) { log.log(Level.FINE, () -> "query for config values failed:}" + e.getMessage()); } } return result; } Repository(Config config); Map<String, String> getAllConfigValues(); String getConfigValue(String key);  }