assertThat(picoContainer.getParent().getParent().getParent().getComponentAdapters()).hasSize(
COMPONENTS_IN_LEVEL_1_AT_CONSTRUCTION
+ 26 // level 1
- + 52 // content of DaoModule
+ + 51 // content of DaoModule
+ 3 // content of EsSearchModule
+ 67 // content of CorePropertyDefinitions
+ 1 // StopFlagContainer
"dashboards",
"issue_filters",
"issue_filter_favourites",
+ "loaded_templates",
"measure_filters",
"measure_filter_favourites",
"resource_index",
"internal_properties",
"issues",
"issue_changes",
- "loaded_templates",
"manual_measures",
"metrics",
"notifications",
CREATE UNIQUE INDEX "METRICS_UNIQUE_NAME" ON "METRICS" ("NAME");
-CREATE TABLE "LOADED_TEMPLATES" (
- "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
- "KEE" VARCHAR(200),
- "TEMPLATE_TYPE" VARCHAR(64) NOT NULL
-);
-CREATE INDEX "IX_LOADED_TEMPLATES_TYPE" ON "LOADED_TEMPLATES" ("TEMPLATE_TYPE");
-
-
CREATE TABLE "ISSUES" (
"ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
"KEE" VARCHAR(50) UNIQUE NOT NULL,
import org.sonar.db.event.EventDao;
import org.sonar.db.issue.IssueChangeDao;
import org.sonar.db.issue.IssueDao;
-import org.sonar.db.loadedtemplate.LoadedTemplateDao;
import org.sonar.db.measure.MeasureDao;
import org.sonar.db.measure.custom.CustomMeasureDao;
import org.sonar.db.metric.MetricDao;
InternalPropertiesDao.class,
IssueChangeDao.class,
IssueDao.class,
- LoadedTemplateDao.class,
MeasureDao.class,
MetricDao.class,
NotificationQueueDao.class,
UserGroupDao.class,
UserPermissionDao.class,
UserTokenDao.class,
- WebhookDeliveryDao.class)
- );
+ WebhookDeliveryDao.class));
@Override
protected void configureModule() {
import org.sonar.db.event.EventDao;
import org.sonar.db.issue.IssueChangeDao;
import org.sonar.db.issue.IssueDao;
-import org.sonar.db.loadedtemplate.LoadedTemplateDao;
import org.sonar.db.measure.MeasureDao;
import org.sonar.db.measure.custom.CustomMeasureDao;
import org.sonar.db.metric.MetricDao;
private final OrganizationDao organizationDao;
private final OrganizationMemberDao organizationMemberDao;
private final QualityProfileDao qualityProfileDao;
- private final LoadedTemplateDao loadedTemplateDao;
private final PropertiesDao propertiesDao;
private final InternalPropertiesDao internalPropertiesDao;
private final SnapshotDao snapshotDao;
organizationDao = getDao(map, OrganizationDao.class);
organizationMemberDao = getDao(map, OrganizationMemberDao.class);
qualityProfileDao = getDao(map, QualityProfileDao.class);
- loadedTemplateDao = getDao(map, LoadedTemplateDao.class);
propertiesDao = getDao(map, PropertiesDao.class);
internalPropertiesDao = getDao(map, InternalPropertiesDao.class);
snapshotDao = getDao(map, SnapshotDao.class);
return qualityProfileDao;
}
- public LoadedTemplateDao loadedTemplateDao() {
- return loadedTemplateDao;
- }
-
public PropertiesDao propertiesDao() {
return propertiesDao;
}
import org.sonar.db.issue.IssueDto;
import org.sonar.db.issue.IssueMapper;
import org.sonar.db.issue.ShortBranchIssueDto;
-import org.sonar.db.loadedtemplate.LoadedTemplateDto;
-import org.sonar.db.loadedtemplate.LoadedTemplateMapper;
import org.sonar.db.measure.MeasureDto;
import org.sonar.db.measure.MeasureMapper;
import org.sonar.db.measure.custom.CustomMeasureDto;
confBuilder.loadAlias("KeyLongValue", KeyLongValue.class);
confBuilder.loadAlias("Issue", IssueDto.class);
confBuilder.loadAlias("ShortBranchIssue", ShortBranchIssueDto.class);
- confBuilder.loadAlias("LoadedTemplate", LoadedTemplateDto.class);
confBuilder.loadAlias("Measure", MeasureDto.class);
confBuilder.loadAlias("NotificationQueue", NotificationQueueDto.class);
confBuilder.loadAlias("Organization", OrganizationDto.class);
IsAliveMapper.class,
IssueChangeMapper.class,
IssueMapper.class,
- LoadedTemplateMapper.class,
MeasureMapper.class,
MetricMapper.class,
NotificationQueueMapper.class,
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * 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.loadedtemplate;
-
-import org.sonar.db.Dao;
-import org.sonar.db.DbSession;
-
-public class LoadedTemplateDao implements Dao {
-
- public int countByTypeAndKey(String type, String key, DbSession session) {
- return session.getMapper(LoadedTemplateMapper.class).countByTypeAndKey(type, key);
- }
-
- public void insert(LoadedTemplateDto loadedTemplateDto, DbSession session) {
- session.getMapper(LoadedTemplateMapper.class).insert(loadedTemplateDto);
- }
-
- public void delete(DbSession session, String type, String key) {
- session.getMapper(LoadedTemplateMapper.class).delete(type, key);
- }
-}
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * 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.loadedtemplate;
-
-import java.util.Objects;
-
-public final class LoadedTemplateDto {
-
- public static final String ONE_SHOT_TASK_TYPE = "ONE_SHOT_TASK";
-
- private Long id;
- private String key;
- private String type;
-
- public LoadedTemplateDto() {
- }
-
- public LoadedTemplateDto(String key, String type) {
- this.key = key;
- this.type = type;
- }
-
- public Long getId() {
- return id;
- }
-
- public LoadedTemplateDto setId(Long l) {
- this.id = l;
- return this;
- }
-
- public String getKey() {
- return key;
- }
-
- public LoadedTemplateDto setKey(String key) {
- this.key = key;
- return this;
- }
-
- public String getType() {
- return type;
- }
-
- public LoadedTemplateDto setType(String type) {
- this.type = type;
- return this;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- LoadedTemplateDto other = (LoadedTemplateDto) o;
- return Objects.equals(id, other.id) && Objects.equals(key, other.key) && Objects.equals(type, other.type);
- }
-
- @Override
- public int hashCode() {
- return id != null ? id.hashCode() : 0;
- }
-}
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * 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.loadedtemplate;
-
-import org.apache.ibatis.annotations.Param;
-
-public interface LoadedTemplateMapper {
-
- int countByTypeAndKey(@Param("type") String type, @Param("key") String key);
-
- void insert(LoadedTemplateDto template);
-
- void delete(@Param("type") String type, @Param("key") String key);
-}
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-@ParametersAreNonnullByDefault
-package org.sonar.db.loadedtemplate;
-
-import javax.annotation.ParametersAreNonnullByDefault;
-
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "mybatis-3-mapper.dtd">
-
-<mapper namespace="org.sonar.db.loadedtemplate.LoadedTemplateMapper">
-
- <resultMap id="loadedTemplateResultMap" type="LoadedTemplate">
- <result property="id" column="id"/>
- <result property="key" column="kee"/>
- <result property="type" column="template_type"/>
- </resultMap>
-
- <select id="countByTypeAndKey" parameterType="map" resultType="int">
- SELECT count(1)
- FROM loaded_templates
- WHERE kee = #{key} AND template_type = #{type}
- </select>
-
- <insert id="insert" parameterType="LoadedTemplate" keyColumn="id" useGeneratedKeys="true" keyProperty="id">
- INSERT INTO loaded_templates (kee, template_type)
- VALUES (#{key}, #{type})
- </insert>
-
- <delete id="delete" parameterType="map">
- delete from loaded_templates where kee = #{key} AND template_type = #{type}
- </delete>
-</mapper>
public void verify_count_of_added_components() {
ComponentContainer container = new ComponentContainer();
new DaoModule().configure(container);
- assertThat(container.size()).isEqualTo(COMPONENTS_IN_EMPTY_COMPONENT_CONTAINER + 52);
+ assertThat(container.size()).isEqualTo(COMPONENTS_IN_EMPTY_COMPONENT_CONTAINER + 51);
}
}
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * 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.loadedtemplate;
-
-import org.junit.Rule;
-import org.junit.Test;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbSession;
-import org.sonar.db.DbTester;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class LoadedTemplateDaoTest {
-
- @Rule
- public DbTester dbTester = DbTester.create(System2.INSTANCE);
-
- private LoadedTemplateDao underTest = dbTester.getDbClient().loadedTemplateDao();
- private DbSession dbSession = dbTester.getSession();
-
- @Test
- public void shouldCountByTypeAndKey() {
- dbTester.prepareDbUnit(getClass(), "shouldCountByTypeAndKey.xml");
-
- assertThat(underTest.countByTypeAndKey("DASHBOARD", "HOTSPOTS", dbSession)).isEqualTo(1);
- assertThat(underTest.countByTypeAndKey("DASHBOARD", "UNKNOWN", dbSession)).isEqualTo(0);
- assertThat(underTest.countByTypeAndKey("PROFILE", "HOTSPOTS", dbSession)).isEqualTo(0);
- }
-
- @Test
- public void shouldInsert() {
- dbTester.prepareDbUnit(getClass(), "shouldInsert.xml");
-
- LoadedTemplateDto template = new LoadedTemplateDto("SQALE", "DASHBOARD");
- underTest.insert(template, dbSession);
- dbSession.commit();
-
- dbTester.assertDbUnit(getClass(), "shouldInsert-result.xml", "loaded_templates");
- }
-}
+++ /dev/null
-<dataset>
-
- <loaded_templates
- id="1"
- kee="HOTSPOTS"
- template_type="DASHBOARD"/>
-
-</dataset>
+++ /dev/null
-<dataset>
-
- <loaded_templates
- id="1"
- kee="SQALE"
- template_type="DASHBOARD"/>
-
-</dataset>
+++ /dev/null
-<dataset>
-
-</dataset>