public void shouldReturnResolution()

in component-test/src/main/java/org/apache/fineract/cn/cheque/TestMICR.java [73:120]


  public void shouldReturnResolution() throws Exception {

    final MICR micr = Fixture.createRandomCheque().getMicr();

    Mockito
        .doAnswer(invocation -> {
          final Office mockedOffice = new Office();
          mockedOffice.setName(TestMICR.OFFICE_NAME);
          return Optional.of(mockedOffice);
        })
        .when(this.organizationServiceSpy).findOffice(micr.getBranchSortCode());

    Mockito
        .doAnswer(invocation -> {
          final ProductInstance mockedProductInstance = new ProductInstance();
          mockedProductInstance.setCustomerIdentifier(TestMICR.CUSTOMER_IDENTIFIER);
          return Optional.of(mockedProductInstance);
        })
        .when(this.depositServiceSpy).findProductInstance(micr.getAccountNumber());

    Mockito
        .doAnswer(invocation -> Collections.emptyList())
        .when(this.depositServiceSpy).getIssueChequeCharges(micr.getAccountNumber());

    Mockito
        .doAnswer(invocation -> {
          final Customer mockedCustomer = new Customer();
          mockedCustomer.setGivenName(TestMICR.GIVEN_NAME);
          mockedCustomer.setSurname(TestMICR.SURNAME);
          return Optional.of(mockedCustomer);
        })
        .when(this.customerServiceSpy).findCustomer(TestMICR.CUSTOMER_IDENTIFIER);

    final IssuingCount issuingCount = new IssuingCount();
    issuingCount.setAccountIdentifier(micr.getAccountNumber());
    issuingCount.setAmount(100);

    super.chequeManager.issue(issuingCount);

    Assert.assertTrue(
        super.eventRecorder.wait(EventConstants.ISSUE_CHEQUES, micr.getAccountNumber())
    );

    final MICRResolution micrResolution = super.chequeManager.expandMicr(MICRParser.toIdentifier(micr));
    Assert.assertNotNull(micrResolution);
    Assert.assertEquals(OFFICE_NAME, micrResolution.getOffice());
    Assert.assertEquals(GIVEN_NAME + " " + SURNAME, micrResolution.getCustomer());
  }