@Test
  public void shouldResetTextColorWhenReselectReason() {
    viewHolder.populate(viewModel, stockCard);

    StockMovementViewHolder.MovementSelectListener listener =
        viewHolder.new MovementSelectListener(viewModel);
    MovementReasonManager.MovementReason receiveReason =
        new MovementReasonManager.MovementReason(
            MovementReasonManager.MovementType.POSITIVE_ADJUST,
            "INVENTORY_POSITIVE",
            "Inventory description...");
    listener.onComplete(receiveReason);

    assertThat(
        viewHolder.txReason.getCurrentTextColor(),
        is(RuntimeEnvironment.application.getResources().getColor(R.color.color_red)));

    MovementReasonManager.MovementReason issueReason =
        new MovementReasonManager.MovementReason(
            MovementReasonManager.MovementType.ISSUE, "PAV", "PAV Description");
    listener.onComplete(issueReason);

    assertThat(
        viewHolder.txReason.getCurrentTextColor(),
        is(RuntimeEnvironment.application.getResources().getColor(R.color.color_black)));
  }
  @Test
  public void shouldOnlyEnableCurrentSelectedEditTextWhenChoseMovementTypeWhenToggleIsOn()
      throws ParseException, LMISException {
    viewModel.setDraft(true);
    viewHolder.populate(viewModel, stockCard);
    viewHolder.txMovementDate.setText("");

    StockMovementViewHolder.MovementSelectListener listener =
        viewHolder.new MovementSelectListener(viewModel);

    MovementReasonManager.MovementReason receiveReason =
        new MovementReasonManager.MovementReason(
            MovementReasonManager.MovementType.RECEIVE, "DON", "Donations");
    listener.onComplete(receiveReason);
    assertTrue(viewHolder.etReceived.isEnabled());
    assertFalse(viewHolder.etPositiveAdjustment.isEnabled());
    assertFalse(viewHolder.etNegativeAdjustment.isEnabled());
    assertFalse(viewHolder.etIssued.isEnabled());
    assertFalse(viewHolder.etRequested.isEnabled());

    MovementReasonManager.MovementReason positiveReason =
        new MovementReasonManager.MovementReason(
            MovementReasonManager.MovementType.POSITIVE_ADJUST, "POSITIVE", "BOUGHT");
    listener.onComplete(positiveReason);

    assertFalse(viewHolder.etReceived.isEnabled());
    assertTrue(viewHolder.etPositiveAdjustment.isEnabled());
    assertFalse(viewHolder.etNegativeAdjustment.isEnabled());
    assertFalse(viewHolder.etIssued.isEnabled());
    assertFalse(viewHolder.etRequested.isEnabled());
  }
  @Test
  public void shouldEnableIssueAndRequestedEditTextWhenChoseIssueMovementTypeWhenToggleIsOn()
      throws ParseException, LMISException {
    StockMovementViewHolder stockMovementViewHolder =
        new StockMovementViewHolder(itemView, mockedListener);

    viewModel.setDraft(true);
    stockMovementViewHolder.populate(viewModel, stockCard);
    stockMovementViewHolder.txMovementDate.setText("");

    StockMovementViewHolder.MovementSelectListener listener =
        stockMovementViewHolder.new MovementSelectListener(viewModel);

    MovementReasonManager.MovementReason receiveReason =
        new MovementReasonManager.MovementReason(
            MovementReasonManager.MovementType.ISSUE, "ISSUE_1", "issue description");

    listener.onComplete(receiveReason);

    assertFalse(stockMovementViewHolder.etReceived.isEnabled());
    assertFalse(stockMovementViewHolder.etPositiveAdjustment.isEnabled());
    assertFalse(stockMovementViewHolder.etNegativeAdjustment.isEnabled());
    assertTrue(stockMovementViewHolder.etIssued.isEnabled());
    assertTrue(stockMovementViewHolder.etRequested.isEnabled());
  }
  @Test
  public void shouldClearDocumentNumberWhenReselectReason() {
    viewHolder.populate(viewModel, stockCard);
    viewHolder.etDocumentNo.setText("888");

    StockMovementViewHolder.MovementSelectListener listener =
        viewHolder.new MovementSelectListener(viewModel);
    MovementReasonManager.MovementReason receiveReason =
        new MovementReasonManager.MovementReason(
            MovementReasonManager.MovementType.RECEIVE, "DON", "Donations");
    listener.onComplete(receiveReason);

    assertThat(viewHolder.etDocumentNo.getText().toString(), is(""));
  }
  @Test
  public void shouldSetReasonAndDateOnComplete() {
    MovementReasonManager.MovementReason reason =
        new MovementReasonManager.MovementReason(
            MovementReasonManager.MovementType.RECEIVE, "DON", "Donations");
    String today = DateUtil.formatDate(new Date());
    viewHolder.populate(viewModel, stockCard);
    viewHolder.txMovementDate.setText("");
    viewHolder.etIssued.setText("100");

    StockMovementViewHolder.MovementSelectListener listener =
        viewHolder.new MovementSelectListener(viewModel);
    listener.onComplete(reason);

    assertEquals(reason.getDescription(), viewHolder.txReason.getText().toString());
    assertEquals(reason.getDescription(), viewModel.getReason().getDescription());
    assertEquals(today, viewHolder.txMovementDate.getText().toString());
    assertEquals(today, viewModel.getMovementDate());
    assertTrue(viewHolder.etReceived.isEnabled());
    assertEquals(viewHolder.etIssued.getText().toString(), "");
    verify(mockedListener).movementChange();
  }