@Test public void testCreatePrioritiesSuccess() { priorityIds.add(Experiment.ID.newInstance()); repository.createPriorities(applicationName, priorityIds); Mockito.verify(accessor).updatePriorities(Mockito.anyList(), Mockito.anyString()); }
@Override public void createPriorities(Application.Name applicationName, List<Experiment.ID> priorityIds) { LOGGER.debug("Creating priority list for {} and ids {}", applicationName, priorityIds); if (priorityIds.isEmpty()) { LOGGER.debug("Deleting priority list for {} and ids {}", applicationName, priorityIds); try { prioritiesAccessor.deletePriorities(applicationName.toString()); } catch (Exception e) { LOGGER.error( "Exception while deleting priority list for {} and ids {}", new Object[]{applicationName, priorityIds}, e); throw new RepositoryException( "Unable to delete the priority list for the application: \"" + applicationName.toString() + "\"" + e); } } else { LOGGER.debug("Updating priority list for {} and ids {}", applicationName, priorityIds); List<UUID> experimentIds = new ArrayList<>(); for (Experiment.ID experimentId : priorityIds) { experimentIds.add(experimentId.getRawID()); } try { prioritiesAccessor.updatePriorities(experimentIds, applicationName.toString()); } catch (Exception e) { LOGGER.error( "Exception while updating priority list for {} and ids {}", new Object[]{applicationName, priorityIds}, e); throw new RepositoryException( "Unable to modify the priority list " + experimentIds + " for application: \"" + applicationName.toString() + "\"" + e); } } }
CassandraPrioritiesRepository implements PrioritiesRepository { @Override public void createPriorities(Application.Name applicationName, List<Experiment.ID> priorityIds) { LOGGER.debug("Creating priority list for {} and ids {}", applicationName, priorityIds); if (priorityIds.isEmpty()) { LOGGER.debug("Deleting priority list for {} and ids {}", applicationName, priorityIds); try { prioritiesAccessor.deletePriorities(applicationName.toString()); } catch (Exception e) { LOGGER.error( "Exception while deleting priority list for {} and ids {}", new Object[]{applicationName, priorityIds}, e); throw new RepositoryException( "Unable to delete the priority list for the application: \"" + applicationName.toString() + "\"" + e); } } else { LOGGER.debug("Updating priority list for {} and ids {}", applicationName, priorityIds); List<UUID> experimentIds = new ArrayList<>(); for (Experiment.ID experimentId : priorityIds) { experimentIds.add(experimentId.getRawID()); } try { prioritiesAccessor.updatePriorities(experimentIds, applicationName.toString()); } catch (Exception e) { LOGGER.error( "Exception while updating priority list for {} and ids {}", new Object[]{applicationName, priorityIds}, e); throw new RepositoryException( "Unable to modify the priority list " + experimentIds + " for application: \"" + applicationName.toString() + "\"" + e); } } } }
CassandraPrioritiesRepository implements PrioritiesRepository { @Override public void createPriorities(Application.Name applicationName, List<Experiment.ID> priorityIds) { LOGGER.debug("Creating priority list for {} and ids {}", applicationName, priorityIds); if (priorityIds.isEmpty()) { LOGGER.debug("Deleting priority list for {} and ids {}", applicationName, priorityIds); try { prioritiesAccessor.deletePriorities(applicationName.toString()); } catch (Exception e) { LOGGER.error( "Exception while deleting priority list for {} and ids {}", new Object[]{applicationName, priorityIds}, e); throw new RepositoryException( "Unable to delete the priority list for the application: \"" + applicationName.toString() + "\"" + e); } } else { LOGGER.debug("Updating priority list for {} and ids {}", applicationName, priorityIds); List<UUID> experimentIds = new ArrayList<>(); for (Experiment.ID experimentId : priorityIds) { experimentIds.add(experimentId.getRawID()); } try { prioritiesAccessor.updatePriorities(experimentIds, applicationName.toString()); } catch (Exception e) { LOGGER.error( "Exception while updating priority list for {} and ids {}", new Object[]{applicationName, priorityIds}, e); throw new RepositoryException( "Unable to modify the priority list " + experimentIds + " for application: \"" + applicationName.toString() + "\"" + e); } } } @Inject  CassandraPrioritiesRepository(PrioritiesAccessor prioritiesAccessor,
                                         ExperimentAccessor experimentAccessor); }
CassandraPrioritiesRepository implements PrioritiesRepository { @Override public void createPriorities(Application.Name applicationName, List<Experiment.ID> priorityIds) { LOGGER.debug("Creating priority list for {} and ids {}", applicationName, priorityIds); if (priorityIds.isEmpty()) { LOGGER.debug("Deleting priority list for {} and ids {}", applicationName, priorityIds); try { prioritiesAccessor.deletePriorities(applicationName.toString()); } catch (Exception e) { LOGGER.error( "Exception while deleting priority list for {} and ids {}", new Object[]{applicationName, priorityIds}, e); throw new RepositoryException( "Unable to delete the priority list for the application: \"" + applicationName.toString() + "\"" + e); } } else { LOGGER.debug("Updating priority list for {} and ids {}", applicationName, priorityIds); List<UUID> experimentIds = new ArrayList<>(); for (Experiment.ID experimentId : priorityIds) { experimentIds.add(experimentId.getRawID()); } try { prioritiesAccessor.updatePriorities(experimentIds, applicationName.toString()); } catch (Exception e) { LOGGER.error( "Exception while updating priority list for {} and ids {}", new Object[]{applicationName, priorityIds}, e); throw new RepositoryException( "Unable to modify the priority list " + experimentIds + " for application: \"" + applicationName.toString() + "\"" + e); } } } @Inject  CassandraPrioritiesRepository(PrioritiesAccessor prioritiesAccessor,
                                         ExperimentAccessor experimentAccessor); @Override PrioritizedExperimentList getPriorities(
            Application.Name applicationName); @Override Map<Application.Name, PrioritizedExperimentList> getPriorities(Collection<Application.Name> applicationNames); @Override int getPriorityListLength(Application.Name applicationName); @Override void createPriorities(Application.Name applicationName,
                                 List<Experiment.ID> priorityIds); @Override List<Experiment.ID> getPriorityList(Application.Name applicationName); }
CassandraPrioritiesRepository implements PrioritiesRepository { @Override public void createPriorities(Application.Name applicationName, List<Experiment.ID> priorityIds) { LOGGER.debug("Creating priority list for {} and ids {}", applicationName, priorityIds); if (priorityIds.isEmpty()) { LOGGER.debug("Deleting priority list for {} and ids {}", applicationName, priorityIds); try { prioritiesAccessor.deletePriorities(applicationName.toString()); } catch (Exception e) { LOGGER.error( "Exception while deleting priority list for {} and ids {}", new Object[]{applicationName, priorityIds}, e); throw new RepositoryException( "Unable to delete the priority list for the application: \"" + applicationName.toString() + "\"" + e); } } else { LOGGER.debug("Updating priority list for {} and ids {}", applicationName, priorityIds); List<UUID> experimentIds = new ArrayList<>(); for (Experiment.ID experimentId : priorityIds) { experimentIds.add(experimentId.getRawID()); } try { prioritiesAccessor.updatePriorities(experimentIds, applicationName.toString()); } catch (Exception e) { LOGGER.error( "Exception while updating priority list for {} and ids {}", new Object[]{applicationName, priorityIds}, e); throw new RepositoryException( "Unable to modify the priority list " + experimentIds + " for application: \"" + applicationName.toString() + "\"" + e); } } } @Inject  CassandraPrioritiesRepository(PrioritiesAccessor prioritiesAccessor,
                                         ExperimentAccessor experimentAccessor); @Override PrioritizedExperimentList getPriorities(
            Application.Name applicationName); @Override Map<Application.Name, PrioritizedExperimentList> getPriorities(Collection<Application.Name> applicationNames); @Override int getPriorityListLength(Application.Name applicationName); @Override void createPriorities(Application.Name applicationName,
                                 List<Experiment.ID> priorityIds); @Override List<Experiment.ID> getPriorityList(Application.Name applicationName);  }