コード例 #1
0
  @Test
  public void runTestDtoToDomain() {
    log.debug("Dto-->Domain Mapper Test");

    // Create DTO object
    FundingRequestDTO dto = new FundingRequestDTO();

    // loan details
    long loanId = 12345;
    String productGroup = "FIXED";
    BigDecimal loanAmount = new BigDecimal("500000");
    BigDecimal purchasePrice = new BigDecimal("600000");
    String propertyAddress = "123 MAIN STREET";

    dto.setLoanId(loanId);
    dto.setProductGroup(productGroup);
    //		dto.setProductName("15-YR NON AGENCY FIXED");
    dto.setLoanAmount(loanAmount);
    dto.setPurchasePrice(purchasePrice);
    dto.setPropertyAddress(propertyAddress);

    // borrower details
    String firstName = "TEST";
    String lastName = "BORROWER";
    String phoneNumber = "123-456-7890";
    String emailAddress = "*****@*****.**";
    dto.setFirstName(firstName);
    dto.setLastName(lastName);
    dto.setPhoneNumber(phoneNumber);
    dto.setEmailAddress(emailAddress);

    // funding details
    String fundType = "FULL DISBURSE";
    BigDecimal fundingAmount = new BigDecimal("500000");
    int termInMonths = 360;

    dto.setFundType(fundType);
    dto.setFundingAmount(fundingAmount);
    dto.setTermInMonths(termInMonths);

    log.debug("dto:" + dto.toString());

    Loan loan = (Loan) mapper.map(dto, Loan.class);
    log.debug("\nloan:" + ToStringBuilder.reflectionToString(loan, ToStringStyle.MULTI_LINE_STYLE));

    Borrower borrower = (Borrower) mapper.map(dto, Borrower.class);
    log.debug(
        "\nloan:" + ToStringBuilder.reflectionToString(borrower, ToStringStyle.MULTI_LINE_STYLE));

    FundingRequest fundingRequest = (FundingRequest) mapper.map(dto, FundingRequest.class);
    log.debug(
        "\nloan:"
            + ToStringBuilder.reflectionToString(fundingRequest, ToStringStyle.MULTI_LINE_STYLE));
  }
コード例 #2
0
 /**
  * Ajoute un article
  *
  * @param post article � ajouter
  * @throws BlogException
  * @throws ValidationException
  */
 public IPost addPost(IPost post) throws BlogException, ValidationException {
   Post postSrv = (Post) mapper.map(post, Post.class);
   try {
     postSrv = bean.addPost(postSrv);
   } catch (EJBAccessException e) {
     throw new BlogException(
         null,
         BlogInternationalizationUtils.getMessages().getString("acces.non.autorise"),
         Constants.HOME_PAGE);
   }
   return (PostGWT) mapper.map(postSrv, PostGWT.class);
 }
コード例 #3
0
 private List<IPost> converterPostList(List<Post> posts) throws BlogException {
   ArrayList<IPost> postsGWT = new ArrayList<IPost>();
   for (Post current : posts) {
     postsGWT.add((PostGWT) mapper.map(current, PostGWT.class));
   }
   return postsGWT;
 }
コード例 #4
0
 /**
  * Retourne un article par rapport � son titre
  *
  * @param title le titer
  * @return l'article trouv�
  * @throws BlogException
  */
 public PostGWT findPost(String title) throws BlogException {
   try {
     Post post = bean.findPost(title);
     return (PostGWT) mapper.map(post, PostGWT.class);
   } catch (EJBAccessException e) {
     throw new BlogException(
         null,
         BlogInternationalizationUtils.getMessages().getString("acces.non.autorise"),
         Constants.HOME_PAGE);
   }
 }
コード例 #5
0
 public IPost findPostId(int postid) throws BlogException {
   try {
     Post post = bean.findPostId(postid);
     log.debug("findPaostId : " + post.getPosttext());
     return (PostGWT) mapper.map(post, PostGWT.class);
   } catch (EJBAccessException e) {
     throw new BlogException(
         null,
         BlogInternationalizationUtils.getMessages().getString("acces.non.autorise"),
         Constants.HOME_PAGE);
   } catch (MappingException e) {
     throw new BlogException(
         null,
         BlogInternationalizationUtils.getMessages().getString("post.no.error"),
         Constants.HOME_PAGE);
   }
 }