Package org.sonar.duplications.index

Examples of org.sonar.duplications.index.CloneIndex


   * x-y-z (3 4)
   * </pre>
   */
  @Test
  public void exampleFromPaper() {
    CloneIndex index = createIndex(
      newBlocks("y", "2 3 4 5"),
      newBlocks("z", "3 4"));
    Block[] fileBlocks = newBlocks("x", "1 2 3 4 5 6");
    List<CloneGroup> result = detect(index, fileBlocks);

View Full Code Here


   * c-a-b (3 4)
   * </pre>
   */
  @Test
  public void exampleFromPaperWithModifiedResourceIds() {
    CloneIndex cloneIndex = createIndex(
      newBlocks("a", "2 3 4 5"),
      newBlocks("b", "3 4"));
    Block[] fileBlocks = newBlocks("c", "1 2 3 4 5 6");
    List<CloneGroup> clones = detect(cloneIndex, fileBlocks);

View Full Code Here

   * a-c (5 6 7)
   * </pre>
   */
  @Test
  public void example1() {
    CloneIndex index = createIndex(
      newBlocks("b", "3 4 5 6"),
      newBlocks("c", "5 6 7"));
    Block[] fileBlocks = newBlocks("a", "1 2 3 4 5 6 7 8 9");
    List<CloneGroup> result = detect(index, fileBlocks);

View Full Code Here

   * a-b-b-b-c (1 2 3)
   * </pre>
   */
  @Test
  public void example2() {
    CloneIndex index = createIndex(
      newBlocks("b", "1 2 3 4 1 2 3 4 1 2 3 4"),
      newBlocks("c", "1 2 3 4"));
    Block[] fileBlocks = newBlocks("a", "1 2 3 5");
    List<CloneGroup> result = detect(index, fileBlocks);

View Full Code Here

   * a-a (1 2)
   * </pre>
   */
  @Test
  public void clonesInFileItself() {
    CloneIndex index = createIndex();
    Block[] fileBlocks = newBlocks("a", "1 2 3 1 2 4");
    List<CloneGroup> result = detect(index, fileBlocks);

    print(result);
    assertThat(result.size(), is(1));
View Full Code Here

   * </pre>
   * "a-a-b-b (1)" should not be reported, because fully covered by "a-b (1 2 1)"
   */
  @Test
  public void covered() {
    CloneIndex index = createIndex(
      newBlocks("b", "1 2 1 2"));
    Block[] fileBlocks = newBlocks("a", "1 2 1");
    List<CloneGroup> result = detect(index, fileBlocks);

    print(result);
View Full Code Here

   * a-b (1 2 1 2 1 2)
   * </pre>
   */
  @Test
  public void problemWithNestedCloneGroups() {
    CloneIndex index = createIndex(
      newBlocks("b", "1 2 1 2 1 2 1"));
    Block[] fileBlocks = newBlocks("a", "1 2 1 2 1 2");
    List<CloneGroup> result = detect(index, fileBlocks);

    print(result);
View Full Code Here

   * a-b (1 2) - instead of "a-a-b", which will be the case if file from index not ignored
   * </pre>
   */
  @Test
  public void fileAlreadyInIndex() {
    CloneIndex index = createIndex(
      newBlocks("a", "1 2 3"),
      newBlocks("b", "1 2 4"));
    // Note about blocks with hashes "3", "4" and "5": those blocks here in order to not face another problem - with EOF (see separate test)
    Block[] fileBlocks = newBlocks("a", "1 2 5");
    List<CloneGroup> result = detect(index, fileBlocks);
View Full Code Here

   * Given: file with repeated hashes
   * Expected: only one query of index for each unique hash
   */
  @Test
  public void only_one_query_of_index_for_each_unique_hash() {
    CloneIndex index = spy(createIndex());
    Block[] fileBlocks = newBlocks("a", "1 2 1 2");
    detect(index, fileBlocks);

    verify(index).getBySequenceHash(new ByteArray("01"));
    verify(index).getBySequenceHash(new ByteArray("02"));
View Full Code Here

   * a-b (1 2 3)
   * </pre>
   */
  @Test
  public void problemWithEndOfFile() {
    CloneIndex cloneIndex = createIndex(
      newBlocks("b", "1 2 3 4"));
    Block[] fileBlocks =
      newBlocks("a", "1 2 3");
    List<CloneGroup> clones = detect(cloneIndex, fileBlocks);

View Full Code Here

TOP

Related Classes of org.sonar.duplications.index.CloneIndex

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.