Package org.springframework.batch.sample.domain.trade

Examples of org.springframework.batch.sample.domain.trade.CustomerCredit


  /**
   * Read all credits using the provided reader.
   */
  private List<CustomerCredit> getCredits(ItemReader<CustomerCredit> reader) throws Exception {
    CustomerCredit credit;
    List<CustomerCredit> result = new ArrayList<CustomerCredit>();
    while ((credit = reader.read()) != null) {
      result.add(credit);
    }
    return result;
View Full Code Here


   */
  @Override
  public void writeCredit(CustomerCredit customerCredit) {
    if (customerCredit.getId() == failOnFlush) {
      // try to insert one with a duplicate ID
      CustomerCredit newCredit = new CustomerCredit();
      newCredit.setId(customerCredit.getId());
      newCredit.setName(customerCredit.getName());
      newCredit.setCredit(customerCredit.getCredit());
      sessionFactory.getCurrentSession().save(newCredit);
    } else {
      sessionFactory.getCurrentSession().update(customerCredit);
    }
  }
View Full Code Here

       
        new RowMapper<CustomerCredit>(){

      @Override
      public CustomerCredit mapRow(ResultSet rs, int rowNum) throws SQLException {
        CustomerCredit customer = new CustomerCredit();
        customer.setName(rs.getString("NAME"));
        customer.setId(rs.getInt("ID"));
        customer.setCredit(rs.getBigDecimal("CREDIT"));
        return customer;
      }
     
    });
 
View Full Code Here

  public static final String NAME_COLUMN = "name";
  public static final String CREDIT_COLUMN = "credit";

  @Override
  public CustomerCredit mapRow(ResultSet rs, int rowNum) throws SQLException {
        CustomerCredit customerCredit = new CustomerCredit();

        customerCredit.setId(rs.getInt(ID_COLUMN));
        customerCredit.setName(rs.getString(NAME_COLUMN));
        customerCredit.setCredit(rs.getBigDecimal(CREDIT_COLUMN));

        return customerCredit;
  }
View Full Code Here

  public static final int NAME_COLUMN = 1;
  public static final int CREDIT_COLUMN = 2;

  @Override
  public CustomerCredit mapFieldSet(FieldSet fieldSet) {
    CustomerCredit trade = new CustomerCredit();
    trade.setId(fieldSet.readInt(ID_COLUMN));
    trade.setName(fieldSet.readString(NAME_COLUMN));
    trade.setCredit(fieldSet.readBigDecimal(CREDIT_COLUMN));

    return trade;
  }
View Full Code Here

  /**
   * Read all credits using the provided reader.
   */
  private Set<CustomerCredit> getCredits(ItemReader<CustomerCredit> reader) throws Exception {
    CustomerCredit credit;
    Set<CustomerCredit> result = new LinkedHashSet<CustomerCredit>();

    while ((credit = reader.read()) != null) {
      result.add(credit);
    }
View Full Code Here

  /**
   * Read all credits using the provided reader.
   */
  private Set<CustomerCredit> getCredits(ItemReader<CustomerCredit> reader) throws Exception {
    CustomerCredit credit;
    Set<CustomerCredit> result = new LinkedHashSet<CustomerCredit>();
    while ((credit = reader.read()) != null) {
      result.add(credit);
    }
    return result;
View Full Code Here

    writer.setCreditFilter(CREDIT_FILTER);
  }
 
  @Test
  public void testProcess() throws Exception {
    CustomerCredit credit = new CustomerCredit();
    credit.setCredit(new BigDecimal(CREDIT_FILTER));

    writer.write(Collections.singletonList(credit));

    credit.setCredit(new BigDecimal(CREDIT_FILTER + 1));

    dao.writeCredit(credit);
   
    writer.write(Collections.singletonList(credit));
  }
View Full Code Here

  private PreparedStatement ps;

  @Before
  public void setUp() throws Exception {
    ps = mock(PreparedStatement.class);
    credit = new CustomerCredit();
    credit.setId(13);
    credit.setCredit(new BigDecimal(12000));
    credit.setName("foo");
  }
View Full Code Here

   * Increases customer's credit by fixed value
   */
  @Test
  public void testProcess() throws Exception {
    final BigDecimal oldCredit = new BigDecimal("10.54");
    CustomerCredit customerCredit = new CustomerCredit();
    customerCredit.setCredit(oldCredit);
   
    assertEquals(oldCredit.add(CustomerCreditIncreaseProcessor.FIXED_AMOUNT),tested.process(customerCredit).getCredit());
  }
View Full Code Here

TOP

Related Classes of org.springframework.batch.sample.domain.trade.CustomerCredit

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.