GraphsInteractor { public Maybe<GraphUiIndicator> getSummationByReimbursement(Trip trip) { return groupingController.getSummationByReimbursementAsGraphEntries(trip) .filter(graphEntries -> graphEntries.size() == 2) .map(GraphUiIndicator::summationByReimbursement) .observeOn(AndroidSchedulers.mainThread()); } @Inject  GraphsInteractor(Context context, GroupingController groupingController); Maybe<GraphUiIndicator> getSummationByCategories(Trip trip); Maybe<GraphUiIndicator> getSummationByReimbursement(Trip trip); Maybe<GraphUiIndicator> getSummationByPaymentMethod(Trip trip); Maybe<GraphUiIndicator> getSummationByDate(Trip trip); final static int PAYMENT_METHODS_MAX_COUNT; }
@Test public void getSumByReimbursementNormal() { entries = new ArrayList<>(); entries.add(new LabeledGraphEntry(15, context.getString(R.string.graphs_label_non_reimbursable))); entries.add(new LabeledGraphEntry(5, context.getString(R.string.graphs_label_reimbursable))); when(groupingController.getSummationByReimbursementAsGraphEntries(trip)).thenReturn(Single.just(entries)); List<LabeledGraphEntry> sortedEntries = new ArrayList<>(entries); Collections.sort(sortedEntries); interactor.getSummationByReimbursement(trip) .test() .assertNoErrors() .assertComplete() .assertResult(GraphUiIndicator.summationByReimbursement(sortedEntries)); }
@Test public void getNothingSumByReimbursementIfOneType() { entries = new ArrayList<>(); entries.add(new LabeledGraphEntry(10, context.getString(R.string.graphs_label_reimbursable))); when(groupingController.getSummationByReimbursementAsGraphEntries(trip)).thenReturn(Single.just(entries)); interactor.getSummationByReimbursement(trip) .test() .assertNoErrors() .assertComplete() .assertNoValues(); }