]> source.dussan.org Git - sonarqube.git/commitdiff
Remove useless constructors with System2.INSTANCE
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Mon, 30 Jun 2014 13:17:42 +0000 (15:17 +0200)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Mon, 30 Jun 2014 13:59:45 +0000 (15:59 +0200)
sonar-plugin-api/src/main/java/org/sonar/api/profiles/RulesProfile.java
sonar-server/src/main/java/org/sonar/server/activity/db/ActivityDao.java
sonar-server/src/main/java/org/sonar/server/component/persistence/ComponentDao.java
sonar-server/src/main/java/org/sonar/server/db/migrations/v43/IssueChangelogMigration.java
sonar-server/src/main/java/org/sonar/server/db/migrations/v43/NotResolvedIssuesOnRemovedComponentsMigration.java
sonar-server/src/test/java/org/sonar/server/db/DbClientTest.java
sonar-server/src/test/java/org/sonar/server/db/migrations/v43/IssueChangelogMigrationTest.java
sonar-server/src/test/java/org/sonar/server/measure/persistence/MeasureDaoTest.java
sonar-server/src/test/java/org/sonar/server/rule/RegisterRulesMediumTest.java
sonar-server/src/test/java/org/sonar/server/rule/RuleOperationsTest.java

index 64f9ea92ab76d4441bc143d868bb844b0efda34d..1847682f73675c786caca21ef6c2188216f1918e 100644 (file)
@@ -64,10 +64,8 @@ public class RulesProfile implements Cloneable {
   @Deprecated
   public static final String SUN_CONVENTIONS_NAME = "Sun checks";
 
-  private Integer id;
   private String name;
   private Boolean defaultProfile = Boolean.FALSE;
-  private Boolean used = Boolean.FALSE;
   private String language;
   private String parentName;
   private List<ActiveRule> activeRules = Lists.newArrayList();
@@ -99,7 +97,7 @@ public class RulesProfile implements Cloneable {
   }
 
   public Integer getId() {
-    return id;
+    return null;
   }
 
   /**
@@ -139,7 +137,7 @@ public class RulesProfile implements Cloneable {
    */
   @Deprecated
   public Boolean getUsed() {
-    return used;
+    return null;
   }
 
   /**
@@ -147,7 +145,6 @@ public class RulesProfile implements Cloneable {
    */
   @Deprecated
   public RulesProfile setUsed(Boolean used) {
-    this.used = used;
     return this;
   }
 
index 0049e3468e49cd93301e1d99fa0ddf16bc1281ae..5800f7d698c3cfee5a43557709ba7276bcdf85e3 100644 (file)
@@ -19,7 +19,6 @@
  */
 package org.sonar.server.activity.db;
 
-import com.google.common.annotations.VisibleForTesting;
 import org.sonar.api.utils.System2;
 import org.sonar.core.activity.db.ActivityDto;
 import org.sonar.core.activity.db.ActivityMapper;
@@ -37,11 +36,6 @@ import java.util.List;
  */
 public class ActivityDao extends BaseDao<ActivityMapper, ActivityDto, String> {
 
-  public ActivityDao() {
-    this(System2.INSTANCE);
-  }
-
-  @VisibleForTesting
   public ActivityDao(System2 system) {
     super(IndexDefinition.LOG, ActivityMapper.class, system);
   }
@@ -59,7 +53,7 @@ public class ActivityDao extends BaseDao<ActivityMapper, ActivityDto, String> {
 
   @Override
   protected ActivityDto doUpdate(DbSession session, ActivityDto item) {
-   throw new IllegalStateException("Cannot update Log!");
+    throw new IllegalStateException("Cannot update Log!");
   }
 
   @Override
@@ -73,7 +67,7 @@ public class ActivityDao extends BaseDao<ActivityMapper, ActivityDto, String> {
 
   @Override
   public void synchronizeAfter(DbSession session, Date time) {
-    for(ActivityDto activity:this.findAll(session)){
+    for (ActivityDto activity : this.findAll(session)) {
       session.enqueue(new DtoIndexAction<ActivityDto>(this.getIndexType(), IndexAction.Method.UPSERT, activity));
     }
     session.commit();
index d6618173c35ebea777f27902b8300ea7e89f1991..940bd4d344e74931629fd6239a39a360bf380d8e 100644 (file)
@@ -19,7 +19,6 @@
  */
 package org.sonar.server.component.persistence;
 
-import com.google.common.annotations.VisibleForTesting;
 import org.apache.ibatis.session.SqlSession;
 import org.sonar.api.ServerComponent;
 import org.sonar.api.utils.System2;
@@ -36,11 +35,6 @@ import java.util.Date;
  */
 public class ComponentDao extends BaseDao<ComponentMapper, ComponentDto, String> implements ServerComponent, DaoComponent {
 
-  public ComponentDao() {
-    this(System2.INSTANCE);
-  }
-
-  @VisibleForTesting
   public ComponentDao(System2 system) {
     super(ComponentMapper.class, system);
   }
index ad2b816aec14d804530b8dfab1230e4da3128437..ef8ae771dfab2173e034b19e77c5c4b26c100478 100644 (file)
@@ -46,12 +46,12 @@ public class IssueChangelogMigration implements DatabaseMigration {
   private final System2 system2;
   private final Database db;
 
-  public IssueChangelogMigration(Database database, PropertiesDao propertiesDao) {
-    this(database, new WorkDurationConvertor(propertiesDao), System2.INSTANCE);
+  public IssueChangelogMigration(Database database, System2 system2, PropertiesDao propertiesDao) {
+    this(database, system2, new WorkDurationConvertor(propertiesDao));
   }
 
   @VisibleForTesting
-  IssueChangelogMigration(Database database, WorkDurationConvertor convertor, System2 system2) {
+  IssueChangelogMigration(Database database, System2 system2, WorkDurationConvertor convertor) {
     this.db = database;
     this.workDurationConvertor = convertor;
     this.system2 = system2;
index cfd9cc707b20267a76302f12191c66080546a859..a06d94615fd32b04e5e645464ed5c86a37bdf9c0 100644 (file)
@@ -43,12 +43,7 @@ public class NotResolvedIssuesOnRemovedComponentsMigration implements DatabaseMi
   private final System2 system2;
   private final Database db;
 
-  public NotResolvedIssuesOnRemovedComponentsMigration(Database database) {
-    this(database, System2.INSTANCE);
-  }
-
-  @VisibleForTesting
-  NotResolvedIssuesOnRemovedComponentsMigration(Database database, System2 system2) {
+  public NotResolvedIssuesOnRemovedComponentsMigration(Database database, System2 system2) {
     this.db = database;
     this.system2 = system2;
   }
index 4aa9465b4f5123ec7bc5cbd12acdc229dd97e014..a6e3c3713d52aae7a11ced05b492563f7aaf8550 100644 (file)
@@ -39,9 +39,9 @@ public class DbClientTest {
   @Test
   public void facade() throws Exception {
     MyBatis myBatis = db.myBatis();
-    RuleDao ruleDao = new RuleDao();
+    RuleDao ruleDao = new RuleDao(System2.INSTANCE);
     QualityProfileDao qualityProfileDao = new QualityProfileDao(myBatis, System2.INSTANCE);
-    ActiveRuleDao activeRuleDao = new ActiveRuleDao(qualityProfileDao, ruleDao);
+    ActiveRuleDao activeRuleDao = new ActiveRuleDao(qualityProfileDao, ruleDao, System2.INSTANCE);
 
     DbClient client = new DbClient(db.database(), myBatis, ruleDao, activeRuleDao, qualityProfileDao);
 
index f55925542b6da7216824c5e4aff193bc1a62cea5..931bc6a12f01d1fcafef6c50eefcd568c7ce451e 100644 (file)
@@ -56,7 +56,7 @@ public class IssueChangelogMigrationTest {
 
     WorkDurationConvertor convertor = new WorkDurationConvertor(propertiesDao);
     convertor.init();
-    migration = new IssueChangelogMigration(db.database(), convertor, system2);
+    migration = new IssueChangelogMigration(db.database(), system2, convertor);
   }
 
   @Test
index be4b2e00ed8f94d91116b831863ab86bc906b595..c6c2027e46c580dafff7b588c52da6bac5bcfc47 100644 (file)
@@ -23,6 +23,7 @@ package org.sonar.server.measure.persistence;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
+import org.sonar.api.utils.System2;
 import org.sonar.core.measure.db.MeasureDto;
 import org.sonar.core.measure.db.MeasureKey;
 import org.sonar.core.persistence.AbstractDaoTestCase;
@@ -42,7 +43,7 @@ public class MeasureDaoTest extends AbstractDaoTestCase {
   @Before
   public void createDao() {
     session = getMyBatis().openSession(false);
-    dao = new MeasureDao();
+    dao = new MeasureDao(System2.INSTANCE);
   }
 
   @After
index 416606b49cdd60da8b1e0bb70d98605456720ee7..ab9df337f33b39850696c89bf0460e006ed80df6 100644 (file)
@@ -21,6 +21,7 @@
 package org.sonar.server.rule;
 
 import com.google.common.collect.ImmutableMap;
+import org.apache.commons.lang.time.DateUtils;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.ClassRule;
@@ -189,7 +190,7 @@ public class RegisterRulesMediumTest {
 
     // Verify rule has not been updated
     Rule customRuleReloaded = index.getByKey(RuleTesting.XOO_X1);
-    assertThat(customRuleReloaded.updatedAt()).isEqualTo(updatedAt);
+    assertThat(DateUtils.isSameInstant(customRuleReloaded.updatedAt(), updatedAt));
   }
 
   @Test
index f7b8b8070ac58b69caa76eb8eb47fd0c7e361f5a..b11dcc0f29d12764f5d6cef49a260b9e36b7b7f0 100644 (file)
@@ -28,6 +28,7 @@ import org.mockito.Captor;
 import org.mockito.Mock;
 import org.mockito.runners.MockitoJUnitRunner;
 import org.sonar.api.rule.RuleKey;
+import org.sonar.api.utils.System2;
 import org.sonar.core.permission.GlobalPermissions;
 import org.sonar.core.persistence.DbSession;
 import org.sonar.core.rule.RuleDto;
@@ -73,7 +74,7 @@ public class RuleOperationsTest {
     when(dbClient.openSession(false)).thenReturn(session);
     when(dbClient.ruleDao()).thenReturn(ruleDao);
     when(dbClient.debtCharacteristicDao()).thenReturn(characteristicDao);
-    operations = new RuleOperations(dbClient);
+    operations = new RuleOperations(dbClient, System2.INSTANCE);
   }
 
   @Test