Package rewards

Examples of rewards.AccountContribution


    // assert the expected reward confirmation results
    assertNotNull(confirmation);
    assertNotNull(confirmation.getConfirmationNumber());

    // assert an account contribution was made
    AccountContribution contribution = confirmation.getAccountContribution();
    assertNotNull(contribution);

    // the contribution account number should be '123456789'
    assertEquals("123456789", contribution.getAccountNumber());

    // the total contribution amount should be 8.00 (8% of 100.00)
    assertEquals(MonetaryAmount.valueOf("8.00"), contribution.getAmount());

    // the total contribution amount should have been split into 2 distributions
    assertEquals(2, contribution.getDistributions().size());

    // each distribution should be 4.00 (as both have a 50% allocation)
    assertEquals(MonetaryAmount.valueOf("4.00"), contribution.getDistribution("Annabelle").getAmount());
    assertEquals(MonetaryAmount.valueOf("4.00"), contribution.getDistribution("Corgan").getAmount());
  }
View Full Code Here


    // assert the expected reward confirmation results
    assertNotNull(confirmation);
    assertNotNull(confirmation.getConfirmationNumber());

    // assert an account contribution was made
    AccountContribution contribution = confirmation.getAccountContribution();
    assertNotNull(contribution);

    // the contribution account number should be '123456789'
    assertEquals("123456789", contribution.getAccountNumber());

    // the total contribution amount should be 8.00 (8% of 100.00)
    assertEquals(MonetaryAmount.valueOf("8.00"), contribution.getAmount());

    // the total contribution amount should have been split into 2 distributions
    assertEquals(2, contribution.getDistributions().size());

    // each distribution should be 4.00 (as both have a 50% allocation)
    assertEquals(MonetaryAmount.valueOf("4.00"), contribution.getDistribution("Annabelle").getAmount());
    assertEquals(MonetaryAmount.valueOf("4.00"), contribution.getDistribution("Corgan").getAmount());
  }
View Full Code Here

  private RewardConfirmation mapRewardConfirmation(Element confirmationElement) {
    String confirmationNumber = confirmationElement.getAttribute("confirmationNumber");
    String accountNumber = confirmationElement.getAttribute("accountNumber");
    String amount = confirmationElement.getAttribute("amount");
    List<Element> distributionElements = DomUtils.getChildElementsByTagName(confirmationElement, "distribution");
    AccountContribution contribution = new AccountContribution(accountNumber, MonetaryAmount.valueOf(amount),
        mapDistributions(distributionElements));
    return new RewardConfirmation(confirmationNumber, contribution);
  }
View Full Code Here

    if (!isValid()) {
      throw new IllegalStateException(
          "Cannot make contributions to this account: it has invalid beneficiary allocations");
    }
    Set<Distribution> distributions = distribute(amount);
    return new AccountContribution(getNumber(), amount, distributions);
  }
View Full Code Here

    // assert the expected reward confirmation results
    assertNotNull(confirmation);
    assertNotNull(confirmation.getConfirmationNumber());

    // assert an account contribution was made
    AccountContribution contribution = confirmation.getAccountContribution();
    assertNotNull(contribution);

    // the account number should be '123456789'
    assertEquals("123456789", contribution.getAccountNumber());

    // the total contribution amount should be 8.00 (8% of 100.00)
    assertEquals(MonetaryAmount.valueOf("8.00"), contribution.getAmount());

    // the total contribution amount should have been split into 2 distributions
    assertEquals(2, contribution.getDistributions().size());

    // each distribution should be 4.00 (as both have a 50% allocation)
    assertEquals(MonetaryAmount.valueOf("4.00"), contribution.getDistribution("Annabelle").getAmount());
    assertEquals(MonetaryAmount.valueOf("4.00"), contribution.getDistribution("Corgan").getAmount());
  }
View Full Code Here

    Account account = new Account("1", "Keith and Keri Donald");
    account.setEntityId(0L);
    account.addBeneficiary("Annabelle", Percentage.valueOf("50%"));
    account.addBeneficiary("Corgan", Percentage.valueOf("50%"));

    AccountContribution contribution = account.makeContribution(MonetaryAmount.valueOf("8.00"));
    RewardConfirmation confirmation = repository.confirmReward(contribution, dining);
    assertNotNull("confirmation should not be null", confirmation);
    assertNotNull("confirmation number should not be null", confirmation.getConfirmationNumber());
    assertEquals("wrong contribution object", contribution, confirmation.getAccountContribution());
    verifyRewardInserted(confirmation, dining);
View Full Code Here

    Account account = new Account("1", "Keith and Keri Donald");
    account.setEntityId(0L);
    account.addBeneficiary("Annabelle", Percentage.valueOf("50%"));
    account.addBeneficiary("Corgan", Percentage.valueOf("50%"));

    AccountContribution contribution = account.makeContribution(MonetaryAmount.valueOf("8.00"));
    RewardConfirmation confirmation = repository.confirmReward(contribution, dining);
    assertNotNull("confirmation should not be null", confirmation);
    assertNotNull("confirmation number should not be null", confirmation.getConfirmationNumber());
    assertEquals("wrong contribution object", contribution, confirmation.getAccountContribution());
    verifyRewardInserted(confirmation, dining);
View Full Code Here

  public RewardConfirmation rewardAccountFor(Dining dining) {
    Account account = accountRepository.findByCreditCard(dining.getCreditCardNumber());
    Restaurant restaurant = restaurantRepository.findByMerchantNumber(dining.getMerchantNumber());
    MonetaryAmount amount = restaurant.calculateBenefitFor(account, dining);
    AccountContribution contribution = account.makeContribution(amount);
    accountRepository.updateBeneficiaries(account);
    return rewardRepository.confirmReward(contribution, dining);
  }
View Full Code Here

    Account account = new Account("1", "Keith and Keri Donald");
    account.setEntityId(0L);
    account.addBeneficiary("Annabelle", Percentage.valueOf("50%"));
    account.addBeneficiary("Corgan", Percentage.valueOf("50%"));

    AccountContribution contribution = account.makeContribution(MonetaryAmount.valueOf("8.00"));
    RewardConfirmation confirmation = repository.confirmReward(contribution, dining);
    assertNotNull("confirmation should not be null", confirmation);
    assertNotNull("confirmation number should not be null", confirmation.getConfirmationNumber());
    assertEquals("wrong contribution object", contribution, confirmation.getAccountContribution());
    verifyRewardInserted(confirmation, dining);
View Full Code Here

    // assert the expected reward confirmation results
    assertNotNull(confirmation);
    assertNotNull(confirmation.getConfirmationNumber());

    // assert an account contribution was made
    AccountContribution contribution = confirmation.getAccountContribution();
    assertNotNull(contribution);

    // the account number should be '123456789'
    assertEquals("123456789", contribution.getAccountNumber());

    // the total contribution amount should be 8.00 (8% of 100.00)
    assertEquals(MonetaryAmount.valueOf("8.00"), contribution.getAmount());

    // the total contribution amount should have been split into 2 distributions
    assertEquals(2, contribution.getDistributions().size());

    // each distribution should be 4.00 (as both have a 50% allocation)
    assertEquals(MonetaryAmount.valueOf("4.00"), contribution.getDistribution("Annabelle").getAmount());
    assertEquals(MonetaryAmount.valueOf("4.00"), contribution.getDistribution("Corgan").getAmount());
  }
View Full Code Here

TOP

Related Classes of rewards.AccountContribution

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.