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;
}
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();
}
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());
}
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);
}
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();
}
Aggregations