in component-test/src/main/java/org/apache/fineract/cn/customer/CustomerApiDocumentation.java [1075:1146]
public void documentFetchCommands ( ) throws Exception {
final Customer customer = 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("Wokoko");
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("677429343");
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("666737653");
nextellContact.setPreferenceLevel(Integer.valueOf(2));
nextellContact.setValidated(Boolean.FALSE);
List <ContactDetail> contactDetails = new ArrayList <>();
contactDetails.add(mtnContact);
contactDetails.add(nextellContact);
customer.setIdentifier("kumba");
customer.setType(Customer.Type.PERSON.name());
customer.setGivenName("Kumba");
customer.setMiddleName("Ebere");
customer.setSurname("Besong");
customer.setDateOfBirth(dateOfBirth);
customer.setMember(Boolean.TRUE);
customer.setAssignedOffice("Mile 16");
customer.setAssignedEmployee("Malafa I.");
customer.setAddress(address);
customer.setContactDetails(contactDetails);
customer.setCurrentState(Customer.State.PENDING.name());
customer.setAccountBeneficiary("Mola");
customer.setReferenceCustomer("eyolle");
customer.setApplicationDate(LocalDate.ofYearDay(2017, 23).toString());
customer.setLastModifiedBy("Epie Ngome");
customer.setLastModifiedOn(LocalDate.ofYearDay(2018, 82).toString());
this.customerManager.createCustomer(customer);
this.eventRecorder.wait(CustomerEventConstants.POST_CUSTOMER, customer.getIdentifier());
this.customerManager.customerCommand(customer.getIdentifier(), CommandGenerator.create(Command.Action.ACTIVATE, "Test"));
this.eventRecorder.wait(CustomerEventConstants.ACTIVATE_CUSTOMER, customer.getIdentifier());
final List <Command> commands = this.customerManager.fetchCustomerCommands(customer.getIdentifier());
this.mockMvc.perform(get("/customers/" + customer.getIdentifier() + "/commands")
.contentType(MediaType.APPLICATION_JSON_VALUE)
.accept(MediaType.ALL_VALUE))
.andExpect(status().isOk())
.andDo(document("document-fetch-commands", preprocessRequest(prettyPrint()),
preprocessResponse(prettyPrint()),
responseFields(
fieldWithPath("[].action").description("A List of commands"),
fieldWithPath("[].comment").description("A comment"),
fieldWithPath("[].createdOn").description("Date and time customer was created"),
fieldWithPath("[].createdBy").description("Employee who created customer"))));
}