Package org.apache.isis.applib.value

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


        assertEquals("0.105", encoded);
    }

    @Test
    public void testParseTextEntryWithNumber() {
        final Percentage parsed = adapter.parseTextEntry(percentage, "21%", null);
        assertEquals(new Percentage(0.21f), parsed);
    }
View Full Code Here


        assertEquals(new Percentage(0.21f), parsed);
    }

    @Test
    public void testParseTextEntryWithNumberAndDecimalPoint() {
        final Percentage parsed = adapter.parseTextEntry(percentage, "21.4%", null);
        assertEquals(new Percentage(0.214f), parsed);
    }
View Full Code Here

        assertEquals(new Percentage(0.214f), parsed);
    }

    @Test
    public void testParseTextEntryWithBlank() {
        final Percentage parsed = adapter.parseTextEntry(percentage, "", null);
        assertEquals(null, parsed);
    }
View Full Code Here

    }

    @Test
    public void testRestoreFromEncodedString() {
        final Object restored = adapter.fromEncodedString("0.2134");
        assertEquals(new Percentage(0.2134f), restored);
    }
View Full Code Here

    // //////////////////////////////////////////////////////////////////

    @Override
    protected Percentage doParse(final Object context, final String text) {
        try {
            return new Percentage(new Float(format.parse(text).floatValue()));
        } catch (final ParseException e) {
            try {
                return new Percentage(asFloat(text));
            } catch (final ParseException ee) {
                throw new TextEntryParseException("Not a number " + text, ee);
            }
        }
    }
View Full Code Here

    // EncoderDecoder
    // //////////////////////////////////////////////////////////////////

    @Override
    protected String doEncode(final Object object) {
        final Percentage per = (Percentage) object;
        return String.valueOf(per.floatValue());
    }
View Full Code Here

        return String.valueOf(per.floatValue());
    }

    @Override
    protected Percentage doRestore(final String data) {
        return new Percentage(Float.valueOf(data).floatValue());
    }
View Full Code Here

    // FloatingPointValueFacet
    // //////////////////////////////////////////////////////////////////

    @Override
    public Float floatValue(final ObjectAdapter object) {
        final Percentage per = (Percentage) object.getObject();
        return new Float(per.floatValue());
    }
View Full Code Here

            }
        });

        setupSpecification(Percentage.class);

        percentage = new Percentage(0.105f);
        allowMockAdapterToReturn(percentage);

        holder = new FacetHolderImpl();

        setValue(adapter = new PercentageValueSemanticsProvider(holder, mockConfiguration, mockContext));
View Full Code Here

        assertEquals("0.105", encoded);
    }

    @Test
    public void testParseTextEntryWithNumber() {
        final Percentage parsed = adapter.parseTextEntry(percentage, "21%");
        assertEquals(new Percentage(0.21f), parsed);
    }
View Full Code Here

TOP

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

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.