in component-test/src/main/java/org/apache/fineract/cn/office/OfficeApiDocumentation.java [181:257]
public void documentGetBranches ( ) throws Exception {
final Office office = OfficeFactory.createRandomOffice();
office.setIdentifier("office001");
this.organizationManager.createOffice(office);
this.eventRecorder.wait(EventConstants.OPERATION_POST_OFFICE, office.getIdentifier());
final Address firstAddress = AddressFactory.createRandomAddress();
firstAddress.setStreet("Rue De Vie");
firstAddress.setCity("Bandjoun");
firstAddress.setRegion("West Region");
firstAddress.setPostalCode("8050");
firstAddress.setCountry("Cameroon");
final Office firstBranch = OfficeFactory.createRandomOffice();
firstBranch.setIdentifier("firstBranch");
firstBranch.setName("First Branch");
firstBranch.setDescription("First Branch Of MFI");
firstBranch.setAddress(firstAddress);
this.organizationManager.addBranch(office.getIdentifier(), firstBranch);
this.eventRecorder.wait(EventConstants.OPERATION_POST_OFFICE, firstBranch.getIdentifier());
final Address secondAddress = AddressFactory.createRandomAddress();
secondAddress.setStreet("Rue Du Bon");
secondAddress.setCity("Baham");
secondAddress.setRegion("West Region");
secondAddress.setPostalCode("8050");
secondAddress.setCountry("Cameroon");
final Office secondBranch = OfficeFactory.createRandomOffice();
secondBranch.setIdentifier("secondBranch");
secondBranch.setName("Second Branch");
secondBranch.setDescription("Second Branch Of MFI");
secondBranch.setAddress(secondAddress);
this.organizationManager.addBranch(office.getIdentifier(), secondBranch);
this.eventRecorder.wait(EventConstants.OPERATION_POST_OFFICE, secondBranch.getIdentifier());
final OfficePage officePage = this.organizationManager.getBranches(office.getIdentifier(), 0, 20, null, null);
Assert.assertEquals(Long.valueOf(2L), officePage.getTotalElements());
this.mockMvc.perform(get("/offices/" + office.getIdentifier() + "/branches")
.contentType(MediaType.APPLICATION_JSON_VALUE)
.accept(MediaType.ALL_VALUE))
.andExpect(status().isOk())
.andDo(document("document-get-branches", preprocessResponse(prettyPrint()),
responseFields(
fieldWithPath("offices[].identifier").description("first employee's identifier"),
fieldWithPath("offices[].parentIdentifier").description("Parent office"),
fieldWithPath("offices[].name").description("first office's name"),
fieldWithPath("offices[].description").description("first branch's description"),
fieldWithPath("offices[].address").type("Address").description("first branch's address + \n " +
" *class* _Address_ { + \n" +
" private String street + \n" +
" private String city + \n" +
" private String region + \n" +
" private String postalCode + \n" +
" private String countryCode + \n" +
" private String country + \n" +
"}"),
fieldWithPath("offices[].externalReferences").description("first branch's external reference"),
fieldWithPath("offices[1].identifier").description("second employee's identifier"),
fieldWithPath("offices[1].parentIdentifier").description("Parent office"),
fieldWithPath("offices[1].name").description("second office's name"),
fieldWithPath("offices[1].description").description("second branch's description"),
fieldWithPath("offices[1].address").type("Address").description("second branch's address + \n " +
" *class* _Address_ { + \n" +
" private String street + \n" +
" private String city + \n" +
" private String region + \n" +
" private String postalCode + \n" +
" private String countryCode + \n" +
" private String country + \n" +
"}"),
fieldWithPath("offices[1].externalReferences").description("second branch's external reference"),
fieldWithPath("totalPages").type("Integer").description("Page of offices"),
fieldWithPath("totalElements").type("Integer").description("Page of offices"))));
}