@Override public void addSubscriber(User user, Test test) { Test freshTest = testDAO.get(test.getId()); User freshUser = userDAO.get(user.getId()); Collection<User> testSubscribers = freshTest.getSubscribers(); if (testSubscribers.contains(freshUser)) { return; } testSubscribers.add(freshUser); testDAO.update(freshTest); }
@Override public void removeSubscriber(User user, Test test) { Test freshTest = testDAO.get(test.getId()); Collection<User> testSubscribers = new ArrayList<>(freshTest.getSubscribers()); for (User testSubscriber : freshTest.getSubscribers()) { if (testSubscriber.getId().equals(user.getId())) { testSubscribers.remove(testSubscriber); } } test.setSubscribers(testSubscribers); testDAO.update(test); }
@Override public void removeTagsFromTestExecutions( Collection<String> tags, Collection<TestExecution> testExecutions) { for (TestExecution testExecutionItem : testExecutions) { TestExecution testExecution = testExecutionDAO.get(testExecutionItem.getId()); if (testExecution == null) { continue; } for (Tag tag : testExecution.getTags()) { if (tags.contains(tag.getName())) { testExecution.getTags().remove(tag); } } testExecutionDAO.update(testExecution); } }