use of com.dexels.navajo.document.types.Money in project navajo by Dexels.
the class TestProperty method tesMoneyParsePresentation.
@Test
public void tesMoneyParsePresentation() {
double d = 1300.50;
Money m = new Money("1.300,50");
logger.info(":: {}", m.doubleValue());
Assert.assertEquals(d, m.doubleValue(), 0.1);
}
use of com.dexels.navajo.document.types.Money in project navajo by Dexels.
the class TestProperty method tesMoneyParseTml.
@Test
public void tesMoneyParseTml() {
double d = 10.30;
Money m = new Money("10.30");
// Strange test, but does no harm
logger.info(":: {}", m.doubleValue());
Assert.assertNotSame(d, m.doubleValue());
}
use of com.dexels.navajo.document.types.Money in project navajo by Dexels.
the class TestProperty method tesNullMoneyEquals.
@Test
public void tesNullMoneyEquals() {
Money m = new Money();
Money mm = new Money();
Assert.assertEquals(m, mm);
}
use of com.dexels.navajo.document.types.Money in project navajo by Dexels.
the class TestProperty method tesMoneyProperty.
@Test
public void tesMoneyProperty() {
BaseNavajoImpl n = new BaseNavajoImpl(NavajoFactory.getInstance());
BaseMessageImpl m = new BaseMessageImpl(n, "Aap");
n.addMessage(m);
BasePropertyImpl p1 = new BasePropertyImpl(n, "Noot");
m.addProperty(p1);
p1.setType(Property.MONEY_PROPERTY);
p1.setValue("10.30");
StringWriter sw = new StringWriter();
n.write(sw);
StringReader sr = new StringReader(sw.toString());
Navajo n2 = NavajoFactory.getInstance().createNavajo(sr);
Property p2 = n2.getProperty("Aap/Noot");
Money mon = (Money) p2.getTypedValue();
logger.info("m: " + mon.toTmlString() + " :: " + mon.editingString() + " :: " + mon.toString());
Assert.assertEquals(mon.toTmlString(), "10.30");
Assert.assertEquals(mon.doubleValue(), 10.30d, 0.1);
}
use of com.dexels.navajo.document.types.Money in project navajo by Dexels.
the class GetCents method evaluate.
@Override
public final Object evaluate() throws com.dexels.navajo.expression.api.TMLExpressionException {
final Object op = this.getOperands().get(0);
if (op == null) {
return ("");
}
if (!(op instanceof Money)) {
throw new TMLExpressionException(this, "Money argument expected");
}
Money mo = (Money) op;
return MoneyToCents(mo);
}
Aggregations