Package accounts

Examples of accounts.Account


    assertEquals("No errors should be registered", 0, errors.getErrorCount());
  }

  @Test
  public void testNoNumberProvided() {
    Account account = new Account("", "");
    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


    getCurrentSession().update(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

  @RequestMapping(method=RequestMethod.GET)
  public @ModelAttribute("account") Account
        setupForm(@RequestParam(value = "entityId", required = false) Long id) {
   
    if(id == null){
      return new Account("", "");
    }
    return accountManager.getAccount(id);
  }
View Full Code Here

  public Account findAccountById(Long accountId) {
   
    StringBuilder query = new StringBuilder("select id, number, name ");
    query.append(" from t_account where id = ? ");

    Account account = this.jdbcTemplate.queryForObject(query.toString(),
            new Object[]{accountId}, new AccountMapper());
    return account;
  }
View Full Code Here

    Beneficiary beneficiary = new Beneficiary(name, Percentage.valueOf(allocationPercentage));
    if(id.longValue() != -1){
      beneficiary.setEntityId(id);     
    }

    Account account = hibernateTemplate.get(Account.class, accountId);
    beneficiary.setAccount(account);
    hibernateTemplate.saveOrUpdate(beneficiary)
   
  }
View Full Code Here

  }
 
  private static final class AccountMapper implements RowMapper<Account> {

      public Account mapRow(ResultSet rs, int rowNum) throws SQLException {
        Account account = new Account();
        account.setEntityId(rs.getLong("id"));
        account.setName(rs.getString("name"));
        account.setNumber(rs.getString("number"));
          return account;
      }       
View Full Code Here

    getCurrentSession().update(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

   * 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

    assertNotNull(accounts);
  }

  @Test
  public void testGetAccount() {
    Account account = accountManager.getAccount(Long.valueOf(1));
    // 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(1), 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(1));
    oldAccount.setName("Ben Hale");
    accountManager.update(oldAccount);
    Account newAccount = accountManager.getAccount(Long.valueOf(1));
    assertEquals("Did not persist the name change", "Ben Hale", newAccount.getName());
  }
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.