/** Test method for {@link javax.money.CurrencyUnitImpl.Builder#getValidUntil()} . */ @Test public void testGetSetValidUntil() { MoneyCurrency.Builder builder = new MoneyCurrency.Builder().setValidUntil(Long.valueOf(10)); assertEquals(Long.valueOf(10), builder.getValidUntil()); builder.setValidUntil(null); assertNull(builder.getValidUntil()); }
/** * Test method for {@link javax.money.CurrencyUnitImpl.Builder#setDefaultFractionDigits(int)} and * {@link javax.money.CurrencyUnitImpl.Builder#getDefaultFractionDigits()}. */ @Test public void testGetSetDefaultFractionDigits() { MoneyCurrency.Builder builder = new MoneyCurrency.Builder().setDefaultFractionDigits(10); assertEquals(10, builder.getDefaultFractionDigits()); builder.setDefaultFractionDigits(-1); assertEquals(-1, builder.getDefaultFractionDigits()); }
/** Test method for {@link javax.money.CurrencyUnitImpl.Builder#build(boolean)}. */ @Test public void testBuildBoolean() { MoneyCurrency.Builder builder = new MoneyCurrency.Builder() .setNamespace("testBuildBoolean") .setCurrencyCode("cd") .setLegalTender(true) .setVirtual(false) .setDefaultFractionDigits(101) .setNumericCode(7) .setValidFrom(10L) .setValidUntil(100L); CurrencyUnit cu = builder.build(true); assertEquals("testBuildBoolean", cu.getNamespace()); assertEquals("cd", cu.getCurrencyCode()); assertEquals(101, cu.getDefaultFractionDigits()); assertEquals(7, cu.getNumericCode()); assertEquals(Long.valueOf(10L), cu.getValidFrom()); assertEquals(Long.valueOf(100L), cu.getValidUntil()); assertTrue(cu.isLegalTender()); assertFalse(cu.isVirtual()); CurrencyUnit cu2 = MoneyCurrency.of("testBuildBoolean", "cd"); assertTrue(cu2 != cu); builder.setValidFrom(System.currentTimeMillis()); builder.setValidUntil(null); cu = builder.build(true); cu2 = MoneyCurrency.of("testBuildBoolean", "cd"); assertTrue(cu2 == cu); }
/** * Test method for {@link javax.money.CurrencyUnitImpl.Builder#setVirtual(boolean)} and {@link * javax.money.CurrencyUnitImpl.Builder#isVirtual()}. */ @Test public void testGetSetVirtual() { MoneyCurrency.Builder builder = new MoneyCurrency.Builder().setVirtual(true); assertTrue(builder.isVirtual()); builder.setVirtual(false); assertFalse(builder.isVirtual()); }
/** * Test method for {@link javax.money.CurrencyUnitImpl.Builder#setLegalTender(boolean)} and {@link * javax.money.CurrencyUnitImpl.Builder#hasLegalTender()}. */ @Test public void testGetSetLegalTender() { MoneyCurrency.Builder builder = new MoneyCurrency.Builder().setLegalTender(true); assertTrue(builder.isLegalTender()); builder.setLegalTender(false); assertFalse(builder.isLegalTender()); }
/** * Test method for {@link javax.money.CurrencyUnitImpl.Builder#setNumericCode(int)} and {@link * javax.money.CurrencyUnitImpl.Builder#getNumericCode()}. */ @Test public void testGetSetNumericCode() { MoneyCurrency.Builder builder = new MoneyCurrency.Builder().setNumericCode(10); assertEquals(10, builder.getNumericCode()); builder.setNumericCode(-1); assertEquals(-1, builder.getNumericCode()); }
/** Test method for {@link javax.money.CurrencyUnitImpl.Builder#build()}. */ @Test public void testBuild() { MoneyCurrency.Builder builder = new MoneyCurrency.Builder() .setNamespace("ns") .setCurrencyCode("cd") .setLegalTender(true) .setVirtual(false) .setDefaultFractionDigits(101) .setNumericCode(7) .setValidFrom(10L) .setValidUntil(100L); CurrencyUnit cu = builder.build(); assertEquals("ns", cu.getNamespace()); assertEquals("cd", cu.getCurrencyCode()); assertEquals(101, cu.getDefaultFractionDigits()); assertEquals(7, cu.getNumericCode()); assertEquals(Long.valueOf(10L), cu.getValidFrom()); assertEquals(Long.valueOf(100L), cu.getValidUntil()); assertTrue(cu.isLegalTender()); assertFalse(cu.isVirtual()); }
/** Test method for {@link javax.money.CurrencyUnitImpl.Builder#isBuildable()}. */ @Test public void testIsBuildable() { MoneyCurrency.Builder builder = new MoneyCurrency.Builder(); assertFalse(builder.isBuildable()); builder.setNamespace("ns"); assertFalse(builder.isBuildable()); builder.setCurrencyCode("cd"); assertTrue(builder.isBuildable()); }
/** * Test method for {@link javax.money.CurrencyUnitImpl.Builder#setCurrencyCode(java.lang.String)} * and {@link javax.money.CurrencyUnitImpl.Builder#getCurrencyCode()} . */ @Test public void testGetSetCurrencyCode() { MoneyCurrency.Builder builder = new MoneyCurrency.Builder().setCurrencyCode("code1"); assertEquals("code1", builder.getCurrencyCode()); }
/** * Test method for {@link javax.money.CurrencyUnitImpl.Builder#setNamespace(java.lang.String)} . */ @Test public void testGetSetNamespace() { MoneyCurrency.Builder builder = new MoneyCurrency.Builder().setNamespace("ns1"); assertEquals("ns1", builder.getNamespace()); }
/** * Test method for {@link javax.money.CurrencyUnitImpl.Builder#Builder(java.lang.String, * java.lang.String)} . */ @Test public void testBuilderStringString() { MoneyCurrency.Builder builder = new MoneyCurrency.Builder("ns", "test"); assertEquals("test", builder.getCurrencyCode()); assertEquals("ns", builder.getNamespace()); }