Package com.volantis.styling.expressions

Examples of com.volantis.styling.expressions.StylingFunction


     *
     * @throws Exception if an error occurs
     */
    public void testCounter() throws Exception {

        StylingFunction function = getFunction();

        // =====================================================================
        //   Set Expectations
        // =====================================================================

        evaluationContextMock.expects.getCounterValue("cow")
                .returns(6).any();

        // =====================================================================
        //   Test Expectations
        // =====================================================================

        List functionArgs = new ArrayList();
        functionArgs.add(getCounterIdentifier("cow"));
        StyleValue functionValue =
                function.evaluate(evaluationContextMock,
                        "counter", functionArgs);

        assertNotNull("Function should return a value", functionValue);
        assertTrue("Function should return a StyleInteger",
                functionValue instanceof StyleInteger);
View Full Code Here


     * @throws Exception
     */
    public void testStyledCounter()
            throws Exception {

        StylingFunction function = getFunction();

        // =====================================================================
        //   Set Expectations
        // =====================================================================

        evaluationContextMock.expects.getCounterValue("hippopotamus")
                .returns(6);

        // =====================================================================
        //   Test Expectations
        // =====================================================================

        List functionArgs = new ArrayList();
        functionArgs.add(getCounterIdentifier("hippopotamus"));
        functionArgs.add(ListStyleTypeKeywords.LOWER_ALPHA);

        StyleValue functionValue =
                function.evaluate(evaluationContextMock,
                        "counter", functionArgs);

        assertNotNull("Function should return a value", functionValue);
        assertTrue("Function should return a StyleString",
                functionValue instanceof StyleString);
View Full Code Here

        // =====================================================================
        //   Test Expectations
        // =====================================================================

        StylingFunction function = new CounterFunction(formatterSelectorMock);

        List functionArgs = new ArrayList();
        functionArgs.add(getCounterIdentifier("hippopotamus"));
        functionArgs.add(ListStyleTypeKeywords.LOWER_ALPHA);

        StyleValue functionValue =
                function.evaluate(evaluationContextMock,
                        "counter", functionArgs);
        assertSame(result, functionValue);
    }
View Full Code Here

    /**
     * Ensure that the counter function works with a counter with a single
     * value.
     */
    public void testSingleValueCounter() {
        StylingFunction function = new CountersFunction();

        // =====================================================================
        //   Set Expectations
        // =====================================================================

        evaluationContextMock.expects.getCounterValues("horse")
                .returns(new int[]{8});

        // =====================================================================
        //   Test Expectations
        // =====================================================================

        List functionArgs = new ArrayList();
        functionArgs.add(getCounterIdentifier("horse"));
        functionArgs.add(STYLE_VALUE_FACTORY.getString(null, "."));
        functionArgs.add(ListStyleTypeKeywords.DECIMAL);
        StyleValue functionValue =
                function.evaluate(evaluationContextMock,
                        "counters", functionArgs);

        assertNotNull("Function should return a value", functionValue);
        assertTrue("Function should return a StyleString",
                functionValue instanceof StyleString);
View Full Code Here

    /**
     * Ensure that the counter function works with a counter with multiple
     * values.
     */
    public void testMultipleValueCounter() {
        StylingFunction function = new CountersFunction();

        // =====================================================================
        //   Set Expectations
        // ==========1===========================================================

        evaluationContextMock.expects.getCounterValues("cow")
                .returns(new int[]{1, 2, 3, 4, 5});

        // =====================================================================
        //   Test Expectations
        // =====================================================================

        List functionArgs = new ArrayList();
        functionArgs.add(getCounterIdentifier("cow"));
        functionArgs.add(STYLE_VALUE_FACTORY.getString(null, "."));
        functionArgs.add(ListStyleTypeKeywords.DECIMAL);
        StyleValue functionValue =
                function.evaluate(evaluationContextMock,
                        "counters", functionArgs);

        assertNotNull("Function should return a value", functionValue);
        assertTrue("Function should return a StyleString",
                functionValue instanceof StyleString);
View Full Code Here

        // =====================================================================
        //   Test Expectations
        // =====================================================================

        StylingFunction function = new CountersFunction(formatterSelectorMock);

        List functionArgs = new ArrayList();
        functionArgs.add(getCounterIdentifier("hippopotamus"));
        functionArgs.add(STYLE_VALUE_FACTORY.getString(null, "."));
        functionArgs.add(ListStyleTypeKeywords.LOWER_ALPHA);

        StyleValue functionValue =
                function.evaluate(evaluationContextMock,
                        "counter", functionArgs);
        StyleString expected = STYLE_VALUE_FACTORY.getString(null, "0.A.B.C");
        assertEquals(expected, functionValue);
    }
View Full Code Here

    }

    // Javadoc inherited.
    public void visit(StyleFunctionCall value, Object object) {
        String name = value.getName();
        StylingFunction function = functionResolver.resolve(name);
        if (function == null) {
            throw new IllegalStateException("Unknown function '" + name + "'");
        }

        List values = value.getArguments();
View Full Code Here

        resolvers.toArray(this.resolvers);
    }

    // Javadoc inherited.
    public StylingFunction resolve(String name) {
        StylingFunction function = null;
        for (int i = 0; i < resolvers.length; i++) {
            FunctionResolver resolver = resolvers[i];
            function = resolver.resolve(name);
            if (function != null) {
                return function;
View Full Code Here

        List arguments = Arrays.asList(new Object[] {
            STYLE_VALUE_FACTORY.getString(null, "container"),
            STYLE_VALUE_FACTORY.getInteger(null, 2),
        });

        StylingFunction function = new MCSContainerInstanceFunction();
        StyleFormatReference referenceValue = (StyleFormatReference)
                function.evaluate(evaluationContextMock, "foo", arguments);
        FormatReference reference = referenceValue.getReference();
        assertEquals("Reference", formatReferenceMock, reference);
    }
View Full Code Here

TOP

Related Classes of com.volantis.styling.expressions.StylingFunction

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.