Package org.apache.isis.applib.value

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


        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

    }

    @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(expected, restored);
    }

    @Test
    public void testTitleOfWithPounds() {
        originalMoney = new Money(10.5, "gbp");
        assertEquals(POUND_SYMBOL + "10.50", adapter.displayTitleOf(originalMoney, (Localization) null));
    }
View Full Code Here

        assertEquals("10.50 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");
        assertEquals(new Money(22.45, "usd"), parsed);
    }
View Full Code Here

        assertEquals(new Money(22.45, "usd"), parsed);
    }

    @Test
    public void testNewUserEntryUsesPreviousCurrency() {
        originalMoney = new Money(10.5, "gbp");
        final Object parsed = adapter.parseTextEntry(originalMoney, "22.45");
        assertEquals(new Money(22.45, "gbp"), parsed);
    }
View Full Code Here

    @Test
    public void testReplacementEntryForDefaultCurrency() {
        // MoneyValueSemanticsProvider adapter = new MoneyValueSemanticsProvider(new Money(10.3, "gbp"));
        final Object parsed = adapter.parseTextEntry(originalMoney, POUND_SYMBOL + "80.90");
        assertEquals(new Money(80.90, "gbp"), parsed);
    }
View Full Code Here

        } catch (final TextEntryParseException expected) {}
    }

    @Test
    public void testNewValueDefaultsToLocalCurrency() throws Exception {
        final Money parsed = adapter.parseTextEntry(originalMoney, "3021.50");
        assertEquals(POUND_SYMBOL + "3,021.50", adapter.displayTitleOf(parsed, (Localization) null));
    }
View Full Code Here

        assertEquals(POUND_SYMBOL + "3,021.50", adapter.displayTitleOf(parsed, (Localization) null));
    }

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

    @Override
    protected Object getObjectFromResults(final Results results) {
        final double doubleValue = results.getDouble(columnName(0));
        final String currencyValue = results.getString(columnName(1));

        final Money moneyObject = new Money(doubleValue, currencyValue);

        return moneyObject;
    }
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.