in component-test/src/main/java/org/apache/fineract/cn/group/GroupApiDocumentation.java [602:666]
public void documentCloseMeeting ( ) 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(RandomStringUtils.randomAlphanumeric(256));
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 Group activatedGroup = this.testSubject.findGroup(randomGroup.getIdentifier());
Assert.assertEquals(Group.Status.ACTIVE.name(), activatedGroup.getStatus());
final List <GroupCommand> groupCommands = this.testSubject.fetchGroupCommands(activatedGroup.getIdentifier());
Assert.assertTrue(groupCommands.size() == 1);
final GroupCommand groupCommand = groupCommands.get(0);
Assert.assertEquals(activate.getAction(), groupCommand.getAction());
Assert.assertEquals(activate.getNote(), groupCommand.getNote());
Assert.assertEquals(activate.getCreatedBy(), groupCommand.getCreatedBy());
Assert.assertNotNull(groupCommand.getCreatedOn());
final List <Meeting> meetings = this.testSubject.fetchMeetings(activatedGroup.getIdentifier(), Boolean.FALSE);
Assert.assertNotNull(meetings);
Assert.assertEquals(randomGroupDefinition.getCycle().getNumberOfMeetings(), Integer.valueOf(meetings.size()));
final Meeting meeting2signOff = meetings.get(0);
final SignOffMeeting signOffMeeting = new SignOffMeeting();
signOffMeeting.setCycle(meeting2signOff.getCurrentCycle());
signOffMeeting.setSequence(meeting2signOff.getMeetingSequence());
signOffMeeting.setDuration(120L);
signOffMeeting.setAttendees(meeting2signOff.getAttendees()
.stream()
.map(attendee -> {
attendee.setStatus(Attendee.Status.ATTENDED.name());
return attendee;
})
.collect(Collectors.toSet())
);
Gson gson = new Gson();
this.mockMvc.perform(put("/groups/" + randomGroup.getIdentifier() + "/meetings")
.accept(MediaType.ALL_VALUE)
.contentType(MediaType.APPLICATION_JSON_VALUE)
.content(gson.toJson(signOffMeeting)))
.andExpect(status().isAccepted())
.andDo(document("document-close-meeting", preprocessRequest(prettyPrint()),
requestFields(
fieldWithPath("cycle").type("Integer").description("Meetings in cycle"),
fieldWithPath("sequence").type("Integer").description("Meeting sequence"),
fieldWithPath("attendees").type("Set<String>").description("Set of attendees"),
fieldWithPath("duration").type("Long").description("Duration of meeting")
)));
}