SchamperViewHolder extends CardViewHolder { @Override public void populate(Card card) { super.populate(card); Article article = card.<SchamperCard>checkCard(Card.Type.SCHAMPER).getArticle(); title.setText(article.getTitle()); Spannable category; if (article.hasCategoryColour()) { int colour = Color.parseColor(article.getCategoryColour()); category = new SpannableString(article.getCategory()); category.setSpan(new ForegroundColorSpan(colour), 0, category.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } else { category = new SpannableString(article.getCategory()); } date.setText(TextUtils.concat(DateUtils.relativeDateTimeString(article.getPubDate(), itemView.getContext()), " • ", category)); author.setText(article.getAuthor()); PriorityUtils.loadThumbnail(itemView.getContext(), article.getImage(), image); this.itemView.setOnClickListener(v -> ArticleViewer.viewArticle(v.getContext(), article, adapter.getCompanion().getHelper())); } SchamperViewHolder(View v, HomeFeedAdapter adapter); @Override void populate(Card card);  }
@Test public void populate() { View view = inflate(activityContext, R.layout.home_card_schamper); SchamperViewHolder schamperViewHolder = new SchamperViewHolder(view, adapter); Article article = generate(Article.class, "image", "categoryColour"); SchamperCard card = new SchamperCard(article); schamperViewHolder.populate(card); assertTextIs(article.getTitle(), view.findViewById(R.id.title)); assertNotEmpty(view.findViewById(R.id.date)); assertTextIs(article.getAuthor(), view.findViewById(R.id.author)); view.performClick(); verify(helper, times(1)).openCustomTab(any(Uri.class)); }