@Test(expected = RepositoryException.class) public void getRollupRowsTest() { Experiment.ID experimentId = Experiment.ID.newInstance(); String rollupDate = "TEST"; Parameters parameters = mock(Parameters.class, RETURNS_DEEP_STUBS); List<Map> expected = mock(List.class); when(parameters.getContext().getContext()).thenReturn("TEST"); when(transaction.select(anyString(), eq(experimentId), eq(true), eq(rollupDate), anyString())) .thenReturn(expected); List<Map> result = databaseAnalytics.getRollupRows(experimentId, rollupDate, parameters); assertThat(result, is(expected)); doThrow(new RuntimeException()) .when(transaction) .select(anyString(), eq(experimentId), eq(true), eq(rollupDate), anyString()); databaseAnalytics.getRollupRows(experimentId, rollupDate, parameters); fail(); }
@Override public List<Map> getRollupRows(Experiment.ID experimentId, String rollupDate, Parameters parameters) throws RepositoryException { List rollupRows; try { String sqlQuery = "select bucket_label as bid, action, impression_count as ic, impression_user_count as iuc, " + "action_count as ac, action_user_count as auc from experiment_rollup " + "where experiment_id = ? and cumulative = ? and day = ? and context = ?"; rollupRows = transaction.select(sqlQuery, experimentId, true, rollupDate, parameters.getContext().getContext()); return rollupRows; } catch (Exception e) { throw new RepositoryException("error reading rollup rows from MySQL", e); } }
DatabaseAnalytics implements AnalyticsRepository { @Override public List<Map> getRollupRows(Experiment.ID experimentId, String rollupDate, Parameters parameters) throws RepositoryException { List rollupRows; try { String sqlQuery = "select bucket_label as bid, action, impression_count as ic, impression_user_count as iuc, " + "action_count as ac, action_user_count as auc from experiment_rollup " + "where experiment_id = ? and cumulative = ? and day = ? and context = ?"; rollupRows = transaction.select(sqlQuery, experimentId, true, rollupDate, parameters.getContext().getContext()); return rollupRows; } catch (Exception e) { throw new RepositoryException("error reading rollup rows from MySQL", e); } } }
DatabaseAnalytics implements AnalyticsRepository { @Override public List<Map> getRollupRows(Experiment.ID experimentId, String rollupDate, Parameters parameters) throws RepositoryException { List rollupRows; try { String sqlQuery = "select bucket_label as bid, action, impression_count as ic, impression_user_count as iuc, " + "action_count as ac, action_user_count as auc from experiment_rollup " + "where experiment_id = ? and cumulative = ? and day = ? and context = ?"; rollupRows = transaction.select(sqlQuery, experimentId, true, rollupDate, parameters.getContext().getContext()); return rollupRows; } catch (Exception e) { throw new RepositoryException("error reading rollup rows from MySQL", e); } } @Inject  DatabaseAnalytics(TransactionFactory transactionFactory, Flyway flyway); }
DatabaseAnalytics implements AnalyticsRepository { @Override public List<Map> getRollupRows(Experiment.ID experimentId, String rollupDate, Parameters parameters) throws RepositoryException { List rollupRows; try { String sqlQuery = "select bucket_label as bid, action, impression_count as ic, impression_user_count as iuc, " + "action_count as ac, action_user_count as auc from experiment_rollup " + "where experiment_id = ? and cumulative = ? and day = ? and context = ?"; rollupRows = transaction.select(sqlQuery, experimentId, true, rollupDate, parameters.getContext().getContext()); return rollupRows; } catch (Exception e) { throw new RepositoryException("error reading rollup rows from MySQL", e); } } @Inject  DatabaseAnalytics(TransactionFactory transactionFactory, Flyway flyway); @Override List<Map> getRollupRows(Experiment.ID experimentId, String rollupDate, Parameters parameters); @Override List<Map> getActionsRows(Experiment.ID experimentID, Parameters parameters); @Override List<Map> getJointActions(Experiment.ID experimentID, Parameters parameters); @Override List<Map> getImpressionRows(Experiment.ID experimentID, Parameters parameters); @Override Map<Bucket.Label, BucketCounts> getEmptyBuckets(Experiment.ID experimentID); @Override List<Map> getCountsFromRollups(Experiment.ID experimentID, Parameters parameters); @Override boolean checkMostRecentRollup(Experiment experiment, Parameters parameters, Date to); }
DatabaseAnalytics implements AnalyticsRepository { @Override public List<Map> getRollupRows(Experiment.ID experimentId, String rollupDate, Parameters parameters) throws RepositoryException { List rollupRows; try { String sqlQuery = "select bucket_label as bid, action, impression_count as ic, impression_user_count as iuc, " + "action_count as ac, action_user_count as auc from experiment_rollup " + "where experiment_id = ? and cumulative = ? and day = ? and context = ?"; rollupRows = transaction.select(sqlQuery, experimentId, true, rollupDate, parameters.getContext().getContext()); return rollupRows; } catch (Exception e) { throw new RepositoryException("error reading rollup rows from MySQL", e); } } @Inject  DatabaseAnalytics(TransactionFactory transactionFactory, Flyway flyway); @Override List<Map> getRollupRows(Experiment.ID experimentId, String rollupDate, Parameters parameters); @Override List<Map> getActionsRows(Experiment.ID experimentID, Parameters parameters); @Override List<Map> getJointActions(Experiment.ID experimentID, Parameters parameters); @Override List<Map> getImpressionRows(Experiment.ID experimentID, Parameters parameters); @Override Map<Bucket.Label, BucketCounts> getEmptyBuckets(Experiment.ID experimentID); @Override List<Map> getCountsFromRollups(Experiment.ID experimentID, Parameters parameters); @Override boolean checkMostRecentRollup(Experiment experiment, Parameters parameters, Date to);  }