Search in sources :

Example 6 with BigDecimal

use of java.math.BigDecimal in project camel by apache.

the class BindySimpleCsvMarshallDslTest method generateModel.

public List<Map<String, Object>> generateModel() {
    Map<String, Object> modelObjects = new HashMap<String, Object>();
    Order order = new Order();
    order.setOrderNr(1);
    order.setOrderType("BUY");
    order.setClientNr("B2");
    order.setFirstName("Keira");
    order.setLastName("Knightley");
    order.setAmount(new BigDecimal("450.45").setScale(2));
    order.setInstrumentCode("ISIN");
    order.setInstrumentNumber("XX23456789");
    order.setInstrumentType("Share");
    order.setCurrency("EUR");
    Calendar calendar = new GregorianCalendar();
    calendar.set(2009, 0, 14);
    order.setOrderDate(calendar.getTime());
    calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
    // 4 hour shift
    // 17-05-2010 23:21:59 by GMT+4
    calendar.set(2010, 4, 17, 19, 21, 59);
    order.setOrderDateTime(calendar.getTime());
    modelObjects.put(order.getClass().getName(), order);
    models.add(modelObjects);
    return models;
}
Also used : Order(org.apache.camel.dataformat.bindy.model.simple.oneclass.Order) HashMap(java.util.HashMap) GregorianCalendar(java.util.GregorianCalendar) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) BigDecimal(java.math.BigDecimal)

Example 7 with BigDecimal

use of java.math.BigDecimal in project camel by apache.

the class BindySimpleCsvMarshallTest method generateModel.

public List<Map<String, Object>> generateModel() {
    Map<String, Object> modelObjects = new HashMap<String, Object>();
    Order order = new Order();
    order.setOrderNr(1);
    order.setOrderType("BUY");
    order.setClientNr("B2");
    order.setFirstName("Keira");
    order.setLastName("Knightley");
    order.setAmount(new BigDecimal("400.25"));
    order.setInstrumentCode("ISIN");
    order.setInstrumentNumber("XX23456789");
    order.setInstrumentType("Share");
    order.setCurrency("EUR");
    Calendar calendar = new GregorianCalendar();
    calendar.set(2009, 0, 14);
    order.setOrderDate(calendar.getTime());
    calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
    // 4 hour shift
    // 17-02-2011 23:21:59 by GMT+4
    calendar.set(2011, 1, 17, 19, 21, 59);
    order.setOrderDateTime(calendar.getTime());
    modelObjects.put(order.getClass().getName(), order);
    models.add(modelObjects);
    return models;
}
Also used : Order(org.apache.camel.dataformat.bindy.model.simple.oneclass.Order) HashMap(java.util.HashMap) GregorianCalendar(java.util.GregorianCalendar) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) BigDecimal(java.math.BigDecimal)

Example 8 with BigDecimal

use of java.math.BigDecimal in project camel by apache.

the class BindyImpliedTest method testMarshall.

// *************************************************************************
// TEST
// *************************************************************************
@Test
@DirtiesContext
public void testMarshall() throws Exception {
    Record rec = new Record();
    rec.setField1(123.45);
    rec.setField2(67.89);
    rec.setField3(11.24F);
    rec.setField4(33.45F);
    rec.setField5(new BigDecimal(60.52));
    rec.setField6(new BigDecimal(70.62));
    mresult.expectedBodiesReceived("1234567.89 112433.45 605270.62\r\n");
    mtemplate.sendBody(rec);
    mresult.assertIsSatisfied();
}
Also used : FixedLengthRecord(org.apache.camel.dataformat.bindy.annotation.FixedLengthRecord) BigDecimal(java.math.BigDecimal) Test(org.junit.Test) DirtiesContext(org.springframework.test.annotation.DirtiesContext)

Example 9 with BigDecimal

use of java.math.BigDecimal in project camel by apache.

the class BindySimpleFixedLengthMarshallTest method generateModel.

public List<Map<String, Object>> generateModel() {
    Map<String, Object> modelObjects = new HashMap<String, Object>();
    Order order = new Order();
    order.setOrderNr(10);
    order.setOrderType("BUY");
    order.setClientNr("A9");
    order.setFirstName("Pauline");
    order.setLastName("M");
    order.setAmount(new BigDecimal("2500.45"));
    order.setInstrumentCode("ISIN");
    order.setInstrumentNumber("XD12345678");
    order.setInstrumentType("Share");
    order.setCurrency("USD");
    Calendar calendar = new GregorianCalendar();
    calendar.set(2009, 7, 1);
    order.setOrderDate(calendar.getTime());
    modelObjects.put(order.getClass().getName(), order);
    models.add(modelObjects);
    return models;
}
Also used : HashMap(java.util.HashMap) GregorianCalendar(java.util.GregorianCalendar) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) BigDecimal(java.math.BigDecimal)

Example 10 with BigDecimal

use of java.math.BigDecimal in project camel by apache.

the class BindyCsvClassTypeAsStringTest method testUnmarshallMessage.

@Test
public void testUnmarshallMessage() throws Exception {
    String data = "1,B2,Keira,Knightley,ISIN,XX23456789,BUY,Share,400.25,EUR,14-01-2009,03-02-2010 23:21:59\r\n";
    getMockEndpoint("mock:out").expectedMessageCount(1);
    getMockEndpoint("mock:out").message(0).body().isInstanceOf(Order.class);
    template.sendBody("direct:out", data);
    assertMockEndpointsSatisfied();
    Order order = getMockEndpoint("mock:out").getReceivedExchanges().get(0).getIn().getBody(Order.class);
    assertEquals(1, order.getOrderNr());
    assertEquals("BUY", order.getOrderType());
    assertEquals("B2", order.getClientNr());
    assertEquals("Keira", order.getFirstName());
    assertEquals("Knightley", order.getLastName());
    assertEquals(new BigDecimal("400.25"), order.getAmount());
    assertEquals("ISIN", order.getInstrumentCode());
    assertEquals("XX23456789", order.getInstrumentNumber());
    assertEquals("Share", order.getInstrumentType());
    assertEquals("EUR", order.getCurrency());
    Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
    // 4 hour shift
    // 03-02-2010 23:21:59 by GMT+4
    calendar.set(2010, 1, 3, 19, 21, 59);
    calendar.set(Calendar.MILLISECOND, 0);
    assertEquals(calendar.getTime(), order.getOrderDateTime());
}
Also used : Order(org.apache.camel.dataformat.bindy.model.simple.oneclass.Order) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Aggregations

BigDecimal (java.math.BigDecimal)4643 Test (org.junit.Test)634 BigInteger (java.math.BigInteger)624 Test (org.testng.annotations.Test)573 LocalDate (org.joda.time.LocalDate)409 ArrayList (java.util.ArrayList)351 ResultSet (java.sql.ResultSet)222 Timestamp (java.sql.Timestamp)205 PreparedStatement (java.sql.PreparedStatement)201 SQLException (java.sql.SQLException)159 Invoice (org.killbill.billing.invoice.api.Invoice)148 Date (java.util.Date)146 UUID (java.util.UUID)144 MathContext (java.math.MathContext)140 DateTime (org.joda.time.DateTime)132 HashMap (java.util.HashMap)130 RoundingMode (java.math.RoundingMode)128 List (java.util.List)113 InvoiceItem (org.killbill.billing.invoice.api.InvoiceItem)104 Session (org.hibernate.Session)96