Package accounts

Examples of accounts.Account


  public void testUpdateAccountBeneficiaries() {
    Map<String, Percentage> allocationPercentages = new HashMap<String, Percentage>();
    allocationPercentages.put("Annabelle", Percentage.valueOf("25%"));
    allocationPercentages.put("Corgan", Percentage.valueOf("75%"));
    accountManager.updateBeneficiaryAllocationPercentages(Long.valueOf(1), allocationPercentages);
    Account account = accountManager.getAccount(Long.valueOf(1));
    assertEquals("Invalid adjusted percentage", Percentage.valueOf("25%"), account.getBeneficiary("Annabelle")
        .getAllocationPercentage());
    assertEquals("Invalid adjusted percentage", Percentage.valueOf("75%"), account.getBeneficiary("Corgan")
        .getAllocationPercentage());
  }
View Full Code Here


  }
 
  @Test
  public void testAddBeneficiary() {
    accountManager.addBeneficiary(Long.valueOf(1), "Ben");
    Account account = accountManager.getAccount(Long.valueOf(1));
    assertEquals("Should only have three beneficiaries", 3, account.getBeneficiaries().size());
  }
View Full Code Here

  @Test
  public void testRemoveBeneficiary() {
    Map<String, Percentage> allocationPercentages = new HashMap<String, Percentage>();
    allocationPercentages.put("Corgan", Percentage.oneHundred());
    accountManager.removeBeneficiary(Long.valueOf(1), "Annabelle", allocationPercentages);
    Account account = accountManager.getAccount(Long.valueOf(1));
    assertEquals("Should only have one beneficiary", 1, account.getBeneficiaries().size());
    assertEquals("Corgan should now have 100% allocation", Percentage.oneHundred(), account
        .getBeneficiary("Corgan").getAllocationPercentage());
  }
View Full Code Here

public class StubAccountManager implements AccountManager {

  private Map<Long, Account> accountsById = new HashMap<Long, Account>();

  public StubAccountManager() {
    Account account = new Account("123456789", "Keith and Keri Donald");
    account.addBeneficiary("Annabelle", Percentage.valueOf("50%"));
    account.addBeneficiary("Corgan", Percentage.valueOf("50%"));
    account.setEntityId(0L);
    accountsById.put(Long.valueOf(0), account);
  }
View Full Code Here

  public List<Account> getAllAccounts() {
    return new ArrayList<Account>(accountsById.values());
  }

  public Account getAccount(Long id) {
    Account account = accountsById.get(id);
    if (account == null) {
      throw new ObjectRetrievalFailureException(Account.class, id);
    }
    return account;
  }
View Full Code Here

  public void update(Account account) {
    accountsById.put(account.getEntityId(), account);
  }

  public void updateBeneficiaryAllocationPercentages(Long accountId, Map<String, Percentage> allocationPercentages) {
    Account account = accountsById.get(accountId);
    for (Entry<String, Percentage> entry : allocationPercentages.entrySet()) {
      account.getBeneficiary(entry.getKey()).setAllocationPercentage(entry.getValue());
    }
  }
View Full Code Here

    controller = new AccountController(new  StubAccountManager());
  }

  @Test
  public void testHandleDetailsRequest() throws Exception {
    Account acc = controller.accountDetails(0l);
    assertNotNull(acc);
    assertEquals(Long.valueOf(0), acc.getEntityId());
  }
View Full Code Here

   * Performs validations for the given account. The main validation
   * is against the account number, which can be changed but not to
   * a number that's already in use by another account.
   */
  public void validate(Object target, Errors errors) {
    Account account = (Account) target;
    if (StringUtils.isNotEmpty(account.getNumber())) {
      Account existingAccount = accountManager.findAccount(account.getNumber());
      if (existingAccount != null) {
        if (! account.getEntityId().equals(existingAccount.getEntityId())) {
          errors.rejectValue("number", "account.number.inuse");
        }
      }
    }
//    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "name", "errors.required", new String[]{"name"});
View Full Code Here

        beneficiary.setAllocationPercentage(percentage);
       
        MonetaryAmount amount = new MonetaryAmount(rs.getDouble("savings"));
        beneficiary.setSavings(amount);
       
        Account account = new Account();
        account.setEntityId(rs.getLong("account_id"));
        beneficiary.setAccount(account);
       
          return beneficiary;
      }       
View Full Code Here

    return hibernateTemplate.find("from Account order by entityId desc");
  }

  @Transactional(readOnly = true)
  public Account getAccount(Long id) {
    Account account = hibernateTemplate.get(Account.class, id);
    return account;
  }
View Full Code Here

TOP

Related Classes of accounts.Account

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.