in component-test/src/main/java/org/apache/fineract/cn/customer/CustomerApiDocumentation.java [1229:1336]
public void documentUpdateCustomerDetails ( ) throws Exception {
final Customer customer = CustomerGenerator.createRandomCustomer();
DateOfBirth dateOfBirth = new DateOfBirth();
dateOfBirth.setYear(Integer.valueOf(1994));
dateOfBirth.setMonth(Integer.valueOf(5));
dateOfBirth.setDay(Integer.valueOf(5));
Address address = new Address();
address.setStreet("Bokwango");
address.setCity("Buea");
address.setRegion("SWR");
address.setPostalCode("8050");
address.setCountryCode("CM");
address.setCountry("Cameroon");
ContactDetail orangeContact = new ContactDetail();
orangeContact.setType(ContactDetail.Type.MOBILE.name());
orangeContact.setGroup(ContactDetail.Group.PRIVATE.name());
orangeContact.setValue("699429343");
orangeContact.setPreferenceLevel(Integer.valueOf(1));
orangeContact.setValidated(Boolean.FALSE);
ContactDetail nextellContact = new ContactDetail();
nextellContact.setType(ContactDetail.Type.MOBILE.name());
nextellContact.setGroup(ContactDetail.Group.PRIVATE.name());
nextellContact.setValue("666737666");
nextellContact.setPreferenceLevel(Integer.valueOf(2));
nextellContact.setValidated(Boolean.FALSE);
List <ContactDetail> contactDetails = new ArrayList <>();
contactDetails.add(nextellContact);
contactDetails.add(orangeContact);
customer.setIdentifier("kome");
customer.setType(Customer.Type.PERSON.name());
customer.setGivenName("Kome");
customer.setMiddleName("Ngome");
customer.setSurname("B.");
customer.setDateOfBirth(dateOfBirth);
customer.setMember(Boolean.TRUE);
customer.setAssignedOffice("Bongo Sq");
customer.setAssignedEmployee("Malafa E.");
customer.setAddress(address);
customer.setContactDetails(contactDetails);
customer.setCurrentState(Customer.State.PENDING.name());
customer.setAccountBeneficiary("Wife");
customer.setReferenceCustomer("likumba");
customer.setApplicationDate(LocalDate.ofYearDay(2017, 230).toString());
customer.setLastModifiedBy("Malafa E.");
customer.setLastModifiedOn(LocalDate.ofYearDay(2018, 21).toString());
this.customerManager.createCustomer(customer);
this.eventRecorder.wait(CustomerEventConstants.POST_CUSTOMER, customer.getIdentifier());
Assert.assertTrue(contactDetails.size() == 2);
contactDetails.remove(1);
Assert.assertTrue(contactDetails.size() == 1);
ContactDetail mtnContact = new ContactDetail();
mtnContact.setType(ContactDetail.Type.MOBILE.name());
mtnContact.setGroup(ContactDetail.Group.PRIVATE.name());
mtnContact.setValue("677757564");
mtnContact.setPreferenceLevel(Integer.valueOf(1));
mtnContact.setValidated(Boolean.TRUE);
contactDetails.add(mtnContact);
Assert.assertTrue(contactDetails.size() == 2);
Gson gson = new Gson();
this.mockMvc.perform(put("/customers/" + customer.getIdentifier() + "/contact")
.contentType(MediaType.APPLICATION_JSON_VALUE)
.content(gson.toJson(contactDetails))
.accept(MediaType.APPLICATION_JSON_VALUE))
.andExpect(status().isAccepted())
.andDo(document("document-update-customer-details", preprocessRequest(prettyPrint()), preprocessResponse(prettyPrint()),
requestFields(
fieldWithPath("[].type").type("Type").description("The type of the first contact +\n" +
" +\n" +
"*enum* _Type_ { +\n" +
" PERSON, +\n" +
" BUSINESS +\n" +
" } +"),
fieldWithPath("[].group").type("Group").description("The group of the first contact +\n" +
" +\n" +
"*enum* _Type_ { +\n" +
" BUSINESS, +\n" +
" PRIVATE +\n" +
" } +"),
fieldWithPath("[].value").description("first contact's value"),
fieldWithPath("[].preferenceLevel").description("Preference Level"),
fieldWithPath("[].validated").description("Is first contact validated ?"),
fieldWithPath("[1].type").type("Type").description("The type of the second contact +\n" +
" +\n" +
"*enum* _Type_ { +\n" +
" PERSON, +\n" +
" BUSINESS +\n" +
" } +"),
fieldWithPath("[1].group").type("Group").description("The Group of the second contact +\n" +
" +\n" +
"*enum* _Type_ { +\n" +
" BUSINESS, +\n" +
" PRIVATE +\n" +
" } +"),
fieldWithPath("[1].value").description("second contact's value"),
fieldWithPath("[1].preferenceLevel").description("Preference Level"),
fieldWithPath("[1].validated").description("Is second contact validated ?"))));
}