*/
package org.sonar.plugins.core.sensors;
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertThat;
-import static org.mockito.Matchers.argThat;
-import static org.mockito.Mockito.*;
-
import org.apache.commons.lang.StringUtils;
import org.apache.maven.project.MavenProject;
-import org.hamcrest.BaseMatcher;
-import org.hamcrest.Description;
import org.junit.Test;
+import org.mockito.ArgumentMatcher;
import org.sonar.api.batch.SensorContext;
import org.sonar.api.resources.Project;
import org.sonar.api.resources.ProjectLink;
import org.sonar.api.test.MavenTestUtils;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+import static org.mockito.Matchers.argThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyNoMoreInteractions;
+import static org.mockito.Mockito.when;
+
public class ProjectLinksSensorTest {
@Test
verify(context).deleteLink(ProjectLinksSensor.KEY_SCM_DEVELOPER_CONNECTION);
}
- private class MatchLink extends BaseMatcher<ProjectLink> {
+ private class MatchLink extends ArgumentMatcher<ProjectLink> {
private String key;
private String name;
private String url;
this.url = url;
}
+ @Override
public boolean matches(Object o) {
ProjectLink link = (ProjectLink) o;
return StringUtils.equals(link.getHref(), url) && StringUtils.equals(link.getKey(), key) && StringUtils.equals(link.getName(), name);
}
-
- public void describeTo(Description description) {
-
- }
}
}
*/
package org.sonar.plugins.core.timemachine;
-import org.hamcrest.BaseMatcher;
-import org.hamcrest.Description;
import org.junit.Test;
+import org.mockito.ArgumentMatcher;
import org.sonar.api.batch.DecoratorContext;
import org.sonar.api.measures.CoreMetrics;
import org.sonar.api.measures.Measure;
import java.util.Date;
import java.util.List;
-import static org.mockito.Mockito.*;
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Matchers.argThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
public class NewCoverageFileAnalyzerTest {
}
- static class VariationMatcher extends BaseMatcher<Measure> {
+ static class VariationMatcher extends ArgumentMatcher<Measure> {
Metric metric;
int index;
Double variation;
this.variation = variation;
}
+ @Override
public boolean matches(Object o) {
Measure m = (Measure)o;
if (m.getMetric().equals(metric)) {
}
return false;
}
-
- public void describeTo(Description description) {
-
- }
}
private AbstractNewCoverageFileAnalyzer newDecorator() throws ParseException {
*/
package org.sonar.plugins.squid.bridges;
-import org.hamcrest.BaseMatcher;
-import org.hamcrest.Description;
import org.junit.Test;
+import org.mockito.ArgumentMatcher;
import org.sonar.api.design.Dependency;
import org.sonar.api.measures.CoreMetrics;
import org.sonar.api.resources.JavaFile;
import org.sonar.api.resources.JavaPackage;
import static org.hamcrest.number.OrderingComparisons.greaterThan;
-import static org.mockito.Matchers.*;
+import static org.mockito.Matchers.anyDouble;
+import static org.mockito.Matchers.argThat;
+import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
verify(context).saveMeasure(eq(new JavaPackage("org.apache.struts.config")), eq(CoreMetrics.FILE_EDGES_WEIGHT), argThat(greaterThan(1.0)));
}
- static class DependencyMatcher extends BaseMatcher<Dependency> {
+ static class DependencyMatcher extends ArgumentMatcher<Dependency> {
private String from;
private String to;
this.to = to;
}
+ @Override
public boolean matches(Object o) {
if (!(o instanceof Dependency)) {
return false;
Dependency dep = (Dependency) o;
return from.equals(dep.getFrom().getKey()) && to.equals(dep.getTo().getKey());
}
-
- public void describeTo(Description description) {
- }
}
}
*/
package org.sonar.batch.phases;
-import org.hamcrest.BaseMatcher;
-import org.hamcrest.Description;
import org.junit.Test;
+import org.mockito.ArgumentMatcher;
import org.sonar.api.batch.BatchExtensionDictionnary;
import org.sonar.api.batch.maven.MavenPlugin;
import org.sonar.api.batch.maven.MavenPluginHandler;
import java.util.Arrays;
+import static org.mockito.Matchers.anyObject;
import static org.mockito.Matchers.argThat;
-import static org.mockito.Mockito.*;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
public class MavenPluginsConfiguratorTest {
verify(handler2).configure(eq(project), argThat(new IsMavenPlugin("myartifact2")));
}
- private class IsMavenPlugin extends BaseMatcher<MavenPlugin> {
+ private class IsMavenPlugin extends ArgumentMatcher<MavenPlugin> {
private String artifactId;
public IsMavenPlugin(String artifactId) {
this.artifactId = artifactId;
}
+ @Override
public boolean matches(Object o) {
return artifactId.equals(((MavenPlugin) o).getPlugin().getArtifactId());
}
-
- public void describeTo(Description description) {
-
- }
}
}
import org.apache.commons.lang.ObjectUtils;
import org.apache.commons.lang.StringUtils;
-import org.hamcrest.BaseMatcher;
-import org.hamcrest.Description;
+import org.mockito.ArgumentMatcher;
import org.sonar.api.resources.Resource;
-public class IsResource extends BaseMatcher<Resource> {
+public class IsResource extends ArgumentMatcher<Resource> {
private String scope;
private String qualifier;
this.key = key;
}
+ @Override
public boolean matches(Object o) {
Resource r = (Resource) o;
boolean keyMatch = (key != null) ? StringUtils.equals(r.getKey(), key) : true;
return ObjectUtils.equals(r.getScope(), scope) && ObjectUtils.equals(r.getQualifier(), qualifier) && keyMatch;
}
-
- public void describeTo(Description description) {
-
- }
-}
\ No newline at end of file
+}
import org.apache.commons.lang.ObjectUtils;
import org.apache.commons.lang.math.NumberUtils;
-import org.hamcrest.BaseMatcher;
-import org.hamcrest.Description;
+import org.mockito.ArgumentMatcher;
import org.sonar.api.measures.Measure;
import org.sonar.api.measures.Metric;
import org.sonar.api.measures.RuleMeasure;
import org.sonar.api.rules.Rule;
-public class IsRuleMeasure extends BaseMatcher<Measure> {
+public class IsRuleMeasure extends ArgumentMatcher<Measure> {
private Metric metric = null;
private Rule rule = null;
this.value = value;
}
+ @Override
public boolean matches(Object o) {
if (!(o instanceof RuleMeasure)) {
return false;
ObjectUtils.equals(rule, m.getRule()) &&
NumberUtils.compare(value, m.getValue()) == 0;
}
-
- public void describeTo(Description description) {
-
- }
}
*/
package org.sonar.api.test;
-import org.hamcrest.BaseMatcher;
-import org.hamcrest.Description;
+import org.mockito.ArgumentMatcher;
import org.sonar.api.resources.Resource;
import org.sonar.api.rules.Rule;
import org.sonar.api.rules.Violation;
-public class IsViolation extends BaseMatcher<Violation> {
+public class IsViolation extends ArgumentMatcher<Violation> {
private Rule rule;
private String message;
this.lineId = lineId;
}
+ @Override
public boolean matches(Object o) {
Violation violation = (Violation) o;
if (lineId != null && !lineId.equals(violation.getLineId())) {
return true;
}
-
- public void describeTo(Description description) {
-
- }
}
package org.sonar.server.configuration;
import com.google.common.collect.ImmutableMap;
-import org.hamcrest.BaseMatcher;
-import org.hamcrest.Description;
import org.junit.Before;
import org.junit.Test;
+import org.mockito.ArgumentMatcher;
import org.sonar.api.CoreProperties;
import org.sonar.api.database.configuration.Property;
import org.sonar.jpa.test.AbstractDbUnitTestCase;
import static org.fest.assertions.Assertions.assertThat;
import static org.mockito.Matchers.argThat;
-import static org.mockito.Mockito.*;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
public class PropertiesBackupTest extends AbstractDbUnitTestCase {
backup.importXml(config);
- verify(persistentSettings).saveProperties(argThat(new BaseMatcher<Map<String, String>>() {
+ verify(persistentSettings).saveProperties(argThat(new ArgumentMatcher<Map<String, String>>() {
+ @Override
public boolean matches(Object o) {
Map<String, String> map = (Map<String, String>) o;
return map.get("key1").equals("value1") && map.get("key2").equals("value2");
}
-
- public void describeTo(Description description) {
- }
}));
}
config.setProperties(newProperties);
backup.importXml(config);
- verify(persistentSettings).saveProperties(argThat(new BaseMatcher<Map<String, String>>() {
+ verify(persistentSettings).saveProperties(argThat(new ArgumentMatcher<Map<String, String>>() {
+ @Override
public boolean matches(Object o) {
Map<String, String> map = (Map<String, String>) o;
return map.get(CoreProperties.SERVER_ID).equals("111");
}
-
- public void describeTo(Description description) {
- }
}));
}
}
import com.google.common.collect.ImmutableMap;
import org.apache.commons.configuration.PropertiesConfiguration;
-import org.hamcrest.BaseMatcher;
-import org.hamcrest.Description;
import org.junit.Before;
import org.junit.Test;
+import org.mockito.ArgumentMatcher;
import org.sonar.api.config.PropertyDefinitions;
import org.sonar.core.properties.PropertiesDao;
import org.sonar.core.properties.PropertyDto;
import static org.fest.assertions.Assertions.assertThat;
import static org.mockito.Matchers.argThat;
-import static org.mockito.Mockito.*;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
public class PersistentSettingsTest {
// kept in memory cache and persisted in db
assertThat(settings.getString("foo")).isEqualTo("bar");
- verify(dao).setProperty(argThat(new BaseMatcher<PropertyDto>() {
+ verify(dao).setProperty(argThat(new ArgumentMatcher<PropertyDto>() {
+ @Override
public boolean matches(Object o) {
PropertyDto dto = (PropertyDto) o;
return dto.getKey().equals("foo");
}
-
- public void describeTo(Description description) {
- }
}));
}
*/
package org.sonar.server.platform;
-import org.hamcrest.BaseMatcher;
-import org.hamcrest.Description;
import org.junit.Test;
+import org.mockito.ArgumentMatcher;
import org.sonar.api.config.GlobalPropertyChangeHandler;
import static org.fest.assertions.Assertions.assertThat;
notifier.onGlobalPropertyChange("foo", "bar");
- verify(handler).onChange(argThat(new BaseMatcher<GlobalPropertyChangeHandler.PropertyChange>() {
+ verify(handler).onChange(argThat(new ArgumentMatcher<GlobalPropertyChangeHandler.PropertyChange>() {
+ @Override
public boolean matches(Object o) {
GlobalPropertyChangeHandler.PropertyChange change = (GlobalPropertyChangeHandler.PropertyChange) o;
return change.getKey().equals("foo") && change.getNewValue().equals("bar");
}
-
- public void describeTo(Description description) {
- }
}));
}
*/
package org.sonar.server.startup;
-import org.hamcrest.BaseMatcher;
-import org.hamcrest.Description;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.mockito.ArgumentMatcher;
import org.sonar.api.CoreProperties;
import org.sonar.api.platform.Server;
import org.sonar.server.platform.PersistentSettings;
import java.util.TimeZone;
import static org.mockito.Matchers.argThat;
-import static org.mockito.Mockito.*;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
public class ServerMetadataPersisterTest {
ServerMetadataPersister persister = new ServerMetadataPersister(server, persistentSettings);
persister.start();
- verify(persistentSettings).saveProperties(argThat(new BaseMatcher<Map<String, String>>() {
+ verify(persistentSettings).saveProperties(argThat(new ArgumentMatcher<Map<String, String>>() {
+ @Override
public boolean matches(Object o) {
Map<String, String> map = (Map<String, String>) o;
return map.get(CoreProperties.SERVER_ID).equals("123")
&& map.get(CoreProperties.SERVER_STARTTIME).equals("2010-05-18T17:59:00+0000")
&& map.size() == 3;
}
-
- public void describeTo(Description description) {
- }
}));
}
-
}
*/
package org.sonar.server.startup;
-import org.hamcrest.BaseMatcher;
-import org.hamcrest.Description;
import org.junit.Test;
+import org.mockito.ArgumentMatcher;
import org.sonar.api.config.Settings;
import org.sonar.server.platform.PersistentSettings;
import java.util.Map;
+import static org.mockito.Matchers.any;
import static org.mockito.Matchers.argThat;
-import static org.mockito.Mockito.*;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
public class SetDefaultProjectPermissionsTest {
@Test
new SetDefaultProjectPermissions(persistentSettings).start();
- verify(persistentSettings).saveProperties(argThat(new BaseMatcher<Map<String, String>>() {
+ verify(persistentSettings).saveProperties(argThat(new ArgumentMatcher<Map<String, String>>() {
+ @Override
public boolean matches(Object o) {
Map<String, String> map = (Map<String, String>) o;
return map.size() == 9 && map.get("sonar.role.admin.TRK.defaultGroups").equals("sonar-administrators");
}
-
- public void describeTo(Description description) {
- }
}));
}