public void documentUpdateCustomer()

in component-test/src/main/java/org/apache/fineract/cn/customer/CustomerApiDocumentation.java [553:674]


  public void documentUpdateCustomer ( ) throws Exception {
    final Customer originalCustomer = CustomerGenerator.createRandomCustomer();

    DateOfBirth dateOfBirth = new DateOfBirth();
    dateOfBirth.setYear(Integer.valueOf(1990));
    dateOfBirth.setMonth(Integer.valueOf(4));
    dateOfBirth.setDay(Integer.valueOf(3));

    Address address = new Address();
    address.setStreet("Sonac");
    address.setCity("Bamenda");
    address.setRegion("NWR");
    address.setPostalCode("8050");
    address.setCountryCode("CM");
    address.setCountry("Cameroon");

    ContactDetail contactDetailOne = new ContactDetail();
    contactDetailOne.setType(ContactDetail.Type.MOBILE.name());
    contactDetailOne.setGroup(ContactDetail.Group.PRIVATE.name());
    contactDetailOne.setValue("677665544");
    contactDetailOne.setPreferenceLevel(Integer.valueOf(1));
    contactDetailOne.setValidated(Boolean.FALSE);

    List <ContactDetail> contactDetails = new ArrayList <>();
    contactDetails.add(contactDetailOne);

    originalCustomer.setIdentifier("tifuh");
    originalCustomer.setType(Customer.Type.PERSON.name());
    originalCustomer.setGivenName("Tifuh");
    originalCustomer.setMiddleName("Ndah");
    originalCustomer.setSurname("Tah");
    originalCustomer.setDateOfBirth(dateOfBirth);
    originalCustomer.setMember(Boolean.TRUE);
    originalCustomer.setAssignedOffice("Nkwen");
    originalCustomer.setAssignedEmployee("Chi Tih");
    originalCustomer.setAddress(address);
    originalCustomer.setContactDetails(contactDetails);
    originalCustomer.setCurrentState(Customer.State.PENDING.name());
    originalCustomer.setAccountBeneficiary("Wife");
    originalCustomer.setReferenceCustomer("sister");
    originalCustomer.setApplicationDate(LocalDate.ofYearDay(2017, 249).toString());
    originalCustomer.setLastModifiedBy("Nah Toh");
    originalCustomer.setLastModifiedOn(LocalDate.ofYearDay(2018, 153).toString());

    this.customerManager.createCustomer(originalCustomer);
    this.eventRecorder.wait(CustomerEventConstants.POST_CUSTOMER, originalCustomer.getIdentifier());

    originalCustomer.setSurname("Sih");

    this.customerManager.updateCustomer(originalCustomer.getIdentifier(), originalCustomer);
    this.eventRecorder.wait(CustomerEventConstants.PUT_CUSTOMER, originalCustomer.getIdentifier());

    final Customer updatedCustomer = this.customerManager.findCustomer(originalCustomer.getIdentifier());

    Gson gson = new Gson();
    this.mockMvc.perform(put("/customers/" + originalCustomer.getIdentifier())
            .contentType(MediaType.APPLICATION_JSON_VALUE)
            .content(gson.toJson(updatedCustomer))
            .accept(MediaType.APPLICATION_JSON_VALUE))
            .andExpect(status().isAccepted())
            .andDo(document("document-update-customer", preprocessRequest(prettyPrint()), preprocessResponse(prettyPrint()),
                    requestFields(
                            fieldWithPath("identifier").description("The customer's identifier"),
                            fieldWithPath("type").description("The type of legal entity  +\n" +
                                    " +\n" +
                                    "*enum* _Type_ { +\n" +
                                    "    PERSON, +\n" +
                                    "    BUSINESS +\n" +
                                    "  } +"),
                            fieldWithPath("givenName").description("The customer's given name"),
                            fieldWithPath("middleName").description("The customer's middle name"),
                            fieldWithPath("surname").description("The customer's surname"),
                            fieldWithPath("dateOfBirth").type("DateOfBirth").description("The customer's date of birth +\n" +
                                    " +\n" +
                                    " _DateOfBirth_ { +\n" +
                                    "    *Integer* year, +\n" +
                                    "    *Integer* month, +\n" +
                                    "    *Integer* day, +\n" +
                                    "} +"),
                            fieldWithPath("member").description("Is customer a member of the MFI ?"),
                            fieldWithPath("assignedOffice").description("The customer's assigned office"),
                            fieldWithPath("assignedEmployee").description("The customer's assigned employee"),
                            fieldWithPath("address").type("Address").description("The customer's physical address +\n" +
                                    " +\n" +
                                    "_Address_ { +\n" +
                                    "*String* street, +\n" +
                                    "*String* city, +\n" +
                                    "*String* region, +\n" +
                                    "*String* postalCode, +\n" +
                                    "*String* countryCode, +\n" +
                                    "*String* country  } +"),
                            fieldWithPath("contactDetails").type("List<ContactDetail>").description("The customer's contact details +\n" +
                                    " +\n" +
                                    "_ContactDetail_ { +\n" +
                                    "  *enum* _Type_ { +\n" +
                                    "     EMAIL, +\n" +
                                    "     PHONE, +\n" +
                                    "     MOBILE +\n" +
                                    "   } type, +\n" +
                                    "   *enum* _Group_ { +\n" +
                                    "     BUSINESS, +\n" +
                                    "     PRIVATE +\n" +
                                    "   } group, +\n" +
                                    "   *String* value +\n" +
                                    " } +"),
                            fieldWithPath("currentState").type("State").description("The customer's current state +\n" +
                                    " +\n" +
                                    "*enum* _State_ { +\n" +
                                    "     PENDING, +\n" +
                                    "     ACTIVE, +\n" +
                                    "     LOCKED, +\n" +
                                    "     CLOSED +\n" +
                                    "   } +"),
                            fieldWithPath("accountBeneficiary").type("String").description("account beneficiary"),
                            fieldWithPath("applicationDate").type("String").description("date customer applied for account"),
                            fieldWithPath("customValues").type("List<Value>").description("Second customer's custom values"),
                            fieldWithPath("createdBy").description("User who created second customer's account"),
                            fieldWithPath("createdOn").description("Date and time when second customer's account was created"),
                            fieldWithPath("lastModifiedBy").type("String").description("employee who last modified account"),
                            fieldWithPath("lastModifiedOn").type("String").description("last time account was modified"),
                            fieldWithPath("referenceCustomer").type("String").description("fellow customer to refer to"))));
  }