public void documentCreateCustomer()

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


  public void documentCreateCustomer ( ) throws Exception {
    final Customer customer = CustomerGenerator.createRandomCustomer();
    Gson gson = new Gson();

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

    Address address = new Address();
    address.setStreet("Hospital");
    address.setCity("Muyuka");
    address.setRegion("SWR");
    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("677777777");
    contactDetailOne.setPreferenceLevel(Integer.valueOf(1));
    contactDetailOne.setValidated(Boolean.FALSE);

    ContactDetail contactDetailTwo = new ContactDetail();
    contactDetailTwo.setType(ContactDetail.Type.PHONE.name());
    contactDetailTwo.setGroup(ContactDetail.Group.BUSINESS.name());
    contactDetailTwo.setValue("233363640");
    contactDetailTwo.setPreferenceLevel(Integer.valueOf(2));
    contactDetailTwo.setValidated(Boolean.FALSE);

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

    customer.setIdentifier("idOne");
    customer.setType(Customer.Type.PERSON.name());
    customer.setGivenName("Kima");
    customer.setMiddleName("Bessem");
    customer.setSurname("Ray");
    customer.setDateOfBirth(dateOfBirth);
    customer.setMember(Boolean.TRUE);
    customer.setAssignedOffice("Oweh ViB");
    customer.setAssignedEmployee("Che Godwin");
    customer.setAddress(address);
    customer.setContactDetails(contactDetails);
    customer.setCurrentState(Customer.State.PENDING.name());
    customer.setAccountBeneficiary("Spouse");
    customer.setReferenceCustomer("mate");
    customer.setApplicationDate(LocalDate.ofYearDay(2017, 200).toString());
    customer.setLastModifiedBy("Nakuve");
    customer.setLastModifiedOn(LocalDate.ofYearDay(2018, 4).toString());

    this.mockMvc.perform(post("/customers")
            .contentType(MediaType.APPLICATION_JSON_VALUE)
            .content(gson.toJson(customer))
            .accept(MediaType.APPLICATION_JSON_VALUE))
            .andExpect(status().isAccepted())
            .andDo(document("document-create-customer", preprocessRequest(prettyPrint()), preprocessResponse(prettyPrint()),
                    requestFields(
                            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("account beneficiary"),
                            fieldWithPath("applicationDate").type("String").description("date customer applied for account"),
                            fieldWithPath("lastModifiedBy").type("String").description("employee who last modified account"),
                            fieldWithPath("lastModifiedOn").type("String").description("last time account was modified"),
                            fieldWithPath("referenceCustomer").type("String").description("fellow customer to refer to")
                    )));
  }