in component-test/src/main/java/org/apache/fineract/cn/office/EmployeeApiDocumentation.java [228:282]
public void documentUpdateEmployee ( ) throws Exception {
final Office office = OfficeFactory.createRandomOffice();
office.setIdentifier("myOfficeOne");
this.organizationManager.createOffice(office);
this.eventRecorder.wait(EventConstants.OPERATION_POST_OFFICE, office.getIdentifier());
ContactDetail orangeContact = new ContactDetail();
orangeContact.setType(ContactDetail.Type.MOBILE.name());
orangeContact.setGroup(ContactDetail.Group.PRIVATE.name());
orangeContact.setValue("699009900");
orangeContact.setPreferenceLevel(new Integer(1));
List <ContactDetail> contacts = new ArrayList <>();
contacts.add(orangeContact);
final Employee employed = EmployeeFactory.createRandomEmployee();
employed.setIdentifier("emNo10");
employed.setGivenName("Ojong");
employed.setMiddleName("Cho");
employed.setSurname("Tah");
employed.setAssignedOffice(office.getIdentifier());
employed.setContactDetails(contacts);
this.organizationManager.createEmployee(employed);
this.eventRecorder.wait(EventConstants.OPERATION_POST_EMPLOYEE, employed.getIdentifier());
ContactDetail updatedContact = new ContactDetail();
updatedContact.setType(ContactDetail.Type.PHONE.name());
updatedContact.setGroup(ContactDetail.Group.BUSINESS.name());
updatedContact.setValue("677557755");
updatedContact.setPreferenceLevel(new Integer(1));
Assert.assertTrue(contacts.size() == 1);
contacts.remove(orangeContact);
Assert.assertTrue(contacts.size() == 0);
contacts.add(updatedContact);
Assert.assertTrue(contacts.size() == 1);
employed.setContactDetails(contacts);
Assert.assertTrue(employed.getContactDetails().size() == contacts.size());
Gson gson = new Gson();
this.mockMvc.perform(put("/employees/" + employed.getIdentifier())
.contentType(MediaType.APPLICATION_JSON_VALUE)
.content(gson.toJson(employed))
.accept(MediaType.APPLICATION_JSON_VALUE))
.andExpect(status().isAccepted())
.andDo(document("document-update-employee", preprocessResponse(prettyPrint()),
requestFields(
fieldWithPath("identifier").description("first employee's identifier"),
fieldWithPath("givenName").description(" first employee given name"),
fieldWithPath("middleName").description("first employee's middle name"),
fieldWithPath("surname").description("first employee's surname"),
fieldWithPath("assignedOffice").description("first employee's assigned office"),
fieldWithPath("contactDetails").type("List<ContactDetail>").description("first employee's contact details"))));
}