Browse Source

Fic compatibility of hamcrest with java 6

tags/4.4-RC1
Simon Brandhof 10 years ago
parent
commit
5b06f60c16

+ 3
- 2
sonar-duplications/src/test/java/org/sonar/duplications/detector/CloneGroupMatcher.java View File

*/ */
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;

+ 2
- 3
sonar-plugin-api/src/test/java/org/sonar/api/batch/bootstrap/ProjectDefinitionTest.java View File

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

+ 1
- 1
sonar-plugin-api/src/test/java/org/sonar/api/utils/FieldUtils2Test.java View File

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 {



+ 1
- 2
sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/ProfileUnmarshallerTest.java View File

*/ */
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());

Loading…
Cancel
Save