*/ | */ | ||||
package org.sonar.duplications.detector; | package org.sonar.duplications.detector; | ||||
import org.hamcrest.CoreMatchers; | |||||
import org.hamcrest.Description; | import org.hamcrest.Description; | ||||
import org.hamcrest.Matcher; | import org.hamcrest.Matcher; | ||||
import org.hamcrest.TypeSafeMatcher; | import org.hamcrest.TypeSafeMatcher; | ||||
import org.sonar.duplications.index.CloneGroup; | import org.sonar.duplications.index.CloneGroup; | ||||
import org.sonar.duplications.index.ClonePart; | import org.sonar.duplications.index.ClonePart; | ||||
import static org.hamcrest.Matchers.hasItem; | |||||
public class CloneGroupMatcher extends TypeSafeMatcher<CloneGroup> { | public class CloneGroupMatcher extends TypeSafeMatcher<CloneGroup> { | ||||
public static Matcher<Iterable<? super CloneGroup>> hasCloneGroup(int expectedLen, ClonePart... expectedParts) { | public static Matcher<Iterable<? super CloneGroup>> hasCloneGroup(int expectedLen, ClonePart... expectedParts) { | ||||
return CoreMatchers.hasItem(new CloneGroupMatcher(expectedLen, expectedParts)); | |||||
return hasItem(new CloneGroupMatcher(expectedLen, expectedParts)); | |||||
} | } | ||||
private final int expectedLen; | private final int expectedLen; |
import java.util.List; | import java.util.List; | ||||
import java.util.Properties; | import java.util.Properties; | ||||
import org.hamcrest.CoreMatchers; | |||||
import org.junit.Test; | import org.junit.Test; | ||||
import org.sonar.api.CoreProperties; | import org.sonar.api.CoreProperties; | ||||
def.addBinaryDir(new File("target/classes")); | def.addBinaryDir(new File("target/classes")); | ||||
assertThat(def.getSourceDirs().size(), is(2)); | assertThat(def.getSourceDirs().size(), is(2)); | ||||
assertThat(def.getTestDirs().size(), CoreMatchers.is(2)); | |||||
assertThat(def.getBinaries().size(), CoreMatchers.is(1)); | |||||
assertThat(def.getTestDirs().size(), is(2)); | |||||
assertThat(def.getBinaries().size(), is(1)); | |||||
} | } | ||||
@Test | @Test |
import java.lang.reflect.Field; | import java.lang.reflect.Field; | ||||
import java.util.List; | import java.util.List; | ||||
import static org.hamcrest.Matchers.hasItem; | |||||
import static org.junit.Assert.assertThat; | import static org.junit.Assert.assertThat; | ||||
import static org.junit.matchers.JUnitMatchers.hasItem; | |||||
public class FieldUtils2Test { | public class FieldUtils2Test { | ||||
*/ | */ | ||||
package org.sonar.wsclient.unmarshallers; | package org.sonar.wsclient.unmarshallers; | ||||
import org.hamcrest.CoreMatchers; | |||||
import org.junit.Test; | import org.junit.Test; | ||||
import org.sonar.wsclient.services.Profile; | import org.sonar.wsclient.services.Profile; | ||||
Profile.Rule rule1 = profile.getRules().get(0); | Profile.Rule rule1 = profile.getRules().get(0); | ||||
assertThat(rule1.getKey(), is("com.puppycrawl.tools.checkstyle.checks.coding.InnerAssignmentCheck")); | assertThat(rule1.getKey(), is("com.puppycrawl.tools.checkstyle.checks.coding.InnerAssignmentCheck")); | ||||
assertThat(rule1.getRepository(), is("checkstyle")); | assertThat(rule1.getRepository(), is("checkstyle")); | ||||
assertThat(rule1.getInheritance(), CoreMatchers.<Object>nullValue()); | |||||
assertThat(rule1.getInheritance(), nullValue()); | |||||
assertThat(rule1.getSeverity(), is("MAJOR")); | assertThat(rule1.getSeverity(), is("MAJOR")); | ||||
assertThat(rule1.getParameters().size(), is(0)); | assertThat(rule1.getParameters().size(), is(0)); | ||||
assertThat(rule1.getParameter("foo"), nullValue()); | assertThat(rule1.getParameter("foo"), nullValue()); |