in component-test/src/main/java/org/apache/fineract/cn/office/EmployeeApiDocumentation.java [158:225]
public void documentFindAllEmployees ( ) throws Exception {
final Office office = OfficeFactory.createRandomOffice();
office.setIdentifier("office001");
this.organizationManager.createOffice(office);
this.eventRecorder.wait(EventConstants.OPERATION_POST_OFFICE, office.getIdentifier());
ContactDetail firstContact = new ContactDetail();
firstContact.setType(ContactDetail.Type.MOBILE.name());
firstContact.setGroup(ContactDetail.Group.PRIVATE.name());
firstContact.setValue("677889900");
firstContact.setPreferenceLevel(new Integer(1));
List <ContactDetail> contactsOne = new ArrayList <>();
contactsOne.add(firstContact);
final Employee firstEmployee = EmployeeFactory.createRandomEmployee();
firstEmployee.setIdentifier("employ001");
firstEmployee.setGivenName("Oru");
firstEmployee.setMiddleName("Asam");
firstEmployee.setSurname("Yoah");
firstEmployee.setAssignedOffice(office.getIdentifier());
firstEmployee.setContactDetails(contactsOne);
this.organizationManager.createEmployee(firstEmployee);
this.eventRecorder.wait(EventConstants.OPERATION_POST_EMPLOYEE, firstEmployee.getIdentifier());
ContactDetail secondContact = new ContactDetail();
secondContact.setType(ContactDetail.Type.MOBILE.name());
secondContact.setGroup(ContactDetail.Group.PRIVATE.name());
secondContact.setValue("675859565");
secondContact.setPreferenceLevel(new Integer(2));
List <ContactDetail> contactsTwo = new ArrayList <>();
contactsTwo.add(secondContact);
final Employee secondEmployee = EmployeeFactory.createRandomEmployee();
secondEmployee.setIdentifier("employ002");
secondEmployee.setGivenName("Oyadipo");
secondEmployee.setMiddleName("Okah");
secondEmployee.setSurname("Omo");
secondEmployee.setAssignedOffice(office.getIdentifier());
secondEmployee.setContactDetails(contactsTwo);
this.organizationManager.createEmployee(secondEmployee);
this.eventRecorder.wait(EventConstants.OPERATION_POST_EMPLOYEE, secondEmployee.getIdentifier());
this.mockMvc.perform(get("/employees")
.contentType(MediaType.APPLICATION_JSON_VALUE)
.accept(MediaType.ALL_VALUE))
.andExpect(status().isOk())
.andDo(document("document-find-all-employees", preprocessResponse(prettyPrint()),
responseFields(
fieldWithPath("employees").description("Page of employees"),
fieldWithPath("employees[].identifier").description("first employee's identifier"),
fieldWithPath("employees[].givenName").description(" first employee given name"),
fieldWithPath("employees[].middleName").description("first employee's middle name"),
fieldWithPath("employees[].surname").description("first employee's surname"),
fieldWithPath("employees[].assignedOffice").description("first employee's assigned office"),
fieldWithPath("employees[].contactDetails").type("List<ContactDetail>").description("first employee's contact details"),
fieldWithPath("employees[1].identifier").description("second employee's identifier"),
fieldWithPath("employees[1].givenName").description(" second employee given name"),
fieldWithPath("employees[1].middleName").description("second employee's middle name"),
fieldWithPath("employees[1].surname").description("second employee's surname"),
fieldWithPath("employees[1].assignedOffice").description("second employee's assigned office"),
fieldWithPath("employees[1].contactDetails").type("List<ContactDetail>").description("second employee's contact details"),
fieldWithPath("totalPages").type("Integer").description("Page of Employees"),
fieldWithPath("totalElements").type("Integer").description("Page of Employees"))));
}