Package accounts

Examples of accounts.Account


    hibernateTemplate.saveOrUpdate(account);   
  }

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


    assertEquals("Wrong number of accounts", 21, accounts.size());
  }

  @Test
  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 allocation percentage", Percentage.valueOf("50%"), b2.getAllocationPercentage());
  }

  @Test
  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

  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

  }

  @Test
  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

  @Test
  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", 2, account.getBeneficiaries().size());
    assertEquals("Corgan should now have 100% allocation", Percentage.oneHundred(), account
        .getBeneficiary("Corgan").getAllocationPercentage());
  }
View Full Code Here

  }

  @Test
  public void testGet() throws Exception {
    // TODO 02: Invoke the controller setupForm method
    Account account = null;
    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();
    // TODO 05: Invoke the controller onSubmit method, test the return val and status
    String view = null;
    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

    assertFalse("Should not support and AccountValidator class", validator.supports(AccountValidator.class));
  }

  @Test
  public void testNumberInUseBySameAccount() {
    Account account = new Account("123456789", "Keith and Keri Donald");
    account.setEntityId(0L);
    Errors errors = new BeanPropertyBindingResult(account, "account");
    validator.validate(account, errors);
    assertEquals("No errors should be registered", 0, errors.getErrorCount());
  }
View Full Code Here

    assertEquals("No errors should be registered", 0, errors.getErrorCount());
  }
 
  @Test
  public void testNumberInUseByAnotherAccount() {
    Account account = new Account("123456001", "Keith and Keri Donald");
    account.setEntityId(0L);
    Errors errors = new BeanPropertyBindingResult(account, "account");
    validator.validate(account, errors);
    assertEquals("One error should be registered", 1, errors.getErrorCount());
    FieldError error = errors.getFieldError("number");
    assertNotNull(error);
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.