ProjectAdapter extends RecyclerView.Adapter<ProjectAdapter.ViewHolder> { @Override public void onBindViewHolder(ViewHolder holder, int position) { final Project project = projects.get(position); holder.activity.setText(project.getActivity()); holder.status.setTag(getDrawableId(project.getLastBuildStatus(), project.getActivity())); holder.name.setText(project.getName()); holder.time.setText(project.getLastBuildTime()); holder.clickContainer.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { DetailsDialog.newInstance(project) .show(fragmentManager, DetailsDialog.KEY_TAG); } }); } ProjectAdapter(List<Project> projects, FragmentManager fragmentManager); @Override int getItemViewType(int position); @Nullable @Override ViewHolder onCreateViewHolder(ViewGroup parent, int viewType); @Override void onBindViewHolder(ViewHolder holder, int position); @Override int getItemCount(); static final String STATUS_SUCCESS; static final String STATUS_FAILURE; static final String STATUS_UNKNOWN; static final String ACTIVITY_BUILDING; }
@Test public void onBindView_SetCorrectFields() throws Exception { ProjectAdapter.ViewHolder holder = getMockedHolder(); adapter.onBindViewHolder(holder, 0); verify(holder.name, only()).setText(ProjectTest.NAME); verify(holder.activity, only()).setText(ProjectTest.ACTIVITY); verify(holder.time, only()).setText(ProjectTest.TIME); verify(holder.clickContainer, only()).setOnClickListener(any(View.OnClickListener.class)); verify(holder.status, only()).setTag(anyInt()); verifyZeroInteractions(holder); }