InitialInventoryViewHolder extends BaseViewHolder { public void populate(final InventoryViewModel inventoryViewModel, String queryKeyWord, ViewHistoryListener listener) { this.viewModel = inventoryViewModel; setUpLotListView(); resetCheckBox(); setUpCheckBox(); checkBox.setChecked(viewModel.isChecked()); productName.setText(TextStyleUtil.getHighlightQueryKeyWord(queryKeyWord, viewModel.getStyledName())); productUnit.setText(TextStyleUtil.getHighlightQueryKeyWord(queryKeyWord, viewModel.getStyleType())); initHistoryView(listener); } InitialInventoryViewHolder(View itemView); void populate(final InventoryViewModel inventoryViewModel, String queryKeyWord, ViewHistoryListener listener); void setUpLotListView(); void showAddNewLotPanel(int visible);  }
@Test public void shouldInitialViewHolder() throws ParseException { InventoryViewModel viewModel = new InventoryViewModelBuilder(product) .setChecked(false) .setType("Embalagem") .build(); viewHolder.populate(viewModel, queryKeyWord, mockedListener); assertThat(viewHolder.productName.getText().toString()).isEqualTo("Lamivudina 150mg [08S40]"); assertThat(viewHolder.productUnit.getText().toString()).isEqualTo("Embalagem"); assertThat(viewHolder.tvHistoryAction.getVisibility()).isEqualTo(View.GONE); }
@Test public void shouldShowHistoryViewAndViewItWhenClicked() { ViewHistoryListener mockedListener = mock(ViewHistoryListener.class); product.setArchived(true); InventoryViewModel viewModel = new InventoryViewModelBuilder(product) .setChecked(false) .setType("Embalagem") .build(); viewHolder.populate(viewModel, queryKeyWord, mockedListener); assertThat(viewHolder.tvHistoryAction.getVisibility()).isEqualTo(View.VISIBLE); viewHolder.tvHistoryAction.performClick(); verify(mockedListener).viewHistory(viewModel.getStockCard()); }