@Test public void testGetExperimentsWithoutLabels() { Page.Name pageName = Page.Name.valueOf("testPage1"); List<PageExperimentByAppNamePage> mockedResult = new ArrayList<>(); mockedResult.add( PageExperimentByAppNamePage.builder() .experimentId(experimentId) .page(pageName.toString()) .appName(APPLICATION_NAME.toString()) .assign(true) .build() ); com.intuit.wasabi.repository.cassandra.pojo.Experiment experiment = com.intuit.wasabi.repository.cassandra.pojo.Experiment.builder() .id(experimentId) .label("testLabel1") .build(); when(pageExperimentIndexAccessor.selectBy(eq(APPLICATION_NAME.toString()), eq(pageName.toString()))).thenReturn(mockedResultMapping); when(mockedResultMapping.iterator()).thenReturn(mockedResult.iterator()); when(experimentAccessor.selectBy(eq(experimentId))).thenReturn(mockedResultMapping); when(mockedResultMapping.one()).thenReturn(experiment); List<PageExperiment> result = repository.getExperimentsWithoutLabels(APPLICATION_NAME, pageName); assertThat(result.size(), is(1)); assertThat(result.get(0).getAllowNewAssignment(), is(mockedResult.get(0).isAssign())); assertThat(result.get(0).getId().getRawID(), is(experimentId)); assertThat(result.get(0).getLabel() == null, is(true)); }
@Override public List<PageExperiment> getExperimentsWithoutLabels(Application.Name applicationName, Page.Name pageName) { Stream<PageExperimentByAppNamePage> resultList = Stream.empty(); try { Result<PageExperimentByAppNamePage> result = pageExperimentIndexAccessor.selectBy(applicationName.toString(), pageName.toString()); resultList = StreamSupport.stream(Spliterators.spliteratorUnknownSize(result.iterator(), Spliterator.ORDERED), false); } catch (ReadTimeoutException | UnavailableException | NoHostAvailableException e) { throw new RepositoryException("Could not retrieve the experiments for applicationName:\"" + applicationName + "\", page:\"" + pageName, e); } return resultList.map(t -> { PageExperiment.Builder builder = new PageExperiment.Builder( Experiment.ID.valueOf(t.getExperimentId()), null, t.isAssign() ); return builder.build(); } ).collect(Collectors.toList()); }
CassandraPagesRepository implements PagesRepository { @Override public List<PageExperiment> getExperimentsWithoutLabels(Application.Name applicationName, Page.Name pageName) { Stream<PageExperimentByAppNamePage> resultList = Stream.empty(); try { Result<PageExperimentByAppNamePage> result = pageExperimentIndexAccessor.selectBy(applicationName.toString(), pageName.toString()); resultList = StreamSupport.stream(Spliterators.spliteratorUnknownSize(result.iterator(), Spliterator.ORDERED), false); } catch (ReadTimeoutException | UnavailableException | NoHostAvailableException e) { throw new RepositoryException("Could not retrieve the experiments for applicationName:\"" + applicationName + "\", page:\"" + pageName, e); } return resultList.map(t -> { PageExperiment.Builder builder = new PageExperiment.Builder( Experiment.ID.valueOf(t.getExperimentId()), null, t.isAssign() ); return builder.build(); } ).collect(Collectors.toList()); } }
CassandraPagesRepository implements PagesRepository { @Override public List<PageExperiment> getExperimentsWithoutLabels(Application.Name applicationName, Page.Name pageName) { Stream<PageExperimentByAppNamePage> resultList = Stream.empty(); try { Result<PageExperimentByAppNamePage> result = pageExperimentIndexAccessor.selectBy(applicationName.toString(), pageName.toString()); resultList = StreamSupport.stream(Spliterators.spliteratorUnknownSize(result.iterator(), Spliterator.ORDERED), false); } catch (ReadTimeoutException | UnavailableException | NoHostAvailableException e) { throw new RepositoryException("Could not retrieve the experiments for applicationName:\"" + applicationName + "\", page:\"" + pageName, e); } return resultList.map(t -> { PageExperiment.Builder builder = new PageExperiment.Builder( Experiment.ID.valueOf(t.getExperimentId()), null, t.isAssign() ); return builder.build(); } ).collect(Collectors.toList()); } @Inject  CassandraPagesRepository(ExperimentAccessor experimentAccessor,
                                    PageExperimentIndexAccessor pageExperimentIndexAccessor,
                                    ExperimentPageAccessor experimentPageAccessor,
                                    AppPageIndexAccessor appPageIndexAccessor,
                                    ExperimentAuditLogAccessor experimentAuditLogAccessor,
                                    MappingManager mappingManager); }
CassandraPagesRepository implements PagesRepository { @Override public List<PageExperiment> getExperimentsWithoutLabels(Application.Name applicationName, Page.Name pageName) { Stream<PageExperimentByAppNamePage> resultList = Stream.empty(); try { Result<PageExperimentByAppNamePage> result = pageExperimentIndexAccessor.selectBy(applicationName.toString(), pageName.toString()); resultList = StreamSupport.stream(Spliterators.spliteratorUnknownSize(result.iterator(), Spliterator.ORDERED), false); } catch (ReadTimeoutException | UnavailableException | NoHostAvailableException e) { throw new RepositoryException("Could not retrieve the experiments for applicationName:\"" + applicationName + "\", page:\"" + pageName, e); } return resultList.map(t -> { PageExperiment.Builder builder = new PageExperiment.Builder( Experiment.ID.valueOf(t.getExperimentId()), null, t.isAssign() ); return builder.build(); } ).collect(Collectors.toList()); } @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 List<PageExperiment> getExperimentsWithoutLabels(Application.Name applicationName, Page.Name pageName) { Stream<PageExperimentByAppNamePage> resultList = Stream.empty(); try { Result<PageExperimentByAppNamePage> result = pageExperimentIndexAccessor.selectBy(applicationName.toString(), pageName.toString()); resultList = StreamSupport.stream(Spliterators.spliteratorUnknownSize(result.iterator(), Spliterator.ORDERED), false); } catch (ReadTimeoutException | UnavailableException | NoHostAvailableException e) { throw new RepositoryException("Could not retrieve the experiments for applicationName:\"" + applicationName + "\", page:\"" + pageName, e); } return resultList.map(t -> { PageExperiment.Builder builder = new PageExperiment.Builder( Experiment.ID.valueOf(t.getExperimentId()), null, t.isAssign() ); return builder.build(); } ).collect(Collectors.toList()); } @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);  }