コード例 #1
0
  @Test
  public void read_duplication_with_duplicates_on_same_file() {
    DuplicationLineReader reader = duplicationLineReader(duplication(1, 2, innerDuplicate(3, 4)));

    reader.read(line1);
    reader.read(line2);
    reader.read(line3);
    reader.read(line4);

    assertThat(line1.getDuplicationList()).containsExactly(1);
    assertThat(line2.getDuplicationList()).containsExactly(1);
    assertThat(line3.getDuplicationList()).containsExactly(2);
    assertThat(line4.getDuplicationList()).containsExactly(2);
  }
コード例 #2
0
  @Test
  public void should_be_sorted_by_line_length() {
    DuplicationLineReader reader =
        duplicationLineReader(
            duplication(1, 2, innerDuplicate(3, 4)), duplication(1, 1, innerDuplicate(4, 4)));

    reader.read(line1);
    reader.read(line2);
    reader.read(line3);
    reader.read(line4);

    assertThat(line1.getDuplicationList()).containsExactly(1, 2);
    assertThat(line2.getDuplicationList()).containsExactly(2);
    assertThat(line3.getDuplicationList()).containsExactly(3);
    assertThat(line4.getDuplicationList()).containsExactly(3, 4);
  }
コード例 #3
0
  @Test
  public void read_many_duplications() {
    DuplicationLineReader reader =
        duplicationLineReader(
            duplication(1, 1, innerDuplicate(2, 2)), duplication(1, 2, innerDuplicate(3, 4)));

    reader.read(line1);
    reader.read(line2);
    reader.read(line3);
    reader.read(line4);

    assertThat(line1.getDuplicationList()).containsExactly(1, 2);
    assertThat(line2.getDuplicationList()).containsExactly(2, 3);
    assertThat(line3.getDuplicationList()).containsExactly(4);
    assertThat(line4.getDuplicationList()).containsExactly(4);
  }
コード例 #4
0
  @Test
  public void read_duplication_with_duplicates_on_other_file() {
    DuplicationLineReader reader =
        duplicationLineReader(
            duplication(
                1, 2, new InProjectDuplicate(fileComponent(1).build(), new TextBlock(3, 4))));

    reader.read(line1);
    reader.read(line2);
    reader.read(line3);
    reader.read(line4);

    assertThat(line1.getDuplicationList()).containsExactly(1);
    assertThat(line2.getDuplicationList()).containsExactly(1);
    assertThat(line3.getDuplicationList()).isEmpty();
    assertThat(line4.getDuplicationList()).isEmpty();
  }
コード例 #5
0
  @Test
  public void read_nothing() {
    DuplicationLineReader reader = new DuplicationLineReader(Collections.<Duplication>emptySet());

    reader.read(line1);

    assertThat(line1.getDuplicationList()).isEmpty();
  }
コード例 #6
0
  @Test
  public void read_duplication_with_duplicates_on_other_file_from_other_project() {
    DuplicationLineReader reader =
        duplicationLineReader(
            duplication(
                1,
                2,
                new CrossProjectDuplicate(
                    "other-component-key-from-another-project", new TextBlock(3, 4))));

    reader.read(line1);
    reader.read(line2);
    reader.read(line3);
    reader.read(line4);

    assertThat(line1.getDuplicationList()).containsExactly(1);
    assertThat(line2.getDuplicationList()).containsExactly(1);
    assertThat(line3.getDuplicationList()).isEmpty();
    assertThat(line4.getDuplicationList()).isEmpty();
  }