Search in sources :

Example 11 with BigDecimal

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

the class BindySimpleFixedLengthMarshallWithNoClipTest 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("A98");
    order.setFirstName("Madame de Sol");
    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 12 with BigDecimal

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

the class BindyNumberTest method testMarshall.

// *************************************************************************
// TEST
// *************************************************************************
@Test
@DirtiesContext
public void testMarshall() throws Exception {
    DataModel rec = new DataModel();
    rec.field1 = new BigDecimal(123.45);
    rec.field2 = new BigDecimal(10.00);
    rec.field3 = new BigDecimal(10.00);
    rec.field4 = new Double(10.00);
    rec.field5 = new Double(10.00);
    mresult.expectedBodiesReceived("1234510.00   1010.00   10\r\n");
    mtemplate.sendBody(rec);
    mresult.assertIsSatisfied();
}
Also used : BigDecimal(java.math.BigDecimal) Test(org.junit.Test) DirtiesContext(org.springframework.test.annotation.DirtiesContext)

Example 13 with BigDecimal

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

the class TransactionGatewayIntegrationTest method testSubmitForSettlementWithIdAndAmount.

@Test
public void testSubmitForSettlementWithIdAndAmount() throws Exception {
    assertNotNull("BraintreeGateway can't be null", this.gateway);
    final Result<Transaction> createResult = requestBody("direct://SALE", new TransactionRequest().amount(new BigDecimal("100.00")).paymentMethodNonce("fake-valid-nonce").options().submitForSettlement(false).done(), Result.class);
    assertNotNull("sale result", createResult);
    assertTrue(createResult.isSuccess());
    LOG.info("Transaction done - id={}", createResult.getTarget().getId());
    this.transactionIds.add(createResult.getTarget().getId());
    final Result<Transaction> result = requestBodyAndHeaders("direct://SUBMITFORSETTLEMENT_WITH_ID_ADN_AMOUNT", null, new BraintreeHeaderBuilder().add("id", createResult.getTarget().getId()).add("amount", new BigDecimal("100.00")).build(), Result.class);
    assertNotNull("Submit For Settlement result", result);
    LOG.debug("Transaction submitted for settlement - id={}" + result.getTarget().getId());
}
Also used : Transaction(com.braintreegateway.Transaction) TransactionRequest(com.braintreegateway.TransactionRequest) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 14 with BigDecimal

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

the class JmsBindingTest method testGetValidJmsHeaderValueWithBigDecimal.

@Test
public void testGetValidJmsHeaderValueWithBigDecimal() {
    JmsBinding binding = new JmsBinding();
    Object value = binding.getValidJMSHeaderValue("foo", new BigDecimal("123.45"));
    assertEquals("123.45", value);
}
Also used : BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 15 with BigDecimal

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

the class OperandStack method pushConstant.

/**
     * load the constant on the operand stack. 
     */
public void pushConstant(ConstantExpression expression) {
    MethodVisitor mv = controller.getMethodVisitor();
    Object value = expression.getValue();
    ClassNode origType = expression.getType().redirect();
    ClassNode type = ClassHelper.getUnwrapper(origType);
    boolean boxing = origType != type;
    boolean asPrimitive = boxing || ClassHelper.isPrimitiveType(type);
    if (value == null) {
        mv.visitInsn(ACONST_NULL);
    } else if (boxing && value instanceof Boolean) {
        // special path for boxed boolean
        Boolean bool = (Boolean) value;
        String text = bool ? "TRUE" : "FALSE";
        mv.visitFieldInsn(GETSTATIC, "java/lang/Boolean", text, "Ljava/lang/Boolean;");
        boxing = false;
        type = origType;
    } else if (asPrimitive) {
        pushPrimitiveConstant(mv, value, type);
    } else if (value instanceof BigDecimal) {
        String className = BytecodeHelper.getClassInternalName(value.getClass().getName());
        mv.visitTypeInsn(NEW, className);
        mv.visitInsn(DUP);
        mv.visitLdcInsn(value.toString());
        mv.visitMethodInsn(INVOKESPECIAL, className, "<init>", "(Ljava/lang/String;)V", false);
    } else if (value instanceof BigInteger) {
        String className = BytecodeHelper.getClassInternalName(value.getClass().getName());
        mv.visitTypeInsn(NEW, className);
        mv.visitInsn(DUP);
        mv.visitLdcInsn(value.toString());
        mv.visitMethodInsn(INVOKESPECIAL, className, "<init>", "(Ljava/lang/String;)V", false);
    } else if (value instanceof String) {
        mv.visitLdcInsn(value);
    } else {
        throw new ClassGeneratorException("Cannot generate bytecode for constant: " + value + " of type: " + type.getName());
    }
    push(type);
    if (boxing)
        box();
}
Also used : BigInteger(java.math.BigInteger) ClassGeneratorException(org.codehaus.groovy.classgen.ClassGeneratorException) BigDecimal(java.math.BigDecimal) MethodVisitor(org.objectweb.asm.MethodVisitor)

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