aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api/src
diff options
context:
space:
mode:
Diffstat (limited to 'sonar-plugin-api/src')
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/batch/bootstrap/ProjectReactorTest.java7
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/config/AesCipherTest.java38
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/config/EncryptionTest.java23
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/measures/CountDistributionBuilderTest.java47
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/measures/MeasureUtilsTest.java88
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/measures/PersistenceModeTest.java16
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/measures/PropertiesBuilderTest.java57
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/profiles/AnnotationProfileParserTest.java21
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/resources/QualifiersTest.java35
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/resources/ResourceTypeTreeTest.java51
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/resources/ScopesTest.java57
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/utils/AnnotationUtilsTest.java18
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/utils/LocalizedMessagesTest.java32
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/utils/ParsingUtilsTest.java21
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/utils/WildcardPatternTest.java163
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/web/AbstractRubyTemplateTest.java17
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/web/DashboardTest.java38
17 files changed, 346 insertions, 383 deletions
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/batch/bootstrap/ProjectReactorTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/batch/bootstrap/ProjectReactorTest.java
index 59dc089097e..f53b24b6368 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/batch/bootstrap/ProjectReactorTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/batch/bootstrap/ProjectReactorTest.java
@@ -21,8 +21,7 @@ package org.sonar.api.batch.bootstrap;
import org.junit.Test;
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertThat;
+import static org.assertj.core.api.Assertions.assertThat;
public class ProjectReactorTest {
@@ -33,8 +32,8 @@ public class ProjectReactorTest {
root.addSubProject(child);
ProjectReactor reactor = new ProjectReactor(root);
- assertThat(reactor.getProjects().size(), is(2));
- assertThat(reactor.getRoot(), is(root));
+ assertThat(reactor.getProjects()).hasSize(2);
+ assertThat(reactor.getRoot()).isSameAs(root);
}
@Test(expected = IllegalArgumentException.class)
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/config/AesCipherTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/config/AesCipherTest.java
index 0c88bcbe30b..7af64f93cbc 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/config/AesCipherTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/config/AesCipherTest.java
@@ -21,7 +21,6 @@ package org.sonar.api.config;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang.StringUtils;
-import org.hamcrest.Matchers;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
@@ -33,10 +32,7 @@ import java.net.URL;
import java.security.InvalidKeyException;
import java.security.Key;
-import static org.hamcrest.Matchers.greaterThan;
-import static org.hamcrest.Matchers.instanceOf;
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertThat;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.fail;
public class AesCipherTest {
@@ -50,8 +46,8 @@ public class AesCipherTest {
String key = cipher.generateRandomSecretKey();
- assertThat(StringUtils.isNotBlank(key), is(true));
- assertThat(Base64.isArrayByteBase64(key.getBytes()), is(true));
+ assertThat(StringUtils.isNotBlank(key)).isTrue();
+ assertThat(Base64.isArrayByteBase64(key.getBytes())).isTrue();
}
@Test
@@ -60,8 +56,8 @@ public class AesCipherTest {
String encryptedText = cipher.encrypt("this is a secret");
- assertThat(StringUtils.isNotBlank(encryptedText), is(true));
- assertThat(Base64.isArrayByteBase64(encryptedText.getBytes()), is(true));
+ assertThat(StringUtils.isNotBlank(encryptedText)).isTrue();
+ assertThat(Base64.isArrayByteBase64(encryptedText.getBytes())).isTrue();
}
@Test
@@ -82,7 +78,7 @@ public class AesCipherTest {
// the following value has been encrypted with the key /org/sonar/api/config/AesCipherTest/aes_secret_key.txt
String clearText = cipher.decrypt("9mx5Zq4JVyjeChTcVjEide4kWCwusFl7P2dSVXtg9IY=");
- assertThat(clearText, is("this is a secret"));
+ assertThat(clearText).isEqualTo("this is a secret");
}
@Test
@@ -95,7 +91,7 @@ public class AesCipherTest {
fail();
} catch (RuntimeException e) {
- assertThat(e.getCause(), instanceOf(InvalidKeyException.class));
+ assertThat(e.getCause()).isInstanceOf(InvalidKeyException.class);
}
}
@@ -110,7 +106,7 @@ public class AesCipherTest {
fail();
} catch (RuntimeException e) {
- assertThat(e.getCause(), instanceOf(BadPaddingException.class));
+ assertThat(e.getCause()).isInstanceOf(BadPaddingException.class);
}
}
@@ -118,7 +114,7 @@ public class AesCipherTest {
public void encryptThenDecrypt() throws Exception {
AesCipher cipher = new AesCipher(pathToSecretKey());
- assertThat(cipher.decrypt(cipher.encrypt("foo")), is("foo"));
+ assertThat(cipher.decrypt(cipher.encrypt("foo"))).isEqualTo("foo");
}
@Test
@@ -127,16 +123,16 @@ public class AesCipherTest {
String path = cipher.getPathToSecretKey();
- assertThat(StringUtils.isNotBlank(path), is(true));
- assertThat(new File(path).getName(), is("sonar-secret.txt"));
+ assertThat(StringUtils.isNotBlank(path)).isTrue();
+ assertThat(new File(path).getName()).isEqualTo("sonar-secret.txt");
}
@Test
public void loadSecretKeyFromFile() throws Exception {
AesCipher cipher = new AesCipher(null);
Key secretKey = cipher.loadSecretFileFromFile(pathToSecretKey());
- assertThat(secretKey.getAlgorithm(), is("AES"));
- assertThat(secretKey.getEncoded().length, greaterThan(10));
+ assertThat(secretKey.getAlgorithm()).isEqualTo("AES");
+ assertThat(secretKey.getEncoded().length).isGreaterThan(10);
}
@Test
@@ -147,8 +143,8 @@ public class AesCipherTest {
Key secretKey = cipher.loadSecretFileFromFile(path);
- assertThat(secretKey.getAlgorithm(), is("AES"));
- assertThat(secretKey.getEncoded().length, greaterThan(10));
+ assertThat(secretKey.getAlgorithm()).isEqualTo("AES");
+ assertThat(secretKey.getEncoded().length).isGreaterThan(10);
}
@Test
@@ -171,14 +167,14 @@ public class AesCipherTest {
public void hasSecretKey() throws Exception {
AesCipher cipher = new AesCipher(pathToSecretKey());
- assertThat(cipher.hasSecretKey(), Matchers.is(true));
+ assertThat(cipher.hasSecretKey()).isTrue();
}
@Test
public void doesNotHaveSecretKey() {
AesCipher cipher = new AesCipher("/my/twitter/id/is/SimonBrandhof");
- assertThat(cipher.hasSecretKey(), Matchers.is(false));
+ assertThat(cipher.hasSecretKey()).isFalse();
}
private String pathToSecretKey() throws Exception {
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/config/EncryptionTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/config/EncryptionTest.java
index 9f94f8fc6cb..feb2f97c942 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/config/EncryptionTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/config/EncryptionTest.java
@@ -21,44 +21,43 @@ package org.sonar.api.config;
import org.junit.Test;
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertThat;
+import static org.assertj.core.api.Assertions.assertThat;
public class EncryptionTest {
@Test
public void isEncrypted() {
Encryption encryption = new Encryption(null);
- assertThat(encryption.isEncrypted("{aes}ADASDASAD"), is(true));
- assertThat(encryption.isEncrypted("{b64}ADASDASAD"), is(true));
- assertThat(encryption.isEncrypted("{abc}ADASDASAD"), is(true));
+ assertThat(encryption.isEncrypted("{aes}ADASDASAD")).isTrue();
+ assertThat(encryption.isEncrypted("{b64}ADASDASAD")).isTrue();
+ assertThat(encryption.isEncrypted("{abc}ADASDASAD")).isTrue();
- assertThat(encryption.isEncrypted("{}"), is(false));
- assertThat(encryption.isEncrypted("{foo"), is(false));
- assertThat(encryption.isEncrypted("foo{aes}"), is(false));
+ assertThat(encryption.isEncrypted("{}")).isFalse();
+ assertThat(encryption.isEncrypted("{foo")).isFalse();
+ assertThat(encryption.isEncrypted("foo{aes}")).isFalse();
}
@Test
public void scramble() {
Encryption encryption = new Encryption(null);
- assertThat(encryption.scramble("foo"), is("{b64}Zm9v"));
+ assertThat(encryption.scramble("foo")).isEqualTo("{b64}Zm9v");
}
@Test
public void decrypt() {
Encryption encryption = new Encryption(null);
- assertThat(encryption.decrypt("{b64}Zm9v"), is("foo"));
+ assertThat(encryption.decrypt("{b64}Zm9v")).isEqualTo("foo");
}
@Test
public void decrypt_unknown_algorithm() {
Encryption encryption = new Encryption(null);
- assertThat(encryption.decrypt("{xxx}Zm9v"), is("{xxx}Zm9v"));
+ assertThat(encryption.decrypt("{xxx}Zm9v")).isEqualTo("{xxx}Zm9v");
}
@Test
public void decrypt_uncrypted_text() {
Encryption encryption = new Encryption(null);
- assertThat(encryption.decrypt("foo"), is("foo"));
+ assertThat(encryption.decrypt("foo")).isEqualTo("foo");
}
}
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/measures/CountDistributionBuilderTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/measures/CountDistributionBuilderTest.java
index baed14aeb51..86bb8f19943 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/measures/CountDistributionBuilderTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/measures/CountDistributionBuilderTest.java
@@ -21,8 +21,7 @@ package org.sonar.api.measures;
import org.junit.Test;
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertThat;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -31,26 +30,26 @@ public class CountDistributionBuilderTest {
public void buildDistribution() {
CountDistributionBuilder builder = new CountDistributionBuilder(CoreMetrics.CLASS_COMPLEXITY_DISTRIBUTION);
Measure measure = builder
- .add("foo")
- .add("bar")
- .add("foo")
- .add("hello")
- .build();
+ .add("foo")
+ .add("bar")
+ .add("foo")
+ .add("hello")
+ .build();
- assertThat(measure.getData(), is("bar=1;foo=2;hello=1"));
+ assertThat(measure.getData()).isEqualTo("bar=1;foo=2;hello=1");
}
@Test
public void addZeroValues() {
CountDistributionBuilder builder = new CountDistributionBuilder(CoreMetrics.CLASS_COMPLEXITY_DISTRIBUTION);
Measure measure = builder
- .addZero("foo")
- .add("bar")
- .add("foo")
- .addZero("hello")
- .build();
+ .addZero("foo")
+ .add("bar")
+ .add("foo")
+ .addZero("hello")
+ .build();
- assertThat(measure.getData(), is("bar=1;foo=1;hello=0"));
+ assertThat(measure.getData()).isEqualTo("bar=1;foo=1;hello=0");
}
@Test
@@ -60,12 +59,12 @@ public class CountDistributionBuilderTest {
CountDistributionBuilder builder = new CountDistributionBuilder(CoreMetrics.CLASS_COMPLEXITY_DISTRIBUTION);
Measure measure = builder
- .add("bar")
- .add("foo")
- .add(measureToAdd)
- .build();
+ .add("bar")
+ .add("foo")
+ .add(measureToAdd)
+ .build();
- assertThat(measure.getData(), is("bar=1;foo=4;hello=5;none=0"));
+ assertThat(measure.getData()).isEqualTo("bar=1;foo=4;hello=5;none=0");
}
@Test
@@ -75,12 +74,12 @@ public class CountDistributionBuilderTest {
CountDistributionBuilder builder = new CountDistributionBuilder(CoreMetrics.CLASS_COMPLEXITY_DISTRIBUTION);
Measure measure = builder
- .add(10)
- .add(measureToAdd)
- .add(1)
- .build();
+ .add(10)
+ .add(measureToAdd)
+ .add(1)
+ .build();
- assertThat(measure.getData(), is("1=4;3=2;10=6"));
+ assertThat(measure.getData()).isEqualTo("1=4;3=2;10=6");
}
}
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/measures/MeasureUtilsTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/measures/MeasureUtilsTest.java
index d92ce7503f8..9a999743cd4 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/measures/MeasureUtilsTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/measures/MeasureUtilsTest.java
@@ -19,98 +19,94 @@
*/
package org.sonar.api.measures;
-import static org.hamcrest.Matchers.nullValue;
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertThat;
-
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
-
import org.junit.Test;
+import static org.assertj.core.api.Assertions.assertThat;
+
public class MeasureUtilsTest {
@Test
public void getValue() {
- assertThat(MeasureUtils.getValue(null, 3.0), is(3.0));
- assertThat(MeasureUtils.getValue(new Measure(), 3.0), is(3.0));
- assertThat(MeasureUtils.getValue(new Measure(CoreMetrics.LINES, 2.0), 3.0), is(2.0));
- assertThat(MeasureUtils.getValue(new Measure(CoreMetrics.LINES, "data"), 3.0), is(3.0));
+ assertThat(MeasureUtils.getValue(null, 3.0)).isEqualTo(3.0);
+ assertThat(MeasureUtils.getValue(new Measure(), 3.0)).isEqualTo(3.0);
+ assertThat(MeasureUtils.getValue(new Measure(CoreMetrics.LINES, 2.0), 3.0)).isEqualTo(2.0);
+ assertThat(MeasureUtils.getValue(new Measure(CoreMetrics.LINES, "data"), 3.0)).isEqualTo(3.0);
}
@Test
public void sumNone() {
- assertThat(MeasureUtils.sum(true), is(0d));
- assertNull(MeasureUtils.sum(false));
+ assertThat(MeasureUtils.sum(true)).isEqualTo(0d);
+ assertThat(MeasureUtils.sum(false)).isNull();
}
@Test
public void shouldNotFailIfDataMeasures() {
- assertThat(MeasureUtils.sum(true, new Measure(CoreMetrics.ALERT_STATUS, "foo"), new Measure(CoreMetrics.LINES, 50.0)), is(50d));
+ assertThat(MeasureUtils.sum(true, new Measure(CoreMetrics.ALERT_STATUS, "foo"), new Measure(CoreMetrics.LINES, 50.0))).isEqualTo(50d);
}
@Test
public void sumNumericMeasures() {
- assertThat(MeasureUtils.sum(true, new Measure(CoreMetrics.LINES, 80.0), new Measure(CoreMetrics.LINES, 50.0)), is(130d));
- assertThat(MeasureUtils.sum(true, Arrays.asList(new Measure(CoreMetrics.LINES, 80.0), new Measure(CoreMetrics.LINES, 50.0))), is(130d));
+ assertThat(MeasureUtils.sum(true, new Measure(CoreMetrics.LINES, 80.0), new Measure(CoreMetrics.LINES, 50.0))).isEqualTo(130d);
+ assertThat(MeasureUtils.sum(true, Arrays.asList(new Measure(CoreMetrics.LINES, 80.0), new Measure(CoreMetrics.LINES, 50.0)))).isEqualTo(130d);
}
@Test
public void sumNullMeasures() {
- assertThat(MeasureUtils.sum(true), is(0.0));
- assertThat(MeasureUtils.sum(true, (Collection<Measure>) null), is(0.0));
- assertThat(MeasureUtils.sum(false), nullValue());
- assertThat(MeasureUtils.sum(true, new Measure(CoreMetrics.LINES, 80.0), null, null, new Measure(CoreMetrics.LINES, 50.0)), is(130d));
+ assertThat(MeasureUtils.sum(true)).isEqualTo(0.0);
+ assertThat(MeasureUtils.sum(true, (Collection<Measure>) null)).isEqualTo(0.0);
+ assertThat(MeasureUtils.sum(false)).isNull();
+ assertThat(MeasureUtils.sum(true, new Measure(CoreMetrics.LINES, 80.0), null, null, new Measure(CoreMetrics.LINES, 50.0))).isEqualTo(130d);
}
@Test
public void hasValue() {
- assertThat(MeasureUtils.hasValue(null), is(false));
- assertThat(MeasureUtils.hasValue(new Measure(CoreMetrics.CLASSES, (Double) null)), is(false));
- assertThat(MeasureUtils.hasValue(new Measure(CoreMetrics.CLASSES, 3.2)), is(true));
+ assertThat(MeasureUtils.hasValue(null)).isFalse();
+ assertThat(MeasureUtils.hasValue(new Measure(CoreMetrics.CLASSES, (Double) null))).isFalse();
+ assertThat(MeasureUtils.hasValue(new Measure(CoreMetrics.CLASSES, 3.2))).isTrue();
}
@Test
public void hasData() {
- assertThat(MeasureUtils.hasData(null), is(false));
- assertThat(MeasureUtils.hasData(new Measure(CoreMetrics.CLASSES, 3.5)), is(false));
- assertThat(MeasureUtils.hasData(new Measure(CoreMetrics.FUNCTION_COMPLEXITY_DISTRIBUTION, (String) null)), is(false));
- assertThat(MeasureUtils.hasData(new Measure(CoreMetrics.FUNCTION_COMPLEXITY_DISTRIBUTION, "")), is(false));
- assertThat(MeasureUtils.hasData(new Measure(CoreMetrics.FUNCTION_COMPLEXITY_DISTRIBUTION, "1=10;2=20")), is(true));
+ assertThat(MeasureUtils.hasData(null)).isFalse();
+ assertThat(MeasureUtils.hasData(new Measure(CoreMetrics.CLASSES, 3.5))).isFalse();
+ assertThat(MeasureUtils.hasData(new Measure(CoreMetrics.FUNCTION_COMPLEXITY_DISTRIBUTION, (String) null))).isFalse();
+ assertThat(MeasureUtils.hasData(new Measure(CoreMetrics.FUNCTION_COMPLEXITY_DISTRIBUTION, ""))).isFalse();
+ assertThat(MeasureUtils.hasData(new Measure(CoreMetrics.FUNCTION_COMPLEXITY_DISTRIBUTION, "1=10;2=20"))).isTrue();
}
@Test
public void shouldHaveValues() {
- assertThat(MeasureUtils.haveValues(), is(false));
- assertThat(MeasureUtils.haveValues(null, null), is(false));
- assertThat(MeasureUtils.haveValues(new Measure(CoreMetrics.CLASSES, (Double) null)), is(false));
- assertThat(MeasureUtils.haveValues(new Measure(CoreMetrics.CLASSES, 3.2)), is(true));
- assertThat(MeasureUtils.haveValues(new Measure(CoreMetrics.CLASSES, 3.2), new Measure(CoreMetrics.COMPLEXITY, "foo")), is(false));
- assertThat(MeasureUtils.haveValues(new Measure(CoreMetrics.CLASSES, 3.2), new Measure(CoreMetrics.COMPLEXITY, 2.5)), is(true));
+ assertThat(MeasureUtils.haveValues()).isFalse();
+ assertThat(MeasureUtils.haveValues(null, null)).isFalse();
+ assertThat(MeasureUtils.haveValues(new Measure(CoreMetrics.CLASSES, (Double) null))).isFalse();
+ assertThat(MeasureUtils.haveValues(new Measure(CoreMetrics.CLASSES, 3.2))).isTrue();
+ assertThat(MeasureUtils.haveValues(new Measure(CoreMetrics.CLASSES, 3.2), new Measure(CoreMetrics.COMPLEXITY, "foo"))).isFalse();
+ assertThat(MeasureUtils.haveValues(new Measure(CoreMetrics.CLASSES, 3.2), new Measure(CoreMetrics.COMPLEXITY, 2.5))).isTrue();
}
@Test
public void shouldGetVariation() {
- assertThat(MeasureUtils.getVariation(null, 2, 3.14), is(3.14));
- assertThat(MeasureUtils.getVariation(null, 2), nullValue());
+ assertThat(MeasureUtils.getVariation(null, 2, 3.14)).isEqualTo(3.14);
+ assertThat(MeasureUtils.getVariation(null, 2)).isNull();
- assertThat(MeasureUtils.getVariation(new Measure(), 2, 3.14), is(3.14));
- assertThat(MeasureUtils.getVariation(new Measure(), 2), nullValue());
+ assertThat(MeasureUtils.getVariation(new Measure(), 2, 3.14)).isEqualTo(3.14);
+ assertThat(MeasureUtils.getVariation(new Measure(), 2)).isNull();
- assertThat(MeasureUtils.getVariation(new Measure().setVariation2(1.618), 2, 3.14), is(1.618));
+ assertThat(MeasureUtils.getVariation(new Measure().setVariation2(1.618), 2, 3.14)).isEqualTo(1.618);
}
@Test
public void shouldGetVariationAsLong() {
- assertThat(MeasureUtils.getVariationAsLong(null, 2, 3L), is(3L));
- assertThat(MeasureUtils.getVariationAsLong(null, 2), nullValue());
+ assertThat(MeasureUtils.getVariationAsLong(null, 2, 3L)).isEqualTo(3L);
+ assertThat(MeasureUtils.getVariationAsLong(null, 2)).isNull();
- assertThat(MeasureUtils.getVariationAsLong(new Measure(), 2, 3L), is(3L));
- assertThat(MeasureUtils.getVariationAsLong(new Measure(), 2), nullValue());
+ assertThat(MeasureUtils.getVariationAsLong(new Measure(), 2, 3L)).isEqualTo(3L);
+ assertThat(MeasureUtils.getVariationAsLong(new Measure(), 2)).isNull();
- assertThat(MeasureUtils.getVariationAsLong(new Measure().setVariation2(222.0), 2, 3L), is(222L));
+ assertThat(MeasureUtils.getVariationAsLong(new Measure().setVariation2(222.0), 2, 3L)).isEqualTo(222L);
}
@Test
@@ -119,9 +115,9 @@ public class MeasureUtilsTest {
Measure measure2 = new Measure(CoreMetrics.NEW_VIOLATIONS).setVariation1(1.0).setVariation2(2.0).setVariation3(3.0);
List<Measure> children = Arrays.asList(measure1, measure2);
- assertThat(MeasureUtils.sumOnVariation(true, 1, children), is(2d));
- assertThat(MeasureUtils.sumOnVariation(true, 2, children), is(3d));
- assertThat(MeasureUtils.sumOnVariation(true, 3, children), is(6d));
+ assertThat(MeasureUtils.sumOnVariation(true, 1, children)).isEqualTo(2d);
+ assertThat(MeasureUtils.sumOnVariation(true, 2, children)).isEqualTo(3d);
+ assertThat(MeasureUtils.sumOnVariation(true, 3, children)).isEqualTo(6d);
}
}
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/measures/PersistenceModeTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/measures/PersistenceModeTest.java
index 9fe10030e25..acd894cfed4 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/measures/PersistenceModeTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/measures/PersistenceModeTest.java
@@ -19,23 +19,23 @@
*/
package org.sonar.api.measures;
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertThat;
import org.junit.Test;
+import static org.assertj.core.api.Assertions.assertThat;
+
public class PersistenceModeTest {
@Test
public void useMemory() {
- assertThat(PersistenceMode.MEMORY.useMemory(), is(true));
- assertThat(PersistenceMode.DATABASE.useMemory(), is(false));
- assertThat(PersistenceMode.FULL.useMemory(), is(true));
+ assertThat(PersistenceMode.MEMORY.useMemory()).isTrue();
+ assertThat(PersistenceMode.DATABASE.useMemory()).isFalse();
+ assertThat(PersistenceMode.FULL.useMemory()).isTrue();
}
@Test
public void useDatabase() {
- assertThat(PersistenceMode.MEMORY.useDatabase(), is(false));
- assertThat(PersistenceMode.DATABASE.useDatabase(), is(true));
- assertThat(PersistenceMode.FULL.useDatabase(), is(true));
+ assertThat(PersistenceMode.MEMORY.useDatabase()).isFalse();
+ assertThat(PersistenceMode.DATABASE.useDatabase()).isTrue();
+ assertThat(PersistenceMode.FULL.useDatabase()).isTrue();
}
}
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/measures/PropertiesBuilderTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/measures/PropertiesBuilderTest.java
index c827c4b47a7..89c57127bf2 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/measures/PropertiesBuilderTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/measures/PropertiesBuilderTest.java
@@ -19,64 +19,59 @@
*/
package org.sonar.api.measures;
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThat;
import org.junit.Test;
+import static org.assertj.core.api.Assertions.assertThat;
+
public class PropertiesBuilderTest {
@Test
public void buildMeasure() {
PropertiesBuilder<Integer, Integer> builder = new PropertiesBuilder<>(CoreMetrics.CLASS_COMPLEXITY_DISTRIBUTION);
Measure measure = builder
- .add(1, 30)
- .add(2, 27)
- .add(4, 50)
- .build();
- assertNotNull(measure);
- assertThat(measure.getData(), is("1=30;2=27;4=50"));
+ .add(1, 30)
+ .add(2, 27)
+ .add(4, 50)
+ .build();
+ assertThat(measure.getData()).isEqualTo("1=30;2=27;4=50");
}
@Test
public void sortKeys() {
PropertiesBuilder<String, String> builder = new PropertiesBuilder<>(CoreMetrics.CLASS_COMPLEXITY_DISTRIBUTION);
Measure measure = builder
- .add("foo", "fooooo")
- .add("bar", "baaaaar")
- .add("hello", "world")
- .build();
- assertNotNull(measure);
- assertThat(measure.getData(), is("bar=baaaaar;foo=fooooo;hello=world"));
+ .add("foo", "fooooo")
+ .add("bar", "baaaaar")
+ .add("hello", "world")
+ .build();
+ assertThat(measure.getData()).isEqualTo("bar=baaaaar;foo=fooooo;hello=world");
}
@Test
public void valueIsOptional() {
PropertiesBuilder<String, String> builder = new PropertiesBuilder<>(CoreMetrics.CLASS_COMPLEXITY_DISTRIBUTION);
Measure measure = builder
- .add("foo", null)
- .add("bar", "bar")
- .add("hello", "world")
- .build();
- assertNotNull(measure);
- assertThat(measure.getData(), is("bar=bar;foo=;hello=world"));
+ .add("foo", null)
+ .add("bar", "bar")
+ .add("hello", "world")
+ .build();
+ assertThat(measure.getData()).isEqualTo("bar=bar;foo=;hello=world");
}
@Test
public void clearBeforeBuildingOtherMeasure() {
PropertiesBuilder<String, String> builder = new PropertiesBuilder<>(CoreMetrics.CLASS_COMPLEXITY_DISTRIBUTION);
builder
- .add("foo", "foo")
- .add("bar", "bar")
- .add("hello", "world")
- .build();
+ .add("foo", "foo")
+ .add("bar", "bar")
+ .add("hello", "world")
+ .build();
builder.clear();
Measure measure = builder
- .add("1", "1")
- .add("2", "2")
- .add("foo", "other")
- .build();
- assertNotNull(measure);
- assertThat(measure.getData(), is("1=1;2=2;foo=other"));
+ .add("1", "1")
+ .add("2", "2")
+ .add("foo", "other")
+ .build();
+ assertThat(measure.getData()).isEqualTo("1=1;2=2;foo=other");
}
}
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/profiles/AnnotationProfileParserTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/profiles/AnnotationProfileParserTest.java
index 45fac83881d..72b8d761132 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/profiles/AnnotationProfileParserTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/profiles/AnnotationProfileParserTest.java
@@ -30,10 +30,7 @@ import org.sonar.api.utils.ValidationMessages;
import org.sonar.check.BelongsToProfile;
import org.sonar.check.Priority;
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertThat;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -50,12 +47,12 @@ public class AnnotationProfileParserTest {
});
ValidationMessages messages = ValidationMessages.create();
- RulesProfile profile = new AnnotationProfileParser(ruleFinder).parse("squid", "Foo way", "java", Lists.<Class> newArrayList(FakeRule.class), messages);
+ RulesProfile profile = new AnnotationProfileParser(ruleFinder).parse("squid", "Foo way", "java", Lists.<Class>newArrayList(FakeRule.class), messages);
- assertThat(profile.getName(), is("Foo way"));
- assertThat(profile.getLanguage(), is("java"));
- assertThat(profile.getActiveRule("squid", "fake").getSeverity(), is(RulePriority.BLOCKER));
- assertThat(messages.hasErrors(), is(false));
+ assertThat(profile.getName()).isEqualTo("Foo way");
+ assertThat(profile.getLanguage()).isEqualTo("java");
+ assertThat(profile.getActiveRule("squid", "fake").getSeverity()).isEqualTo(RulePriority.BLOCKER);
+ assertThat(messages.hasErrors()).isFalse();
}
@Test
@@ -68,10 +65,10 @@ public class AnnotationProfileParserTest {
});
ValidationMessages messages = ValidationMessages.create();
- RulesProfile profile = new AnnotationProfileParser(ruleFinder).parse("squid", "Foo way", "java", Lists.<Class> newArrayList(FakeRule.class, RuleOnOtherProfile.class), messages);
+ RulesProfile profile = new AnnotationProfileParser(ruleFinder).parse("squid", "Foo way", "java", Lists.<Class>newArrayList(FakeRule.class, RuleOnOtherProfile.class), messages);
- assertNotNull(profile.getActiveRule("squid", "fake"));
- assertNull(profile.getActiveRule("squid", "other"));
+ assertThat(profile.getActiveRule("squid", "fake")).isNotNull();
+ assertThat(profile.getActiveRule("squid", "other")).isNull();
}
}
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/resources/QualifiersTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/resources/QualifiersTest.java
index 250ec56468e..112d1818408 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/resources/QualifiersTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/resources/QualifiersTest.java
@@ -22,27 +22,26 @@ package org.sonar.api.resources;
import org.junit.Test;
import org.sonar.api.batch.bootstrap.ProjectDefinition;
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertThat;
+import static org.assertj.core.api.Assertions.assertThat;
public class QualifiersTest {
@Test
public void testRootView() {
View root = View.createRootView();
- assertThat(Qualifiers.isView(root, true), is(true));
- assertThat(Qualifiers.isView(root, false), is(true));
- assertThat(Qualifiers.isProject(root, true), is(false));
- assertThat(Qualifiers.isProject(root, false), is(false));
+ assertThat(Qualifiers.isView(root, true)).isTrue();
+ assertThat(Qualifiers.isView(root, false)).isTrue();
+ assertThat(Qualifiers.isProject(root, true)).isFalse();
+ assertThat(Qualifiers.isProject(root, false)).isFalse();
}
@Test
public void testSubView() {
View subview = View.createSubView();
- assertThat(Qualifiers.isView(subview, true), is(true));
- assertThat(Qualifiers.isView(subview, false), is(false));
- assertThat(Qualifiers.isProject(subview, true), is(false));
- assertThat(Qualifiers.isProject(subview, false), is(false));
+ assertThat(Qualifiers.isView(subview, true)).isTrue();
+ assertThat(Qualifiers.isView(subview, false)).isFalse();
+ assertThat(Qualifiers.isProject(subview, true)).isFalse();
+ assertThat(Qualifiers.isProject(subview, false)).isFalse();
}
@Test
@@ -51,10 +50,10 @@ public class QualifiersTest {
ProjectDefinition moduleDef = ProjectDefinition.create();
rootDef.addSubProject(moduleDef);
Resource root = new Project(rootDef);
- assertThat(Qualifiers.isView(root, true), is(false));
- assertThat(Qualifiers.isView(root, false), is(false));
- assertThat(Qualifiers.isProject(root, true), is(true));
- assertThat(Qualifiers.isProject(root, false), is(true));
+ assertThat(Qualifiers.isView(root, true)).isFalse();
+ assertThat(Qualifiers.isView(root, false)).isFalse();
+ assertThat(Qualifiers.isProject(root, true)).isTrue();
+ assertThat(Qualifiers.isProject(root, false)).isTrue();
}
@Test
@@ -63,10 +62,10 @@ public class QualifiersTest {
ProjectDefinition moduleDef = ProjectDefinition.create();
rootDef.addSubProject(moduleDef);
Resource sub = new Project(moduleDef);
- assertThat(Qualifiers.isView(sub, true), is(false));
- assertThat(Qualifiers.isView(sub, false), is(false));
- assertThat(Qualifiers.isProject(sub, true), is(true));
- assertThat(Qualifiers.isProject(sub, false), is(false));
+ assertThat(Qualifiers.isView(sub, true)).isFalse();
+ assertThat(Qualifiers.isView(sub, false)).isFalse();
+ assertThat(Qualifiers.isProject(sub, true)).isTrue();
+ assertThat(Qualifiers.isProject(sub, false)).isFalse();
}
private static class View extends Resource {
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/resources/ResourceTypeTreeTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/resources/ResourceTypeTreeTest.java
index bea44bfea68..e38a0257905 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/resources/ResourceTypeTreeTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/resources/ResourceTypeTreeTest.java
@@ -21,64 +21,59 @@ package org.sonar.api.resources;
import org.junit.Test;
-import static org.hamcrest.Matchers.hasItems;
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertThat;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.sonar.api.resources.ResourceTypesTest.qualifiers;
public class ResourceTypeTreeTest {
private final ResourceTypeTree tree = ResourceTypeTree.builder()
- .addType(ResourceType.builder("TRK").build())
- .addType(ResourceType.builder("DIR").build())
- .addType(ResourceType.builder("FIL").build())
- .addType(ResourceType.builder("UTS").build())
- .addRelations("TRK", "DIR")
- .addRelations("DIR", "FIL")
- .addRelations("DIR", "UTS")
- .build();
+ .addType(ResourceType.builder("TRK").build())
+ .addType(ResourceType.builder("DIR").build())
+ .addType(ResourceType.builder("FIL").build())
+ .addType(ResourceType.builder("UTS").build())
+ .addRelations("TRK", "DIR")
+ .addRelations("DIR", "FIL")
+ .addRelations("DIR", "UTS")
+ .build();
@Test
public void getTypes() {
- assertThat(tree.getTypes().size(), is(4));
- assertThat(qualifiers(tree.getTypes()), hasItems("TRK", "DIR", "FIL", "UTS"));
+ assertThat(tree.getTypes()).hasSize(4);
+ assertThat(qualifiers(tree.getTypes())).containsOnly("TRK", "DIR", "FIL", "UTS");
}
@Test
public void getChildren() {
- assertThat(tree.getChildren("TRK").size(), is(1));
- assertThat(tree.getChildren("TRK"), hasItems("DIR"));
+ assertThat(tree.getChildren("TRK")).containsOnly("DIR");
- assertThat(tree.getChildren("DIR").size(), is(2));
- assertThat(tree.getChildren("DIR"), hasItems("FIL", "UTS"));
+ assertThat(tree.getChildren("DIR")).containsOnly("FIL", "UTS");
- assertThat(tree.getChildren("FIL").size(), is(0));
+ assertThat(tree.getChildren("FIL")).isEmpty();
}
@Test
public void getRoot() {
- assertThat(tree.getRootType(), is(ResourceType.builder("TRK").build()));
+ assertThat(tree.getRootType()).isEqualTo(ResourceType.builder("TRK").build());
}
@Test
public void getLeaves() {
- assertThat(tree.getLeaves().size(), is(2));
- assertThat(tree.getLeaves(), hasItems("FIL", "UTS"));
+ assertThat(tree.getLeaves()).containsOnly("FIL", "UTS");
}
@Test(expected = IllegalArgumentException.class)
public void forbidNullRelation() {
ResourceTypeTree.builder()
- .addType(ResourceType.builder("TRK").build())
- .addType(ResourceType.builder("DIR").build())
- .addRelations("DIR" /* missing child */)
- .build();
+ .addType(ResourceType.builder("TRK").build())
+ .addType(ResourceType.builder("DIR").build())
+ .addRelations("DIR" /* missing child */)
+ .build();
}
@Test(expected = IllegalArgumentException.class)
public void forbidDuplicatedType() {
ResourceTypeTree.builder()
- .addType(ResourceType.builder("TRK").build())
- .addType(ResourceType.builder("TRK").build())
- .build();
+ .addType(ResourceType.builder("TRK").build())
+ .addType(ResourceType.builder("TRK").build())
+ .build();
}
}
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/resources/ScopesTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/resources/ScopesTest.java
index ac934548de2..662781e95c6 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/resources/ScopesTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/resources/ScopesTest.java
@@ -22,60 +22,59 @@ package org.sonar.api.resources;
import org.junit.Test;
import org.sonar.api.batch.bootstrap.ProjectDefinition;
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertThat;
+import static org.assertj.core.api.Assertions.assertThat;
public class ScopesTest {
@Test
public void testProject() {
Project resource = new Project(ProjectDefinition.create());
- assertThat(Scopes.isProject(resource), is(true));
- assertThat(Scopes.isDirectory(resource), is(false));
- assertThat(Scopes.isFile(resource), is(false));
- assertThat(Scopes.isBlockUnit(resource), is(false));
- assertThat(Scopes.isProgramUnit(resource), is(false));
+ assertThat(Scopes.isProject(resource)).isTrue();
+ assertThat(Scopes.isDirectory(resource)).isFalse();
+ assertThat(Scopes.isFile(resource)).isFalse();
+ assertThat(Scopes.isBlockUnit(resource)).isFalse();
+ assertThat(Scopes.isProgramUnit(resource)).isFalse();
}
@Test
public void testDirectory() {
Resource resource = Directory.create("org/foo");
- assertThat(Scopes.isProject(resource), is(false));
- assertThat(Scopes.isDirectory(resource), is(true));
- assertThat(Scopes.isFile(resource), is(false));
- assertThat(Scopes.isBlockUnit(resource), is(false));
- assertThat(Scopes.isProgramUnit(resource), is(false));
+ assertThat(Scopes.isProject(resource)).isFalse();
+ assertThat(Scopes.isDirectory(resource)).isTrue();
+ assertThat(Scopes.isFile(resource)).isFalse();
+ assertThat(Scopes.isBlockUnit(resource)).isFalse();
+ assertThat(Scopes.isProgramUnit(resource)).isFalse();
}
@Test
public void testFile() {
Resource resource = File.create("org/foo/Bar.java");
- assertThat(Scopes.isProject(resource), is(false));
- assertThat(Scopes.isDirectory(resource), is(false));
- assertThat(Scopes.isFile(resource), is(true));
- assertThat(Scopes.isBlockUnit(resource), is(false));
- assertThat(Scopes.isProgramUnit(resource), is(false));
+ assertThat(Scopes.isProject(resource)).isFalse();
+ assertThat(Scopes.isDirectory(resource)).isFalse();
+ assertThat(Scopes.isFile(resource)).isTrue();
+ assertThat(Scopes.isBlockUnit(resource)).isFalse();
+ assertThat(Scopes.isProgramUnit(resource)).isFalse();
}
@Test
public void shouldBeHigherThan() {
- assertThat(Scopes.isHigherThan(Scopes.PROJECT, Scopes.PROJECT), is(false));
- assertThat(Scopes.isHigherThan(Scopes.PROJECT, Scopes.DIRECTORY), is(true));
- assertThat(Scopes.isHigherThan(Scopes.PROJECT, Scopes.BLOCK_UNIT), is(true));
+ assertThat(Scopes.isHigherThan(Scopes.PROJECT, Scopes.PROJECT)).isFalse();
+ assertThat(Scopes.isHigherThan(Scopes.PROJECT, Scopes.DIRECTORY)).isTrue();
+ assertThat(Scopes.isHigherThan(Scopes.PROJECT, Scopes.BLOCK_UNIT)).isTrue();
- assertThat(Scopes.isHigherThan(Scopes.FILE, Scopes.FILE), is(false));
- assertThat(Scopes.isHigherThan(Scopes.FILE, Scopes.DIRECTORY), is(false));
- assertThat(Scopes.isHigherThan(Scopes.FILE, Scopes.BLOCK_UNIT), is(true));
+ assertThat(Scopes.isHigherThan(Scopes.FILE, Scopes.FILE)).isFalse();
+ assertThat(Scopes.isHigherThan(Scopes.FILE, Scopes.DIRECTORY)).isFalse();
+ assertThat(Scopes.isHigherThan(Scopes.FILE, Scopes.BLOCK_UNIT)).isTrue();
}
@Test
public void shouldBeHigherThanOrEquals() {
- assertThat(Scopes.isHigherThanOrEquals(Scopes.PROJECT, Scopes.PROJECT), is(true));
- assertThat(Scopes.isHigherThanOrEquals(Scopes.PROJECT, Scopes.DIRECTORY), is(true));
- assertThat(Scopes.isHigherThanOrEquals(Scopes.PROJECT, Scopes.BLOCK_UNIT), is(true));
+ assertThat(Scopes.isHigherThanOrEquals(Scopes.PROJECT, Scopes.PROJECT)).isTrue();
+ assertThat(Scopes.isHigherThanOrEquals(Scopes.PROJECT, Scopes.DIRECTORY)).isTrue();
+ assertThat(Scopes.isHigherThanOrEquals(Scopes.PROJECT, Scopes.BLOCK_UNIT)).isTrue();
- assertThat(Scopes.isHigherThanOrEquals(Scopes.FILE, Scopes.FILE), is(true));
- assertThat(Scopes.isHigherThanOrEquals(Scopes.FILE, Scopes.DIRECTORY), is(false));
- assertThat(Scopes.isHigherThanOrEquals(Scopes.FILE, Scopes.BLOCK_UNIT), is(true));
+ assertThat(Scopes.isHigherThanOrEquals(Scopes.FILE, Scopes.FILE)).isTrue();
+ assertThat(Scopes.isHigherThanOrEquals(Scopes.FILE, Scopes.DIRECTORY)).isFalse();
+ assertThat(Scopes.isHigherThanOrEquals(Scopes.FILE, Scopes.BLOCK_UNIT)).isTrue();
}
}
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/utils/AnnotationUtilsTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/utils/AnnotationUtilsTest.java
index 0435da87541..011d91b0415 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/utils/AnnotationUtilsTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/utils/AnnotationUtilsTest.java
@@ -26,49 +26,47 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.core.IsNull.nullValue;
-import static org.junit.Assert.assertThat;
+import static org.assertj.core.api.Assertions.assertThat;
public class AnnotationUtilsTest {
@Test
public void getClassAnnotation() {
FakeAnnotation annotation = AnnotationUtils.getAnnotation(new SuperClass(), FakeAnnotation.class);
- assertThat(annotation.value(), is("foo"));
+ assertThat(annotation.value()).isEqualTo("foo");
}
@Test
public void getClassAnnotationWithDeprecatedMethod() {
FakeAnnotation annotation = AnnotationUtils.getClassAnnotation(new SuperClass(), FakeAnnotation.class);
- assertThat(annotation.value(), is("foo"));
+ assertThat(annotation.value()).isEqualTo("foo");
}
@Test
public void searchClassAnnotationInSuperClass() {
FakeAnnotation annotation = AnnotationUtils.getAnnotation(new ChildClass(), FakeAnnotation.class);
- assertThat(annotation.value(), is("foo"));
+ assertThat(annotation.value()).isEqualTo("foo");
}
@Test
public void searchClassAnnotationInInterface() {
FakeAnnotation annotation = AnnotationUtils.getAnnotation(new ImplementedClass(), FakeAnnotation.class);
- assertThat(annotation.value(), is("foo"));
+ assertThat(annotation.value()).isEqualTo("foo");
}
@Test
public void noClassAnnotation() {
FakeAnnotation annotation = AnnotationUtils.getAnnotation("a string", FakeAnnotation.class);
- assertThat(annotation, nullValue());
+ assertThat(annotation).isNull();
}
@Test
public void shouldAcceptClasses() {
FakeAnnotation annotation = AnnotationUtils.getAnnotation(SuperClass.class, FakeAnnotation.class);
- assertThat(annotation.value(), is("foo"));
+ assertThat(annotation.value()).isEqualTo("foo");
annotation = AnnotationUtils.getAnnotation(ChildClass.class, FakeAnnotation.class);
- assertThat(annotation.value(), is("foo"));
+ assertThat(annotation.value()).isEqualTo("foo");
}
}
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/utils/LocalizedMessagesTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/utils/LocalizedMessagesTest.java
index ecbf13b00f6..50f2a0c209c 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/utils/LocalizedMessagesTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/utils/LocalizedMessagesTest.java
@@ -30,9 +30,7 @@ import java.util.List;
import java.util.Locale;
import java.util.MissingResourceException;
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertThat;
-import static org.junit.matchers.JUnitMatchers.hasItems;
+import static org.assertj.core.api.Assertions.assertThat;
public class LocalizedMessagesTest {
private static final Locale DEFAULT_LOCALE = Locale.getDefault();
@@ -51,26 +49,26 @@ public class LocalizedMessagesTest {
public void mergeBundles() {
LocalizedMessages messages = new LocalizedMessages(Locale.ENGLISH, "Test", "PluginFoo");
- assertThat(messages.getString("test.one"), is("One"));
- assertThat(messages.getString("test.two"), is("Two"));
- assertThat(messages.getString("foo.hello"), is("Hello"));
+ assertThat(messages.getString("test.one")).isEqualTo("One");
+ assertThat(messages.getString("test.two")).isEqualTo("Two");
+ assertThat(messages.getString("foo.hello")).isEqualTo("Hello");
}
@Test
public void mergeBundlesByLocale() {
LocalizedMessages messages = new LocalizedMessages(Locale.FRENCH, "Test", "PluginFoo");
- assertThat(messages.getString("test.one"), is("Un"));
- assertThat(messages.getString("test.two"), is("Deux"));
- assertThat(messages.getString("foo.hello"), is("Hello"));// not in french, use the default locale
+ assertThat(messages.getString("test.one")).isEqualTo("Un");
+ assertThat(messages.getString("test.two")).isEqualTo("Deux");
+ assertThat(messages.getString("foo.hello")).isEqualTo("Hello");// not in french, use the default locale
}
@Test
public void useDefaultWhenMissingLocale() {
LocalizedMessages messages = new LocalizedMessages(Locale.JAPANESE, "Test", "PluginFoo");
- assertThat(messages.getString("test.one"), is("One"));
- assertThat(messages.getString("foo.hello"), is("Hello"));
+ assertThat(messages.getString("test.one")).isEqualTo("One");
+ assertThat(messages.getString("foo.hello")).isEqualTo("Hello");
}
@Test(expected = MissingResourceException.class)
@@ -82,29 +80,29 @@ public class LocalizedMessagesTest {
@Test
public void format() {
LocalizedMessages messages = new LocalizedMessages(Locale.ENGLISH, "Test", "PluginFoo");
- assertThat(messages.format("test.one"), is("One"));
+ assertThat(messages.format("test.one")).isEqualTo("One");
}
@Test
public void formatNeverFails() {
LocalizedMessages messages = new LocalizedMessages(Locale.ENGLISH, "Test", "PluginFoo");
- assertThat(messages.format("unknown"), is("unknown"));
+ assertThat(messages.format("unknown")).isEqualTo("unknown");
}
@Test
public void formatParameters() {
LocalizedMessages messages = new LocalizedMessages(Locale.ENGLISH, "Test", "PluginFoo");
- assertThat(messages.format("with.string.params", "inspection", "rock"), is("Continuous inspection will rock !"));
- assertThat(messages.format("with.string.params", "rock", "inspection"), is("Continuous rock will inspection !"));
+ assertThat(messages.format("with.string.params", "inspection", "rock")).isEqualTo("Continuous inspection will rock !");
+ assertThat(messages.format("with.string.params", "rock", "inspection")).isEqualTo("Continuous rock will inspection !");
}
@Test
public void getKeys() {
LocalizedMessages messages = new LocalizedMessages(Locale.ENGLISH, "Test", "PluginFoo");
- assertThat(toList(messages.getKeys()), hasItems("test.one", "test.two", "foo.hello"));
+ assertThat(toList(messages.getKeys())).contains("test.one", "test.two", "foo.hello");
LocalizedMessages spanishMessages = new LocalizedMessages(new Locale("es"), "Test", "PluginFoo");
- assertThat(toList(spanishMessages.getKeys()), hasItems("test.one", "only.in.spanish"));
+ assertThat(toList(spanishMessages.getKeys())).contains("test.one", "only.in.spanish");
}
private List<String> toList(Enumeration<String> enumeration) {
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/utils/ParsingUtilsTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/utils/ParsingUtilsTest.java
index 877380a98d3..1b4556a6a8d 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/utils/ParsingUtilsTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/utils/ParsingUtilsTest.java
@@ -19,28 +19,27 @@
*/
package org.sonar.api.utils;
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertThat;
-import org.junit.Test;
-
import java.text.ParseException;
import java.util.Locale;
+import org.junit.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
public class ParsingUtilsTest {
@Test
public void scaleValue() {
- assertThat(ParsingUtils.scaleValue(23.3333333), is(23.33));
- assertThat(ParsingUtils.scaleValue(23.777777), is(23.78));
+ assertThat(ParsingUtils.scaleValue(23.3333333)).isEqualTo(23.33);
+ assertThat(ParsingUtils.scaleValue(23.777777)).isEqualTo(23.78);
- assertThat(ParsingUtils.scaleValue(23.3333333, 0), is(23.0));
- assertThat(ParsingUtils.scaleValue(23.777777, 0), is(24.0));
+ assertThat(ParsingUtils.scaleValue(23.3333333, 0)).isEqualTo(23.0);
+ assertThat(ParsingUtils.scaleValue(23.777777, 0)).isEqualTo(24.0);
}
@Test
public void parseString() throws ParseException {
- assertThat(ParsingUtils.parseNumber("23.12", Locale.ENGLISH), is(23.12));
- assertThat(ParsingUtils.parseNumber("12345.67", Locale.ENGLISH), is(12345.67));
- assertThat(ParsingUtils.parseNumber("12345,67", Locale.FRENCH), is(12345.67));
+ assertThat(ParsingUtils.parseNumber("23.12", Locale.ENGLISH)).isEqualTo(23.12);
+ assertThat(ParsingUtils.parseNumber("12345.67", Locale.ENGLISH)).isEqualTo(12345.67);
+ assertThat(ParsingUtils.parseNumber("12345,67", Locale.FRENCH)).isEqualTo(12345.67);
}
}
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/utils/WildcardPatternTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/utils/WildcardPatternTest.java
index dbf0744f1cc..f12e28dc7e6 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/utils/WildcardPatternTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/utils/WildcardPatternTest.java
@@ -19,13 +19,10 @@
*/
package org.sonar.api.utils;
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
-
import org.junit.Test;
+import static org.assertj.core.api.Assertions.assertThat;
+
public class WildcardPatternTest {
private boolean match(String pattern, String value, String separator) {
@@ -38,88 +35,88 @@ public class WildcardPatternTest {
@Test
public void examples() {
- assertTrue(match("org/T?st.java", "org/Test.java"));
- assertTrue(match("org/T?st.java", "org/Tost.java"));
+ assertThat(match("org/T?st.java", "org/Test.java")).isTrue();
+ assertThat(match("org/T?st.java", "org/Tost.java")).isTrue();
- assertTrue(match("org/*.java", "org/Foo.java"));
- assertTrue(match("org/*.java", "org/Bar.java"));
+ assertThat(match("org/*.java", "org/Foo.java")).isTrue();
+ assertThat(match("org/*.java", "org/Bar.java")).isTrue();
- assertTrue(match("org/**", "org/Foo.java"));
- assertTrue(match("org/**", "org/foo/bar.jsp"));
+ assertThat(match("org/**", "org/Foo.java")).isTrue();
+ assertThat(match("org/**", "org/foo/bar.jsp")).isTrue();
- assertTrue(match("org/**/Test.java", "org/Test.java"));
- assertTrue(match("org/**/Test.java", "org/foo/Test.java"));
- assertTrue(match("org/**/Test.java", "org/foo/bar/Test.java"));
+ assertThat(match("org/**/Test.java", "org/Test.java")).isTrue();
+ assertThat(match("org/**/Test.java", "org/foo/Test.java")).isTrue();
+ assertThat(match("org/**/Test.java", "org/foo/bar/Test.java")).isTrue();
- assertTrue(match("org/**/*.java", "org/Foo.java"));
- assertTrue(match("org/**/*.java", "org/foo/Bar.java"));
- assertTrue(match("org/**/*.java", "org/foo/bar/Baz.java"));
+ assertThat(match("org/**/*.java", "org/Foo.java")).isTrue();
+ assertThat(match("org/**/*.java", "org/foo/Bar.java")).isTrue();
+ assertThat(match("org/**/*.java", "org/foo/bar/Baz.java")).isTrue();
}
@Test
public void javaResourcesShouldMatchWildcards() {
- assertTrue(match("Foo", "Foo", "."));
- assertFalse(match("Foo", "Bar", "."));
+ assertThat(match("Foo", "Foo", ".")).isTrue();
+ assertThat(match("Foo", "Bar", ".")).isFalse();
- assertTrue(match("org/sonar/**", "org.sonar.commons.Foo", "."));
- assertTrue(match("org/sonar/**", "org.sonar.Foo", "."));
- assertFalse(match("xxx/org/sonar/**", "org.sonar.Foo", "."));
+ assertThat(match("org/sonar/**", "org.sonar.commons.Foo", ".")).isTrue();
+ assertThat(match("org/sonar/**", "org.sonar.Foo", ".")).isTrue();
+ assertThat(match("xxx/org/sonar/**", "org.sonar.Foo", ".")).isFalse();
- assertTrue(match("org/sonar/**/**", "org.sonar.commons.Foo", "."));
- assertTrue(match("org/sonar/**/**", "org.sonar.commons.sub.Foo", "."));
- assertTrue(match("org/sonar/**/Foo", "org.sonar.commons.sub.Foo", "."));
- assertTrue(match("org/sonar/**/Foo", "org.sonar.Foo", "."));
+ assertThat(match("org/sonar/**/**", "org.sonar.commons.Foo", ".")).isTrue();
+ assertThat(match("org/sonar/**/**", "org.sonar.commons.sub.Foo", ".")).isTrue();
+ assertThat(match("org/sonar/**/Foo", "org.sonar.commons.sub.Foo", ".")).isTrue();
+ assertThat(match("org/sonar/**/Foo", "org.sonar.Foo", ".")).isTrue();
- assertTrue(match("*/foo/*", "org.foo.Bar", "."));
- assertFalse(match("*/foo/*", "foo.Bar", "."));
- assertFalse(match("*/foo/*", "foo", "."));
- assertFalse(match("*/foo/*", "org.foo.bar.Hello", "."));
+ assertThat(match("*/foo/*", "org.foo.Bar", ".")).isTrue();
+ assertThat(match("*/foo/*", "foo.Bar", ".")).isFalse();
+ assertThat(match("*/foo/*", "foo", ".")).isFalse();
+ assertThat(match("*/foo/*", "org.foo.bar.Hello", ".")).isFalse();
- assertTrue(match("hell?", "hello", "."));
- assertFalse(match("hell?", "helloworld", "."));
- assertFalse(match("hell?", "hell", "."));
+ assertThat(match("hell?", "hello", ".")).isTrue();
+ assertThat(match("hell?", "helloworld", ".")).isFalse();
+ assertThat(match("hell?", "hell", ".")).isFalse();
- assertTrue(match("a.b.c", "a.b.c", "."));
- assertTrue(match("*/a.b.c", "foo.a.b.c", "."));
- assertFalse(match("*/a.b.c", "foo/aabbc", "."));
+ assertThat(match("a.b.c", "a.b.c", ".")).isTrue();
+ assertThat(match("*/a.b.c", "foo.a.b.c", ".")).isTrue();
+ assertThat(match("*/a.b.c", "foo/aabbc", ".")).isFalse();
- assertTrue(match("**/Reader", "java.io.Reader", "."));
- assertFalse(match("**/Reader", "org.sonar.channel.CodeReader", "."));
+ assertThat(match("**/Reader", "java.io.Reader", ".")).isTrue();
+ assertThat(match("**/Reader", "org.sonar.channel.CodeReader", ".")).isFalse();
- assertTrue(match("**", "java.io.Reader", "."));
+ assertThat(match("**", "java.io.Reader", ".")).isTrue();
}
@Test
public void directoriesShouldMatchWildcards() {
- assertTrue(match("Foo", "Foo"));
- assertFalse(match("Foo", "Bar"));
+ assertThat(match("Foo", "Foo")).isTrue();
+ assertThat(match("Foo", "Bar")).isFalse();
- assertTrue(match("org/sonar/**", "org/sonar/commons/Foo"));
- assertTrue(match("org/sonar/**", "org/sonar/Foo.java"));
- assertFalse(match("xxx/org/sonar/**", "org/sonar/Foo"));
+ assertThat(match("org/sonar/**", "org/sonar/commons/Foo")).isTrue();
+ assertThat(match("org/sonar/**", "org/sonar/Foo.java")).isTrue();
+ assertThat(match("xxx/org/sonar/**", "org/sonar/Foo")).isFalse();
- assertTrue(match("org/sonar/**/**", "org/sonar/commons/Foo"));
- assertTrue(match("org/sonar/**/**", "org/sonar/commons/sub/Foo.java"));
- assertTrue(match("org/sonar/**/Foo", "org/sonar/commons/sub/Foo"));
- assertTrue(match("org/sonar/**/Foo", "org/sonar/Foo"));
+ assertThat(match("org/sonar/**/**", "org/sonar/commons/Foo")).isTrue();
+ assertThat(match("org/sonar/**/**", "org/sonar/commons/sub/Foo.java")).isTrue();
+ assertThat(match("org/sonar/**/Foo", "org/sonar/commons/sub/Foo")).isTrue();
+ assertThat(match("org/sonar/**/Foo", "org/sonar/Foo")).isTrue();
- assertTrue(match("*/foo/*", "org/foo/Bar"));
- assertFalse(match("*/foo/*", "foo/Bar"));
- assertFalse(match("*/foo/*", "foo"));
- assertFalse(match("*/foo/*", "org/foo/bar/Hello"));
+ assertThat(match("*/foo/*", "org/foo/Bar")).isTrue();
+ assertThat(match("*/foo/*", "foo/Bar")).isFalse();
+ assertThat(match("*/foo/*", "foo")).isFalse();
+ assertThat(match("*/foo/*", "org/foo/bar/Hello")).isFalse();
- assertTrue(match("hell?", "hello"));
- assertFalse(match("hell?", "helloworld"));
- assertFalse(match("hell?", "hell"));
+ assertThat(match("hell?", "hello")).isTrue();
+ assertThat(match("hell?", "helloworld")).isFalse();
+ assertThat(match("hell?", "hell")).isFalse();
- assertTrue(match("a.b.c", "a.b.c"));
- assertTrue(match("*/a.b.c", "foo/a.b.c"));
- assertFalse(match("*/a.b.c", "foo/aabbc"));
+ assertThat(match("a.b.c", "a.b.c")).isTrue();
+ assertThat(match("*/a.b.c", "foo/a.b.c")).isTrue();
+ assertThat(match("*/a.b.c", "foo/aabbc")).isFalse();
- assertTrue(match("**/Reader", "java/io/Reader"));
- assertFalse(match("**/Reader", "org/sonar/channel/CodeReader"));
+ assertThat(match("**/Reader", "java/io/Reader")).isTrue();
+ assertThat(match("**/Reader", "org/sonar/channel/CodeReader")).isFalse();
- assertTrue(match("**", "java/io/Reader"));
+ assertThat(match("**", "java/io/Reader")).isTrue();
}
/**
@@ -127,11 +124,11 @@ public class WildcardPatternTest {
*/
@Test
public void issue2193() {
- assertTrue(match("**/app/**", "com.app.Utils", "."));
- assertFalse(match("**/app/**", "com.application.MyService", "."));
+ assertThat(match("**/app/**", "com.app.Utils", ".")).isTrue();
+ assertThat(match("**/app/**", "com.application.MyService", ".")).isFalse();
- assertTrue(match("**/app/**", "com/app/Utils"));
- assertFalse(match("**/app/**", "com/application/MyService"));
+ assertThat(match("**/app/**", "com/app/Utils")).isTrue();
+ assertThat(match("**/app/**", "com/application/MyService")).isFalse();
}
/**
@@ -139,28 +136,28 @@ public class WildcardPatternTest {
*/
@Test
public void shouldEscapeRegexpSpecificCharacters() {
- assertFalse(match("**/*$*", "foo/bar"));
- assertTrue(match("**/*$*", "foo/bar$baz"));
+ assertThat(match("**/*$*", "foo/bar")).isFalse();
+ assertThat(match("**/*$*", "foo/bar$baz")).isTrue();
- assertFalse(match("a+", "aa"));
- assertTrue(match("a+", "a+"));
+ assertThat(match("a+", "aa")).isFalse();
+ assertThat(match("a+", "a+")).isTrue();
- assertFalse(match("[ab]", "a"));
- assertTrue(match("[ab]", "[ab]"));
+ assertThat(match("[ab]", "a")).isFalse();
+ assertThat(match("[ab]", "[ab]")).isTrue();
- assertTrue("all regexp-specific characters", match("()[]^$.{}+|", "()[]^$.{}+|"));
+ assertThat(match("()[]^$.{}+|", "()[]^$.{}+|")).as("all regexp-specific characters").isTrue();
}
@Test
public void backslash() {
- assertFalse("backslash is not an escape character", match("\\n", "\n"));
- assertTrue("backslash is the same as forward slash", match("foo\\bar", "foo/bar"));
+ assertThat(match("\\n", "\n")).as("backslash is not an escape character").isFalse();
+ assertThat(match("foo\\bar", "foo/bar")).as("backslash is the same as forward slash").isTrue();
}
@Test
public void shouldIgnoreStartingSlash() {
- assertTrue(match("/foo", "foo"));
- assertTrue(match("\\foo", "foo"));
+ assertThat(match("/foo", "foo")).isTrue();
+ assertThat(match("\\foo", "foo")).isTrue();
}
/**
@@ -169,21 +166,21 @@ public class WildcardPatternTest {
*/
@Test
public void cornerCase() {
- assertTrue(match("org/**.*", "org.sonar.commons.Foo.java", "."));
+ assertThat(match("org/**.*", "org.sonar.commons.Foo.java", ".")).isTrue();
}
@Test
public void multiplePatterns() {
- WildcardPattern[] patterns = WildcardPattern.create(new String[] { "Foo", "Bar" });
- assertTrue(WildcardPattern.match(patterns, "Foo"));
- assertTrue(WildcardPattern.match(patterns, "Bar"));
- assertFalse(WildcardPattern.match(patterns, "Other"));
+ WildcardPattern[] patterns = WildcardPattern.create(new String[] {"Foo", "Bar"});
+ assertThat(WildcardPattern.match(patterns, "Foo")).isTrue();
+ assertThat(WildcardPattern.match(patterns, "Bar")).isTrue();
+ assertThat(WildcardPattern.match(patterns, "Other")).isFalse();
- assertThat(WildcardPattern.create((String[]) null).length, is(0));
+ assertThat(WildcardPattern.create((String[]) null)).isEmpty();
}
@Test
public void testToString() {
- assertThat(WildcardPattern.create("foo*").toString(), is("foo*"));
+ assertThat(WildcardPattern.create("foo*").toString()).isEqualTo("foo*");
}
}
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/web/AbstractRubyTemplateTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/web/AbstractRubyTemplateTest.java
index 869466fb6be..65b385bf9ed 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/web/AbstractRubyTemplateTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/web/AbstractRubyTemplateTest.java
@@ -19,14 +19,13 @@
*/
package org.sonar.api.web;
-import static org.hamcrest.Matchers.nullValue;
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertThat;
import org.junit.Test;
import org.sonar.api.utils.SonarException;
import java.net.URL;
+import static org.assertj.core.api.Assertions.assertThat;
+
public class AbstractRubyTemplateTest {
@Test
@@ -38,9 +37,9 @@ public class AbstractRubyTemplateTest {
}
};
- assertThat(template.loadTemplateFromCache(), nullValue());
- assertThat(template.getTemplate(), is("ok"));
- assertThat(template.loadTemplateFromCache(), is("ok"));
+ assertThat(template.loadTemplateFromCache()).isNull();
+ assertThat(template.getTemplate()).isEqualTo("ok");
+ assertThat(template.loadTemplateFromCache()).isEqualTo("ok");
}
@Test
@@ -53,9 +52,9 @@ public class AbstractRubyTemplateTest {
}
};
- assertThat(template.loadTemplateFromCache(), nullValue());
- assertThat(template.getTemplate(), is("ok"));
- assertThat(template.loadTemplateFromCache(), nullValue());
+ assertThat(template.loadTemplateFromCache()).isNull();
+ assertThat(template.getTemplate()).isEqualTo("ok");
+ assertThat(template.loadTemplateFromCache()).isNull();
}
@Test(expected = SonarException.class)
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/web/DashboardTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/web/DashboardTest.java
index f28ba47e3da..80ed02d6dc6 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/web/DashboardTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/web/DashboardTest.java
@@ -21,34 +21,32 @@ package org.sonar.api.web;
import org.junit.Test;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.nullValue;
-import static org.junit.Assert.assertThat;
+import static org.assertj.core.api.Assertions.assertThat;
public class DashboardTest {
@Test
public void shouldCreateDashboard() {
Dashboard dashboard = Dashboard.create();
- assertThat(dashboard.getLayout(), is(DashboardLayout.TWO_COLUMNS));
- assertThat(dashboard.getDescription(), nullValue());
- assertThat(dashboard.getWidgets().size(), is(0));
+ assertThat(dashboard.getLayout()).isEqualTo(DashboardLayout.TWO_COLUMNS);
+ assertThat(dashboard.getDescription()).isNull();
+ assertThat(dashboard.getWidgets()).hasSize(0);
}
@Test
public void shouldAddWidgets() {
Dashboard dashboard = Dashboard.create();
Dashboard.Widget mostViolatedRules = dashboard.addWidget("most_violated_rules", 1);
- assertThat(mostViolatedRules.getId(), is("most_violated_rules"));
- assertThat(dashboard.getWidgets().size(), is(1));
- assertThat(dashboard.getWidgetsOfColumn(1).size(), is(1));
+ assertThat(mostViolatedRules.getId()).isEqualTo("most_violated_rules");
+ assertThat(dashboard.getWidgets()).hasSize(1);
+ assertThat(dashboard.getWidgetsOfColumn(1)).hasSize(1);
dashboard.addWidget("hotspots", 1);
- assertThat(dashboard.getWidgets().size(), is(2));
- assertThat(dashboard.getWidgetsOfColumn(1).size(), is(2));
+ assertThat(dashboard.getWidgets()).hasSize(2);
+ assertThat(dashboard.getWidgetsOfColumn(1)).hasSize(2);
// widgets are sorted by order of insertion
- assertThat(dashboard.getWidgetsOfColumn(1).get(1).getId(), is("hotspots"));
+ assertThat(dashboard.getWidgetsOfColumn(1).get(1).getId()).isEqualTo("hotspots");
}
@Test
@@ -56,12 +54,12 @@ public class DashboardTest {
Dashboard dashboard = Dashboard.create();
dashboard.addWidget("most_violated_rules", 1);
- assertThat(dashboard.getWidgets().size(), is(1));
- assertThat(dashboard.getWidgetsOfColumn(1).size(), is(1));
+ assertThat(dashboard.getWidgets().size()).isEqualTo(1);
+ assertThat(dashboard.getWidgetsOfColumn(1).size()).isEqualTo(1);
dashboard.addWidget("hotspots", 2);
- assertThat(dashboard.getWidgets().size(), is(2));
- assertThat(dashboard.getWidgetsOfColumn(2).size(), is(1));
+ assertThat(dashboard.getWidgets().size()).isEqualTo(2);
+ assertThat(dashboard.getWidgetsOfColumn(2).size()).isEqualTo(1);
}
@Test
@@ -70,9 +68,9 @@ public class DashboardTest {
dashboard.addWidget("most_violated_rules", 1);
dashboard.addWidget("most_violated_rules", 1).setProperty("foo", "bar");
- assertThat(dashboard.getWidgets().size(), is(2));
- assertThat(dashboard.getWidgetsOfColumn(1).get(0).getProperties().size(), is(0));
- assertThat(dashboard.getWidgetsOfColumn(1).get(1).getProperty("foo"), is("bar"));
+ assertThat(dashboard.getWidgets().size()).isEqualTo(2);
+ assertThat(dashboard.getWidgetsOfColumn(1).get(0).getProperties().size()).isEqualTo(0);
+ assertThat(dashboard.getWidgetsOfColumn(1).get(1).getProperty("foo")).isEqualTo("bar");
}
@Test
@@ -81,6 +79,6 @@ public class DashboardTest {
Dashboard.Widget widget = dashboard.addWidget("fake-widget", 1);
widget.setProperty("foo", "bar");
- assertThat(widget.getProperties().get("foo"), is("bar"));
+ assertThat(widget.getProperties().get("foo")).isEqualTo("bar");
}
}