Package accounts

Examples of accounts.Account


    controller = new EditAccountController(accountManager);
  }

  @Test
  public void testGet() throws Exception {
    Account account = controller.setupForm(new Long(0));
    assertNotNull("Should have an account", account);
    assertEquals("Should be an entity with id of 0", Long.valueOf(0), account.getEntityId());
  }
View Full Code Here


    assertEquals("Should be an entity with id of 0", Long.valueOf(0), account.getEntityId());
  }

  @Test
  public void testPost() throws Exception {
    Account account = new Account("1", "Ben");
    account.setEntityId(new Long(0));
    BindingResult result = new BeanPropertyBindingResult(account, "account");
    SessionStatus sessionStatus = new SimpleSessionStatus();
    String view = controller.onSubmit(account , result, sessionStatus);
    assertEquals("redirect:/accounts/accountDetails.htm?entityId=0", view);
    assertTrue(sessionStatus.isComplete());
    account = accountManager.getAccount(Long.valueOf(0));
    assertEquals("1", account.getNumber());
    assertEquals("Ben", account.getName());
  }
View Full Code Here

    List<Account> accounts = accountManager.getAllAccounts();
    assertEquals("Wrong number of accounts", 21, accounts.size());
  }

  public void testGetAccount() {
    Account account = accountManager.getAccount(Long.valueOf(0));
    // assert the returned account contains what you expect given the state
    // of the database
    assertNotNull("account should never be null", account);
    assertEquals("wrong entity id", Long.valueOf(0), account.getEntityId());
    assertEquals("wrong account number", "123456789", account.getNumber());
    assertEquals("wrong name", "Keith and Keri Donald", account.getName());
    assertEquals("wrong beneficiary collection size", 2, account.getBeneficiaries().size());

    Beneficiary b1 = account.getBeneficiary("Annabelle");
    assertNotNull("Annabelle should be a beneficiary", b1);
    assertEquals("wrong savings", MonetaryAmount.valueOf("0.00"), b1.getSavings());
    assertEquals("wrong allocation percentage", Percentage.valueOf("50%"), b1.getAllocationPercentage());

    Beneficiary b2 = account.getBeneficiary("Corgan");
    assertNotNull("Corgan should be a beneficiary", b2);
    assertEquals("wrong savings", MonetaryAmount.valueOf("0.00"), b2.getSavings());
    assertEquals("wrong allocation percentage", Percentage.valueOf("50%"), b2.getAllocationPercentage());
  }
View Full Code Here

    assertEquals("wrong savings", MonetaryAmount.valueOf("0.00"), b2.getSavings());
    assertEquals("wrong allocation percentage", Percentage.valueOf("50%"), b2.getAllocationPercentage());
  }

  public void testUpdateAccount() {
    Account oldAccount = accountManager.getAccount(Long.valueOf(0));
    oldAccount.setName("Ben Hale");
    accountManager.update(oldAccount);
    Account newAccount = accountManager.getAccount(Long.valueOf(0));
    assertEquals("Did not persist the name change", "Ben Hale", newAccount.getName());
  }
View Full Code Here

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

  public StubAccountManager() {
    String number = "123456789";
    Account account = new Account(number, "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);
    accountsByNumber.put("123456789", account);
   
    number = "123456001";
    account = new Account(number, "Dollie R. Adams");
    account.setEntityId(1L);
    accountsById.put(Long.valueOf(1), account);
    accountsByNumber.put(number, account);
  }
View Full Code Here

  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(0), allocationPercentages);
    Account account = accountManager.getAccount(Long.valueOf(0));
    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

        .getAllocationPercentage());
  }

  public void testAddBeneficiary() {
    accountManager.addBeneficiary(Long.valueOf(0), "Ben");
    Account account = accountManager.getAccount(Long.valueOf(0));
    assertEquals("Should only have three beneficiaries", 3, account.getBeneficiaries().size());
  }
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 testRemoveBeneficiary() {
    Map<String, Percentage> allocationPercentages = new HashMap<String, Percentage>();
    allocationPercentages.put("Corgan", Percentage.oneHundred());
    accountManager.removeBeneficiary(Long.valueOf(0), "Annabelle", allocationPercentages);
    Account account = accountManager.getAccount(Long.valueOf(0));
    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 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

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.