in component-test/src/main/java/org/apache/fineract/cn/group/GroupApiDocumentation.java [340:387]
public void documentCloseGroup ( ) throws Exception {
final GroupDefinition randomGroupDefinition = GroupDefinitionGenerator.createRandomGroupDefinition();
this.testSubject.createGroupDefinition(randomGroupDefinition);
this.eventRecorder.wait(EventConstants.POST_GROUP_DEFINITION, randomGroupDefinition.getIdentifier());
final Group randomGroup = GroupGenerator.createRandomGroup(randomGroupDefinition.getIdentifier());
this.testSubject.createGroup(randomGroup);
this.eventRecorder.wait(EventConstants.POST_GROUP, randomGroup.getIdentifier());
final Group fetchedGroup = this.testSubject.findGroup(randomGroup.getIdentifier());
Assert.assertEquals(Group.Status.PENDING.name(), fetchedGroup.getStatus());
final GroupCommand activate = new GroupCommand();
activate.setAction(GroupCommand.Action.ACTIVATE.name());
activate.setNote("Activate Note" + RandomStringUtils.randomAlphanumeric(3));
activate.setCreatedBy(SuiteTestEnvironment.TEST_USER);
activate.setCreatedOn(ZonedDateTime.now(Clock.systemUTC()).format(DateTimeFormatter.ISO_ZONED_DATE_TIME));
this.testSubject.processGroupCommand(randomGroup.getIdentifier(), activate);
this.eventRecorder.wait(EventConstants.ACTIVATE_GROUP, randomGroup.getIdentifier());
final GroupCommand close = new GroupCommand();
close.setAction(GroupCommand.Action.CLOSE.name());
close.setNote("Close Note" + RandomStringUtils.randomAlphanumeric(3));
close.setCreatedBy(SuiteTestEnvironment.TEST_USER);
close.setCreatedOn(ZonedDateTime.now(Clock.systemUTC()).format(DateTimeFormatter.ISO_ZONED_DATE_TIME));
Gson serialize = new Gson();
this.mockMvc.perform(post("/groups/" + fetchedGroup.getIdentifier() + "/commands")
.accept(MediaType.APPLICATION_JSON_VALUE)
.contentType(MediaType.APPLICATION_JSON_VALUE)
.content(serialize.toJson(close)))
.andExpect(status().isAccepted())
.andDo(document("document-close-group", preprocessRequest(prettyPrint()),
requestFields(
fieldWithPath("action").description("Action " +
"" +
"*enum* _Action_ { + \n" +
" ACTIVATE, + \n" +
" CLOSE, + \n" +
" REOPEN + \n" +
" }"),
fieldWithPath("note").description("Group NOte"),
fieldWithPath("createdBy").description("Assigned Employee to Group"),
fieldWithPath("createdOn").type("String").description("Date when group was created")
)));
}