コード例 #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>>()));
  }