diff options
author | Evgeny Mandrikov <mandrikov@gmail.com> | 2012-02-12 20:44:41 +0400 |
---|---|---|
committer | Evgeny Mandrikov <mandrikov@gmail.com> | 2012-02-13 11:42:13 +0400 |
commit | e0589ad21f8cb45b38c9879a44f73ad6aafeb618 (patch) | |
tree | f890ab74bdb8b930b944edcf83ec5ba1c9568ac8 /sonar-duplications/src/test/java/org/sonar/duplications/detector | |
parent | c2cb97c242b64f0815d01ed5fa193fffadc97bca (diff) | |
download | sonarqube-e0589ad21f8cb45b38c9879a44f73ad6aafeb618.tar.gz sonarqube-e0589ad21f8cb45b38c9879a44f73ad6aafeb618.zip |
Remove deprecated and unused code
Diffstat (limited to 'sonar-duplications/src/test/java/org/sonar/duplications/detector')
2 files changed, 28 insertions, 21 deletions
diff --git a/sonar-duplications/src/test/java/org/sonar/duplications/detector/DetectorTestCase.java b/sonar-duplications/src/test/java/org/sonar/duplications/detector/DetectorTestCase.java index 3ce2f6a70f9..7a216b12c95 100644 --- a/sonar-duplications/src/test/java/org/sonar/duplications/detector/DetectorTestCase.java +++ b/sonar-duplications/src/test/java/org/sonar/duplications/detector/DetectorTestCase.java @@ -19,18 +19,7 @@ */ package org.sonar.duplications.detector; -import static org.hamcrest.Matchers.hasItem; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.sameInstance; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoMoreInteractions; -import static org.sonar.duplications.detector.CloneGroupMatcher.hasCloneGroup; - -import java.util.*; - +import com.google.common.collect.Lists; import org.junit.Rule; import org.junit.Test; import org.sonar.duplications.block.Block; @@ -41,7 +30,13 @@ import org.sonar.duplications.index.ClonePart; import org.sonar.duplications.index.MemoryCloneIndex; import org.sonar.duplications.junit.TestNamePrinter; -import com.google.common.collect.Lists; +import java.util.*; + +import static org.hamcrest.Matchers.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThat; +import static org.mockito.Mockito.*; +import static org.sonar.duplications.detector.CloneGroupMatcher.hasCloneGroup; public abstract class DetectorTestCase { @@ -55,7 +50,12 @@ public abstract class DetectorTestCase { * so we can simply use index and hash. */ protected static Block newBlock(String resourceId, ByteArray hash, int index) { - return new Block(resourceId, hash, index, index, index + LINES_PER_BLOCK); + return Block.builder() + .setResourceId(resourceId) + .setBlockHash(hash) + .setIndexInFile(index) + .setLines(index, index + LINES_PER_BLOCK) + .build(); } protected static ClonePart newClonePart(String resourceId, int unitStart, int cloneUnitLength) { @@ -390,10 +390,13 @@ public abstract class DetectorTestCase { @Test public void same_lines_but_different_indexes() { CloneIndex cloneIndex = createIndex(); + Block.Builder block = Block.builder() + .setResourceId("a") + .setLines(0, 1); List<Block> fileBlocks = Arrays.asList( - new Block("a", new ByteArray("1".getBytes()), 0, 0, 1), - new Block("a", new ByteArray("2".getBytes()), 1, 0, 1), - new Block("a", new ByteArray("1".getBytes()), 2, 0, 1)); + block.setBlockHash(new ByteArray("1".getBytes())).setIndexInFile(0).build(), + block.setBlockHash(new ByteArray("2".getBytes())).setIndexInFile(1).build(), + block.setBlockHash(new ByteArray("1".getBytes())).setIndexInFile(2).build()); List<CloneGroup> clones = detect(cloneIndex, fileBlocks); print(clones); diff --git a/sonar-duplications/src/test/java/org/sonar/duplications/detector/original/BlocksGroupTest.java b/sonar-duplications/src/test/java/org/sonar/duplications/detector/original/BlocksGroupTest.java index 536456c7a2d..e2476d41146 100644 --- a/sonar-duplications/src/test/java/org/sonar/duplications/detector/original/BlocksGroupTest.java +++ b/sonar-duplications/src/test/java/org/sonar/duplications/detector/original/BlocksGroupTest.java @@ -19,19 +19,23 @@ */ package org.sonar.duplications.detector.original; -import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertThat; - import org.junit.Test; import org.sonar.duplications.block.Block; +import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertThat; + public class BlocksGroupTest { /** * {@link BlocksGroup} uses only resourceId and index from block, thus we can simplify testing. */ private static Block newBlock(String resourceId, int indexInFile) { - return new Block(resourceId, null, indexInFile, indexInFile, indexInFile); + return Block.builder() + .setResourceId(resourceId) + .setIndexInFile(indexInFile) + .setLines(indexInFile, indexInFile) + .build(); } public static BlocksGroup newBlocksGroup(Block... blocks) { |