EventCardViewHolder extends CardViewHolder { @Override public void populate(Card card) { super.populate(card); event = card.<EventCard>checkCard(Card.Type.ACTIVITY).getEvent(); title.setText(event.first.getTitle()); association.setText(event.first.getLocation()); start.setText(DateUtils.relativeDateTimeString(event.first.getStart(), itemView.getContext(), false)); String description = itemView.getResources().getString(R.string.feed_event_title); toolbar.setTitle(String.format(description, event.second.getAbbreviation())); PriorityUtils.loadThumbnail(itemView.getContext(), event.second.getImageLink(), imageView); itemView.setOnClickListener(v -> v.getContext().startActivity(EventDetailsActivity.start(itemView.getContext(), event.first, event.second))); } EventCardViewHolder(View v, HomeFeedAdapter adapter); @Override void populate(Card card); @Override boolean onMenuItemClick(MenuItem item);  }
@Test public void populate() { View view = inflate(activityContext, R.layout.home_card_event); EventCardViewHolder viewHolder = new EventCardViewHolder(view, adapter); EventCard eventCard = generate(EventCard.class); Pair<Event, Association> event = eventCard.getEvent(); viewHolder.populate(eventCard); assertTextIs(event.first.getTitle(), view.findViewById(R.id.name)); assertTextIs(event.first.getLocation(), view.findViewById(R.id.association)); assertNotEmpty(view.findViewById(R.id.starttime)); view.performClick(); Intent expected = EventDetailsActivity.start(activityContext, event.first, event.second); Intent actual = getShadowApplication().getNextStartedActivity(); assertEquals(expected.getComponent(), actual.getComponent()); }