public void documentGetGroupCommands()

in component-test/src/main/java/org/apache/fineract/cn/group/GroupApiDocumentation.java [450:492]


  public void documentGetGroupCommands ( ) 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 Group activatedGroup = this.testSubject.findGroup(randomGroup.getIdentifier());
    Assert.assertEquals(Group.Status.ACTIVE.name(), activatedGroup.getStatus());

    this.mockMvc.perform(get("/groups/" + activatedGroup.getIdentifier() + "/commands")
            .accept(MediaType.ALL_VALUE)
            .contentType(MediaType.APPLICATION_JSON_VALUE))
            .andExpect(status().isOk())
            .andDo(document("document-get-group-commands", preprocessResponse(prettyPrint()),
                    responseFields(
                            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")
                    )));
  }