@Test(expected = RepositoryException.class) public void executeBatchStatement() { Session session = mock(Session.class); when(mappingManager.getSession()).thenReturn(session); doThrow(WriteTimeoutException.class).when(session).execute(any(Statement.class)); repository.executeBatchStatement(Experiment.ID.valueOf(experimentId), new BatchStatement()); assertThat(1, is(2)); }
void executeBatchStatement(Experiment.ID experimentID, BatchStatement batch) { try { ResultSet resultSet = mappingManager.getSession().execute(batch); logger.debug("Batch statement is applied: {} using consistency level: {}", resultSet.wasApplied(), resultSet.getExecutionInfo().getAchievedConsistencyLevel()); } catch (WriteTimeoutException | UnavailableException | NoHostAvailableException e) { throw new RepositoryException("Could not add the page(s) to the experiment:\"" + experimentID + "\"", e); } }
CassandraPagesRepository implements PagesRepository { void executeBatchStatement(Experiment.ID experimentID, BatchStatement batch) { try { ResultSet resultSet = mappingManager.getSession().execute(batch); logger.debug("Batch statement is applied: {} using consistency level: {}", resultSet.wasApplied(), resultSet.getExecutionInfo().getAchievedConsistencyLevel()); } catch (WriteTimeoutException | UnavailableException | NoHostAvailableException e) { throw new RepositoryException("Could not add the page(s) to the experiment:\"" + experimentID + "\"", e); } } }
CassandraPagesRepository implements PagesRepository { void executeBatchStatement(Experiment.ID experimentID, BatchStatement batch) { try { ResultSet resultSet = mappingManager.getSession().execute(batch); logger.debug("Batch statement is applied: {} using consistency level: {}", resultSet.wasApplied(), resultSet.getExecutionInfo().getAchievedConsistencyLevel()); } catch (WriteTimeoutException | UnavailableException | NoHostAvailableException e) { throw new RepositoryException("Could not add the page(s) to the experiment:\"" + experimentID + "\"", e); } } @Inject  CassandraPagesRepository(ExperimentAccessor experimentAccessor,
                                    PageExperimentIndexAccessor pageExperimentIndexAccessor,
                                    ExperimentPageAccessor experimentPageAccessor,
                                    AppPageIndexAccessor appPageIndexAccessor,
                                    ExperimentAuditLogAccessor experimentAuditLogAccessor,
                                    MappingManager mappingManager); }
CassandraPagesRepository implements PagesRepository { void executeBatchStatement(Experiment.ID experimentID, BatchStatement batch) { try { ResultSet resultSet = mappingManager.getSession().execute(batch); logger.debug("Batch statement is applied: {} using consistency level: {}", resultSet.wasApplied(), resultSet.getExecutionInfo().getAchievedConsistencyLevel()); } catch (WriteTimeoutException | UnavailableException | NoHostAvailableException e) { throw new RepositoryException("Could not add the page(s) to the experiment:\"" + experimentID + "\"", e); } } @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 { void executeBatchStatement(Experiment.ID experimentID, BatchStatement batch) { try { ResultSet resultSet = mappingManager.getSession().execute(batch); logger.debug("Batch statement is applied: {} using consistency level: {}", resultSet.wasApplied(), resultSet.getExecutionInfo().getAchievedConsistencyLevel()); } catch (WriteTimeoutException | UnavailableException | NoHostAvailableException e) { throw new RepositoryException("Could not add the page(s) to the experiment:\"" + experimentID + "\"", e); } } @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);  }