diff options
author | Teryk Bellahsene <teryk.bellahsene@sonarsource.com> | 2015-07-23 12:03:23 +0200 |
---|---|---|
committer | Teryk Bellahsene <teryk.bellahsene@sonarsource.com> | 2015-07-23 12:03:23 +0200 |
commit | d55de7dbda057f2aeb56d9d1b047da65510bd7c3 (patch) | |
tree | d1788cbbe970a499b3b4d23743735f1287c542c0 /sonar-db/src | |
parent | 5e13c8df30ee8f5ae8c58cde1a3d6b8b5510b3ed (diff) | |
download | sonarqube-d55de7dbda057f2aeb56d9d1b047da65510bd7c3.tar.gz sonarqube-d55de7dbda057f2aeb56d9d1b047da65510bd7c3.zip |
Replace DaoUtils by DaoModule
Diffstat (limited to 'sonar-db/src')
-rw-r--r-- | sonar-db/src/main/java/org/sonar/db/DaoModule.java (renamed from sonar-db/src/main/java/org/sonar/db/DaoUtils.java) | 103 | ||||
-rw-r--r-- | sonar-db/src/test/java/org/sonar/db/DaoModuleTest.java (renamed from sonar-db/src/test/java/org/sonar/db/DaoUtilsTest.java) | 11 | ||||
-rw-r--r-- | sonar-db/src/test/java/org/sonar/db/DbTester.java | 2 |
3 files changed, 61 insertions, 55 deletions
diff --git a/sonar-db/src/main/java/org/sonar/db/DaoUtils.java b/sonar-db/src/main/java/org/sonar/db/DaoModule.java index e0f02da0fa3..6300c253adf 100644 --- a/sonar-db/src/main/java/org/sonar/db/DaoUtils.java +++ b/sonar-db/src/main/java/org/sonar/db/DaoModule.java @@ -17,10 +17,12 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + package org.sonar.db; -import java.util.Arrays; +import com.google.common.collect.ImmutableList; import java.util.List; +import org.sonar.core.platform.Module; import org.sonar.db.activity.ActivityDao; import org.sonar.db.component.ComponentDao; import org.sonar.db.component.ComponentLinkDao; @@ -65,57 +67,58 @@ import org.sonar.db.user.RoleDao; import org.sonar.db.user.UserDao; import org.sonar.db.user.UserGroupDao; -public final class DaoUtils { +public class DaoModule extends Module { + private static final List<Class<? extends Dao>> classes = ImmutableList.<Class<? extends Dao>>builder().add( + ActionPlanDao.class, + ActionPlanStatsDao.class, + ActiveDashboardDao.class, + ActivityDao.class, + AnalysisReportDao.class, + AuthorDao.class, + AuthorizationDao.class, + ComponentDao.class, + ComponentLinkDao.class, + CustomMeasureDao.class, + DashboardDao.class, + DuplicationDao.class, + EventDao.class, + FileSourceDao.class, + GroupDao.class, + GroupMembershipDao.class, + IssueDao.class, + IssueChangeDao.class, + IssueFilterDao.class, + IssueFilterFavouriteDao.class, + LoadedTemplateDao.class, + MeasureDao.class, + MeasureFilterDao.class, + MetricDao.class, + NotificationQueueDao.class, + PermissionDao.class, + PermissionTemplateDao.class, + PropertiesDao.class, + QualityGateDao.class, + QualityGateConditionDao.class, + ProjectQgateAssociationDao.class, + QualityProfileDao.class, + PurgeDao.class, + CharacteristicDao.class, + ResourceIndexDao.class, + ResourceDao.class, + ResourceKeyUpdaterDao.class, + RoleDao.class, + SnapshotDao.class, + UserDao.class, + UserGroupDao.class, + WidgetDao.class, + WidgetPropertyDao.class).build(); - private DaoUtils() { - // only static stuff + @Override + protected void configureModule() { + add(classes.toArray()); } - public static List<Class<? extends Dao>> getDaoClasses() { - return Arrays.asList( - ActionPlanDao.class, - ActionPlanStatsDao.class, - ActiveDashboardDao.class, - ActivityDao.class, - AnalysisReportDao.class, - AuthorDao.class, - AuthorizationDao.class, - ComponentDao.class, - ComponentLinkDao.class, - CustomMeasureDao.class, - DashboardDao.class, - DuplicationDao.class, - EventDao.class, - FileSourceDao.class, - GroupDao.class, - GroupMembershipDao.class, - IssueDao.class, - IssueChangeDao.class, - IssueFilterDao.class, - IssueFilterFavouriteDao.class, - LoadedTemplateDao.class, - MeasureDao.class, - MeasureFilterDao.class, - MetricDao.class, - NotificationQueueDao.class, - PermissionDao.class, - PermissionTemplateDao.class, - PropertiesDao.class, - QualityGateDao.class, - QualityGateConditionDao.class, - ProjectQgateAssociationDao.class, - QualityProfileDao.class, - PurgeDao.class, - CharacteristicDao.class, - ResourceIndexDao.class, - ResourceDao.class, - ResourceKeyUpdaterDao.class, - RoleDao.class, - SnapshotDao.class, - UserDao.class, - UserGroupDao.class, - WidgetDao.class, - WidgetPropertyDao.class - ); + public static List<Class<? extends Dao>> classes() { + return classes; } } diff --git a/sonar-db/src/test/java/org/sonar/db/DaoUtilsTest.java b/sonar-db/src/test/java/org/sonar/db/DaoModuleTest.java index fc7c4b1ef80..a99a08aa856 100644 --- a/sonar-db/src/test/java/org/sonar/db/DaoUtilsTest.java +++ b/sonar-db/src/test/java/org/sonar/db/DaoModuleTest.java @@ -17,16 +17,19 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + package org.sonar.db; import org.junit.Test; +import org.sonar.core.platform.ComponentContainer; import static org.assertj.core.api.Assertions.assertThat; -public class DaoUtilsTest { - +public class DaoModuleTest { @Test - public void list_all_dao_classes() { - assertThat(DaoUtils.getDaoClasses()).isNotEmpty(); + public void verify_count_of_added_components() { + ComponentContainer container = new ComponentContainer(); + new DaoModule().configure(container); + assertThat(container.size()).isEqualTo(45); } } diff --git a/sonar-db/src/test/java/org/sonar/db/DbTester.java b/sonar-db/src/test/java/org/sonar/db/DbTester.java index 41d1ea5623a..80728e04727 100644 --- a/sonar-db/src/test/java/org/sonar/db/DbTester.java +++ b/sonar-db/src/test/java/org/sonar/db/DbTester.java @@ -118,7 +118,7 @@ public class DbTester extends ExternalResource { TransientPicoContainer ioc = new TransientPicoContainer(); ioc.addComponent(db.getMyBatis()); ioc.addComponent(system2); - for (Class daoClass : DaoUtils.getDaoClasses()) { + for (Class daoClass : DaoModule.classes()) { ioc.addComponent(daoClass); } List<Dao> daos = ioc.getComponents(Dao.class); |