@Test public void testGetPrioritiesSuccess() { applications.add(application); priorityUUIDs.add(experimentId); application.setPriorities(priorityUUIDs); Mockito.when(accessor.getPriorities(applicationName.toString())).thenReturn(result); Mockito.when(result.all()).thenReturn(applications); Mockito.when(experimentAccessor.getExperimentById(Mockito.any())).thenReturn(experimentResult); Mockito.when(experimentResult.one()).thenReturn(experiment); PrioritizedExperimentList priorities = repository.getPriorities(applicationName); assertEquals("Values should be equal", 1, priorities.getPrioritizedExperiments().size()); assertEquals("Values should be equal", experimentId, priorities.getPrioritizedExperiments().get(0).getID().getRawID()); }
@Override public PrioritizedExperimentList getPriorities( Application.Name applicationName) { LOGGER.debug("Getting priorities for {} ", applicationName); PrioritizedExperimentList prioritizedExperimentList = new PrioritizedExperimentList(); try { List<ID> priorityList = getPriorityList(applicationName); LOGGER.debug("Received priorities list {} for {} ", new Object[]{ priorityList, applicationName}); if (priorityList != null) { final List<UUID> priorityUUIDs = priorityList.stream() .map(id -> id.getRawID()).collect(Collectors.toList()); List<com.intuit.wasabi.repository.cassandra.pojo.Experiment> experimentPojos = priorityUUIDs.stream().map(uuid -> experimentAccessor.getExperimentById(uuid).one()) .collect(Collectors.toList()); LOGGER.debug("Received experimentPojos {} for priorityUUIDs {}", new Object[]{experimentPojos, priorityUUIDs}); int priorityValue = 1; for (com.intuit.wasabi.repository.cassandra.pojo.Experiment experimentPojo : experimentPojos) { prioritizedExperimentList .addPrioritizedExperiment(PrioritizedExperiment .from(ExperimentHelper .makeExperiment(experimentPojo), priorityValue).build()); priorityValue += 1; } } } catch (Exception e) { LOGGER.error("Exception while getting priority list for {} ", new Object[]{applicationName}, e); throw new RepositoryException( "Unable to retrieve the priority list for application: \"" + applicationName.toString() + "\"" + e); } LOGGER.debug("Returning prioritizedExperimentList {} ", prioritizedExperimentList); return prioritizedExperimentList; }
CassandraPrioritiesRepository implements PrioritiesRepository { @Override public PrioritizedExperimentList getPriorities( Application.Name applicationName) { LOGGER.debug("Getting priorities for {} ", applicationName); PrioritizedExperimentList prioritizedExperimentList = new PrioritizedExperimentList(); try { List<ID> priorityList = getPriorityList(applicationName); LOGGER.debug("Received priorities list {} for {} ", new Object[]{ priorityList, applicationName}); if (priorityList != null) { final List<UUID> priorityUUIDs = priorityList.stream() .map(id -> id.getRawID()).collect(Collectors.toList()); List<com.intuit.wasabi.repository.cassandra.pojo.Experiment> experimentPojos = priorityUUIDs.stream().map(uuid -> experimentAccessor.getExperimentById(uuid).one()) .collect(Collectors.toList()); LOGGER.debug("Received experimentPojos {} for priorityUUIDs {}", new Object[]{experimentPojos, priorityUUIDs}); int priorityValue = 1; for (com.intuit.wasabi.repository.cassandra.pojo.Experiment experimentPojo : experimentPojos) { prioritizedExperimentList .addPrioritizedExperiment(PrioritizedExperiment .from(ExperimentHelper .makeExperiment(experimentPojo), priorityValue).build()); priorityValue += 1; } } } catch (Exception e) { LOGGER.error("Exception while getting priority list for {} ", new Object[]{applicationName}, e); throw new RepositoryException( "Unable to retrieve the priority list for application: \"" + applicationName.toString() + "\"" + e); } LOGGER.debug("Returning prioritizedExperimentList {} ", prioritizedExperimentList); return prioritizedExperimentList; } }
CassandraPrioritiesRepository implements PrioritiesRepository { @Override public PrioritizedExperimentList getPriorities( Application.Name applicationName) { LOGGER.debug("Getting priorities for {} ", applicationName); PrioritizedExperimentList prioritizedExperimentList = new PrioritizedExperimentList(); try { List<ID> priorityList = getPriorityList(applicationName); LOGGER.debug("Received priorities list {} for {} ", new Object[]{ priorityList, applicationName}); if (priorityList != null) { final List<UUID> priorityUUIDs = priorityList.stream() .map(id -> id.getRawID()).collect(Collectors.toList()); List<com.intuit.wasabi.repository.cassandra.pojo.Experiment> experimentPojos = priorityUUIDs.stream().map(uuid -> experimentAccessor.getExperimentById(uuid).one()) .collect(Collectors.toList()); LOGGER.debug("Received experimentPojos {} for priorityUUIDs {}", new Object[]{experimentPojos, priorityUUIDs}); int priorityValue = 1; for (com.intuit.wasabi.repository.cassandra.pojo.Experiment experimentPojo : experimentPojos) { prioritizedExperimentList .addPrioritizedExperiment(PrioritizedExperiment .from(ExperimentHelper .makeExperiment(experimentPojo), priorityValue).build()); priorityValue += 1; } } } catch (Exception e) { LOGGER.error("Exception while getting priority list for {} ", new Object[]{applicationName}, e); throw new RepositoryException( "Unable to retrieve the priority list for application: \"" + applicationName.toString() + "\"" + e); } LOGGER.debug("Returning prioritizedExperimentList {} ", prioritizedExperimentList); return prioritizedExperimentList; } @Inject  CassandraPrioritiesRepository(PrioritiesAccessor prioritiesAccessor,
                                         ExperimentAccessor experimentAccessor); }
CassandraPrioritiesRepository implements PrioritiesRepository { @Override public PrioritizedExperimentList getPriorities( Application.Name applicationName) { LOGGER.debug("Getting priorities for {} ", applicationName); PrioritizedExperimentList prioritizedExperimentList = new PrioritizedExperimentList(); try { List<ID> priorityList = getPriorityList(applicationName); LOGGER.debug("Received priorities list {} for {} ", new Object[]{ priorityList, applicationName}); if (priorityList != null) { final List<UUID> priorityUUIDs = priorityList.stream() .map(id -> id.getRawID()).collect(Collectors.toList()); List<com.intuit.wasabi.repository.cassandra.pojo.Experiment> experimentPojos = priorityUUIDs.stream().map(uuid -> experimentAccessor.getExperimentById(uuid).one()) .collect(Collectors.toList()); LOGGER.debug("Received experimentPojos {} for priorityUUIDs {}", new Object[]{experimentPojos, priorityUUIDs}); int priorityValue = 1; for (com.intuit.wasabi.repository.cassandra.pojo.Experiment experimentPojo : experimentPojos) { prioritizedExperimentList .addPrioritizedExperiment(PrioritizedExperiment .from(ExperimentHelper .makeExperiment(experimentPojo), priorityValue).build()); priorityValue += 1; } } } catch (Exception e) { LOGGER.error("Exception while getting priority list for {} ", new Object[]{applicationName}, e); throw new RepositoryException( "Unable to retrieve the priority list for application: \"" + applicationName.toString() + "\"" + e); } LOGGER.debug("Returning prioritizedExperimentList {} ", prioritizedExperimentList); return prioritizedExperimentList; } @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 PrioritizedExperimentList getPriorities( Application.Name applicationName) { LOGGER.debug("Getting priorities for {} ", applicationName); PrioritizedExperimentList prioritizedExperimentList = new PrioritizedExperimentList(); try { List<ID> priorityList = getPriorityList(applicationName); LOGGER.debug("Received priorities list {} for {} ", new Object[]{ priorityList, applicationName}); if (priorityList != null) { final List<UUID> priorityUUIDs = priorityList.stream() .map(id -> id.getRawID()).collect(Collectors.toList()); List<com.intuit.wasabi.repository.cassandra.pojo.Experiment> experimentPojos = priorityUUIDs.stream().map(uuid -> experimentAccessor.getExperimentById(uuid).one()) .collect(Collectors.toList()); LOGGER.debug("Received experimentPojos {} for priorityUUIDs {}", new Object[]{experimentPojos, priorityUUIDs}); int priorityValue = 1; for (com.intuit.wasabi.repository.cassandra.pojo.Experiment experimentPojo : experimentPojos) { prioritizedExperimentList .addPrioritizedExperiment(PrioritizedExperiment .from(ExperimentHelper .makeExperiment(experimentPojo), priorityValue).build()); priorityValue += 1; } } } catch (Exception e) { LOGGER.error("Exception while getting priority list for {} ", new Object[]{applicationName}, e); throw new RepositoryException( "Unable to retrieve the priority list for application: \"" + applicationName.toString() + "\"" + e); } LOGGER.debug("Returning prioritizedExperimentList {} ", prioritizedExperimentList); return prioritizedExperimentList; } @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);  }