From 8ae01aa5e760fe236fabe57d3e2ffa68dd66e786 Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Tue, 21 Nov 2017 14:47:15 +0100 Subject: [PATCH] SONAR-10087 Add built-in flag to provided quality gate --- .../ComputeEngineContainerImplTest.java | 2 +- .../org/sonar/db/version/schema-h2.ddl | 1 + .../sonar/db/qualitygate/QualityGateDto.java | 13 ++++- .../db/qualitygate/QualityGateMapper.xml | 6 +- .../db/qualitygate/QualityGateDaoTest.java | 33 +++++++---- .../db/qualitygate/QualityGateDbTester.java | 2 +- .../ProjectQgateAssociationDaoTest/shared.xml | 4 +- .../QualityGateDaoTest/delete-result.xml | 4 +- .../QualityGateDaoTest/insert-result.xml | 2 +- .../QualityGateDaoTest/selectAll.xml | 6 +- .../QualityGateDaoTest/update-result.xml | 6 +- .../MigrationConfigurationModule.java | 2 + .../v70/AddIsBuiltInToQualityGates.java | 45 +++++++++++++++ .../db/migration/version/v70/DbVersion70.java | 33 +++++++++++ .../migration/version/v70/package-info.java | 24 ++++++++ .../MigrationConfigurationModuleTest.java | 2 +- .../v70/AddIsBuiltInToQualityGatesTest.java | 56 +++++++++++++++++++ .../version/v70/DbVersion70Test.java | 41 ++++++++++++++ .../quality_gates_7_0.sql | 7 +++ .../qualitygate/RegisterQualityGates.java | 14 +++-- .../qualitygate/RegisterQualityGatesTest.java | 2 +- 21 files changed, 268 insertions(+), 37 deletions(-) create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/AddIsBuiltInToQualityGates.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/DbVersion70.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/package-info.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/AddIsBuiltInToQualityGatesTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/DbVersion70Test.java create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/AddIsBuiltInToQualityGatesTest/quality_gates_7_0.sql diff --git a/server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java b/server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java index c692eed52f4..950cbde71b7 100644 --- a/server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java +++ b/server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java @@ -109,8 +109,8 @@ public class ComputeEngineContainerImplTest { ); assertThat(picoContainer.getParent().getParent().getComponentAdapters()).hasSize( CONTAINER_ITSELF + + 14 // MigrationConfigurationModule + 17 // level 2 - + 13 // MigrationConfigurationModule ); assertThat(picoContainer.getParent().getParent().getParent().getComponentAdapters()).hasSize( COMPONENTS_IN_LEVEL_1_AT_CONSTRUCTION diff --git a/server/sonar-db-core/src/main/resources/org/sonar/db/version/schema-h2.ddl b/server/sonar-db-core/src/main/resources/org/sonar/db/version/schema-h2.ddl index f3bedc4ba6b..733e8d5f09d 100644 --- a/server/sonar-db-core/src/main/resources/org/sonar/db/version/schema-h2.ddl +++ b/server/sonar-db-core/src/main/resources/org/sonar/db/version/schema-h2.ddl @@ -229,6 +229,7 @@ CREATE UNIQUE INDEX "EVENTS_UUID" ON "EVENTS" ("UUID"); CREATE TABLE "QUALITY_GATES" ( "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), "NAME" VARCHAR(100) NOT NULL, + "IS_BUILT_IN" BOOLEAN NULL, "CREATED_AT" TIMESTAMP, "UPDATED_AT" TIMESTAMP, ); diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/qualitygate/QualityGateDto.java b/server/sonar-db-dao/src/main/java/org/sonar/db/qualitygate/QualityGateDto.java index 98832bbfaae..2e0d294825c 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/qualitygate/QualityGateDto.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/qualitygate/QualityGateDto.java @@ -27,11 +27,9 @@ import java.util.Date; public class QualityGateDto { private Long id; - private String name; - + private boolean isBuiltIn; private Date createdAt; - private Date updatedAt; public Long getId() { @@ -52,6 +50,15 @@ public class QualityGateDto { return this; } + public boolean isBuiltIn() { + return isBuiltIn; + } + + public QualityGateDto setBuiltIn(boolean builtIn) { + isBuiltIn = builtIn; + return this; + } + public Date getCreatedAt() { return createdAt; } diff --git a/server/sonar-db-dao/src/main/resources/org/sonar/db/qualitygate/QualityGateMapper.xml b/server/sonar-db-dao/src/main/resources/org/sonar/db/qualitygate/QualityGateMapper.xml index 0dfb59d5d08..290a4966886 100644 --- a/server/sonar-db-dao/src/main/resources/org/sonar/db/qualitygate/QualityGateMapper.xml +++ b/server/sonar-db-dao/src/main/resources/org/sonar/db/qualitygate/QualityGateMapper.xml @@ -4,12 +4,12 @@ - insert into quality_gates (name, created_at, updated_at) - values (#{name}, #{createdAt}, #{updatedAt}) + insert into quality_gates (name, is_built_in, created_at, updated_at) + values (#{name}, #{isBuiltIn}, #{createdAt}, #{updatedAt}) - id, name, created_at as createdAt, updated_at as updatedAt + id, name, is_built_in as isBuiltIn, created_at as createdAt, updated_at as updatedAt