in component-test/src/main/java/org/apache/fineract/cn/office/OfficeApiDocumentation.java [151:178]
public void documentAddBranch ( ) throws Exception {
final Office parentOffice = OfficeFactory.createRandomOffice();
parentOffice.setIdentifier("parentOffice");
parentOffice.setName("Parent Office");
parentOffice.setDescription("My Parent Office");
this.organizationManager.createOffice(parentOffice);
this.eventRecorder.wait(EventConstants.OPERATION_POST_OFFICE, parentOffice.getIdentifier());
final Office branch = OfficeFactory.createRandomOffice();
branch.setIdentifier("Branch");
branch.setName("Branch To Add");
branch.setDescription("Branch To Be Added");
branch.setParentIdentifier(parentOffice.getIdentifier());
Gson gson = new Gson();
this.mockMvc.perform(post("/offices/" + parentOffice.getIdentifier())
.contentType(MediaType.APPLICATION_JSON_VALUE)
.content(gson.toJson(branch))
.accept(MediaType.APPLICATION_JSON_VALUE))
.andExpect(status().isAccepted())
.andDo(document("document-add-branch", preprocessRequest(prettyPrint()),
requestFields(
fieldWithPath("identifier").description("office's identifier"),
fieldWithPath("name").description("office name"),
fieldWithPath("description").description("office description"),
fieldWithPath("parentIdentifier").description("Parent Office"))));
}