Package org.sonar.duplications.index

Examples of org.sonar.duplications.index.CloneIndex


   * </pre>
   * Expected: one clone with two parts, which contain exactly the same lines
   */
  @Test
  public void same_lines_but_different_indexes() {
    CloneIndex cloneIndex = createIndex();
    Block.Builder block = Block.builder()
      .setResourceId("a")
      .setLines(0, 1);
    Block[] fileBlocks = new Block[]{
      block.setBlockHash(new ByteArray("1".getBytes())).setIndexInFile(0).build(),
View Full Code Here


    }
    return result.toArray(new Block[result.size()]);
  }

  protected static CloneIndex createIndex(Block[]... blocks) {
    CloneIndex cloneIndex = new MemoryCloneIndex();
    for (Block[] b : blocks) {
      for (Block block : b) {
        cloneIndex.insert(block);
      }
    }
    return cloneIndex;
  }
View Full Code Here

   * Given: file without duplications
   * Expected: {@link Collections#EMPTY_LIST} (no need to construct suffix-tree)
   */
  @Test
  public void noDuplications() {
    CloneIndex index = createIndex();
    Block[] fileBlocks = newBlocks("a", "1 2 3");
    List<CloneGroup> result = detect(index, fileBlocks);
    assertThat(result, sameInstance(Collections.EMPTY_LIST));
  }
View Full Code Here

   * But such cases nearly never appear in real-world, so current implementation is acceptable for the moment.
   * </p>
   */
  @Test
  public void huge() {
    CloneIndex index = createIndex();
    Block[] fileBlocks = new Block[5000];
    for (int i = 0; i < 5000; i++) {
      fileBlocks[i] = newBlock("x", new ByteArray("01"), i);
    }
    List<CloneGroup> result = detect(index, fileBlocks);
View Full Code Here

   * <pre>
   * TODO Godin: however would be better to receive only (2)
   */
  @Test
  public void myTest() {
    CloneIndex index = createIndex();
    Block[] fileBlocks = newBlocks("x", "a 2 b 2 c 2 2 2");
    List<CloneGroup> result = detect(index, fileBlocks);

    print(result);
    assertEquals(2, result.size());
View Full Code Here

   * <pre>
   * TODO Godin: however would be better to receive only (2 3)
   */
  @Test
  public void myTest2() {
    CloneIndex index = createIndex();
    Block[] fileBlocks = newBlocks("x", "a 2 3 b 2 3 c 2 3 d 2 3 2 3 2 3");
    List<CloneGroup> result = detect(index, fileBlocks);

    print(result);
    assertEquals(2, result.size());
View Full Code Here

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