Package org.stringtemplate.v4

Examples of org.stringtemplate.v4.ST$AttributeList


    }

  @Test public void testSeparatorWithTwoNullValuesInRow() throws Exception {
    STGroup group = new STGroup();
    group.defineTemplate("test", "name", "hi <name; separator=\", \">!");
    ST st = group.getInstanceOf("test");
    st.add("name", "Ter");
    st.add("name", "Tom");
    st.add("name", null);
    st.add("name", null);
    st.add("name", "Sri");
    String expected = "hi Ter, Tom, Sri!";
    String result = st.render();
    assertEquals(expected, result);
  }
View Full Code Here


  }

  @Test public void testTwoNullValues() throws Exception {
    STGroup group = new STGroup();
    group.defineTemplate("test", "name", "hi <name; null=\"x\">!");
    ST st = group.getInstanceOf("test");
    st.add("name", null);
    st.add("name", null);
    String expected = "hi xx!";
    String result = st.render();
    assertEquals(expected, result);
  }
View Full Code Here

  }

  @Test public void testNullListItemNotCountedForIteratorIndex() throws Exception {
    STGroup group = new STGroup();
    group.defineTemplate("test", "name", "<name:{n | <i>:<n>}>");
    ST st = group.getInstanceOf("test");
    st.add("name", "Ter");
    st.add("name", null);
    st.add("name", null);
    st.add("name", "Jesse");
    String expected = "1:Ter2:Jesse";
    String result = st.render();
    assertEquals(expected, result);
  }
View Full Code Here

        STGroup group = new STGroup();
        group.defineTemplate("test", "users",
            "begin\n" +
            "<users>\n" +
            "end\n");
        ST t = group.getInstanceOf("test");
        t.add("users", null);
        String expecting="begin"+newline+"end";
        String result = t.render();
        assertEquals(expecting, result);
    }
View Full Code Here

        STGroup group = new STGroup();
        group.defineTemplate("test", "users",
            "begin\n" +
            "<users:{u | name: <u>}; separator=\", \">\n" +
            "end\n");
        ST t = group.getInstanceOf("test");
        String expecting="begin"+newline+"end";
        String result = t.render();
        assertEquals(expecting, result);
    }
View Full Code Here

        STGroup group = new STGroup();
        group.defineTemplate("test", "users",
            "begin\n" +
            "<users:{u | name: <u>}; separator=\", \">\n" +
            "end\n");
        ST t = group.getInstanceOf("test");
        t.add("users", new ArrayList<Object>());
        String expecting="begin"+newline+"end";
        String result = t.render();
        assertEquals(expecting, result);
    }
View Full Code Here

    }

    @Test public void testMissingDictionaryValue() throws Exception {
        STGroup group = new STGroup();
        group.defineTemplate("test", "m", "<m.foo>");
        ST t = group.getInstanceOf("test");
        t.add("m", new HashMap<Object, Object>());
        String expecting="";
        String result = t.render();
        assertEquals(expecting, result);
    }
View Full Code Here

    }

    @Test public void testMissingDictionaryValue2() throws Exception {
        STGroup group = new STGroup();
        group.defineTemplate("test", "m", "<if(m.foo)>[<m.foo>]<endif>");
        ST t = group.getInstanceOf("test");
        t.add("m", new HashMap<Object, Object>());
        String expecting="";
        String result = t.render();
        assertEquals(expecting, result);
    }
View Full Code Here

    }

    @Test public void testMissingDictionaryValue3() throws Exception {
        STGroup group = new STGroup();
        group.defineTemplate("test", "m", "<if(m.foo)>[<m.foo>]<endif>");
        ST t = group.getInstanceOf("test");
        t.add("m", new HashMap<String, Object>() {{put("foo",null);}});
        String expecting="";
        String result = t.render();
        assertEquals(expecting, result);
    }
View Full Code Here

    }

  @Test public void TestSeparatorEmittedForEmptyIteratorValue()
    throws IOException
  {
    ST st = new ST(
      "<values:{v|<if(v)>x<endif>}; separator=\" \">"
    );
    st.add("values", new boolean[] {true, false, true});
    StringWriter sw = new StringWriter();
    st.write(new AutoIndentWriter(sw));
    String result = sw.toString();
    String expecting = "x  x";
    assertEquals(expecting, result);
  }
View Full Code Here

TOP

Related Classes of org.stringtemplate.v4.ST$AttributeList

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.