public void documentUpdateInstance()

in component-test/src/main/java/org/apache/fineract/cn/deposit/DepositApiDocumentation.java [656:698]


  public void documentUpdateInstance ( ) throws Exception {
    final ProductDefinition productDefinition = Fixture.productDefinition();

    super.depositAccountManager.create(productDefinition);
    super.eventRecorder.wait(EventConstants.POST_PRODUCT_DEFINITION, productDefinition.getIdentifier());

    final ProductInstance productInstance = Fixture.productInstance(productDefinition.getIdentifier());

    super.depositAccountManager.create(productInstance);
    super.eventRecorder.wait(EventConstants.POST_PRODUCT_INSTANCE, productInstance.getCustomerIdentifier());

    final List <ProductInstance> productInstances =
            super.depositAccountManager.findProductInstances(productDefinition.getIdentifier());

    final ProductInstance fetchedProductInstance = productInstances.get(0);
    final HashSet <String> newBeneficiaries = new HashSet <>(Arrays.asList("BeneficiaryOne", "BeneficiaryTwo"));

    fetchedProductInstance.setBeneficiaries(newBeneficiaries);

    final Account account = new Account();
    account.setIdentifier(fetchedProductInstance.getAccountIdentifier());
    account.setName(RandomStringUtils.randomAlphanumeric(256));
    account.setLedger(RandomStringUtils.randomAlphanumeric(32));
    account.setBalance(0.00D);

    Mockito.doAnswer(invocation -> account)
            .when(super.accountingServiceSpy).findAccount(fetchedProductInstance.getAccountIdentifier());

    Gson gson = new Gson();
    this.mockMvc.perform(put("/instances/" + fetchedProductInstance.getAccountIdentifier())
            .contentType(MediaType.APPLICATION_JSON_VALUE)
            .content(gson.toJson(fetchedProductInstance))
            .accept(MediaType.APPLICATION_JSON_VALUE))
            .andExpect(status().isAccepted())
            .andDo(document("document-update-instance", preprocessRequest(prettyPrint()),
                    requestFields(
                            fieldWithPath("customerIdentifier").description("Customer Identifier"),
                            fieldWithPath("productIdentifier").description("Product identifier"),
                            fieldWithPath("accountIdentifier").description("Account Identifier"),
                            fieldWithPath("beneficiaries").type("Set<String>").description("Set of beneficiaries"),
                            fieldWithPath("state").description("State of product")
                    )));
  }