@Test public void postPagesTest() { Experiment.ID experimentID = Experiment.ID.valueOf(experimentId); ExperimentPageList inputExperiemntPages = new ExperimentPageList(); inputExperiemntPages.addPage( ExperimentPage.withAttributes( Page.Name.valueOf("testPage1"), true ) .build() ); ExperimentPageList mockedExperimentPageList = mock(ExperimentPageList.class); doReturn(mockedExperimentPageList).when(spyRepository).getExperimentPages(eq(experimentID)); doNothing().when(spyRepository).saveExperimentPageState( eq(experimentID), any(ExperimentPageList.class), any(ExperimentPageList.class) ); spyRepository.postPages(APPLICATION_NAME, experimentID, inputExperiemntPages); verify(spyRepository, times(1)).saveExperimentPageState(eq(experimentID), any(ExperimentPageList.class), any(ExperimentPageList.class)); verify(spyRepository, times(2)).getExperimentPages(eq(experimentID)); verify(pageExperimentIndexAccessor, times(inputExperiemntPages.getPages().size())) .insertBy(eq("testApp"), eq("testPage1"), eq(experimentId), eq(true)); verify(experimentPageAccessor, times(inputExperiemntPages.getPages().size())) .insertBy(eq("testPage1"), eq(experimentId), eq(true)); verify(appPageIndexAccessor, times(inputExperiemntPages.getPages().size())) .insertBy(eq("testApp"), eq("testPage1")); }
@Override public void postPages(Application.Name applicationName, Experiment.ID experimentID, ExperimentPageList experimentPageList) throws RepositoryException { ExperimentPageList oldPageList = getExperimentPages(experimentID); BatchStatement batch = new BatchStatement(); for (ExperimentPage experimentPage : experimentPageList.getPages()) { batch.add(pageExperimentIndexAccessor.insertBy( applicationName.toString(), experimentPage.getName().toString(), experimentID.getRawID(), experimentPage.getAllowNewAssignment() )); batch.add(experimentPageAccessor.insertBy( experimentPage.getName().toString(), experimentID.getRawID(), experimentPage.getAllowNewAssignment() )); batch.add(appPageIndexAccessor.insertBy( applicationName.toString(), experimentPage.getName().toString() )); } executeBatchStatement(experimentID, batch); ExperimentPageList newPageList = getExperimentPages(experimentID); saveExperimentPageState(experimentID, oldPageList, newPageList); }
CassandraPagesRepository implements PagesRepository { @Override public void postPages(Application.Name applicationName, Experiment.ID experimentID, ExperimentPageList experimentPageList) throws RepositoryException { ExperimentPageList oldPageList = getExperimentPages(experimentID); BatchStatement batch = new BatchStatement(); for (ExperimentPage experimentPage : experimentPageList.getPages()) { batch.add(pageExperimentIndexAccessor.insertBy( applicationName.toString(), experimentPage.getName().toString(), experimentID.getRawID(), experimentPage.getAllowNewAssignment() )); batch.add(experimentPageAccessor.insertBy( experimentPage.getName().toString(), experimentID.getRawID(), experimentPage.getAllowNewAssignment() )); batch.add(appPageIndexAccessor.insertBy( applicationName.toString(), experimentPage.getName().toString() )); } executeBatchStatement(experimentID, batch); ExperimentPageList newPageList = getExperimentPages(experimentID); saveExperimentPageState(experimentID, oldPageList, newPageList); } }
CassandraPagesRepository implements PagesRepository { @Override public void postPages(Application.Name applicationName, Experiment.ID experimentID, ExperimentPageList experimentPageList) throws RepositoryException { ExperimentPageList oldPageList = getExperimentPages(experimentID); BatchStatement batch = new BatchStatement(); for (ExperimentPage experimentPage : experimentPageList.getPages()) { batch.add(pageExperimentIndexAccessor.insertBy( applicationName.toString(), experimentPage.getName().toString(), experimentID.getRawID(), experimentPage.getAllowNewAssignment() )); batch.add(experimentPageAccessor.insertBy( experimentPage.getName().toString(), experimentID.getRawID(), experimentPage.getAllowNewAssignment() )); batch.add(appPageIndexAccessor.insertBy( applicationName.toString(), experimentPage.getName().toString() )); } executeBatchStatement(experimentID, batch); ExperimentPageList newPageList = getExperimentPages(experimentID); saveExperimentPageState(experimentID, oldPageList, newPageList); } @Inject  CassandraPagesRepository(ExperimentAccessor experimentAccessor,
                                    PageExperimentIndexAccessor pageExperimentIndexAccessor,
                                    ExperimentPageAccessor experimentPageAccessor,
                                    AppPageIndexAccessor appPageIndexAccessor,
                                    ExperimentAuditLogAccessor experimentAuditLogAccessor,
                                    MappingManager mappingManager); }
CassandraPagesRepository implements PagesRepository { @Override public void postPages(Application.Name applicationName, Experiment.ID experimentID, ExperimentPageList experimentPageList) throws RepositoryException { ExperimentPageList oldPageList = getExperimentPages(experimentID); BatchStatement batch = new BatchStatement(); for (ExperimentPage experimentPage : experimentPageList.getPages()) { batch.add(pageExperimentIndexAccessor.insertBy( applicationName.toString(), experimentPage.getName().toString(), experimentID.getRawID(), experimentPage.getAllowNewAssignment() )); batch.add(experimentPageAccessor.insertBy( experimentPage.getName().toString(), experimentID.getRawID(), experimentPage.getAllowNewAssignment() )); batch.add(appPageIndexAccessor.insertBy( applicationName.toString(), experimentPage.getName().toString() )); } executeBatchStatement(experimentID, batch); ExperimentPageList newPageList = getExperimentPages(experimentID); saveExperimentPageState(experimentID, oldPageList, newPageList); } @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 void postPages(Application.Name applicationName, Experiment.ID experimentID, ExperimentPageList experimentPageList) throws RepositoryException { ExperimentPageList oldPageList = getExperimentPages(experimentID); BatchStatement batch = new BatchStatement(); for (ExperimentPage experimentPage : experimentPageList.getPages()) { batch.add(pageExperimentIndexAccessor.insertBy( applicationName.toString(), experimentPage.getName().toString(), experimentID.getRawID(), experimentPage.getAllowNewAssignment() )); batch.add(experimentPageAccessor.insertBy( experimentPage.getName().toString(), experimentID.getRawID(), experimentPage.getAllowNewAssignment() )); batch.add(appPageIndexAccessor.insertBy( applicationName.toString(), experimentPage.getName().toString() )); } executeBatchStatement(experimentID, batch); ExperimentPageList newPageList = getExperimentPages(experimentID); saveExperimentPageState(experimentID, oldPageList, newPageList); } @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);  }