public void documentFetchContactDetails()

in component-test/src/main/java/org/apache/fineract/cn/office/EmployeeApiDocumentation.java [371:420]


  public void documentFetchContactDetails ( ) throws Exception {

    final Office office = OfficeFactory.createRandomOffice();
    office.setIdentifier("officeZero");
    this.organizationManager.createOffice(office);
    this.eventRecorder.wait(EventConstants.OPERATION_POST_OFFICE, office.getIdentifier());

    final Employee employee = EmployeeFactory.createRandomEmployee();

    ContactDetail emailContact = new ContactDetail();
    emailContact.setType(ContactDetail.Type.EMAIL.toString());
    emailContact.setGroup(ContactDetail.Group.PRIVATE.toString());
    emailContact.setValue("me@example.com");
    emailContact.setPreferenceLevel(new Integer(2));

    ContactDetail phoneContact = new ContactDetail();
    phoneContact.setType(ContactDetail.Type.MOBILE.name());
    phoneContact.setGroup(ContactDetail.Group.BUSINESS.name());
    phoneContact.setValue("6667667667");
    phoneContact.setPreferenceLevel(new Integer(1));

    List <ContactDetail> contacts = new ArrayList <>();
    contacts.add(emailContact);
    contacts.add(phoneContact);

    employee.setIdentifier("empNoThree");
    employee.setGivenName("Mendi");
    employee.setMiddleName("Ngong");
    employee.setSurname("Ngang");
    employee.setAssignedOffice(office.getIdentifier());
    employee.setContactDetails(contacts);
    this.organizationManager.createEmployee(employee);
    this.eventRecorder.wait(EventConstants.OPERATION_POST_EMPLOYEE, employee.getIdentifier());

    this.mockMvc.perform(get("/employees/" + employee.getIdentifier() + "/contacts")
            .contentType(MediaType.APPLICATION_JSON_VALUE)
            .accept(MediaType.ALL_VALUE))
            .andExpect(status().isOk())
            .andDo(document("document-fetch-contact-details", preprocessResponse(prettyPrint()),
                    responseFields(
                            fieldWithPath("[].type").description("Type of first contact"),
                            fieldWithPath("[].group").description("Group of first contact"),
                            fieldWithPath("[].value").description("Value of first contact"),
                            fieldWithPath("[].preferenceLevel").type("Integer").description("Preference level of first contact"),
                            fieldWithPath("[1].type").description("Type of second contact"),
                            fieldWithPath("[1].group").description("Group of second contact"),
                            fieldWithPath("[1].value").description("Value of second contact"),
                            fieldWithPath("[1].preferenceLevel").type("Integer").description("Preference level of second contact")
                    )));
  }