public void documentFindCustomer()

in component-test/src/main/java/org/apache/fineract/cn/customer/CustomerApiDocumentation.java [198:314]


  public void documentFindCustomer ( ) throws Exception {
    final Customer customer = CustomerGenerator.createRandomCustomer();

    DateOfBirth dateOfBirth = new DateOfBirth();
    dateOfBirth.setYear(Integer.valueOf(1997));
    dateOfBirth.setMonth(Integer.valueOf(6));
    dateOfBirth.setDay(Integer.valueOf(5));

    Address address = new Address();
    address.setStreet("Che St");
    address.setCity("Bali");
    address.setRegion("WC");
    address.setPostalCode("8050");
    address.setCountryCode("CM");
    address.setCountry("Cameroon");

    ContactDetail contactDetailOne = new ContactDetail();
    contactDetailOne.setType(ContactDetail.Type.MOBILE.name());
    contactDetailOne.setGroup(ContactDetail.Group.PRIVATE.name());
    contactDetailOne.setValue("675673477");
    contactDetailOne.setPreferenceLevel(Integer.valueOf(1));
    contactDetailOne.setValidated(Boolean.FALSE);

    List <ContactDetail> contactDetails = new ArrayList <>();
    contactDetails.add(contactDetailOne);

    customer.setIdentifier("eniruth");
    customer.setType(Customer.Type.PERSON.name());
    customer.setGivenName("Eni");
    customer.setMiddleName("Ruth");
    customer.setSurname("Tah");
    customer.setDateOfBirth(dateOfBirth);
    customer.setMember(Boolean.TRUE);
    customer.setAssignedOffice("Bali ViB");
    customer.setAssignedEmployee("Shu Dion");
    customer.setAddress(address);
    customer.setContactDetails(contactDetails);
    customer.setCurrentState(Customer.State.PENDING.name());
    customer.setAccountBeneficiary("Hubby");
    customer.setReferenceCustomer("friend");
    customer.setApplicationDate(LocalDate.ofYearDay(2018, 4).toString());
    customer.setLastModifiedBy("Asah Aaron");
    customer.setLastModifiedOn(LocalDate.ofYearDay(2018, 100).toString());

    this.customerManager.createCustomer(customer);
    this.eventRecorder.wait(CustomerEventConstants.POST_CUSTOMER, customer.getIdentifier());

    final Customer foundCustomer = this.customerManager.findCustomer(customer.getIdentifier());
    Assert.assertNotNull(foundCustomer);

    this.mockMvc.perform(get("/customers/" + foundCustomer.getIdentifier())
            .contentType(MediaType.APPLICATION_JSON_VALUE)
            .accept(MediaType.ALL_VALUE))
            .andExpect(status().isOk())
            .andDo(document("document-find-customer", preprocessRequest(prettyPrint()), preprocessResponse(prettyPrint()),
                    responseFields(
                            fieldWithPath("identifier").description("The customer's identifier"),
                            fieldWithPath("type").description("The type of legal entity  +\n" +
                                    " +\n" +
                                    "*enum* _Type_ { +\n" +
                                    "    PERSON, +\n" +
                                    "    BUSINESS +\n" +
                                    "  } +"),
                            fieldWithPath("givenName").description("The customer's given name"),
                            fieldWithPath("middleName").description("The customer's middle name"),
                            fieldWithPath("surname").description("The customer's surName"),
                            fieldWithPath("dateOfBirth").type("DateOfBirth").description("The customer's date of birth +\n" +
                                    " +\n" +
                                    " _DateOfBirth_ { +\n" +
                                    "    *Integer* year, +\n" +
                                    "    *Integer* month, +\n" +
                                    "    *Integer* day, +\n" +
                                    "} +"),
                            fieldWithPath("member").description("Is customer a member of the MFI ?"),
                            fieldWithPath("assignedOffice").description("The customer's assigned office"),
                            fieldWithPath("assignedEmployee").description("The customer's assigned employee"),
                            fieldWithPath("address").type("Address").description("The customer's physical address +\n" +
                                    " +\n" +
                                    "_Address_ { +\n" +
                                    "*String* street, +\n" +
                                    "*String* city, +\n" +
                                    "*String* region, +\n" +
                                    "*String* postalCode, +\n" +
                                    "*String* countryCode, +\n" +
                                    "*String* country  } +"),
                            fieldWithPath("contactDetails").type("List<ContactDetail>").description("The customer's contact details +\n" +
                                    " +\n" +
                                    "_ContactDetail_ { +\n" +
                                    "  *enum* _Type_ { +\n" +
                                    "     EMAIL, +\n" +
                                    "     PHONE, +\n" +
                                    "     MOBILE +\n" +
                                    "   } type, +\n" +
                                    "   *enum* _Group_ { +\n" +
                                    "     BUSINESS, +\n" +
                                    "     PRIVATE +\n" +
                                    "   } group, +\n" +
                                    "   *String* value +\n" +
                                    " } +"),
                            fieldWithPath("currentState").type("State").description("The customer's current state +\n" +
                                    " +\n" +
                                    "*enum* _State_ { +\n" +
                                    "     PENDING, +\n" +
                                    "     ACTIVE, +\n" +
                                    "     LOCKED, +\n" +
                                    "     CLOSED +\n" +
                                    "   } +"),
                            fieldWithPath("accountBeneficiary").type("String").description("(Optional) The customer beneficiary").optional(),
                            fieldWithPath("referenceCustomer").type("String").description("(Optional) The customer's reference").optional(),
                            fieldWithPath("applicationDate").type("String").description("(Optional) The date customer applied for account"),
                            fieldWithPath("customValues").type("List<Value>").description("Some custom values"),
                            fieldWithPath("createdBy").description("User who created account"),
                            fieldWithPath("createdOn").description("Date and time when account was created"),
                            fieldWithPath("lastModifiedBy").type("String").description("(Optional) Employee who last modified account"),
                            fieldWithPath("lastModifiedOn").type("String").description("(Optional) Date and time account was last modified")
                    )));
  }