本文整理汇总了Java中javax.money.Monetary.getAmountFactory方法的典型用法代码示例。如果您正苦于以下问题:Java Monetary.getAmountFactory方法的具体用法?Java Monetary.getAmountFactory怎么用?Java Monetary.getAmountFactory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.money.Monetary
的用法示例。
在下文中一共展示了Monetary.getAmountFactory方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testQueryAmountType
import javax.money.Monetary; //导入方法依赖的package包/类
/**
* Test method for
* {@link javax.money.Monetary#getAmountFactory(javax.money.MonetaryAmountFactoryQuery)}.
*/
@Test
public void testQueryAmountType(){
MonetaryAmountFactory<?> f = Monetary
.getAmountFactory(MonetaryAmountFactoryQueryBuilder.of().setTargetType(RoundedMoney.class).build());
assertNotNull(f);
assertTrue(f.getAmountType() == RoundedMoney.class);
f = Monetary.getAmountFactory(
MonetaryAmountFactoryQueryBuilder.of().setTargetType(FastMoney.class).setPrecision(5).build());
assertNotNull(f);
assertTrue(f.getAmountType() == FastMoney.class);
f = Monetary.getAmountFactory(MonetaryAmountFactoryQueryBuilder.of().setTargetType(Money.class).build());
assertNotNull(f);
assertTrue(f.getAmountType() == Money.class);
f = Monetary.getAmountFactory(MonetaryAmountFactoryQueryBuilder.of().build());
assertNotNull(f);
assertTrue(f.getAmountType() == Monetary.getDefaultAmountType());
f = Monetary.getAmountFactory(MonetaryAmountFactoryQueryBuilder.of().build());
assertNotNull(f);
assertTrue(f.getAmountType() == Money.class);
f = Monetary.getAmountFactory(MonetaryAmountFactoryQueryBuilder.of().setPrecision(5).build());
assertNotNull(f);
f = Monetary.getAmountFactory(MonetaryAmountFactoryQueryBuilder.of().setPrecision(20).build());
assertNotNull(f);
assertTrue(f.getAmountType() == Money.class);
f = Monetary.getAmountFactory(MonetaryAmountFactoryQueryBuilder.of().setPrecision(5).build());
assertNotNull(f);
assertTrue(f.getAmountType() == Money.class);
f = Monetary.getAmountFactory(MonetaryAmountFactoryQueryBuilder.of().setPrecision(5).build());
assertNotNull(f);
assertTrue(f.getAmountType() == Money.class);
f = Monetary.getAmountFactory(MonetaryAmountFactoryQueryBuilder.of().setPrecision(5).build());
assertNotNull(f);
assertTrue(f.getAmountType() == Money.class);
f = Monetary.getAmountFactory(MonetaryAmountFactoryQueryBuilder.of().setPrecision(200).build());
assertNotNull(f);
assertTrue(f.getAmountType() == Money.class);
}
示例2: testGetAmountFactory_WithNull
import javax.money.Monetary; //导入方法依赖的package包/类
/**
* Test method for
* {@link javax.money.Monetary#getAmountFactory(javax.money.MonetaryAmountFactoryQuery)} .
*/
@Test(expectedExceptions = NullPointerException.class)
public void testGetAmountFactory_WithNull(){
Monetary.getAmountFactory((MonetaryAmountFactoryQuery) null);
}
示例3: testQueryAmountType_InvalidContext
import javax.money.Monetary; //导入方法依赖的package包/类
/**
* Test method for
* {@link javax.money.Monetary#getAmountFactory(javax.money.MonetaryAmountFactoryQuery)} .
*/
@Test(expectedExceptions = MonetaryException.class)
public void testQueryAmountType_InvalidContext(){
Monetary.getAmountFactory(
MonetaryAmountFactoryQueryBuilder.of().setTargetType(FastMoney.class).setPrecision(20).build());
}