class BPIViewHolder extends RecyclerView.ViewHolder {

    public void bind(BPI item) {
        if (date != null) {
            date.setText(simpleDateFormat.format(item.getDate()));
        }
        SpannableStringBuilder closeText = new SpannableStringBuilder(String.format("$%.2f", item.getClose()));
        if (largeCloseTextSize) {
            // if large text, the price looks better with a small $
            closeText.setSpan(new RelativeSizeSpan(0.4f), 0, 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        }
        close.setText(closeText);

        int changeTextColorRes = R.color.textColorSecondary;
        String changeText = "";
        String changeArrow = "";
        if (item.getChange() != null) {
            changeText = String.format("%.2f%%", item.getChange() * 100);
            if (item.getChange() > 0) {
                changeArrow = " ▲";
                changeTextColorRes = R.color.bpiChangeIncrease;
            } else if (item.getChange() < 0) {
                changeArrow = " ▼";
                changeTextColorRes = R.color.bpiChangeDecrease;
            }
        }
        change.setText(changeText + changeArrow);
        change.setTextColor(change.getResources().getColor(changeTextColorRes));
    }

}

class BPIViewHolderTest {

    private int layoutId;
    private SimpleDateFormat simpleDateFormat;
    private BPIViewHolder viewHolder;

    @Test
    public void bind_noChange() {

        BPI bpi = new BPI(new Date(System.currentTimeMillis()), 225.25f);

        viewHolder.bind(bpi);

        if (viewHolder.date != null) {
            ANDROID.assertThat(viewHolder.date).hasTextString(simpleDateFormat.format(bpi.getDate()));
        }
        ANDROID.assertThat(viewHolder.close).hasTextString("$" + bpi.getClose());
        ANDROID.assertThat(viewHolder.change).hasTextString("");
    }

}