public void testWithoutCssRenamingMap() {

    TemplateNode template =
        (TemplateNode) SharedTestUtils.getNode(SharedTestUtils.parseSoyFiles(TEST_FILE_CONTENT));

    // Before.
    assertEquals(9, template.numChildren());
    CssNode cn1 = (CssNode) template.getChild(1);
    assertEquals("AAA", cn1.getSelectorText());
    CssNode cn7 = (CssNode) template.getChild(7);
    assertEquals("$goo", cn7.getComponentNameText());
    assertEquals("BBB", cn7.getSelectorText());

    (new RenameCssVisitor(null)).exec(template);
    (new CombineConsecutiveRawTextNodesVisitor()).exec(template);

    // After.
    assertEquals(5, template.numChildren());
    RawTextNode rtn0 = (RawTextNode) template.getChild(0);
    assertEquals("<div class=\"AAA ", rtn0.getRawText());
    PrintNode pn1 = (PrintNode) template.getChild(1);
    assertEquals("$goo", pn1.getExprText());
    RawTextNode rtn2 = (RawTextNode) template.getChild(2);
    assertEquals("-AAA BBB ", rtn2.getRawText());
    PrintNode pn3 = (PrintNode) template.getChild(3);
    assertEquals("$goo", pn3.getExprText());
    RawTextNode rtn4 = (RawTextNode) template.getChild(4);
    assertEquals("-BBB\">", rtn4.getRawText());
  }
  public void testAssociateNode() {

    String message = "Some error happened.";
    Throwable cause = new Throwable();
    SoySyntaxException sse = SoySyntaxException.createCausedWithoutMetaInfo(message, cause);

    String testFileContent =
        "{namespace boo}\n"
            + "\n"
            + "/** @param goo */\n"
            + "{template name=\".foo\"}\n"
            + "  {$goo}\n"
            + "{/template}\n";
    SoyFileSetNode soyTree = SharedTestUtils.parseSoyFiles(testFileContent);
    PrintNode pn = (PrintNode) soyTree.getChild(0).getChild(0).getChild(0);

    // Before.
    assertTrue(sse.getMessage().contains(message));
    assertEquals(cause, sse.getCause());
    assertEquals("unknown", sse.getSourceLocation().getFilePath());
    assertEquals(null, sse.getTemplateName());

    SoySyntaxExceptionUtils.associateNode(sse, pn);

    // After.
    assertTrue(sse.getMessage().contains(message));
    assertEquals(cause, sse.getCause());
    assertEquals("no-path", sse.getSourceLocation().getFilePath());
    assertEquals("boo.foo", sse.getTemplateName());
  }
  public void testWithCssRenamingMap() {

    TemplateNode template =
        (TemplateNode) SharedTestUtils.getNode(SharedTestUtils.parseSoyFiles(TEST_FILE_CONTENT));

    // Before.
    assertEquals(9, template.numChildren());
    CssNode cn1 = (CssNode) template.getChild(1);
    assertEquals("AAA", cn1.getSelectorText());
    CssNode cn7 = (CssNode) template.getChild(7);
    assertEquals("$goo", cn7.getComponentNameText());
    assertEquals("BBB", cn7.getSelectorText());

    // Use a CSS renaming map that only renames 'AAA'.
    SoyCssRenamingMap cssRenamingMap =
        new SoyCssRenamingMap() {
          @Override
          public String get(String key) {
            return key.equals("AAA") ? "XXX" : null;
          }
        };

    (new RenameCssVisitor(cssRenamingMap)).exec(template);
    (new CombineConsecutiveRawTextNodesVisitor()).exec(template);

    // After.
    assertEquals(5, template.numChildren());
    RawTextNode rtn0 = (RawTextNode) template.getChild(0);
    assertEquals("<div class=\"XXX ", rtn0.getRawText());
    PrintNode pn1 = (PrintNode) template.getChild(1);
    assertEquals("$goo", pn1.getExprText());
    RawTextNode rtn2 = (RawTextNode) template.getChild(2);
    assertEquals("-XXX BBB ", rtn2.getRawText());
    PrintNode pn3 = (PrintNode) template.getChild(3);
    assertEquals("$goo", pn3.getExprText());
    RawTextNode rtn4 = (RawTextNode) template.getChild(4);
    assertEquals("-BBB\">", rtn4.getRawText());
  }