@Test public void getExperimentPagesEmptyResultTest() { List<PageExperimentByAppNamePage> mockedResult = new ArrayList<>(); when(experimentPageAccessor.selectBy(any(UUID.class))).thenReturn(mockedResultMapping); when(mockedResultMapping.iterator()).thenReturn(mockedResult.iterator()); ExperimentPageList result = repository.getExperimentPages(Experiment.ID.newInstance()); assertThat(result.getPages().size(), is(0)); }
@Override public ExperimentPageList getExperimentPages(Experiment.ID experimentID) { ExperimentPageList experimentPageList = new ExperimentPageList(); try { Result<PageExperimentByAppNamePage> result = experimentPageAccessor.selectBy(experimentID.getRawID()); Stream<PageExperimentByAppNamePage> resultList = StreamSupport.stream( Spliterators.spliteratorUnknownSize(result.iterator(), Spliterator.ORDERED), false); List<ExperimentPage> experimentPages = resultList .map(t -> ExperimentPage.withAttributes( Page.Name.valueOf(t.getPage()), t.isAssign() ).build() ).collect(Collectors.toList()); experimentPageList.setPages(experimentPages); } catch (ReadTimeoutException | UnavailableException | NoHostAvailableException e) { throw new RepositoryException("Could not retrieve the pages for experiment: \"" + experimentID + "\"", e); } return experimentPageList; }
CassandraPagesRepository implements PagesRepository { @Override public ExperimentPageList getExperimentPages(Experiment.ID experimentID) { ExperimentPageList experimentPageList = new ExperimentPageList(); try { Result<PageExperimentByAppNamePage> result = experimentPageAccessor.selectBy(experimentID.getRawID()); Stream<PageExperimentByAppNamePage> resultList = StreamSupport.stream( Spliterators.spliteratorUnknownSize(result.iterator(), Spliterator.ORDERED), false); List<ExperimentPage> experimentPages = resultList .map(t -> ExperimentPage.withAttributes( Page.Name.valueOf(t.getPage()), t.isAssign() ).build() ).collect(Collectors.toList()); experimentPageList.setPages(experimentPages); } catch (ReadTimeoutException | UnavailableException | NoHostAvailableException e) { throw new RepositoryException("Could not retrieve the pages for experiment: \"" + experimentID + "\"", e); } return experimentPageList; } }
CassandraPagesRepository implements PagesRepository { @Override public ExperimentPageList getExperimentPages(Experiment.ID experimentID) { ExperimentPageList experimentPageList = new ExperimentPageList(); try { Result<PageExperimentByAppNamePage> result = experimentPageAccessor.selectBy(experimentID.getRawID()); Stream<PageExperimentByAppNamePage> resultList = StreamSupport.stream( Spliterators.spliteratorUnknownSize(result.iterator(), Spliterator.ORDERED), false); List<ExperimentPage> experimentPages = resultList .map(t -> ExperimentPage.withAttributes( Page.Name.valueOf(t.getPage()), t.isAssign() ).build() ).collect(Collectors.toList()); experimentPageList.setPages(experimentPages); } catch (ReadTimeoutException | UnavailableException | NoHostAvailableException e) { throw new RepositoryException("Could not retrieve the pages for experiment: \"" + experimentID + "\"", e); } return experimentPageList; } @Inject  CassandraPagesRepository(ExperimentAccessor experimentAccessor,
                                    PageExperimentIndexAccessor pageExperimentIndexAccessor,
                                    ExperimentPageAccessor experimentPageAccessor,
                                    AppPageIndexAccessor appPageIndexAccessor,
                                    ExperimentAuditLogAccessor experimentAuditLogAccessor,
                                    MappingManager mappingManager); }
CassandraPagesRepository implements PagesRepository { @Override public ExperimentPageList getExperimentPages(Experiment.ID experimentID) { ExperimentPageList experimentPageList = new ExperimentPageList(); try { Result<PageExperimentByAppNamePage> result = experimentPageAccessor.selectBy(experimentID.getRawID()); Stream<PageExperimentByAppNamePage> resultList = StreamSupport.stream( Spliterators.spliteratorUnknownSize(result.iterator(), Spliterator.ORDERED), false); List<ExperimentPage> experimentPages = resultList .map(t -> ExperimentPage.withAttributes( Page.Name.valueOf(t.getPage()), t.isAssign() ).build() ).collect(Collectors.toList()); experimentPageList.setPages(experimentPages); } catch (ReadTimeoutException | UnavailableException | NoHostAvailableException e) { throw new RepositoryException("Could not retrieve the pages for experiment: \"" + experimentID + "\"", e); } return experimentPageList; } @Inject  CassandraPagesRepository(ExperimentAccessor experimentAccessor,
                                    PageExperimentIndexAccessor pageExperimentIndexAccessor,
                                    ExperimentPageAccessor experimentPageAccessor,
                                    AppPageIndexAccessor appPageIndexAccessor,
                                    ExperimentAuditLogAccessor experimentAuditLogAccessor,
                                    MappingManager mappingManager); @Override void postPages(Application.Name applicationName, Experiment.ID experimentID, ExperimentPageList experimentPageList); @Override void deletePage(Application.Name applicationName, Experiment.ID experimentID, Page.Name pageName); @Override List<Page> getPageList(Application.Name applicationName); @Override Map<Page.Name, List<PageExperiment>> getPageExperimentList(Application.Name applicationName); @Override ExperimentPageList getExperimentPages(Experiment.ID experimentID); @Override List<PageExperiment> getExperiments(Application.Name applicationName, Page.Name pageName); @Override List<PageExperiment> getExperimentsWithoutLabels(Application.Name applicationName, Page.Name pageName); @Override Map<Pair<Application.Name, Page.Name>, List<PageExperiment>> getExperimentsWithoutLabels(Collection<Pair<Application.Name, Page.Name>> appAndPagePairs); @Override void erasePageData(Application.Name applicationName, Experiment.ID experimentID); }
CassandraPagesRepository implements PagesRepository { @Override public ExperimentPageList getExperimentPages(Experiment.ID experimentID) { ExperimentPageList experimentPageList = new ExperimentPageList(); try { Result<PageExperimentByAppNamePage> result = experimentPageAccessor.selectBy(experimentID.getRawID()); Stream<PageExperimentByAppNamePage> resultList = StreamSupport.stream( Spliterators.spliteratorUnknownSize(result.iterator(), Spliterator.ORDERED), false); List<ExperimentPage> experimentPages = resultList .map(t -> ExperimentPage.withAttributes( Page.Name.valueOf(t.getPage()), t.isAssign() ).build() ).collect(Collectors.toList()); experimentPageList.setPages(experimentPages); } catch (ReadTimeoutException | UnavailableException | NoHostAvailableException e) { throw new RepositoryException("Could not retrieve the pages for experiment: \"" + experimentID + "\"", e); } return experimentPageList; } @Inject  CassandraPagesRepository(ExperimentAccessor experimentAccessor,
                                    PageExperimentIndexAccessor pageExperimentIndexAccessor,
                                    ExperimentPageAccessor experimentPageAccessor,
                                    AppPageIndexAccessor appPageIndexAccessor,
                                    ExperimentAuditLogAccessor experimentAuditLogAccessor,
                                    MappingManager mappingManager); @Override void postPages(Application.Name applicationName, Experiment.ID experimentID, ExperimentPageList experimentPageList); @Override void deletePage(Application.Name applicationName, Experiment.ID experimentID, Page.Name pageName); @Override List<Page> getPageList(Application.Name applicationName); @Override Map<Page.Name, List<PageExperiment>> getPageExperimentList(Application.Name applicationName); @Override ExperimentPageList getExperimentPages(Experiment.ID experimentID); @Override List<PageExperiment> getExperiments(Application.Name applicationName, Page.Name pageName); @Override List<PageExperiment> getExperimentsWithoutLabels(Application.Name applicationName, Page.Name pageName); @Override Map<Pair<Application.Name, Page.Name>, List<PageExperiment>> getExperimentsWithoutLabels(Collection<Pair<Application.Name, Page.Name>> appAndPagePairs); @Override void erasePageData(Application.Name applicationName, Experiment.ID experimentID);  }