CalendarAdapter extends RecyclerView.Adapter { @Override public final void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { CalendarDayViewHolder viewHolder = (CalendarDayViewHolder) holder; DayState state = new DayState(); fillViewState(position, selectedPosition, data, state); viewHolder.bind(data.getAt(position), state); addCustomData(viewHolder, data.getAt(position)); } CalendarAdapter(@LayoutRes int layout, LayoutInflater inflater, VisibleMonths data); void replace(@NonNull VisibleMonths months); @Override final RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType); @Override final void onBindViewHolder(RecyclerView.ViewHolder holder, int position); @Override int getItemCount(); void select(Day selectedDay); void select(int position);  }
@Test public void should_bind() { tested.onBindViewHolder(viewHolder, 10); verify(viewHolder).bind(eq(day), captor.capture()); DayState state = captor.getValue(); assertFalse(state.isSelected()); assertFalse(state.isCurrentMonth()); assertFalse(state.isToday()); }
@Test public void should_set_current_month() { when(months.isCurrentMonth(anyInt())).thenReturn(true); tested.onBindViewHolder(viewHolder, 10); verify(viewHolder).bind(eq(day), captor.capture()); DayState state = captor.getValue(); assertTrue(state.isCurrentMonth()); }
@Test public void should_mark_today() { when(day.isToday()).thenReturn(true); tested.onBindViewHolder(viewHolder, 10); verify(viewHolder).bind(eq(day), captor.capture()); DayState state = captor.getValue(); assertTrue(state.isToday()); }