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

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


  private static final BigDecimal PRICE = new BigDecimal("1.1");
  private static final String CUSTOMER = "Martin Hrancok";

  @Override
  protected Trade expectedDomainObject() {
    Trade trade = new Trade();
    trade.setIsin(ISIN);
    trade.setQuantity(QUANTITY);
    trade.setPrice(PRICE);
    trade.setCustomer(CUSTOMER);

    return trade;
  }
View Full Code Here


import org.springframework.batch.sample.domain.trade.Trade;

public class CustomerUpdateProcessorTests {
  @Test
  public void testProcess() {
    Trade trade = new Trade();
    trade.setCustomer("testCustomerName");
    trade.setPrice(new BigDecimal("123.0"));
   
    CustomerDebitDao dao = new CustomerDebitDao() {
      @Override
      public void write(CustomerDebit customerDebit) {
        assertEquals("testCustomerName", customerDebit.getName());
View Full Code Here

  }

  @Test
  @Transactional
  public void testWrite() {
    Trade trade = new Trade();
    trade.setCustomer("testCustomer");
    trade.setIsin("5647238492");
    trade.setPrice(new BigDecimal("99.69"));
    trade.setQuantity(5);

    writer.writeTrade(trade);

    jdbcTemplate.query("SELECT * FROM TRADE WHERE ISIN = '5647238492'", new RowCallbackHandler() {
      @Override
View Full Code Here

  /**
   * @see org.springframework.batch.item.ItemReader#read()
   */
  @Override
  public Trade read() throws Exception {
    Trade t = null;

    for (FieldSet line; (line = this.delegate.read()) != null;) {
      String prefix = line.readString(0);
      if (prefix.equals("BEGIN")) {
        t = new Trade(); // Record must start with 'BEGIN'
      }
      else if (prefix.equals("INFO")) {
        Assert.notNull(t, "No 'BEGIN' was found.");
        t.setIsin(line.readString(1));
        t.setCustomer(line.readString(2));
      }
      else if (prefix.equals("AMNT")) {
        Assert.notNull(t, "No 'BEGIN' was found.");
        t.setQuantity(line.readInt(1));
        t.setPrice(line.readBigDecimal(2));
      }
      else if (prefix.equals("END")) {
        return t; // Record must end with 'END'
      }
    }
View Full Code Here

  private int count;

  @Override
  public void write(List<? extends CustomerCredit> items) throws Exception {
    for (CustomerCredit c : items) {
      Trade t = new Trade("ISIN" + count++, 100, new BigDecimal("1.50"), c.getName());
      this.dao.writeTrade(t);
    }
  }
View Full Code Here

TOP

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

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.