Examples of XhtmlTemplate


Examples of org.pirkaengine.core.template.XhtmlTemplate

        Assert.assertEquals(expectedItem, template.createArrayItemModel("items"));
    }

    @Test
    public void createViewModel_array_with_obj() {
        XhtmlTemplate template = new XhtmlTemplate("test");
        StartTagNode start = new StartTagNode("li", "prk:for", "item in items");
        EndTagNode end = new EndTagNode("li");
        ExpressionNode node = new ExpressionNode("item.name");
        template.stack(new LoopNode(start, end, new Node[] { node }));

        Map<String, Object> expected = new HashMap<String, Object>();
        expected.put("items", new ArrayList<Map<String, Object>>());
        Assert.assertEquals(expected, template.createViewModel());

        Map<String, Object> expectedItem = new HashMap<String, Object>();
        expectedItem.put("name", XhtmlTemplate.NULL_VALUE);
        Assert.assertEquals(expectedItem, template.createArrayItemModel("items"));
    }
View Full Code Here

Examples of org.pirkaengine.core.template.XhtmlTemplate

        Assert.assertEquals(expectedItem, template.createArrayItemModel("items"));
    }

    @Test
    public void createViewModel() {
        XhtmlTemplate template = new XhtmlTemplate("test");
        StartTagNode start = new StartTagNode("li", "prk:for", "item in items");
        EndTagNode end = new EndTagNode("li");
        ExpressionNode node1 = new ExpressionNode("item.name");
        ExpressionNode node2 = new ExpressionNode("item.price");
        template.stack(new LoopNode(start, end, new Node[] { node1, node2 }));
        template.stack(new ExpressionNode("foo.bar"));
        template.stack(new ExpressionNode("poo"));

        Map<String, Object> expected = new HashMap<String, Object>();
        expected.put("items", new ArrayList<Map<String, Object>>());
        Map<String, Object> foo = new HashMap<String, Object>();
        foo.put("bar", XhtmlTemplate.NULL_VALUE);
        expected.put("foo", foo);
        expected.put("poo", XhtmlTemplate.NULL_VALUE);
        Assert.assertEquals(expected, template.createViewModel());

        Map<String, Object> expectedItem = new HashMap<String, Object>();
        expectedItem.put("name", XhtmlTemplate.NULL_VALUE);
        expectedItem.put("price", XhtmlTemplate.NULL_VALUE);
        Assert.assertEquals(expectedItem, template.createArrayItemModel("items"));
    }
View Full Code Here

Examples of org.pirkaengine.core.template.XhtmlTemplate

        Assert.assertEquals(expectedItem, template.createArrayItemModel("items"));
    }

    @Test
    public void createViewModel_condition() {
        XhtmlTemplate template = new XhtmlTemplate("test");
        StartTagNode start = new StartTagNode("div", "prk:if", "cond");
        EndTagNode end = new EndTagNode("div");
        template.stack(new ConditionNode(start, end, new Node[] {}));
        Map<String, Object> expected = new HashMap<String, Object>();
        expected.put("cond", XhtmlTemplate.NULL_VALUE);
        Assert.assertEquals(expected, template.createViewModel());
    }
View Full Code Here

Examples of org.pirkaengine.core.template.XhtmlTemplate

        Assert.assertEquals(expected, template.createViewModel());
    }

    @Test
    public void createViewModel_condition_with_expression() {
        XhtmlTemplate template = new XhtmlTemplate("test");
        StartTagNode start = new StartTagNode("div", "prk:if", "cond");
        EndTagNode end = new EndTagNode("div");
        ExpressionNode node = new ExpressionNode("name");
        template.stack(new ConditionNode(start, end, new Node[] { node }));
        Map<String, Object> expected = new HashMap<String, Object>();
        expected.put("cond", XhtmlTemplate.NULL_VALUE);
        expected.put("name", XhtmlTemplate.NULL_VALUE);
        Assert.assertEquals(expected, template.createViewModel());
    }
View Full Code Here

Examples of org.pirkaengine.core.template.XhtmlTemplate

        Assert.assertEquals(expected, template.createViewModel());
    }

    @Test
    public void createViewModel_repeat() {
        XhtmlTemplate template = new XhtmlTemplate("test");
        StartTagNode start = new StartTagNode("span", "prk:repeat", "count");
        EndTagNode end = new EndTagNode("span");
        template.stack(new RepeatNode(start, end, new Node[] {}));
        Map<String, Object> expected = new HashMap<String, Object>();
        expected.put("count", XhtmlTemplate.NULL_VALUE);
        Assert.assertEquals(expected, template.createViewModel());
    }
View Full Code Here

Examples of org.pirkaengine.core.template.XhtmlTemplate

        Assert.assertEquals(expected, template.createViewModel());
    }

    @Test(expected = KeyNotContainsException.class)
    public void createViewModel_KeyNotContains() {
        XhtmlTemplate template = new XhtmlTemplate("test");
        template.createArrayItemModel("hoge");
    }
View Full Code Here

Examples of org.pirkaengine.core.template.XhtmlTemplate

    }

    @Test
    public void serializeAndDeserialize_simple() throws SerializeException {
        String templateName = "simple";
        XhtmlTemplate template = new XhtmlTemplate(templateName);
        template.stack(new TextNode("<html><body></body></html>"));
        target.serialize(template);
        Template result = target.deserialize(template.getName());
        assertEquals(template, result);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.