summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2014-06-30 15:17:42 +0200
committerSimon Brandhof <simon.brandhof@sonarsource.com>2014-06-30 15:59:45 +0200
commit12fac031dc2702e565f33254593d32bfce29faa1 (patch)
tree15854378508ab0ce9b3fe01ddc3eafe0ab63e3b3
parentae4c7b72d7d9b64a970bad102606b398e61b2243 (diff)
downloadsonarqube-12fac031dc2702e565f33254593d32bfce29faa1.tar.gz
sonarqube-12fac031dc2702e565f33254593d32bfce29faa1.zip
Remove useless constructors with System2.INSTANCE
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/profiles/RulesProfile.java7
-rw-r--r--sonar-server/src/main/java/org/sonar/server/activity/db/ActivityDao.java10
-rw-r--r--sonar-server/src/main/java/org/sonar/server/component/persistence/ComponentDao.java6
-rw-r--r--sonar-server/src/main/java/org/sonar/server/db/migrations/v43/IssueChangelogMigration.java6
-rw-r--r--sonar-server/src/main/java/org/sonar/server/db/migrations/v43/NotResolvedIssuesOnRemovedComponentsMigration.java7
-rw-r--r--sonar-server/src/test/java/org/sonar/server/db/DbClientTest.java4
-rw-r--r--sonar-server/src/test/java/org/sonar/server/db/migrations/v43/IssueChangelogMigrationTest.java2
-rw-r--r--sonar-server/src/test/java/org/sonar/server/measure/persistence/MeasureDaoTest.java3
-rw-r--r--sonar-server/src/test/java/org/sonar/server/rule/RegisterRulesMediumTest.java3
-rw-r--r--sonar-server/src/test/java/org/sonar/server/rule/RuleOperationsTest.java3
10 files changed, 17 insertions, 34 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/profiles/RulesProfile.java b/sonar-plugin-api/src/main/java/org/sonar/api/profiles/RulesProfile.java
index 64f9ea92ab7..1847682f736 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/profiles/RulesProfile.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/profiles/RulesProfile.java
@@ -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;
}
diff --git a/sonar-server/src/main/java/org/sonar/server/activity/db/ActivityDao.java b/sonar-server/src/main/java/org/sonar/server/activity/db/ActivityDao.java
index 0049e3468e4..5800f7d698c 100644
--- a/sonar-server/src/main/java/org/sonar/server/activity/db/ActivityDao.java
+++ b/sonar-server/src/main/java/org/sonar/server/activity/db/ActivityDao.java
@@ -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();
diff --git a/sonar-server/src/main/java/org/sonar/server/component/persistence/ComponentDao.java b/sonar-server/src/main/java/org/sonar/server/component/persistence/ComponentDao.java
index d6618173c35..940bd4d344e 100644
--- a/sonar-server/src/main/java/org/sonar/server/component/persistence/ComponentDao.java
+++ b/sonar-server/src/main/java/org/sonar/server/component/persistence/ComponentDao.java
@@ -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);
}
diff --git a/sonar-server/src/main/java/org/sonar/server/db/migrations/v43/IssueChangelogMigration.java b/sonar-server/src/main/java/org/sonar/server/db/migrations/v43/IssueChangelogMigration.java
index ad2b816aec1..ef8ae771dfa 100644
--- a/sonar-server/src/main/java/org/sonar/server/db/migrations/v43/IssueChangelogMigration.java
+++ b/sonar-server/src/main/java/org/sonar/server/db/migrations/v43/IssueChangelogMigration.java
@@ -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;
diff --git a/sonar-server/src/main/java/org/sonar/server/db/migrations/v43/NotResolvedIssuesOnRemovedComponentsMigration.java b/sonar-server/src/main/java/org/sonar/server/db/migrations/v43/NotResolvedIssuesOnRemovedComponentsMigration.java
index cfd9cc707b2..a06d94615fd 100644
--- a/sonar-server/src/main/java/org/sonar/server/db/migrations/v43/NotResolvedIssuesOnRemovedComponentsMigration.java
+++ b/sonar-server/src/main/java/org/sonar/server/db/migrations/v43/NotResolvedIssuesOnRemovedComponentsMigration.java
@@ -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;
}
diff --git a/sonar-server/src/test/java/org/sonar/server/db/DbClientTest.java b/sonar-server/src/test/java/org/sonar/server/db/DbClientTest.java
index 4aa9465b4f5..a6e3c3713d5 100644
--- a/sonar-server/src/test/java/org/sonar/server/db/DbClientTest.java
+++ b/sonar-server/src/test/java/org/sonar/server/db/DbClientTest.java
@@ -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);
diff --git a/sonar-server/src/test/java/org/sonar/server/db/migrations/v43/IssueChangelogMigrationTest.java b/sonar-server/src/test/java/org/sonar/server/db/migrations/v43/IssueChangelogMigrationTest.java
index f55925542b6..931bc6a12f0 100644
--- a/sonar-server/src/test/java/org/sonar/server/db/migrations/v43/IssueChangelogMigrationTest.java
+++ b/sonar-server/src/test/java/org/sonar/server/db/migrations/v43/IssueChangelogMigrationTest.java
@@ -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
diff --git a/sonar-server/src/test/java/org/sonar/server/measure/persistence/MeasureDaoTest.java b/sonar-server/src/test/java/org/sonar/server/measure/persistence/MeasureDaoTest.java
index be4b2e00ed8..c6c2027e46c 100644
--- a/sonar-server/src/test/java/org/sonar/server/measure/persistence/MeasureDaoTest.java
+++ b/sonar-server/src/test/java/org/sonar/server/measure/persistence/MeasureDaoTest.java
@@ -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
diff --git a/sonar-server/src/test/java/org/sonar/server/rule/RegisterRulesMediumTest.java b/sonar-server/src/test/java/org/sonar/server/rule/RegisterRulesMediumTest.java
index 416606b49cd..ab9df337f33 100644
--- a/sonar-server/src/test/java/org/sonar/server/rule/RegisterRulesMediumTest.java
+++ b/sonar-server/src/test/java/org/sonar/server/rule/RegisterRulesMediumTest.java
@@ -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
diff --git a/sonar-server/src/test/java/org/sonar/server/rule/RuleOperationsTest.java b/sonar-server/src/test/java/org/sonar/server/rule/RuleOperationsTest.java
index f7b8b8070ac..b11dcc0f29d 100644
--- a/sonar-server/src/test/java/org/sonar/server/rule/RuleOperationsTest.java
+++ b/sonar-server/src/test/java/org/sonar/server/rule/RuleOperationsTest.java
@@ -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