]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-6370 fix quality flaws 350/head
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Wed, 3 Jun 2015 10:22:16 +0000 (12:22 +0200)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Fri, 5 Jun 2015 07:54:06 +0000 (09:54 +0200)
server/sonar-process/src/test/java/org/sonar/process/MinimumViableSystemTest.java
server/sonar-server/src/main/java/org/sonar/server/notifications/email/EmailNotificationChannel.java
server/sonar-server/src/main/java/org/sonar/server/plugins/ws/InstallAction.java
server/sonar-server/src/main/java/org/sonar/server/plugins/ws/InstalledAction.java
server/sonar-server/src/test/java/org/sonar/server/issue/IssuesFinderSortTest.java
server/sonar-server/src/test/java/org/sonar/server/notifications/email/EmailNotificationChannelTest.java
server/sonar-server/src/test/java/org/sonar/server/rule/DefaultRuleFinderMediumTest.java
sonar-core/src/main/java/org/sonar/core/platform/PluginLoader.java
sonar-plugin-api/src/test/java/org/sonar/api/batch/fs/internal/DefaultFilePredicatesTest.java
sonar-plugin-api/src/test/java/org/sonar/api/utils/DateUtilsTest.java

index dc2bdf2c4a6b0376c50662c94f6d12a0b350d4ee..ca2d7f2ce95a7f504d5e498258c231c8177bf4e9 100644 (file)
@@ -26,6 +26,7 @@ import org.junit.rules.TemporaryFolder;
 
 import java.io.File;
 
+import static org.assertj.core.api.Assertions.assertThat;
 import static org.junit.Assert.fail;
 
 public class MinimumViableSystemTest {
@@ -61,7 +62,7 @@ public class MinimumViableSystemTest {
       mve.checkJavaVersion("1.9");
       fail();
     } catch (MessageException e) {
-      Assertions.assertThat(e).hasMessage("Supported versions of Java are 1.6, 1.7 and 1.8. Got 1.9.");
+      assertThat(e).hasMessage("Supported versions of Java are 1.6, 1.7 and 1.8. Got 1.9.");
     }
   }
 
@@ -76,7 +77,7 @@ public class MinimumViableSystemTest {
       mve.checkJavaOptions();
       fail();
     } catch (MessageException e) {
-      Assertions.assertThat(e).hasMessage("JVM option '" + key + "' must be set to 'true'. Got 'false'");
+      assertThat(e).hasMessage("JVM option '" + key + "' must be set to 'true'. Got 'false'");
     }
 
     System.setProperty(key, "true");
@@ -96,7 +97,7 @@ public class MinimumViableSystemTest {
       mve.checkWritableDir(dir.getAbsolutePath());
       fail();
     } catch (IllegalStateException e) {
-      Assertions.assertThat(e).hasMessage("Temp directory is not writable: " + dir.getAbsolutePath());
+      assertThat(e).hasMessage("Temp directory is not writable: " + dir.getAbsolutePath());
     }
   }
 }
index 203038713391c4d92a453b404c953db14fb12efe..3b96270736b72333859947b3073ddf2b94bd552a 100644 (file)
@@ -163,7 +163,7 @@ public class EmailNotificationChannel extends NotificationChannel {
       }
       // Set general information
       email.setCharset("UTF-8");
-      String from = StringUtils.isBlank(emailMessage.getFrom()) ? FROM_NAME_DEFAULT : emailMessage.getFrom() + " (SonarQube)";
+      String from = StringUtils.isBlank(emailMessage.getFrom()) ? FROM_NAME_DEFAULT : (emailMessage.getFrom() + " (SonarQube)");
       email.setFrom(configuration.getFrom(), from);
       email.addTo(emailMessage.getTo(), " ");
       String subject = StringUtils.defaultIfBlank(StringUtils.trimToEmpty(configuration.getPrefix()) + " ", "")
index e69f4d61b1c198005308ce95808859549c877961..e629620df2e5f374666e4730ce57a73e7fd7387a 100644 (file)
@@ -21,6 +21,7 @@ package org.sonar.server.plugins.ws;
 
 import com.google.common.base.Predicate;
 import com.google.common.collect.Iterables;
+import javax.annotation.Nullable;
 import org.sonar.api.server.ws.Request;
 import org.sonar.api.server.ws.Response;
 import org.sonar.api.server.ws.WebService;
@@ -30,8 +31,6 @@ import org.sonar.server.plugins.UpdateCenterMatrixFactory;
 import org.sonar.server.user.UserSession;
 import org.sonar.updatecenter.common.PluginUpdate;
 
-import javax.annotation.Nullable;
-
 import static java.lang.String.format;
 
 /**
@@ -47,7 +46,7 @@ public class InstallAction implements PluginsWsAction {
   private final UserSession userSession;
 
   public InstallAction(UpdateCenterMatrixFactory updateCenterFactory,
-                       PluginDownloader pluginDownloader, UserSession userSession) {
+    PluginDownloader pluginDownloader, UserSession userSession) {
     this.updateCenterFactory = updateCenterFactory;
     this.pluginDownloader = pluginDownloader;
     this.userSession = userSession;
index 97946e070bee93039a906055852286aebd79207e..37cc7436ec4682e4dffb0a7511eb59020df8094e 100644 (file)
@@ -19,9 +19,9 @@
  */
 package org.sonar.server.plugins.ws;
 
-import com.google.common.base.Predicate;
-import com.google.common.collect.ImmutableSortedSet;
 import com.google.common.io.Resources;
+import java.util.Collection;
+import java.util.SortedSet;
 import org.sonar.api.server.ws.Request;
 import org.sonar.api.server.ws.Response;
 import org.sonar.api.server.ws.WebService;
@@ -29,13 +29,7 @@ import org.sonar.api.utils.text.JsonWriter;
 import org.sonar.core.platform.PluginInfo;
 import org.sonar.server.plugins.ServerPluginRepository;
 
-import javax.annotation.Nullable;
-
-import java.util.Collection;
-import java.util.SortedSet;
-
 import static com.google.common.collect.ImmutableSortedSet.copyOf;
-import static com.google.common.collect.Iterables.filter;
 import static org.sonar.server.plugins.ws.PluginWSCommons.NAME_KEY_PLUGIN_METADATA_COMPARATOR;
 
 /**
@@ -47,8 +41,7 @@ public class InstalledAction implements PluginsWsAction {
   private final ServerPluginRepository pluginRepository;
   private final PluginWSCommons pluginWSCommons;
 
-  public InstalledAction(ServerPluginRepository pluginRepository,
-                         PluginWSCommons pluginWSCommons) {
+  public InstalledAction(ServerPluginRepository pluginRepository, PluginWSCommons pluginWSCommons) {
     this.pluginRepository = pluginRepository;
     this.pluginWSCommons = pluginWSCommons;
   }
index f9ffcdf429ca7ed164aa86f0e1145d0193c21dd4..80ede6a36f0a0cda4357abdc682ac3d8626398b2 100644 (file)
@@ -23,7 +23,6 @@ package org.sonar.server.issue;
 import java.util.Date;
 import java.util.List;
 import org.apache.commons.lang.time.DateUtils;
-import org.assertj.core.api.Assertions;
 import org.junit.Rule;
 import org.junit.Test;
 import org.sonar.core.issue.db.IssueDto;
@@ -70,10 +69,10 @@ public class IssuesFinderSortTest {
 
     List<IssueDto> result = newArrayList(issuesFinderSort.sort());
 
-    Assertions.assertThat(result).hasSize(3);
-    Assertions.assertThat(result.get(0).getStatus()).isEqualTo("REOPENED");
-    Assertions.assertThat(result.get(1).getStatus()).isEqualTo("OPEN");
-    Assertions.assertThat(result.get(2).getStatus()).isEqualTo("CLOSED");
+    assertThat(result).hasSize(3);
+    assertThat(result.get(0).getStatus()).isEqualTo("REOPENED");
+    assertThat(result.get(1).getStatus()).isEqualTo("OPEN");
+    assertThat(result.get(2).getStatus()).isEqualTo("CLOSED");
   }
 
   @Test
@@ -88,10 +87,10 @@ public class IssuesFinderSortTest {
 
     List<IssueDto> result = newArrayList(issuesFinderSort.sort());
 
-    Assertions.assertThat(result).hasSize(3);
-    Assertions.assertThat(result.get(0).getSeverity()).isEqualTo("INFO");
-    Assertions.assertThat(result.get(1).getSeverity()).isEqualTo("MAJOR");
-    Assertions.assertThat(result.get(2).getSeverity()).isEqualTo("BLOCKER");
+    assertThat(result).hasSize(3);
+    assertThat(result.get(0).getSeverity()).isEqualTo("INFO");
+    assertThat(result.get(1).getSeverity()).isEqualTo("MAJOR");
+    assertThat(result.get(2).getSeverity()).isEqualTo("BLOCKER");
   }
 
   @Test
@@ -106,10 +105,10 @@ public class IssuesFinderSortTest {
 
     List<IssueDto> result = newArrayList(issuesFinderSort.sort());
 
-    Assertions.assertThat(result).hasSize(3);
-    Assertions.assertThat(result.get(0).getSeverity()).isEqualTo("BLOCKER");
-    Assertions.assertThat(result.get(1).getSeverity()).isEqualTo("MAJOR");
-    Assertions.assertThat(result.get(2).getSeverity()).isEqualTo("INFO");
+    assertThat(result).hasSize(3);
+    assertThat(result.get(0).getSeverity()).isEqualTo("BLOCKER");
+    assertThat(result.get(1).getSeverity()).isEqualTo("MAJOR");
+    assertThat(result.get(2).getSeverity()).isEqualTo("INFO");
   }
 
   @Test
@@ -128,10 +127,10 @@ public class IssuesFinderSortTest {
 
     List<IssueDto> result = newArrayList(issuesFinderSort.sort());
 
-    Assertions.assertThat(result).hasSize(3);
-    Assertions.assertThat(result.get(0).getIssueCreationDate()).isEqualTo(date3);
-    Assertions.assertThat(result.get(1).getIssueCreationDate()).isEqualTo(date2);
-    Assertions.assertThat(result.get(2).getIssueCreationDate()).isEqualTo(date1);
+    assertThat(result).hasSize(3);
+    assertThat(result.get(0).getIssueCreationDate()).isEqualTo(date3);
+    assertThat(result.get(1).getIssueCreationDate()).isEqualTo(date2);
+    assertThat(result.get(2).getIssueCreationDate()).isEqualTo(date1);
   }
 
   @Test
@@ -150,10 +149,10 @@ public class IssuesFinderSortTest {
 
     List<IssueDto> result = newArrayList(issuesFinderSort.sort());
 
-    Assertions.assertThat(result).hasSize(3);
-    Assertions.assertThat(result.get(0).getIssueUpdateDate()).isEqualTo(date3);
-    Assertions.assertThat(result.get(1).getIssueUpdateDate()).isEqualTo(date2);
-    Assertions.assertThat(result.get(2).getIssueUpdateDate()).isEqualTo(date1);
+    assertThat(result).hasSize(3);
+    assertThat(result.get(0).getIssueUpdateDate()).isEqualTo(date3);
+    assertThat(result.get(1).getIssueUpdateDate()).isEqualTo(date2);
+    assertThat(result.get(2).getIssueUpdateDate()).isEqualTo(date1);
   }
 
   @Test
@@ -172,10 +171,10 @@ public class IssuesFinderSortTest {
 
     List<IssueDto> result = newArrayList(issuesFinderSort.sort());
 
-    Assertions.assertThat(result).hasSize(3);
-    Assertions.assertThat(result.get(0).getIssueCloseDate()).isEqualTo(date3);
-    Assertions.assertThat(result.get(1).getIssueCloseDate()).isEqualTo(date2);
-    Assertions.assertThat(result.get(2).getIssueCloseDate()).isEqualTo(date1);
+    assertThat(result).hasSize(3);
+    assertThat(result.get(0).getIssueCloseDate()).isEqualTo(date3);
+    assertThat(result.get(1).getIssueCloseDate()).isEqualTo(date2);
+    assertThat(result.get(2).getIssueCloseDate()).isEqualTo(date1);
   }
 
   @Test
index d3e2144fd08a48607d287c4e80bf1619b3146cf2..3c5e94587afd9f04a1fa27ef77d484f3c7e42a10 100644 (file)
@@ -24,7 +24,6 @@ import java.net.ServerSocket;
 import java.util.List;
 import javax.mail.internet.MimeMessage;
 import org.apache.commons.mail.EmailException;
-import org.assertj.core.api.Assertions;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Rule;
@@ -86,10 +85,10 @@ public class EmailNotificationChannelTest {
     assertThat(messages).hasSize(1);
 
     MimeMessage email = messages.get(0).getMimeMessage();
-    Assertions.assertThat(email.getHeader("Content-Type", null)).isEqualTo("text/plain; charset=UTF-8");
-    Assertions.assertThat(email.getHeader("From", ",")).isEqualTo("SonarQube <server@nowhere>");
-    Assertions.assertThat(email.getHeader("To", null)).isEqualTo("<user@nowhere>");
-    Assertions.assertThat(email.getHeader("Subject", null)).isEqualTo("[SONARQUBE] Test Message from SonarQube");
+    assertThat(email.getHeader("Content-Type", null)).isEqualTo("text/plain; charset=UTF-8");
+    assertThat(email.getHeader("From", ",")).isEqualTo("SonarQube <server@nowhere>");
+    assertThat(email.getHeader("To", null)).isEqualTo("<user@nowhere>");
+    assertThat(email.getHeader("Subject", null)).isEqualTo("[SONARQUBE] Test Message from SonarQube");
     assertThat((String) email.getContent()).startsWith("This is a test message from SonarQube.");
   }
 
@@ -113,7 +112,7 @@ public class EmailNotificationChannelTest {
       .setSubject("Foo")
       .setMessage("Bar");
     channel.deliver(emailMessage);
-    Assertions.assertThat(server.getMessages()).isEmpty();
+    assertThat(server.getMessages()).isEmpty();
   }
 
   @Test
@@ -132,17 +131,17 @@ public class EmailNotificationChannelTest {
 
     MimeMessage email = messages.get(0).getMimeMessage();
 
-    Assertions.assertThat(email.getHeader("Content-Type", null)).isEqualTo("text/plain; charset=UTF-8");
+    assertThat(email.getHeader("Content-Type", null)).isEqualTo("text/plain; charset=UTF-8");
 
-    Assertions.assertThat(email.getHeader("In-Reply-To", null)).isEqualTo("<reviews/view/1@nemo.sonarsource.org>");
-    Assertions.assertThat(email.getHeader("References", null)).isEqualTo("<reviews/view/1@nemo.sonarsource.org>");
+    assertThat(email.getHeader("In-Reply-To", null)).isEqualTo("<reviews/view/1@nemo.sonarsource.org>");
+    assertThat(email.getHeader("References", null)).isEqualTo("<reviews/view/1@nemo.sonarsource.org>");
 
-    Assertions.assertThat(email.getHeader("List-ID", null)).isEqualTo("SonarQube <sonar.nemo.sonarsource.org>");
-    Assertions.assertThat(email.getHeader("List-Archive", null)).isEqualTo("http://nemo.sonarsource.org");
+    assertThat(email.getHeader("List-ID", null)).isEqualTo("SonarQube <sonar.nemo.sonarsource.org>");
+    assertThat(email.getHeader("List-Archive", null)).isEqualTo("http://nemo.sonarsource.org");
 
-    Assertions.assertThat(email.getHeader("From", ",")).isEqualTo("\"Full Username (SonarQube)\" <server@nowhere>");
-    Assertions.assertThat(email.getHeader("To", null)).isEqualTo("<user@nowhere>");
-    Assertions.assertThat(email.getHeader("Subject", null)).isEqualTo("[SONARQUBE] Review #3");
+    assertThat(email.getHeader("From", ",")).isEqualTo("\"Full Username (SonarQube)\" <server@nowhere>");
+    assertThat(email.getHeader("To", null)).isEqualTo("<user@nowhere>");
+    assertThat(email.getHeader("Subject", null)).isEqualTo("[SONARQUBE] Review #3");
     assertThat((String) email.getContent()).startsWith("I'll take care of this violation.");
   }
 
@@ -160,17 +159,17 @@ public class EmailNotificationChannelTest {
 
     MimeMessage email = messages.get(0).getMimeMessage();
 
-    Assertions.assertThat(email.getHeader("Content-Type", null)).isEqualTo("text/plain; charset=UTF-8");
+    assertThat(email.getHeader("Content-Type", null)).isEqualTo("text/plain; charset=UTF-8");
 
-    Assertions.assertThat(email.getHeader("In-Reply-To", null)).isNull();
-    Assertions.assertThat(email.getHeader("References", null)).isNull();
+    assertThat(email.getHeader("In-Reply-To", null)).isNull();
+    assertThat(email.getHeader("References", null)).isNull();
 
-    Assertions.assertThat(email.getHeader("List-ID", null)).isEqualTo("SonarQube <sonar.nemo.sonarsource.org>");
-    Assertions.assertThat(email.getHeader("List-Archive", null)).isEqualTo("http://nemo.sonarsource.org");
+    assertThat(email.getHeader("List-ID", null)).isEqualTo("SonarQube <sonar.nemo.sonarsource.org>");
+    assertThat(email.getHeader("List-Archive", null)).isEqualTo("http://nemo.sonarsource.org");
 
-    Assertions.assertThat(email.getHeader("From", null)).isEqualTo("SonarQube <server@nowhere>");
-    Assertions.assertThat(email.getHeader("To", null)).isEqualTo("<user@nowhere>");
-    Assertions.assertThat(email.getHeader("Subject", null)).isEqualTo("[SONARQUBE] Foo");
+    assertThat(email.getHeader("From", null)).isEqualTo("SonarQube <server@nowhere>");
+    assertThat(email.getHeader("To", null)).isEqualTo("<user@nowhere>");
+    assertThat(email.getHeader("Subject", null)).isEqualTo("[SONARQUBE] Foo");
     assertThat((String) email.getContent()).startsWith("Bar");
   }
 
@@ -198,7 +197,7 @@ public class EmailNotificationChannelTest {
       fail("An SSL exception was expected a a proof that STARTTLS is enabled");
     } catch (EmailException e) {
       // We don't have a SSL certificate so we are expecting a SSL error
-      Assertions.assertThat(e.getCause().getMessage()).isEqualTo("Could not convert socket to TLS");
+      assertThat(e.getCause().getMessage()).isEqualTo("Could not convert socket to TLS");
     }
   }
 
index ff3138efd8b1f089b3d42d8c70c52def7520a32c..3d5939bdd1613eb284db203804ed6822d1176302 100644 (file)
  */
 package org.sonar.server.rule;
 
-import org.assertj.core.api.Assertions;
-import org.junit.*;
+import java.util.Collections;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
+import org.junit.Test;
 import org.sonar.api.rule.RuleKey;
 import org.sonar.api.rule.RuleStatus;
 import org.sonar.api.rules.Rule;
@@ -29,8 +33,6 @@ import org.sonar.core.persistence.DbSession;
 import org.sonar.core.rule.RuleDto;
 import org.sonar.server.db.DbClient;
 import org.sonar.server.tester.ServerTester;
-
-import java.util.Collections;
 import org.sonar.server.tester.UserSessionRule;
 
 import static com.google.common.collect.Lists.newArrayList;
@@ -92,7 +94,7 @@ public class DefaultRuleFinderMediumTest {
         .setSeverity(2)
         .setStatus(RuleStatus.READY),
       RuleTesting.newManualRule("Manual_Rule").setName("Manual Rule")
-    );
+      );
     session.commit();
     session.close();
   }
@@ -106,39 +108,39 @@ public class DefaultRuleFinderMediumTest {
   public void should_success_finder_wrap() {
 
     // has Id
-    Assertions.assertThat(finder.findById(1).getId()).isEqualTo(1);
+    assertThat(finder.findById(1).getId()).isEqualTo(1);
 
     // should_find_by_id
-    Assertions.assertThat(finder.findById(3).getConfigKey()).isEqualTo("Checker/Treewalker/AnnotationUseStyleCheck");
+    assertThat(finder.findById(3).getConfigKey()).isEqualTo("Checker/Treewalker/AnnotationUseStyleCheck");
 
     // should_not_find_disabled_rule_by_id
-    Assertions.assertThat(finder.findById(2)).isNull();
+    assertThat(finder.findById(2)).isNull();
 
     // should_find_by_ids
     assertThat(finder.findByIds(newArrayList(2, 3))).hasSize(2);
 
     // should_find_by_key
     Rule rule = finder.findByKey("checkstyle", "com.puppycrawl.tools.checkstyle.checks.header.HeaderCheck");
-    Assertions.assertThat(rule).isNotNull();
-    Assertions.assertThat(rule.getKey()).isEqualTo(("com.puppycrawl.tools.checkstyle.checks.header.HeaderCheck"));
-    Assertions.assertThat(rule.isEnabled()).isTrue();
+    assertThat(rule).isNotNull();
+    assertThat(rule.getKey()).isEqualTo(("com.puppycrawl.tools.checkstyle.checks.header.HeaderCheck"));
+    assertThat(rule.isEnabled()).isTrue();
 
     // find_should_return_null_if_no_results
-    Assertions.assertThat(finder.findByKey("checkstyle", "unknown")).isNull();
-    Assertions.assertThat(finder.find(RuleQuery.create().withRepositoryKey("checkstyle").withConfigKey("unknown"))).isNull();
+    assertThat(finder.findByKey("checkstyle", "unknown")).isNull();
+    assertThat(finder.find(RuleQuery.create().withRepositoryKey("checkstyle").withConfigKey("unknown"))).isNull();
 
     // find_repository_rules
-    Assertions.assertThat(finder.findAll(RuleQuery.create().withRepositoryKey("checkstyle"))).hasSize(2);
+    assertThat(finder.findAll(RuleQuery.create().withRepositoryKey("checkstyle"))).hasSize(2);
 
     // find_all_enabled
-    Assertions.assertThat(finder.findAll(RuleQuery.create())).extracting("id").containsOnly(1, 3, 4, 5);
-    Assertions.assertThat(finder.findAll(RuleQuery.create())).hasSize(4);
+    assertThat(finder.findAll(RuleQuery.create())).extracting("id").containsOnly(1, 3, 4, 5);
+    assertThat(finder.findAll(RuleQuery.create())).hasSize(4);
 
     // do_not_find_disabled_rules
-    Assertions.assertThat(finder.findByKey("checkstyle", "DisabledCheck")).isNull();
+    assertThat(finder.findByKey("checkstyle", "DisabledCheck")).isNull();
 
     // do_not_find_unknown_rules
-    Assertions.assertThat(finder.findAll(RuleQuery.create().withRepositoryKey("unknown_repository"))).isEmpty();
+    assertThat(finder.findAll(RuleQuery.create().withRepositoryKey("unknown_repository"))).isEmpty();
 
     // should_find_by_ids_empty
     tester.clearDbAndIndexes();
@@ -170,17 +172,17 @@ public class DefaultRuleFinderMediumTest {
   @Test
   public void find_all_not_include_removed_rule() {
     // find rule with id 2 is REMOVED
-    Assertions.assertThat(finder.findAll(RuleQuery.create())).extracting("id").containsOnly(1, 3, 4, 5);
+    assertThat(finder.findAll(RuleQuery.create())).extracting("id").containsOnly(1, 3, 4, 5);
   }
 
   @Test
   public void find_manual_rule() {
     // find by id
-    Assertions.assertThat(finder.findById(5)).isNotNull();
+    assertThat(finder.findById(5)).isNotNull();
 
     // find by key
     Rule rule = finder.findByKey("manual", "Manual_Rule");
-    Assertions.assertThat(rule).isNotNull();
-    Assertions.assertThat(rule.isEnabled()).isTrue();
+    assertThat(rule).isNotNull();
+    assertThat(rule.isEnabled()).isTrue();
   }
 }
index 1012c8ca4387bf147d2c1d066ae1ac9cbcc3970d..f5f96814066ab270caa44a27faff213f292c4375 100644 (file)
@@ -94,7 +94,7 @@ public class PluginLoader {
       if (Strings.isNullOrEmpty(info.getBasePlugin())) {
         def.setSelfFirstStrategy(info.isUseChildFirstClassLoader());
         Version minSqVersion = info.getMinimalSqVersion();
-        boolean compatibilityMode = (minSqVersion != null && minSqVersion.compareToIgnoreQualifier(COMPATIBILITY_MODE_MAX_VERSION) < 0);
+        boolean compatibilityMode = minSqVersion != null && minSqVersion.compareToIgnoreQualifier(COMPATIBILITY_MODE_MAX_VERSION) < 0;
         def.setCompatibilityMode(compatibilityMode);
         if (compatibilityMode) {
           Loggers.get(getClass()).info("API compatibility mode is enabled on plugin {} [{}] " +
@@ -112,8 +112,8 @@ public class PluginLoader {
    * @return the instances grouped by plugin key
    * @throws IllegalStateException if at least one plugin can't be correctly loaded
    */
-   @VisibleForTesting
-   Map<String, Plugin> instantiatePluginClasses(Map<PluginClassloaderDef, ClassLoader> classloaders) {
+  @VisibleForTesting
+  Map<String, Plugin> instantiatePluginClasses(Map<PluginClassloaderDef, ClassLoader> classloaders) {
     // instantiate plugins
     Map<String, Plugin> instancesByPluginKey = new HashMap<>();
     for (Map.Entry<PluginClassloaderDef, ClassLoader> entry : classloaders.entrySet()) {
index 1877b74831cc784c471f683161fd586415ad9871..794b8e7b615629d87041457181643e30ab9a6a4d 100644 (file)
@@ -54,7 +54,7 @@ public class DefaultFilePredicatesTest {
 
   @Test
   public void all() {
-    Assertions.assertThat(predicates.all().apply(javaFile)).isTrue();
+    assertThat(predicates.all().apply(javaFile)).isTrue();
   }
 
   @Test
index ca4052f33e3bae84d2ab569a122cd12efd4da87c..d737f3c077941ef68172dc33daeb49135fb657e2 100644 (file)
  */
 package org.sonar.api.utils;
 
-import org.assertj.core.api.Assertions;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
 
-import static org.hamcrest.Matchers.*;
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.*;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Fail.fail;
 
 public class DateUtilsTest {
 
@@ -40,7 +37,7 @@ public class DateUtilsTest {
   @Test
   public void parseDate_valid_format() {
     Date date = DateUtils.parseDate("2010-05-18");
-    assertThat(date.getDate(), is(18));
+    assertThat(date.getDate()).isEqualTo(18);
   }
 
   @Test
@@ -51,9 +48,9 @@ public class DateUtilsTest {
 
   @Test
   public void parseDateQuietly() {
-    assertNull(DateUtils.parseDateQuietly("2010/05/18"));
+    assertThat(DateUtils.parseDateQuietly("2010/05/18")).isNull();
     Date date = DateUtils.parseDateQuietly("2010-05-18");
-    assertThat(date.getDate(), is(18));
+    assertThat(date.getDate()).isEqualTo(18);
   }
 
   @Test
@@ -65,7 +62,7 @@ public class DateUtilsTest {
   @Test
   public void parseDateTime_valid_format() {
     Date date = DateUtils.parseDateTime("2010-05-18T15:50:45+0100");
-    assertThat(date.getMinutes(), is(50));
+    assertThat(date.getMinutes()).isEqualTo(50);
   }
 
   @Test
@@ -82,42 +79,42 @@ public class DateUtilsTest {
 
   @Test
   public void parseDateTimeQuietly() {
-    assertNull(DateUtils.parseDateTimeQuietly("2010/05/18 10:55"));
+    assertThat(DateUtils.parseDateTimeQuietly("2010/05/18 10:55")).isNull();
     Date date = DateUtils.parseDateTimeQuietly("2010-05-18T15:50:45+0100");
-    assertThat(date.getMinutes(), is(50));
+    assertThat(date.getMinutes()).isEqualTo(50);
   }
 
   @Test
   public void shouldFormatDate() {
-    assertThat(DateUtils.formatDate(new Date()), startsWith("20"));
-    assertThat(DateUtils.formatDate(new Date()).length(), is(10));
+    assertThat(DateUtils.formatDate(new Date())).startsWith("20");
+    assertThat(DateUtils.formatDate(new Date()).length()).isEqualTo(10);
   }
 
   @Test
   public void shouldFormatDateTime() {
-    assertThat(DateUtils.formatDateTime(new Date()), startsWith("20"));
-    assertThat(DateUtils.formatDateTime(new Date()).length(), greaterThan(20));
+    assertThat(DateUtils.formatDateTime(new Date())).startsWith("20");
+    assertThat(DateUtils.formatDateTime(new Date()).length()).isGreaterThan(20);
   }
 
   @Test
   public void format_date_time_null_safe() {
-    Assertions.assertThat(DateUtils.formatDateTimeNullSafe(new Date())).startsWith("20");
-    Assertions.assertThat(DateUtils.formatDateTimeNullSafe(new Date()).length()).isGreaterThan(20);
-    Assertions.assertThat(DateUtils.formatDateTimeNullSafe(null)).isEmpty();
+    assertThat(DateUtils.formatDateTimeNullSafe(new Date())).startsWith("20");
+    assertThat(DateUtils.formatDateTimeNullSafe(new Date()).length()).isGreaterThan(20);
+    assertThat(DateUtils.formatDateTimeNullSafe(null)).isEmpty();
   }
 
   @Test
   public void long_to_date() {
     Date date = new Date();
-    Assertions.assertThat(DateUtils.longToDate(date.getTime())).isEqualTo(date);
-    Assertions.assertThat(DateUtils.longToDate(null)).isNull();
+    assertThat(DateUtils.longToDate(date.getTime())).isEqualTo(date);
+    assertThat(DateUtils.longToDate(null)).isNull();
   }
 
   @Test
   public void date_to_long() {
     Date date = new Date();
-    Assertions.assertThat(DateUtils.dateToLong(date)).isEqualTo(date.getTime());
-    Assertions.assertThat(DateUtils.dateToLong(null)).isEqualTo(null);
+    assertThat(DateUtils.dateToLong(date)).isEqualTo(date.getTime());
+    assertThat(DateUtils.dateToLong(null)).isEqualTo(null);
   }
 
   /**
@@ -155,7 +152,7 @@ public class DateUtilsTest {
             while (i < 1000 && !interrupted()) {
               String formatted = format.format(now);
               Thread.yield();
-              assertEquals(now, format.parse(formatted));
+              assertThat(now).isEqualTo(format.parse(formatted));
               ++i;
             }
           } catch (Exception e) {
@@ -193,7 +190,7 @@ public class DateUtilsTest {
       }
     }
 
-    assertThat(throwables.size(), is(0));
-    assertThat(counter[0], greaterThanOrEqualTo(threads.length));
+    assertThat(throwables).isEmpty();
+    assertThat(counter[0]).isGreaterThanOrEqualTo(threads.length);
   }
 }