Package org.apache.isis.applib.value

Examples of org.apache.isis.applib.value.Money


    private FacetHolder holder;

    @Before
    public void setUpObjects() throws Exception {
        Locale.setDefault(new Locale("pl", "PL"));
        originalMoney = new Money(10.50, "pln");
        holder = new FacetHolderImpl();
        setValue(adapter = new MoneyValueSemanticsProvider(holder, mockConfiguration, mockContext));
    }
View Full Code Here


        holder = new FacetHolderImpl();
        setValue(adapter = new MoneyValueSemanticsProvider(holder, mockConfiguration, mockContext));
    }

    private Money createMoney(final double amount, final String currency) {
        return new Money(amount, currency);
    }
View Full Code Here

    }

    @Test
    public void testDecoding() {
        final Object restored = adapter.fromEncodedString("23.77 FFR");
        final Money expected = new Money(23.77, "FFR");
        assertEquals(expected, restored);
    }
View Full Code Here

        assertEquals("10,5 UNK", adapter.displayTitleOf(createMoney(10.50, "UNK"), (Localization) null));
    }

    @Test
    public void testUserEntryWithCurrency() {
        final Money money = createMoney(10.5, "gbp");
        final Money parsed = adapter.parseTextEntry(money, "22,45 USD", null);
        assertEquals(new Money(22.45, "usd"), parsed);
    }
View Full Code Here

    }

    @Test
    public void testUserEntryUsesPreviousCurrency() {
        final Object parsed = adapter.parseTextEntry(originalMoney, "22,45", null);
        assertEquals(new Money(22.45, "pln"), parsed);
    }
View Full Code Here

    }

    @Test
    public void testReplacementEntryForDefaultCurrency() {
        final Object parsed = adapter.parseTextEntry(originalMoney, "80,90 " + ZLOTYCH_SYMBOL, null);
        assertEquals(new Money(80.90, "pln"), parsed);
    }
View Full Code Here

        }
    }

    @Test
    public void testNewValueDefaultsToLocalCurrency() throws Exception {
        final Money parsed = adapter.parseTextEntry(originalMoney, "3021,50", null);
        assertEquals("3" + CURRENCY_SPACE + "021,5 " + ZLOTYCH_SYMBOL, adapter.displayTitleOf(parsed, (Localization) null));
    }
View Full Code Here

        assertEquals("3" + CURRENCY_SPACE + "021,5 " + ZLOTYCH_SYMBOL, adapter.displayTitleOf(parsed, (Localization) null));
    }

    @Test
    public void testUnrelatedCurrencySymbolIsRejected() throws Exception {
        final Money money = createMoney(1, "eur");
        try {
            adapter.parseTextEntry(money, "$3021.50", null);
            fail("invalid code accepted " + adapter);
        } catch (final TextEntryParseException expected) {
        }
View Full Code Here

        holder = new FacetHolderImpl();
        setValue(adapter = new MoneyValueSemanticsProvider(holder, mockConfiguration, mockContext));
    }

    private Money createMoney(final double amount, final String currency) {
        return new Money(amount, currency);
    }
View Full Code Here

        assertEquals(Locale.UK, Locale.getDefault());
    }

    @Test
    public void testEncoding() {
        originalMoney = new Money(10.5, "gbp");
        final String data = adapter.toEncodedString(originalMoney);
        assertEquals("10.5 GBP", data);
    }
View Full Code Here

TOP

Related Classes of org.apache.isis.applib.value.Money

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.