public void documentOpenAccount()

in component-test/src/main/java/org/apache/fineract/cn/teller/TellerApiDocumentation.java [625:678]


  public void documentOpenAccount ( ) throws Exception {

    final Teller teller = this.prepareTeller();

    final UnlockDrawerCommand unlockDrawerCommand = new UnlockDrawerCommand();
    unlockDrawerCommand.setEmployeeIdentifier(AbstractTellerTest.TEST_USER);
    unlockDrawerCommand.setPassword(teller.getPassword());

    super.testSubject.unlockDrawer(teller.getCode(), unlockDrawerCommand);

    super.eventRecorder.wait(EventConstants.AUTHENTICATE_TELLER, teller.getCode());

    final TellerTransaction tellerTransaction = new TellerTransaction();
    tellerTransaction.setTransactionType(ServiceConstants.TX_OPEN_ACCOUNT);
    tellerTransaction.setTransactionDate(DateConverter.toIsoString(LocalDateTime.now(Clock.systemUTC())));
    tellerTransaction.setProductIdentifier("product101");
    tellerTransaction.setCustomerAccountIdentifier("Customer001");
    tellerTransaction.setCustomerIdentifier("CustomerOne");
    tellerTransaction.setClerk(AbstractTellerTest.TEST_USER);
    tellerTransaction.setAmount(BigDecimal.valueOf(1234.56D));

    final Account account = new Account();
    account.setState(Account.State.OPEN.name());
    Mockito.doAnswer(invocation -> Optional.of(account))
            .when(super.accountingServiceSpy).findAccount(tellerTransaction.getCustomerAccountIdentifier());
    Mockito.doAnswer(invocation -> Collections.emptyList())
            .when(super.depositAccountManagementServiceSpy).getCharges(Matchers.eq(tellerTransaction));
    Mockito.doAnswer(invocation -> Collections.emptyList())
            .when(super.depositAccountManagementServiceSpy).fetchProductInstances(tellerTransaction.getCustomerIdentifier());
    Mockito.doAnswer(invocation -> new ProductDefinition())
            .when(super.depositAccountManagementServiceSpy).findProductDefinition(tellerTransaction.getProductIdentifier());

    Gson gson = new Gson();
    this.mockMvc.perform(post("/teller/" + teller.getCode() + "/transactions")
            .contentType(MediaType.APPLICATION_JSON_VALUE)
            .content(gson.toJson(tellerTransaction))
            .accept(MediaType.APPLICATION_JSON_VALUE))
            .andExpect(status().isOk())
            .andDo(document("document-open-account", preprocessRequest(prettyPrint()), preprocessResponse(prettyPrint()),
                    requestFields(
                            fieldWithPath("transactionType").description("Transaction type"),
                            fieldWithPath("transactionDate").description("Transaction Date"),
                            fieldWithPath("customerIdentifier").type("String").optional().description("Customer Identifier"),
                            fieldWithPath("productIdentifier").description("Product identifier"),
                            fieldWithPath("customerAccountIdentifier").description("Customer's account"),
                            fieldWithPath("clerk").description("Clerk's name"),
                            fieldWithPath("amount").type("BigDecimal").description("Amount in account")
                    ),
                    responseFields(
                            fieldWithPath("tellerTransactionIdentifier").type("String").description("Teller transaction"),
                            fieldWithPath("totalAmount").type("BigDecimal").description("Total Amount"),
                            fieldWithPath("charges").type("List<Charge>").description("List of Charges")
                    )));
  }