JdbcDependencyManager { public Map<Dependency, FileValidationStatus> getValidationStatuses(final Set<Dependency> deps, final String validationKey) throws SQLException { Map<Dependency, FileValidationStatus> depValidationStatuses = new HashMap<>(); if (deps.isEmpty()) { return depValidationStatuses; } Map<String, Dependency> hashAndFileNameToDep = new HashMap<>(); Connection conn = null; ResultSet rs = null; PreparedStatement stmnt = null; try { conn = this.dbOperator.getDataSource().getConnection(); if (conn == null) { throw new SQLException("Null connection"); } stmnt = conn.prepareStatement( String .format("SELECT file_name, file_sha1, validation_status FROM validated_dependencies " + "WHERE validation_key = ? AND (%s)", makeStrWithQuestionMarks(deps.size()))); stmnt.setString(1, validationKey); int index = 2; for (Dependency d : deps) { stmnt.setString(index++, d.getFileName()); stmnt.setString(index++, d.getSHA1()); hashAndFileNameToDep.put(d.getFileName() + d.getSHA1(), d); } rs = stmnt.executeQuery(); while (rs.next()) { Dependency d = hashAndFileNameToDep.remove(rs.getString(1) + rs.getString(2)); if (d != null) { FileValidationStatus v = FileValidationStatus.valueOf(rs.getInt(3)); depValidationStatuses.put(d, v); } } hashAndFileNameToDep.values().stream() .forEach(d -> depValidationStatuses.put(d, FileValidationStatus.NEW)); } catch (final SQLException ex) { log.error("Transaction failed: ", ex); throw ex; } finally { DbUtils.closeQuietly(conn, stmnt, rs); } return depValidationStatuses; } @Inject  JdbcDependencyManager(final DatabaseOperator dbOperator); Map<Dependency, FileValidationStatus> getValidationStatuses(final Set<Dependency> deps,
      final String validationKey); void updateValidationStatuses(final Map<Dependency, FileValidationStatus> depValidationStatuses,
      final String validationKey);  }
@Test public void testEmptyGetValidationStatuses() throws Exception { Map<Dependency, FileValidationStatus> expectedResult = new HashMap(); assertEquals(expectedResult, this.jdbcDependencyManager.getValidationStatuses(new HashSet(), VALIDATION_KEY)); verify(this.dbOperator, never()).query(anyString(), any()); }