public void documentUpdateAddress()

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


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

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

    Address address = new Address();
    address.setStreet("Bolifamba");
    address.setCity("Buea");
    address.setRegion("SWR");
    address.setPostalCode("8050");
    address.setCountryCode("CM");
    address.setCountry("Cameroon");

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

    ContactDetail nextellContact = new ContactDetail();
    nextellContact.setType(ContactDetail.Type.MOBILE.name());
    nextellContact.setGroup(ContactDetail.Group.PRIVATE.name());
    nextellContact.setValue("666767693");
    nextellContact.setPreferenceLevel(Integer.valueOf(2));
    nextellContact.setValidated(Boolean.FALSE);

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

    originalCustomer.setIdentifier("likumba");
    originalCustomer.setType(Customer.Type.PERSON.name());
    originalCustomer.setGivenName("Ikome");
    originalCustomer.setMiddleName("Esong");
    originalCustomer.setSurname("Ikome");
    originalCustomer.setDateOfBirth(dateOfBirth);
    originalCustomer.setMember(Boolean.TRUE);
    originalCustomer.setAssignedOffice("Bolifamba");
    originalCustomer.setAssignedEmployee("Malafa Ikome");
    originalCustomer.setAddress(address);
    originalCustomer.setContactDetails(contactDetails);
    originalCustomer.setCurrentState(Customer.State.PENDING.name());
    originalCustomer.setAccountBeneficiary("Mola Kola");
    originalCustomer.setReferenceCustomer("likumba");
    originalCustomer.setApplicationDate(LocalDate.ofYearDay(2017, 239).toString());
    originalCustomer.setLastModifiedBy("Malafa Ikome");
    originalCustomer.setLastModifiedOn(LocalDate.ofYearDay(2018, 97).toString());

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

    final Address updatedAddress = AddressGenerator.createRandomAddress();
    updatedAddress.setStreet("Ombe Rd");
    updatedAddress.setCity("Mutengene");
    updatedAddress.setRegion("SWR");
    updatedAddress.setPostalCode("8050");
    updatedAddress.setCountryCode("CM");
    updatedAddress.setCountry("Cameroon");

    Gson gson = new Gson();
    this.mockMvc.perform(put("/customers/" + originalCustomer.getIdentifier() + "/address")
            .contentType(MediaType.APPLICATION_JSON_VALUE)
            .content(gson.toJson(updatedAddress))
            .accept(MediaType.APPLICATION_JSON_VALUE))
            .andExpect(status().isAccepted())
            .andDo(document("document-update-address", preprocessRequest(prettyPrint()), preprocessResponse(prettyPrint()),
                    requestFields(
                            fieldWithPath("street").description("street"),
                            fieldWithPath("city").description("city"),
                            fieldWithPath("region").description("region"),
                            fieldWithPath("postalCode").description("postal code"),
                            fieldWithPath("countryCode").description("country code"),
                            fieldWithPath("country").description("country"))));
  }