### Question:
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);  }### Answer:
@Test void testGetAllConfigValues_no_stmt() throws SQLException { assertEquals(0, repository.getAllConfigValues().size()); }
@Test void testGetAllConfigValues_exception() throws SQLException { repository.selectAll = mock(PreparedStatement.class); when(repository.selectAll.executeQuery()).thenThrow(SQLException.class); assertEquals(0, repository.getAllConfigValues().size()); }
@Test void testGetAllConfigValues() throws SQLException { repository.selectAll = mock(PreparedStatement.class); ResultSet rs = mock(ResultSet.class); when(rs.next()).thenReturn(true).thenReturn(false); when(rs.getString(1)).thenReturn("test"); when(rs.getString(2)).thenReturn("value"); when(repository.selectAll.executeQuery()).thenReturn(rs); assertEquals(1, repository.getAllConfigValues().size()); }