### Question:
ConfirmLossesAdapter extends ArrayAdapter<LossItem> { @Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder viewHolder; if (convertView == null) { viewHolder = new ViewHolder(); LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(LAYOUT_INFLATER_SERVICE); convertView = inflater.inflate(resource, parent, false); viewHolder.textViewCommodityName = (TextView) convertView.findViewById(R.id.lossesCommodityName); viewHolder.textViewTotalLosses = (TextView) convertView.findViewById(R.id.totalLosses); viewHolder.textViewNewStockOnHand = (TextView) convertView.findViewById(R.id.newStockOnHand); convertView.setTag(viewHolder); } else { viewHolder = (ViewHolder) convertView.getTag(); } viewHolder.textViewCommodityName.setText(getItem(position).getCommodity().getName()); viewHolder.textViewNewStockOnHand.setText(String.valueOf(getItem(position).getNewStockOnHand())); viewHolder.textViewTotalLosses.setText(String.valueOf(getItem(position).getTotalLosses())); return convertView; } ConfirmLossesAdapter(Context context, int resource, List<LossItem> lossItems); @Override View getView(int position, View convertView, ViewGroup parent);  }### Answer:
@Test public void shouldShowTotalLossesOnConfirmLossesDialog() throws Exception { View view = this.confirmLossesAdapter.getView(0, null, parent); TextView textViewTotalLosses = (TextView) view.findViewById(R.id.totalLosses); int totalLosses = getIntFromString(textViewTotalLosses.getText().toString()); assertThat(totalLosses, is(5)); }
@Test public void shouldShowNewStockOnHandOnConfirmLossesDialog() throws Exception { View view = this.confirmLossesAdapter.getView(0, null, parent); String commodityName = ((TextView) view.findViewById(R.id.lossesCommodityName)).getText().toString(); TextView textViewNewStockOnHand = (TextView) view.findViewById(R.id.newStockOnHand); int newStockOnHand = getIntFromString(textViewNewStockOnHand.getText().toString()); assertThat(commodityName, is(COMMODITY_NAME)); assertThat(newStockOnHand, is(15)); }