Пример #1
0
  @Test
  public void test_equals_overriden() {
    FileHeader header1 = new FileHeader("hello", '%') {};
    FileHeader header2 = new FileHeader("hello", '%') {};

    assertTrue(header1.equals(header2));
  }
Пример #2
0
  @Test
  public void test_hashCode_overriden() {
    FileHeader header1 = new FileHeader("hello", '%') {};
    FileHeader header2 = new FileHeader("hello", '%') {};

    assertEquals(header1.hashCode(), header2.hashCode());
  }
Пример #3
0
  @Test
  public void test_getRawContent_replaces_classname() throws ContentSyntaxErrorException {
    final String headerStr = "/* constant \n" + " * %classname% */";
    FileHeader header = new FileHeader(headerStr, '%') {};

    assertEquals(
        "/* constant \n * MyClass */",
        header.getRawContent(new HashMap<String, List<String>>(), "MyClass.cs"));
  }
Пример #4
0
  @Test
  public void test_getContent_does_not_replace_id_of_alternating_part() {

    final String headerStr = "/* constant \n" + " * <description>%description%0%</description>*/";
    FileHeader header = new FileHeader(headerStr, '%') {};

    assertEquals(
        "/* constant \n * <description>%description%0%</description>*/", header.getContent());
  }
Пример #5
0
  @Test
  public void test_getRawContent_replaces_back_alternating_parts()
      throws ContentSyntaxErrorException {

    Map<String, List<String>> altData = new HashMap<String, List<String>>();
    List<String> value = new Vector<String>();
    value.add("real-value");
    altData.put("description", value);

    final String headerStr = "/* constant \n" + " * <description>%description%0%</description>*/";
    FileHeader header = new FileHeader(headerStr, '%') {};

    assertEquals(
        "/* constant \n * <description>real-value</description>*/", header.getRawContent(altData));
  }
Пример #6
0
  @Test
  public void tets_getRawContent_replaces_two_block_with_same_id_correctly()
      throws ContentSyntaxErrorException {
    Map<String, List<String>> altData = new HashMap<String, List<String>>();
    List<String> value = new Vector<String>();
    value.add("real-value");
    value.add("real-value2");
    altData.put("description", value);

    final String headerStr =
        "/* constant \n"
            + " * <description>%description%1%</description> \n"
            + " * <description>%description%0%</description> */";
    FileHeader header = new FileHeader(headerStr, '%') {};

    assertEquals(
        "/* constant \n"
            + " * <description>real-value2</description> \n"
            + " * <description>real-value</description> */",
        header.getRawContent(altData));
  }
Пример #7
0
  @Test
  public void test_getNewlinesCount() throws ContentSyntaxErrorException {
    FileHeader header1 = new FileHeader("lin1\n line2 \n adsadasd \n", '%') {};

    assertEquals(3, header1.getNewlinesCount(new Hashtable<String, List<String>>()));
  }