INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1600');
INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1601');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1602');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1603');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1604');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1605');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1606');
INSERT INTO USERS(ID, LOGIN, NAME, EMAIL, EXTERNAL_IDENTITY, EXTERNAL_IDENTITY_PROVIDER, USER_LOCAL, CRYPTED_PASSWORD, SALT, IS_ROOT, CREATED_AT, UPDATED_AT) VALUES (1, 'admin', 'Administrator', '', 'admin', 'sonarqube', true, 'a373a0e667abb2604c1fd571eb4ad47fe8cc0878', '48bc4b0d93179b5103fd3885ea9119498e9d161b', false, '1418215735482', '1418215735482');
ALTER TABLE USERS ALTER COLUMN ID RESTART WITH 2;
"ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
"NAME" VARCHAR(100) NOT NULL,
"LANGUAGE" VARCHAR(20),
+ "ORGANIZATION_UUID" VARCHAR(40) NOT NULL,
"KEE" VARCHAR(255) NOT NULL,
"PARENT_KEE" VARCHAR(255),
"RULES_UPDATED_AT" VARCHAR(100),
"LAST_USED" BIGINT,
"USER_UPDATED_AT" BIGINT
);
-CREATE UNIQUE INDEX "UNIQ_QPROF_KEY" ON "RULES_PROFILES" ("KEE");
+CREATE UNIQUE INDEX "UNIQ_QPROF_ORG_AND_KEY" ON "RULES_PROFILES" ("ORGANIZATION_UUID", "KEE");
CREATE TABLE "PROJECT_QPROFILES" (
import javax.annotation.Nullable;
import org.sonar.core.util.UtcDateUtils;
import org.sonar.db.Dto;
+import org.sonar.db.organization.OrganizationDto;
public class QualityProfileDto extends Dto<String> {
private Integer id;
+ /**
+ * The organization, that this quality profile belongs to.
+ * Must not be null, but can be the default organization's uuid.
+ * Refers to {@link OrganizationDto#getUuid()}.
+ */
+ private String organizationUuid;
private String kee;
private String name;
private String language;
}
+ public String getOrganizationUuid() {
+ return organizationUuid;
+ }
+
+ public QualityProfileDto setOrganizationUuid(String organizationUuid) {
+ this.organizationUuid = organizationUuid;
+ return this;
+ }
+
@Override
public String getKey() {
return kee;
<sql id="profilesColumns">
p.id as id,
+ p.organization_uuid as organizationUuid,
p.kee as kee,
p.name as name,
p.language as language,
</sql>
<insert id="insert" parameterType="QualityProfile" keyColumn="id" useGeneratedKeys="true" keyProperty="id">
- INSERT INTO rules_profiles (kee, parent_kee, name, language, is_default, created_at, updated_at, rules_updated_at, last_used, user_updated_at)
+ INSERT INTO rules_profiles (organization_uuid, kee, parent_kee, name, language, is_default, created_at, updated_at, rules_updated_at, last_used, user_updated_at)
VALUES (
+ #{organizationUuid, jdbcType=VARCHAR},
#{kee, jdbcType=VARCHAR},
#{parentKee, jdbcType=VARCHAR},
#{name, jdbcType=VARCHAR},
import org.sonar.db.DbSession;
import org.sonar.db.DbTester;
import org.sonar.db.RowNotFoundException;
+import org.sonar.db.organization.OrganizationDto;
+import org.sonar.db.organization.OrganizationTesting;
import org.sonar.db.rule.RuleDto;
import org.sonar.db.rule.RuleParamDto;
import org.sonar.db.rule.RuleTesting;
private static final long NOW = 10000000L;
- private QualityProfileDto profile1 = QualityProfileDto.createFor("qp1").setName("QProile1");
- private QualityProfileDto profile2 = QualityProfileDto.createFor("qp2").setName("QProile2");
+ private OrganizationDto organization = OrganizationTesting.newOrganizationDto();
+
+ private QualityProfileDto profile1 = QualityProfileDto.createFor("qp1").setOrganizationUuid(organization.getUuid()).setName("QProfile1");
+ private QualityProfileDto profile2 = QualityProfileDto.createFor("qp2").setOrganizationUuid(organization.getUuid()).setName("QProfile2");
private RuleDto rule1 = RuleTesting.newDto(RuleTesting.XOO_X1);
private RuleDto rule2 = RuleTesting.newDto(RuleTesting.XOO_X2);
import org.sonar.db.DbSession;
import org.sonar.db.DbTester;
import org.sonar.db.component.ComponentDto;
+import org.sonar.db.organization.OrganizationDto;
+import org.sonar.db.organization.OrganizationTesting;
import static com.google.common.collect.ImmutableList.of;
import static com.google.common.collect.Lists.newArrayList;
private DbSession dbSession = dbTester.getSession();
private QualityProfileDbTester qualityProfileDb = new QualityProfileDbTester(dbTester);
private QualityProfileDao underTest = dbTester.getDbClient().qualityProfileDao();
+ private OrganizationDto organization = OrganizationTesting.newOrganizationDto();
@Before
public void before() {
dbTester.prepareDbUnit(getClass(), "shared.xml");
QualityProfileDto dto = QualityProfileDto.createFor("abcde")
+ .setOrganizationUuid("org-123")
.setName("ABCDE")
.setLanguage("xoo");
public void update() {
dbTester.prepareDbUnit(getClass(), "shared.xml");
- QualityProfileDto dto = new QualityProfileDto()
+ QualityProfileDto dto = QualityProfileDto.createFor("key")
.setId(1)
+ .setOrganizationUuid(organization.getUuid())
.setName("New Name")
.setLanguage("js")
.setParentKee("fghij")
}
private QualityProfileDto insertQualityProfileDto(String key, String name, String language) {
- QualityProfileDto dto = QualityProfileDto.createFor(key).setName(name).setLanguage(language);
+ QualityProfileDto dto = QualityProfileDto.createFor(key)
+ .setOrganizationUuid(organization.getUuid())
+ .setName(name)
+ .setLanguage(language);
underTest.insert(dbSession, dto);
return dto;
}
public static QualityProfileDto newQualityProfileDto() {
String uuid = Uuids.createFast();
QualityProfileDto dto = QualityProfileDto.createFor(uuid)
+ .setOrganizationUuid(randomAlphanumeric(40))
.setName(uuid)
.setLanguage(randomAlphanumeric(20))
.setLastUsed(nextLong());
<dataset>
- <rules_profiles id="2" name="Sonar Way" language="js" parent_kee="[null]" kee="js_sonar_way" is_default="[false]"
+ <rules_profiles id="2" name="Sonar Way" language="js" organization_uuid="org-123" parent_kee="[null]" kee="js_sonar_way" is_default="[false]"
rules_updated_at="[null]" created_at="[null]" updated_at="[null]" last_used="123456789" user_updated_at="987654321"/>
</dataset>
<dataset>
- <rules_profiles id="1" name="Child1" language="java" parent_kee="java_parent" kee="java_child1" is_default="[false]"
+ <rules_profiles id="1" name="Child1" language="java" organization_uuid="org-123" parent_kee="java_parent" kee="java_child1" is_default="[false]"
rules_updated_at="[null]" created_at="[null]" updated_at="[null]"/>
- <rules_profiles id="2" name="Child2" language="java" parent_kee="java_parent" kee="java_child2" is_default="[false]"
+ <rules_profiles id="2" name="Child2" language="java" organization_uuid="org-123" parent_kee="java_parent" kee="java_child2" is_default="[false]"
rules_updated_at="[null]" created_at="[null]" updated_at="[null]"/>
- <rules_profiles id="3" name="Parent" language="java" parent_kee="[null]" kee="java_parent" is_default="[false]"
+ <rules_profiles id="3" name="Parent" language="java" organization_uuid="org-123" parent_kee="[null]" kee="java_parent" is_default="[false]"
rules_updated_at="[null]" created_at="[null]" updated_at="[null]"/>
<!-- Same profile for another language -->
- <rules_profiles id="4" name="Child1" language="js" parent_kee="js_parent" kee="js_child1" is_default="[false]"
+ <rules_profiles id="4" name="Child1" language="js" organization_uuid="org-123" parent_kee="js_parent" kee="js_child1" is_default="[false]"
rules_updated_at="[null]" created_at="[null]" updated_at="[null]"/>
- <rules_profiles id="5" name="Child2" language="js" parent_kee="js_parent" kee="js_child2" is_default="[false]"
+ <rules_profiles id="5" name="Child2" language="js" organization_uuid="org-123" parent_kee="js_parent" kee="js_child2" is_default="[false]"
rules_updated_at="[null]" created_at="[null]" updated_at="[null]"/>
- <rules_profiles id="6" name="Parent" language="js" parent_kee="[null]" kee="js_parent" is_default="[false]"
+ <rules_profiles id="6" name="Parent" language="js" organization_uuid="org-123" parent_kee="[null]" kee="js_parent" is_default="[false]"
rules_updated_at="[null]" created_at="[null]" updated_at="[null]"/>
</dataset>
<dataset>
- <rules_profiles id="1" name="Sonar Way" language="java" parent_kee="[null]" kee="java_sonar_way" is_default="[true]"
+ <rules_profiles id="1" name="Sonar Way" language="java" organization_uuid="org-123" parent_kee="[null]" kee="java_sonar_way" is_default="[true]"
rules_updated_at="[null]" created_at="[null]" updated_at="[null]" last_used="[null]" user_updated_at="[null]"/>
- <rules_profiles id="2" name="Sonar Way" language="js" parent_kee="[null]" kee="js_sonar_way" is_default="[false]"
+ <rules_profiles id="2" name="Sonar Way" language="js" organization_uuid="org-123" parent_kee="[null]" kee="js_sonar_way" is_default="[false]"
rules_updated_at="[null]" created_at="[null]" updated_at="[null]" last_used="123456789" user_updated_at="987654321"/>
- <rules_profiles id="3" name="ABCDE" language="xoo" parent_kee="[null]" kee="abcde" is_default="[false]"
+ <rules_profiles id="3" name="ABCDE" language="xoo" organization_uuid="org-123" parent_kee="[null]" kee="abcde" is_default="[false]"
rules_updated_at="[null]" created_at="[null]" updated_at="[null]" last_used="[null]" user_updated_at="[null]"/>
<rules_profiles id="1"
name="Sonar Way"
language="java"
+ organization_uuid="org-123"
parent_kee="[null]"
kee="java_sonar_way"
is_default="[true]"
<rules_profiles id="2"
name="Sonar Way"
language="js"
+ organization_uuid="org-123"
parent_kee="[null]"
kee="js_sonar_way"
is_default="[true]"
<dataset>
- <rules_profiles id="3" name="Third" language="js" parent_kee="[null]" kee="js_third" is_default="[false]"
+ <rules_profiles id="3" name="Third" language="js" organization_uuid="org-123" parent_kee="[null]" kee="js_third" is_default="[false]"
rules_updated_at="[null]" created_at="[null]" updated_at="[null]"/>
- <rules_profiles id="1" name="First" language="js" parent_kee="[null]" kee="js_first" is_default="[false]"
+ <rules_profiles id="1" name="First" language="js" organization_uuid="org-123" parent_kee="[null]" kee="js_first" is_default="[false]"
rules_updated_at="[null]" created_at="[null]" updated_at="[null]"/>
- <rules_profiles id="2" name="Second" language="js" parent_kee="[null]" kee="js_second" is_default="[false]"
+ <rules_profiles id="2" name="Second" language="js" organization_uuid="org-123" parent_kee="[null]" kee="js_second" is_default="[false]"
rules_updated_at="[null]" created_at="[null]" updated_at="[null]"/>
<dataset>
- <rules_profiles id="1" name="Sonar Way 1" language="java" parent_kee="[null]" kee="java_sonar_way"
+ <rules_profiles id="1" name="Sonar Way 1" language="java" organization_uuid="org-123" parent_kee="[null]" kee="java_sonar_way"
is_default="[false]"
rules_updated_at="[null]" created_at="[null]" updated_at="[null]"/>
- <rules_profiles id="2" name="Sonar Way" language="js" parent_kee="[null]" kee="js_sonar_way" is_default="[false]"
+ <rules_profiles id="2" name="Sonar Way" language="js" organization_uuid="org-123" parent_kee="[null]" kee="js_sonar_way" is_default="[false]"
rules_updated_at="[null]" created_at="[null]" updated_at="[null]"/>
- <rules_profiles id="3" name="Sonar Way 2" language="java" parent_kee="[null]" kee="java_sonar_way2"
+ <rules_profiles id="3" name="Sonar Way 2" language="java" organization_uuid="org-123" parent_kee="[null]" kee="java_sonar_way2"
is_default="[false]"
rules_updated_at="[null]" created_at="[null]" updated_at="[null]"/>
<dataset>
- <rules_profiles id="1" name="Sonar Way" language="java" parent_kee="[null]" kee="java_sonar_way" is_default="[true]"
+ <rules_profiles id="1" name="Sonar Way" language="java" organization_uuid="org-123" parent_kee="[null]" kee="java_sonar_way" is_default="[true]"
rules_updated_at="[null]" created_at="[null]" updated_at="[null]" last_used="[null]" user_updated_at="[null]"/>
- <rules_profiles id="2" name="Sonar Way" language="js" parent_kee="[null]" kee="js_sonar_way" is_default="[false]"
+ <rules_profiles id="2" name="Sonar Way" language="js" organization_uuid="org-123" parent_kee="[null]" kee="js_sonar_way" is_default="[false]"
rules_updated_at="[null]" created_at="[null]" updated_at="[null]" last_used="123456789" user_updated_at="987654321"/>
</dataset>
<dataset>
- <rules_profiles id="1" name="New Name" language="js" parent_kee="fghij" kee="java_sonar_way" is_default="[false]"
+ <rules_profiles id="1" name="New Name" language="js" organization_uuid="org-123" parent_kee="fghij" kee="java_sonar_way" is_default="[false]"
rules_updated_at="[null]" created_at="[null]" updated_at="[null]" last_used="[null]" user_updated_at="[null]"/>
- <rules_profiles id="2" name="Sonar Way" language="js" parent_kee="[null]" kee="js_sonar_way" is_default="[false]"
+ <rules_profiles id="2" name="Sonar Way" language="js" organization_uuid="org-123" parent_kee="[null]" kee="js_sonar_way" is_default="[false]"
rules_updated_at="[null]" created_at="[null]" updated_at="[null]" last_used="123456789" user_updated_at="987654321"/>
</dataset>
--- /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.server.platform.db.migration.version.v64;
+
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder;
+import org.sonar.server.platform.db.migration.step.DdlChange;
+
+import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.UUID_SIZE;
+import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder;
+
+public class AddQualityProfileOrganizationUuid extends DdlChange {
+
+ public AddQualityProfileOrganizationUuid(Database db) {
+ super(db);
+ }
+
+ @Override
+ public void execute(Context context) throws SQLException {
+ context.execute(
+ new AddColumnsBuilder(getDialect(), "rules_profiles")
+ .addColumn(newVarcharColumnDefBuilder()
+ .setColumnName("organization_uuid")
+ .setIsNullable(true)
+ .setLimit(UUID_SIZE)
+ .build())
+ .build());
+ }
+}
@Override
public void addSteps(MigrationStepRegistry registry) {
registry
- .add(1600, "Add Projects.TAGS", AddTagsToProjects.class)
- .add(1601, "Set PROJECTS.COPY_COMPONENT_UUID on local views", SetCopyComponentUuidOnLocalViews.class);
+ .add(1600, "Add PROJECTS.TAGS", AddTagsToProjects.class)
+ .add(1601, "Set PROJECTS.COPY_COMPONENT_UUID on local views", SetCopyComponentUuidOnLocalViews.class)
+ .add(1602, "Add RULES_PROFILES.ORGANIZATION_UUID", AddQualityProfileOrganizationUuid.class)
+ .add(1603, "Set RULES_PROFILES.ORGANIZATION_UUID to default", SetQualityProfileOrganizationUuidToDefault.class)
+ .add(1604, "Make RULES_PROFILES.ORGANIZATION_UUID not nullable", MakeQualityProfileOrganizationUuidNotNullable.class)
+ .add(1605, "Drop unique index on RULES_PROFILES.KEE", DropUniqueIndexOnQualityProfileKey.class)
+ .add(1606, "Make RULES_PROFILES.ORGANIZATION_UUID and KEE unique", MakeQualityProfileOrganizationUuidAndKeyUnique.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.server.platform.db.migration.version.v64;
+
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.server.platform.db.migration.sql.DropIndexBuilder;
+import org.sonar.server.platform.db.migration.step.DdlChange;
+
+public class DropUniqueIndexOnQualityProfileKey extends DdlChange {
+
+ public DropUniqueIndexOnQualityProfileKey(Database db) {
+ super(db);
+ }
+
+ @Override
+ public void execute(DdlChange.Context context) throws SQLException {
+ context.execute(
+ new DropIndexBuilder(getDialect())
+ .setTable("rules_profiles")
+ .setName("uniq_qprof_key")
+ .build());
+ }
+}
--- /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.server.platform.db.migration.version.v64;
+
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder;
+import org.sonar.server.platform.db.migration.step.DdlChange;
+
+import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.UUID_SIZE;
+import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder;
+
+public class MakeQualityProfileOrganizationUuidAndKeyUnique extends DdlChange {
+
+ public MakeQualityProfileOrganizationUuidAndKeyUnique(Database db) {
+ super(db);
+ }
+
+ @Override
+ public void execute(DdlChange.Context context) throws SQLException {
+ context.execute(
+ new CreateIndexBuilder(getDialect())
+ .setTable("rules_profiles")
+ .setName("uniq_qprof_org_and_key")
+ .addColumn(
+ newVarcharColumnDefBuilder()
+ .setColumnName("organization_uuid")
+ .setLimit(UUID_SIZE)
+ .build())
+ .addColumn(
+ newVarcharColumnDefBuilder()
+ .setColumnName("kee")
+ .setLimit(255)
+ .build())
+ .setUnique(true)
+ .build());
+ }
+}
--- /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.server.platform.db.migration.version.v64;
+
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder;
+import org.sonar.server.platform.db.migration.step.DdlChange;
+
+import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.UUID_SIZE;
+import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder;
+
+public class MakeQualityProfileOrganizationUuidNotNullable extends DdlChange {
+
+ public MakeQualityProfileOrganizationUuidNotNullable(Database db) {
+ super(db);
+ }
+
+ @Override
+ public void execute(DdlChange.Context context) throws SQLException {
+ context.execute(
+ new AlterColumnsBuilder(getDatabase().getDialect(), "rules_profiles")
+ .updateColumn(newVarcharColumnDefBuilder()
+ .setColumnName("organization_uuid")
+ .setLimit(UUID_SIZE)
+ .setIsNullable(false)
+ .build())
+ .build());
+ }
+}
--- /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.server.platform.db.migration.version.v64;
+
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.server.platform.db.migration.step.DataChange;
+import org.sonar.server.platform.db.migration.version.v63.DefaultOrganizationUuid;
+
+public class SetQualityProfileOrganizationUuidToDefault extends DataChange {
+
+ private final DefaultOrganizationUuid defaultOrganizationUuid;
+
+ public SetQualityProfileOrganizationUuidToDefault(Database db, DefaultOrganizationUuid defaultOrganizationUuid) {
+ super(db);
+ this.defaultOrganizationUuid = defaultOrganizationUuid;
+ }
+
+ @Override
+ public void execute(Context context) throws SQLException {
+ context.prepareUpsert("update rules_profiles set organization_uuid=? where organization_uuid is null")
+ .setString(1, defaultOrganizationUuid.get(context))
+ .execute()
+ .commit();
+ }
+}
--- /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.server.platform.db.migration.version.v64;
+
+import java.sql.SQLException;
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonar.db.CoreDbTester;
+
+public class AddQualityProfileOrganizationUuidTest {
+
+ /** @see org.sonar.db.AbstractDbTester#assertColumnDefinition(String, String, int, Integer, Boolean) */
+ private static final boolean NULLABLE = true;
+
+ @Rule
+ public CoreDbTester db = CoreDbTester.createForSchema(AddQualityProfileOrganizationUuidTest.class, "initial.sql");
+
+ public AddQualityProfileOrganizationUuid underTest = new AddQualityProfileOrganizationUuid(db.database());
+
+ @Test
+ public void test() throws SQLException {
+ underTest.execute();
+ db.assertColumnDefinition("rules_profiles", "organization_uuid", java.sql.Types.VARCHAR, 40, NULLABLE);
+ }
+}
@Test
public void verify_migration_count() {
- verifyMigrationCount(underTest, 2);
+ verifyMigrationCount(underTest, 7);
}
}
--- /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.server.platform.db.migration.version.v64;
+
+import java.sql.SQLException;
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonar.db.CoreDbTester;
+
+public class LetQualityProfileKeyNotBeUniqueAnymoreTest {
+
+ @Rule
+ public CoreDbTester db = CoreDbTester.createForSchema(LetQualityProfileKeyNotBeUniqueAnymoreTest.class, "initial.sql");
+
+ public DropUniqueIndexOnQualityProfileKey underTest = new DropUniqueIndexOnQualityProfileKey(db.database());
+
+ @Test
+ public void test() throws SQLException {
+ underTest.execute();
+ db.assertIndexDoesNotExist("rules_profiles", "uniq_qprof_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.server.platform.db.migration.version.v64;
+
+import java.sql.SQLException;
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonar.db.CoreDbTester;
+
+public class LetQualityProfileOrganizationUuidAndKeyBeUniqueTest {
+
+ @Rule
+ public CoreDbTester db = CoreDbTester.createForSchema(LetQualityProfileOrganizationUuidAndKeyBeUniqueTest.class, "initial.sql");
+
+ public MakeQualityProfileOrganizationUuidAndKeyUnique underTest = new MakeQualityProfileOrganizationUuidAndKeyUnique(db.database());
+
+ @Test
+ public void test() throws SQLException {
+ underTest.execute();
+ db.assertUniqueIndex("rules_profiles", "uniq_qprof_org_and_key", "organization_uuid", "kee");
+ }
+}
--- /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.server.platform.db.migration.version.v64;
+
+import java.sql.SQLException;
+import org.assertj.core.api.Assertions;
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonar.db.CoreDbTester;
+import org.sonar.server.platform.db.migration.version.v63.DefaultOrganizationUuid;
+import org.sonar.server.platform.db.migration.version.v63.TestDefaultOrganizationUuid;
+
+public class SetQualityProfileOrganizationUuidToDefaultTest {
+
+ private static final String DEFAULT_ORG = "some uuid";
+ private static final String PROFILE_KEY = "java-sonar-way-999999";
+
+ @Rule
+ public CoreDbTester db = CoreDbTester.createForSchema(SetQualityProfileOrganizationUuidToDefaultTest.class, "initial.sql");
+
+ private DefaultOrganizationUuid defaultOrganization = new TestDefaultOrganizationUuid(DEFAULT_ORG);
+
+ public SetQualityProfileOrganizationUuidToDefault underTest = new SetQualityProfileOrganizationUuidToDefault(db.database(), defaultOrganization);
+
+ @Test
+ public void should_change_profile_without_organization() throws SQLException {
+ db.executeInsert("RULES_PROFILES", "NAME", "java", "kee", PROFILE_KEY);
+
+ underTest.execute();
+
+ Assertions.assertThat(db.selectFirst("SELECT ORGANIZATION_UUID FROM RULES_PROFILES WHERE KEE = '" + PROFILE_KEY + "'")).containsValue(DEFAULT_ORG);
+ }
+
+ @Test
+ public void should_keep_existing_organization() throws SQLException {
+ String otherOrg = "existing uuid";
+ db.executeInsert("RULES_PROFILES", "NAME", "java", "kee", PROFILE_KEY, "organization_uuid", otherOrg);
+
+ underTest.execute();
+
+ Assertions.assertThat(db.selectFirst("SELECT ORGANIZATION_UUID FROM RULES_PROFILES WHERE KEE = '" + PROFILE_KEY + "'")).containsValue(otherOrg);
+ }
+}
--- /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.server.platform.db.migration.version.v64;
+
+import java.sql.SQLException;
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonar.db.CoreDbTester;
+
+public class SetQualityProfileOrganizationUuidToNotNullableTest {
+
+ /** @see org.sonar.db.AbstractDbTester#assertColumnDefinition(String, String, int, Integer, Boolean) */
+ private static final boolean NOT_NULLABLE = false;
+
+ @Rule
+ public CoreDbTester db = CoreDbTester.createForSchema(SetQualityProfileOrganizationUuidToNotNullableTest.class, "initial.sql");
+
+ public MakeQualityProfileOrganizationUuidNotNullable underTest = new MakeQualityProfileOrganizationUuidNotNullable(db.database());
+
+ @Test
+ public void test() throws SQLException {
+ underTest.execute();
+ db.assertColumnDefinition("rules_profiles", "organization_uuid", java.sql.Types.VARCHAR, 40, NOT_NULLABLE);
+ }
+}
--- /dev/null
+CREATE TABLE "RULES_PROFILES" (
+ "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+ "NAME" VARCHAR(100) NOT NULL,
+ "LANGUAGE" VARCHAR(20),
+ "KEE" VARCHAR(255) NOT NULL,
+ "PARENT_KEE" VARCHAR(255),
+ "RULES_UPDATED_AT" VARCHAR(100),
+ "IS_DEFAULT" BOOLEAN NOT NULL DEFAULT FALSE,
+ "CREATED_AT" TIMESTAMP,
+ "UPDATED_AT" TIMESTAMP,
+ "LAST_USED" BIGINT,
+ "USER_UPDATED_AT" BIGINT
+);
+CREATE UNIQUE INDEX "UNIQ_QPROF_KEY" ON "RULES_PROFILES" ("KEE");
--- /dev/null
+CREATE TABLE "RULES_PROFILES" (
+ "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+ "NAME" VARCHAR(100) NOT NULL,
+ "LANGUAGE" VARCHAR(20),
+ "ORGANIZATION_UUID" VARCHAR(40) NOT NULL,
+ "KEE" VARCHAR(255) NOT NULL,
+ "PARENT_KEE" VARCHAR(255),
+ "RULES_UPDATED_AT" VARCHAR(100),
+ "IS_DEFAULT" BOOLEAN NOT NULL DEFAULT FALSE,
+ "CREATED_AT" TIMESTAMP,
+ "UPDATED_AT" TIMESTAMP,
+ "LAST_USED" BIGINT,
+ "USER_UPDATED_AT" BIGINT
+);
+CREATE UNIQUE INDEX "UNIQ_QPROF_KEY" ON "RULES_PROFILES" ("KEE");
--- /dev/null
+CREATE TABLE "RULES_PROFILES" (
+ "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+ "NAME" VARCHAR(100) NOT NULL,
+ "LANGUAGE" VARCHAR(20),
+ "ORGANIZATION_UUID" VARCHAR(40) NOT NULL,
+ "KEE" VARCHAR(255) NOT NULL,
+ "PARENT_KEE" VARCHAR(255),
+ "RULES_UPDATED_AT" VARCHAR(100),
+ "IS_DEFAULT" BOOLEAN NOT NULL DEFAULT FALSE,
+ "CREATED_AT" TIMESTAMP,
+ "UPDATED_AT" TIMESTAMP,
+ "LAST_USED" BIGINT,
+ "USER_UPDATED_AT" BIGINT
+);
--- /dev/null
+CREATE TABLE "RULES_PROFILES" (
+ "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+ "NAME" VARCHAR(100) NOT NULL,
+ "LANGUAGE" VARCHAR(20),
+ "ORGANIZATION_UUID" VARCHAR(40) NULL,
+ "KEE" VARCHAR(255) NOT NULL,
+ "PARENT_KEE" VARCHAR(255),
+ "RULES_UPDATED_AT" VARCHAR(100),
+ "IS_DEFAULT" BOOLEAN NOT NULL DEFAULT FALSE,
+ "CREATED_AT" TIMESTAMP,
+ "UPDATED_AT" TIMESTAMP,
+ "LAST_USED" BIGINT,
+ "USER_UPDATED_AT" BIGINT
+);
+CREATE UNIQUE INDEX "UNIQ_QPROF_KEY" ON "RULES_PROFILES" ("KEE");
--- /dev/null
+CREATE TABLE "RULES_PROFILES" (
+ "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+ "NAME" VARCHAR(100) NOT NULL,
+ "LANGUAGE" VARCHAR(20),
+ "ORGANIZATION_UUID" VARCHAR(40) NULL,
+ "KEE" VARCHAR(255) NOT NULL,
+ "PARENT_KEE" VARCHAR(255),
+ "RULES_UPDATED_AT" VARCHAR(100),
+ "IS_DEFAULT" BOOLEAN NOT NULL DEFAULT FALSE,
+ "CREATED_AT" TIMESTAMP,
+ "UPDATED_AT" TIMESTAMP,
+ "LAST_USED" BIGINT,
+ "USER_UPDATED_AT" BIGINT
+);
+CREATE UNIQUE INDEX "UNIQ_QPROF_KEY" ON "RULES_PROFILES" ("KEE");
import org.sonar.db.qualityprofile.QualityProfileDto;
import org.sonar.server.exceptions.BadRequestException;
import org.sonar.server.exceptions.NotFoundException;
+import org.sonar.server.organization.DefaultOrganizationProvider;
import static org.sonar.server.qualityprofile.ActiveRuleChange.Type.DEACTIVATED;
import static org.sonar.server.ws.WsUtils.checkFound;
public class QProfileFactory {
private final DbClient db;
+ private final DefaultOrganizationProvider defaultOrganizationProvider;
- public QProfileFactory(DbClient db) {
+ public QProfileFactory(DbClient db, DefaultOrganizationProvider defaultOrganizationProvider) {
this.db = db;
+ this.defaultOrganizationProvider = defaultOrganizationProvider;
}
// ------------- CREATION
String key = Slug.slugify(String.format("%s %s %s", name.getLanguage(), name.getName(), RandomStringUtils.randomNumeric(5)));
QualityProfileDto dto = QualityProfileDto.createFor(key)
.setName(name.getName())
+ .setOrganizationUuid(defaultOrganizationProvider.get().getUuid())
.setLanguage(name.getLanguage())
.setRulesUpdatedAtAsDate(now);
if (db.qualityProfileDao().selectByKey(dbSession, dto.getKey()) == null) {
}
private void addDefaultProfile() {
- QualityProfileDto profileDto = newQProfileDto(QProfileName.createFor(ServerTester.Xoo.KEY, "SonarQube way"), "abcd").setRulesUpdatedAt(
+ QualityProfileDto profileDto = newQProfileDto("org-123", QProfileName.createFor(ServerTester.Xoo.KEY, "SonarQube way"), "abcd").setRulesUpdatedAt(
formatDateTime(new Date())).setDefault(true);
dbClient.qualityProfileDao().insert(dbSession, profileDto);
}
ruleIndexer.index();
// create profile P1 with rules x2 and x1 activated
- db.qualityProfileDao().insert(dbSession, newXooP1());
+ db.qualityProfileDao().insert(dbSession, newXooP1("org-123"));
RuleActivation activation1 = new RuleActivation(XOO_X2).setSeverity("MINOR");
RuleActivation activation2 = new RuleActivation(XOO_X1);
RuleActivation activation3 = new RuleActivation(blahRuleKey);
@Test
public void restore_and_update_profile() throws Exception {
// create profile P1 with rules x1 and x2 activated
- db.qualityProfileDao().insert(dbSession, newXooP1());
+ db.qualityProfileDao().insert(dbSession, newXooP1("org-123"));
RuleActivation activation = new RuleActivation(XOO_X1);
activation.setSeverity(Severity.INFO);
activation.setParameter("max", "10");
public void restore_child_profile() throws Exception {
// define two parent/child profiles
db.qualityProfileDao().insert(dbSession,
- newXooP1(),
- newXooP2().setParentKee(XOO_P1_KEY));
+ newXooP1("org-123"),
+ newXooP2("org-123").setParentKee(XOO_P1_KEY));
dbSession.commit();
// rule x1 is activated on parent profile (so inherited by child profile)
public void restore_parent_profile() throws Exception {
// define two parent/child profiles
db.qualityProfileDao().insert(dbSession,
- newXooP1(),
- newXooP2().setParentKee(XOO_P1_KEY));
+ newXooP1("org-123"),
+ newXooP2("org-123").setParentKee(XOO_P1_KEY));
dbSession.commit();
// rule x1 is activated on parent profile (so inherited by child profile)
public void keep_other_inherited_rules() throws Exception {
// define two parent/child profiles
db.qualityProfileDao().insert(dbSession,
- newXooP1(),
- newXooP2().setParentKee(XOO_P1_KEY));
+ newXooP1("org-123"),
+ newXooP2("org-123").setParentKee(XOO_P1_KEY));
dbSession.commit();
// rule x1 is activated on parent profile and is inherited by child profile
db.ruleDao().insertRuleParam(dbSession, xooRule1, RuleParamDto.createFor(xooRule1)
.setName("min").setType(RuleParamType.INTEGER.type()));
- left = QProfileTesting.newXooP1();
- right = QProfileTesting.newXooP2();
+ left = QProfileTesting.newXooP1("org-123");
+ right = QProfileTesting.newXooP2("org-123");
db.qualityProfileDao().insert(dbSession, left, right);
dbSession.commit();
.setName("max").setDefaultValue("10").setType(RuleParamType.INTEGER.type()));
// create pre-defined profile
- db.qualityProfileDao().insert(dbSession, QProfileTesting.newXooP1());
+ db.qualityProfileDao().insert(dbSession, QProfileTesting.newXooP1("org-123"));
dbSession.commit();
dbSession.clearCache();
ruleIndexer.index();
activeRuleIndexer.index();
// create target with both x1 and x2 activated
- db.qualityProfileDao().insert(dbSession, QProfileTesting.newXooP2());
+ db.qualityProfileDao().insert(dbSession, QProfileTesting.newXooP2("org-123"));
activation = new RuleActivation(RuleTesting.XOO_X1);
activation.setSeverity(Severity.CRITICAL);
activation.setParameter("max", "20");
@Test
public void create_target_profile_with_same_parent_than_source() {
// two profiles : parent and its child
- db.qualityProfileDao().insert(dbSession, QProfileTesting.newXooP2().setParentKee(QProfileTesting.XOO_P1_KEY));
+ db.qualityProfileDao().insert(dbSession, QProfileTesting.newXooP2("org-123").setParentKee(QProfileTesting.XOO_P1_KEY));
// parent and child with x1 activated
RuleActivation activation = new RuleActivation(RuleTesting.XOO_X1);
@Test
public void import_xml() {
- QualityProfileDto profileDto = QProfileTesting.newQProfileDto(QProfileName.createFor("xoo", "import_xml"), "import_xml");
+ QualityProfileDto profileDto = QProfileTesting.newQProfileDto("org-123", QProfileName.createFor("xoo", "import_xml"), "import_xml");
db.qualityProfileDao().insert(dbSession, profileDto);
dbSession.commit();
@Test
public void import_xml_return_messages() {
- QProfileResult result = exporters.importXml(QProfileTesting.newXooP1(), "XooProfileImporterWithMessages", toInputStream("<xml/>", UTF_8), dbSession);
+ QProfileResult result = exporters.importXml(QProfileTesting.newXooP1("org-123"), "XooProfileImporterWithMessages", toInputStream("<xml/>", UTF_8), dbSession);
dbSession.commit();
assertThat(result.infos()).containsOnly("an info");
@Test
public void fail_to_import_xml_when_error_in_importer() {
try {
- exporters.importXml(QProfileTesting.newXooP1(), "XooProfileImporterWithError", toInputStream("<xml/>", UTF_8), dbSession);
+ exporters.importXml(QProfileTesting.newXooP1("org-123"), "XooProfileImporterWithError", toInputStream("<xml/>", UTF_8), dbSession);
fail();
} catch (Exception e) {
assertThat(e).isInstanceOf(BadRequestException.class).hasMessage("error!");
@Test
public void fail_to_import_xml_on_unknown_importer() {
try {
- exporters.importXml(QProfileTesting.newXooP1(), "Unknown", toInputStream("<xml/>", UTF_8), dbSession);
+ exporters.importXml(QProfileTesting.newXooP1("org-123"), "Unknown", toInputStream("<xml/>", UTF_8), dbSession);
fail();
} catch (Exception e) {
assertThat(e).isInstanceOf(BadRequestException.class).hasMessage("No such importer : Unknown");
@Test
public void delete() {
initRules();
- db.qualityProfileDao().insert(dbSession, QProfileTesting.newXooP1());
+ db.qualityProfileDao().insert(dbSession, QProfileTesting.newXooP1("org-123"));
tester.get(RuleActivator.class).activate(dbSession, new RuleActivation(RuleTesting.XOO_X1), XOO_P1_KEY);
dbSession.commit();
dbSession.clearCache();
initRules();
// create parent and child profiles
- db.qualityProfileDao().insert(dbSession, QProfileTesting.newXooP1(), QProfileTesting.newXooP2(), QProfileTesting.newXooP3());
+ db.qualityProfileDao().insert(dbSession, QProfileTesting.newXooP1("org-123"), QProfileTesting.newXooP2("org-123"), QProfileTesting.newXooP3("org-123"));
List<ActiveRuleChange> changes = tester.get(RuleActivator.class).setParent(dbSession, XOO_P2_KEY, XOO_P1_KEY);
changes.addAll(tester.get(RuleActivator.class).setParent(dbSession, XOO_P3_KEY, XOO_P1_KEY));
changes.addAll(tester.get(RuleActivator.class).activate(dbSession, new RuleActivation(RuleTesting.XOO_X1), XOO_P1_KEY));
@Test
public void do_not_delete_default_profile() {
- db.qualityProfileDao().insert(dbSession, QProfileTesting.newXooP1());
+ db.qualityProfileDao().insert(dbSession, QProfileTesting.newXooP1("org-123"));
factory.setDefault(dbSession, XOO_P1_KEY);
dbSession.commit();
dbSession.clearCache();
@Test
public void do_not_delete_if_default_descendant() {
- db.qualityProfileDao().insert(dbSession, QProfileTesting.newXooP1(), QProfileTesting.newXooP2(), QProfileTesting.newXooP3());
+ db.qualityProfileDao().insert(dbSession, QProfileTesting.newXooP1("org-123"), QProfileTesting.newXooP2("org-123"), QProfileTesting.newXooP3("org-123"));
List<ActiveRuleChange> changes = tester.get(RuleActivator.class).setParent(dbSession, XOO_P2_KEY, XOO_P1_KEY);
changes.addAll(tester.get(RuleActivator.class).setParent(dbSession, XOO_P3_KEY, XOO_P1_KEY));
@Test
public void set_default_profile() {
- db.qualityProfileDao().insert(dbSession, QProfileTesting.newXooP1());
+ db.qualityProfileDao().insert(dbSession, QProfileTesting.newXooP1("org-123"));
dbSession.commit();
dbSession.clearCache();
import org.sonar.db.qualityprofile.QualityProfileDto;
import org.sonar.db.qualityprofile.QualityProfileTesting;
import org.sonar.server.exceptions.NotFoundException;
+import org.sonar.server.organization.DefaultOrganizationProvider;
+import org.sonar.server.organization.TestDefaultOrganizationProvider;
import static org.assertj.core.api.Assertions.assertThat;
@Rule
public ExpectedException expectedException = ExpectedException.none();
+ private DefaultOrganizationProvider defaultOrganizationProvider = TestDefaultOrganizationProvider.from(dbTester);
private DbSession dbSession = dbTester.getSession();
- private QProfileFactory underTest = new QProfileFactory(dbTester.getDbClient());
+ private QProfileFactory underTest = new QProfileFactory(dbTester.getDbClient(), defaultOrganizationProvider);
@Before
public void setUp() throws Exception {
dbClient.ruleDao().insert(dbSession, xooRule1);
// create pre-defined profiles P1 and P2
- dbClient.qualityProfileDao().insert(dbSession, QProfileTesting.newXooP1(), QProfileTesting.newXooP2());
+ dbClient.qualityProfileDao().insert(dbSession, QProfileTesting.newXooP1("org-123"), QProfileTesting.newXooP2("org-123"));
dbSession.commit();
dbSession.clearCache();
public static final QProfileName XOO_P3_NAME = new QProfileName("xoo", "P3");
public static final String XOO_P3_KEY = "XOO_P3";
- public static QualityProfileDto newQProfileDto(QProfileName name, String key) {
- return QualityProfileDto.createFor(key).setName(name.getName()).setLanguage(name.getLanguage());
+ public static QualityProfileDto newQProfileDto(String organizationUuid, QProfileName name, String key) {
+ return QualityProfileDto.createFor(key).setOrganizationUuid(organizationUuid).setName(name.getName()).setLanguage(name.getLanguage());
}
- public static QualityProfileDto newXooP1() {
- return newQProfileDto(XOO_P1_NAME, XOO_P1_KEY);
+ public static QualityProfileDto newXooP1(String organizationUuid) {
+ return newQProfileDto(organizationUuid, XOO_P1_NAME, XOO_P1_KEY);
}
- public static QualityProfileDto newXooP2() {
- return newQProfileDto(XOO_P2_NAME, XOO_P2_KEY);
+ public static QualityProfileDto newXooP2(String organizationUuid) {
+ return newQProfileDto(organizationUuid, XOO_P2_NAME, XOO_P2_KEY);
}
- public static QualityProfileDto newXooP3() {
- return newQProfileDto(XOO_P3_NAME, XOO_P3_KEY);
+ public static QualityProfileDto newXooP3(String organizationUuid) {
+ return newQProfileDto(organizationUuid, XOO_P3_NAME, XOO_P3_KEY);
}
}
.setName("format").setDefaultValue("txt").setType(RuleParamType.STRING.type()));
// create pre-defined profile P1
- profileDto = QProfileTesting.newXooP1();
+ profileDto = QProfileTesting.newXooP1("org-123");
db.qualityProfileDao().insert(dbSession, profileDto);
dbSession.commit();
dbSession.clearCache();
verifyOneActiveRuleInDb(XOO_P1_KEY, XOO_X1, MAJOR, null, ImmutableMap.of("max", "10"));
// create profile P2 with x2
- db.qualityProfileDao().insert(dbSession, QProfileTesting.newXooP2());
+ db.qualityProfileDao().insert(dbSession, QProfileTesting.newXooP2("org-123"));
activation = new RuleActivation(XOO_X2);
activation.setSeverity("MAJOR");
activate(activation, XOO_P2_KEY);
verifyOneActiveRuleInDb(XOO_P1_KEY, XOO_X1, MAJOR, null, ImmutableMap.of("max", "10"));
// create empty profile P2
- db.qualityProfileDao().insert(dbSession, QProfileTesting.newXooP2());
+ db.qualityProfileDao().insert(dbSession, QProfileTesting.newXooP2("org-123"));
dbSession.commit();
dbSession.clearCache();
activate(activation, XOO_P1_KEY);
// create profile P2
- db.qualityProfileDao().insert(dbSession, QProfileTesting.newXooP2());
+ db.qualityProfileDao().insert(dbSession, QProfileTesting.newXooP2("org-123"));
// mark rule x1 as REMOVED
RuleDto rule = db.ruleDao().selectOrFailByKey(dbSession, XOO_X1);
}
private void createChildProfiles() {
- db.qualityProfileDao().insert(dbSession, QProfileTesting.newXooP2().setParentKee(XOO_P1_KEY));
- db.qualityProfileDao().insert(dbSession, QProfileTesting.newXooP3().setParentKee(XOO_P2_KEY));
+ db.qualityProfileDao().insert(dbSession, QProfileTesting.newXooP2("org-123").setParentKee(XOO_P1_KEY));
+ db.qualityProfileDao().insert(dbSession, QProfileTesting.newXooP3("org-123").setParentKee(XOO_P2_KEY));
dbSession.commit();
}
import org.sonar.api.rule.Severity;
import org.sonar.api.utils.System2;
import org.sonar.db.DbTester;
+import org.sonar.db.organization.OrganizationDto;
+import org.sonar.db.organization.OrganizationTesting;
import org.sonar.db.qualityprofile.ActiveRuleDto;
import org.sonar.db.qualityprofile.ActiveRuleKey;
import org.sonar.db.qualityprofile.QualityProfileDto;
private ActiveRuleIndexer indexer = new ActiveRuleIndexer(system2, dbTester.getDbClient(), esTester.client());
+ private OrganizationDto organization = OrganizationTesting.newOrganizationDto();
+
@Test
public void index_nothing() {
indexer.index(Iterators.emptyIterator());
// Index one active rule
RuleDto rule = RuleTesting.newDto(RULE_KEY_1);
dbTester.getDbClient().ruleDao().insert(dbTester.getSession(), rule);
- QualityProfileDto profile = QualityProfileDto.createFor("qp").setLanguage("xoo").setName("profile");
+ QualityProfileDto profile = QualityProfileDto.createFor("qp")
+ .setOrganizationUuid(organization.getUuid())
+ .setLanguage("xoo")
+ .setName("profile");
dbTester.getDbClient().qualityProfileDao().insert(dbTester.getSession(), profile);
ActiveRuleDto activeRule = ActiveRuleDto.createFor(profile, rule).setSeverity(Severity.BLOCKER)
.setCreatedAt(yesterday).setUpdatedAt(yesterday);
@Test
public void add_project() throws Exception {
setUserAsQualityProfileAdmin();
- QualityProfileDto profile = qualityProfileDbTester.insertQualityProfile(newQProfileDto(QProfileName.createFor(LANGUAGE_1, "profile1"), "Profile"));
+ QualityProfileDto profile = qualityProfileDbTester.insertQualityProfile(newQProfileDto("org-123", QProfileName.createFor(LANGUAGE_1, "profile1"), "Profile"));
session.commit();
executeRequest(project, profile);
@Test
public void change_project_association() throws Exception {
setUserAsQualityProfileAdmin();
- QualityProfileDto profile1 = newQProfileDto(QProfileName.createFor(LANGUAGE_1, "profile1"), "Profile 1");
- QualityProfileDto profile2 = newQProfileDto(QProfileName.createFor(LANGUAGE_1, "profile2"), "Profile 2");
+ QualityProfileDto profile1 = newQProfileDto("org-123", QProfileName.createFor(LANGUAGE_1, "profile1"), "Profile 1");
+ QualityProfileDto profile2 = newQProfileDto("org-123", QProfileName.createFor(LANGUAGE_1, "profile2"), "Profile 2");
qualityProfileDbTester.insertQualityProfiles(profile1, profile2);
qualityProfileDbTester.associateProjectWithQualityProfile(project, profile1);
session.commit();
@Test
public void change_project_association_when_project_is_linked_on_many_profiles() throws Exception {
setUserAsQualityProfileAdmin();
- QualityProfileDto profile1Language1 = newQProfileDto(QProfileName.createFor(LANGUAGE_1, "profile1"), "Profile 1");
- QualityProfileDto profile2Language2 = newQProfileDto(QProfileName.createFor(LANGUAGE_2, "profile2"), "Profile 2");
- QualityProfileDto profile3Language1 = newQProfileDto(QProfileName.createFor(LANGUAGE_1, "profile3"), "Profile 3");
+ QualityProfileDto profile1Language1 = newQProfileDto("org-123", QProfileName.createFor(LANGUAGE_1, "profile1"), "Profile 1");
+ QualityProfileDto profile2Language2 = newQProfileDto("org-123", QProfileName.createFor(LANGUAGE_2, "profile2"), "Profile 2");
+ QualityProfileDto profile3Language1 = newQProfileDto("org-123", QProfileName.createFor(LANGUAGE_1, "profile3"), "Profile 3");
qualityProfileDbTester.insertQualityProfiles(profile1Language1, profile2Language2, profile3Language1);
qualityProfileDbTester.associateProjectWithQualityProfile(project, profile1Language1, profile2Language2);
session.commit();
}
private QualityProfileDto createProfile(String lang, String name) {
- QualityProfileDto profile = QProfileTesting.newQProfileDto(new QProfileName(lang, name), "p" + lang + "-" + name.toLowerCase());
+ QualityProfileDto profile = QProfileTesting.newQProfileDto("org-123", new QProfileName(lang, name), "p" + lang + "-" + name.toLowerCase());
db.qualityProfileDao().insert(session, profile);
return profile;
}
@Test
public void changelog_empty() throws Exception {
- when(profileFactory.find(any(DbSession.class), eq(QProfileRef.fromKey(XOO_P1_KEY)))).thenReturn(QProfileTesting.newXooP1());
+ when(profileFactory.find(any(DbSession.class), eq(QProfileRef.fromKey(XOO_P1_KEY)))).thenReturn(QProfileTesting.newXooP1("org-123"));
when(changelogLoader.load(any(DbSession.class), any(QProfileChangeQuery.class))).thenReturn(new ChangelogLoader.Changelog(0, Collections.emptyList()));
wsTester.newGetRequest(QProfilesWs.API_ENDPOINT, "changelog").setParam(PARAM_PROFILE_KEY, XOO_P1_KEY)
@Test
public void changelog_nominal() throws Exception {
- when(profileFactory.find(any(DbSession.class), eq(QProfileRef.fromKey(XOO_P1_KEY)))).thenReturn(QProfileTesting.newXooP1());
+ when(profileFactory.find(any(DbSession.class), eq(QProfileRef.fromKey(XOO_P1_KEY)))).thenReturn(QProfileTesting.newXooP1("org-123"));
ChangelogLoader.Change change1 = new ChangelogLoader.Change("C1", "ACTIVATED", A_DATE, null, null, null, null, null, null);
ChangelogLoader.Change change2 = new ChangelogLoader.Change("C2", "ACTIVATED", A_DATE + 10, null, null, null, null, null, null);
List<ChangelogLoader.Change> changes = asList(change1, change2);
@Test
public void changelog_with_all_fields() throws Exception {
- when(profileFactory.find(any(DbSession.class), eq(QProfileRef.fromKey(XOO_P1_KEY)))).thenReturn(QProfileTesting.newXooP1());
+ when(profileFactory.find(any(DbSession.class), eq(QProfileRef.fromKey(XOO_P1_KEY)))).thenReturn(QProfileTesting.newXooP1("org-123"));
ChangelogLoader.Change change1 = new ChangelogLoader.Change("C1", "ACTIVATED", A_DATE, "MAJOR", "marcel", "Marcel", "INHERITED", RuleTesting.XOO_X1, "X One");
change1.getParams().put("foo", "foo_value");
change1.getParams().put("bar", "bar_value");
@Test
public void changelog_inclusive_for_dates() throws Exception {
- when(profileFactory.find(any(DbSession.class), eq(QProfileRef.fromKey(XOO_P1_KEY)))).thenReturn(QProfileTesting.newXooP1());
+ when(profileFactory.find(any(DbSession.class), eq(QProfileRef.fromKey(XOO_P1_KEY)))).thenReturn(QProfileTesting.newXooP1("org-123"));
when(changelogLoader.load(any(DbSession.class), any(QProfileChangeQuery.class))).thenReturn(new ChangelogLoader.Changelog(0, Collections.emptyList()));
wsTester.newGetRequest(QProfilesWs.API_ENDPOINT, "changelog")
}
private QualityProfileDto createProfile(String lang, String name, String key) {
- QualityProfileDto profile = QProfileTesting.newQProfileDto(new QProfileName(lang, name), key);
+ QualityProfileDto profile = QProfileTesting.newQProfileDto("org-123", new QProfileName(lang, name), key);
db.qualityProfileDao().insert(session, profile);
session.commit();
return profile;
new RuleActivator(mock(System2.class), dbClient, ruleIndex, new RuleActivatorContextFactory(dbClient), null, activeRuleIndexer, userSession),
profileImporters);
- private CreateAction underTest = new CreateAction(dbClient, new QProfileFactory(dbClient), qProfileExporters,
+ private CreateAction underTest = new CreateAction(dbClient, new QProfileFactory(dbClient, defaultOrganizationProvider), qProfileExporters,
newLanguages(XOO_LANGUAGE), new QProfileWsSupport(userSession, defaultOrganizationProvider),
activeRuleIndexer, profileImporters);
private WsActionTester wsTester = new WsActionTester(underTest);
tester = new WsTester(new QProfilesWs(
mock(RuleActivationActions.class),
mock(BulkRuleActivationActions.class),
- new DeleteAction(new Languages(xoo1, xoo2), new QProfileFactory(dbClient), dbClient, new QProfileWsSupport(userSessionRule, defaultOrganizationProvider))));
+ new DeleteAction(new Languages(xoo1, xoo2), new QProfileFactory(dbClient, defaultOrganizationProvider), dbClient,
+ new QProfileWsSupport(userSessionRule, defaultOrganizationProvider))));
}
@After
ComponentDto project = ComponentTesting.newProjectDto(dbTester.organizations().insert(), "polop");
componentDao.insert(session, project);
- qualityProfileDao.insert(session, QualityProfileDto.createFor(profileKey).setLanguage(xoo1.getKey()).setName("Sonar way"));
+ QualityProfileDto qualityProfile = QualityProfileDto.createFor(profileKey)
+ .setOrganizationUuid(defaultOrganizationProvider.get().getUuid())
+ .setLanguage(xoo1.getKey())
+ .setName("Sonar way");
+ qualityProfileDao.insert(session, qualityProfile);
qualityProfileDao.insertProjectProfileAssociation(project.uuid(), profileKey, session);
session.commit();
ComponentDto project = ComponentTesting.newProjectDto(dbTester.organizations().insert(), "polop");
componentDao.insert(session, project);
- qualityProfileDao.insert(session, QualityProfileDto.createFor(profileKey).setLanguage(xoo1.getKey()).setName("Sonar way"));
+ qualityProfileDao.insert(session,
+ QualityProfileDto.createFor(profileKey)
+ .setOrganizationUuid(defaultOrganizationProvider.get().getUuid())
+ .setLanguage(xoo1.getKey())
+ .setName("Sonar way"));
qualityProfileDao.insertProjectProfileAssociation(project.uuid(), profileKey, session);
session.commit();
@Test
public void export_without_format() throws Exception {
- QualityProfileDto profile = db.qualityProfiles().insertQualityProfile(QProfileTesting.newXooP1());
+ QualityProfileDto profile = db.qualityProfiles().insertQualityProfile(QProfileTesting.newXooP1("org-123"));
doAnswer(invocation -> {
invocation.getArgumentAt(2, Writer.class).write("As exported by SQ !");
@Test
public void export_with_format() throws Exception {
- QualityProfileDto profile = db.qualityProfiles().insertQualityProfile(QProfileTesting.newXooP1());
+ QualityProfileDto profile = db.qualityProfiles().insertQualityProfile(QProfileTesting.newXooP1("org-123"));
String result = newWsActionTester(newExporter("polop"), newExporter("palap")).newRequest().setParam("language", profile.getLanguage()).setParam("name", profile.getName())
.setParam("exporterKey", "polop").execute()
@Test
public void export_default_profile() throws Exception {
- db.qualityProfiles().insertQualityProfiles(QProfileTesting.newXooP1(), QProfileTesting.newXooP2().setName("SonarWay").setDefault(true));
+ db.qualityProfiles().insertQualityProfiles(QProfileTesting.newXooP1("org-123"), QProfileTesting.newXooP2("org-123").setName("SonarWay").setDefault(true));
String result = newWsActionTester(newExporter("polop"), newExporter("palap")).newRequest().setParam("language", "xoo").setParam("exporterKey", "polop").execute().getInput();
@Test
public void fail_on_unknown_exporter() throws Exception {
- db.qualityProfiles().insertQualityProfile(QProfileTesting.newXooP1());
+ db.qualityProfiles().insertQualityProfile(QProfileTesting.newXooP1("org-123"));
expectedException.expect(IllegalArgumentException.class);
newWsActionTester(newExporter("polop"), newExporter("palap")).newRequest().setParam("language", "xoo").setParam("exporterKey", "unknown").execute();
@Test
public void does_not_fail_when_no_exporters() throws Exception {
- QualityProfileDto profile = db.qualityProfiles().insertQualityProfile(QProfileTesting.newXooP1());
+ QualityProfileDto profile = db.qualityProfiles().insertQualityProfile(QProfileTesting.newXooP1("org-123"));
newWsActionTester().newRequest().setParam("language", "xoo").setParam("name", profile.getName()).execute();
}
}
private QualityProfileDto createProfile(String lang, String name, String key) {
- QualityProfileDto profile = QProfileTesting.newQProfileDto(new QProfileName(lang, name), key);
+ QualityProfileDto profile = QProfileTesting.newQProfileDto("org-123", new QProfileName(lang, name), key);
db.qualityProfileDao().insert(session, profile);
session.commit();
return profile;
}
private void createProfiles() {
- xooP1 = QProfileTesting.newXooP1();
- xooP2 = QProfileTesting.newXooP2();
+ xooP1 = QProfileTesting.newXooP1("org-123");
+ xooP2 = QProfileTesting.newXooP2("org-123");
dbClient.qualityProfileDao().insert(dbSession, xooP1, xooP2);
}
import org.sonar.db.qualityprofile.QualityProfileDto;
import org.sonar.db.qualityprofile.QualityProfileTesting;
import org.sonar.server.exceptions.NotFoundException;
+import org.sonar.server.organization.DefaultOrganizationProvider;
+import org.sonar.server.organization.TestDefaultOrganizationProvider;
import org.sonar.server.qualityprofile.QProfileFactory;
import org.sonar.server.qualityprofile.QProfileRef;
@Rule
public ExpectedException expectedException = ExpectedException.none();
- private QProfileFactory underTest = new QProfileFactory(dbTester.getDbClient());
+ private DefaultOrganizationProvider defaultOrganizationProvider = TestDefaultOrganizationProvider.from(dbTester);
+
+ private QProfileFactory underTest = new QProfileFactory(dbTester.getDbClient(), defaultOrganizationProvider);
@Before
public void setUp() throws Exception {
@Test
public void reset() throws Exception {
- QualityProfileDto profile = QProfileTesting.newXooP1();
- QualityProfileDto subProfile = QProfileTesting.newXooP2().setParentKee(QProfileTesting.XOO_P1_KEY);
+ QualityProfileDto profile = QProfileTesting.newXooP1("org-123");
+ QualityProfileDto subProfile = QProfileTesting.newXooP2("org-123").setParentKee(QProfileTesting.XOO_P1_KEY);
db.qualityProfileDao().insert(session, profile, subProfile);
RuleDto rule = createRule(profile.getLanguage(), "rule");
db.organizationDao().insert(session, organizationDto);
ComponentDto project = ComponentTesting.newProjectDto(organizationDto, "ABCD").setId(1L);
db.componentDao().insert(session, project);
- QualityProfileDto profile = QProfileTesting.newXooP1();
+ QualityProfileDto profile = QProfileTesting.newXooP1("org-123");
db.qualityProfileDao().insert(session, profile);
session.commit();
db.organizationDao().insert(session, organizationDto);
ComponentDto project = ComponentTesting.newProjectDto(organizationDto, "ABCD").setId(1L);
db.componentDao().insert(session, project);
- QualityProfileDto profile1 = QProfileTesting.newXooP1();
- QualityProfileDto profile2 = QProfileTesting.newXooP2();
+ QualityProfileDto profile1 = QProfileTesting.newXooP1("org-123");
+ QualityProfileDto profile2 = QProfileTesting.newXooP2("org-123");
db.qualityProfileDao().insert(session, profile1, profile2);
db.qualityProfileDao().insertProjectProfileAssociation(project.uuid(), profile1.getKey(), session);
db.organizationDao().insert(session, organizationDto);
ComponentDto project = ComponentTesting.newProjectDto(organizationDto, "ABCD").setId(1L);
db.componentDao().insert(session, project);
- QualityProfileDto profile = QProfileTesting.newXooP1();
+ QualityProfileDto profile = QProfileTesting.newXooP1("org-123");
db.qualityProfileDao().insert(session, profile);
session.commit();
db.organizationDao().insert(session, organizationDto);
ComponentDto project = ComponentTesting.newProjectDto(organizationDto, "ABCD").setId(1L);
db.componentDao().insert(session, project);
- QualityProfileDto profile = QProfileTesting.newXooP1();
+ QualityProfileDto profile = QProfileTesting.newXooP1("org-123");
db.qualityProfileDao().insert(session, profile);
db.qualityProfileDao().insertProjectProfileAssociation(project.uuid(), profile.getKee(), session);
db.organizationDao().insert(session, organizationDto);
ComponentDto project = ComponentTesting.newProjectDto(organizationDto, "ABCD").setId(1L);
db.componentDao().insert(session, project);
- QualityProfileDto profile = QProfileTesting.newXooP1();
+ QualityProfileDto profile = QProfileTesting.newXooP1("org-123");
db.qualityProfileDao().insert(session, profile);
db.qualityProfileDao().insertProjectProfileAssociation(project.uuid(), profile.getKee(), session);
}
private QualityProfileDto createProfile(String lang) {
- QualityProfileDto profile = QProfileTesting.newQProfileDto(new QProfileName(lang, "P" + lang), "p" + lang);
+ QualityProfileDto profile = QProfileTesting.newQProfileDto("org-123", new QProfileName(lang, "P" + lang), "p" + lang);
db.qualityProfileDao().insert(session, profile);
return profile;
}
tester = new WsTester(new QProfilesWs(
mock(RuleActivationActions.class),
mock(BulkRuleActivationActions.class),
- new RenameAction(new QProfileFactory(dbClient), wsSupport)));
+ new RenameAction(new QProfileFactory(dbClient, defaultOrganizationProvider), wsSupport)));
}
@Test
}
private void createProfiles() {
+ String orgUuid = defaultOrganizationProvider.get().getUuid();
dbClient.qualityProfileDao().insert(db.getSession(),
- QualityProfileDto.createFor("sonar-way-xoo1-12345").setLanguage(xoo1Key).setName("Sonar way").setDefault(true),
- QualityProfileDto.createFor("sonar-way-xoo2-23456").setLanguage(xoo2Key).setName("Sonar way"),
- QualityProfileDto.createFor("my-sonar-way-xoo2-34567").setLanguage(xoo2Key).setName("My Sonar way").setParentKee("sonar-way-xoo2-23456").setDefault(true));
+ QualityProfileDto.createFor("sonar-way-xoo1-12345")
+ .setOrganizationUuid(orgUuid)
+ .setLanguage(xoo1Key)
+ .setName("Sonar way")
+ .setDefault(true),
+
+ QualityProfileDto.createFor("sonar-way-xoo2-23456")
+ .setOrganizationUuid(orgUuid)
+ .setLanguage(xoo2Key)
+ .setName("Sonar way"),
+
+ QualityProfileDto.createFor("my-sonar-way-xoo2-34567")
+ .setOrganizationUuid(orgUuid)
+ .setLanguage(xoo2Key)
+ .setName("My Sonar way")
+ .setParentKee("sonar-way-xoo2-23456")
+ .setDefault(true));
db.commit();
}
import org.sonar.db.qualityprofile.QualityProfileDto;
import org.sonar.server.component.ComponentFinder;
import org.sonar.server.language.LanguageTesting;
+import org.sonar.server.organization.DefaultOrganizationProvider;
+import org.sonar.server.organization.TestDefaultOrganizationProvider;
import org.sonar.server.qualityprofile.QProfileFactory;
import org.sonar.server.qualityprofile.QProfileLookup;
import org.sonar.server.qualityprofile.index.ActiveRuleIndex;
import static org.sonar.db.component.ComponentTesting.newProjectDto;
import static org.sonar.db.qualityprofile.QualityProfileTesting.newQualityProfileDto;
import static org.sonar.test.JsonAssert.assertJson;
-import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.*;
+import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_DEFAULTS;
+import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROFILE_NAME;
+import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROJECT_KEY;
public class SearchActionTest {
DbClient dbClient = db.getDbClient();
DbSession dbSession = db.getSession();
QualityProfileDao qualityProfileDao = dbClient.qualityProfileDao();
+ private DefaultOrganizationProvider defaultOrganizationProvider = TestDefaultOrganizationProvider.from(db);
private ActiveRuleIndex activeRuleIndex = mock(ActiveRuleIndex.class);
new SearchDataLoader(
languages,
new QProfileLookup(dbClient),
- new QProfileFactory(dbClient),
+ new QProfileFactory(dbClient, defaultOrganizationProvider),
dbClient,
new ComponentFinder(dbClient), activeRuleIndex),
languages));
"my-sonar-way-xoo2-34567", 2L));
OrganizationDto organizationDto = db.organizations().insert();
+ String organizationUuid = organizationDto.getUuid();
qualityProfileDao.insert(dbSession,
- QualityProfileDto.createFor("sonar-way-xoo1-12345").setLanguage(xoo1.getKey()).setName("Sonar way").setDefault(true),
- QualityProfileDto.createFor("sonar-way-xoo2-23456").setLanguage(xoo2.getKey()).setName("Sonar way"),
- QualityProfileDto.createFor("my-sonar-way-xoo2-34567").setLanguage(xoo2.getKey()).setName("My Sonar way").setParentKee("sonar-way-xoo2-23456"),
- QualityProfileDto.createFor("sonar-way-other-666").setLanguage("other").setName("Sonar way").setDefault(true));
+ QualityProfileDto.createFor("sonar-way-xoo1-12345")
+ .setOrganizationUuid(organizationUuid)
+ .setLanguage(xoo1.getKey())
+ .setName("Sonar way")
+ .setDefault(true),
+
+ QualityProfileDto
+ .createFor("sonar-way-xoo2-23456")
+ .setOrganizationUuid(organizationUuid)
+ .setLanguage(xoo2.getKey())
+ .setName("Sonar way"),
+
+ QualityProfileDto
+ .createFor("my-sonar-way-xoo2-34567")
+ .setOrganizationUuid(organizationUuid)
+ .setLanguage(xoo2.getKey())
+ .setName("My Sonar way")
+ .setParentKee("sonar-way-xoo2-23456"),
+
+ QualityProfileDto.createFor("sonar-way-other-666")
+ .setOrganizationUuid(organizationUuid)
+ .setLanguage("other").setName("Sonar way")
+ .setDefault(true));
new ComponentDao().insert(dbSession,
newProjectDto(organizationDto, "project-uuid1"),
newProjectDto(organizationDto, "project-uuid2"));
@Test
public void search_for_language() throws Exception {
- qualityProfileDb.insertQualityProfiles(QualityProfileDto.createFor("sonar-way-xoo1-12345").setLanguage(xoo1.getKey()).setName("Sonar way"));
+ qualityProfileDb.insertQualityProfiles(
+ QualityProfileDto.createFor("sonar-way-xoo1-12345")
+ .setOrganizationUuid(defaultOrganizationProvider.get().getUuid())
+ .setLanguage(xoo1.getKey())
+ .setName("Sonar way"));
String result = ws.newRequest().setParam("language", xoo1.getKey()).execute().getInput();
@Test
public void search_for_project_qp() {
long time = DateUtils.parseDateTime("2016-12-22T19:10:03+0100").getTime();
+ OrganizationDto org = db.organizations().insert();
QualityProfileDto qualityProfileOnXoo1 = QualityProfileDto.createFor("sonar-way-xoo1-12345")
+ .setOrganizationUuid(org.getUuid())
.setLanguage(xoo1.getKey())
.setRulesUpdatedAt("2016-12-21T19:10:03+0100")
.setLastUsed(time)
.setName("Sonar way");
QualityProfileDto qualityProfileOnXoo2 = QualityProfileDto.createFor("sonar-way-xoo2-12345")
+ .setOrganizationUuid(org.getUuid())
.setLanguage(xoo2.getKey())
.setRulesUpdatedAt("2016-12-21T19:10:03+0100")
.setLastUsed(time)
.setName("Sonar way");
QualityProfileDto anotherQualityProfileOnXoo1 = QualityProfileDto.createFor("sonar-way-xoo1-45678")
+ .setOrganizationUuid(org.getUuid())
.setLanguage(xoo1.getKey())
.setRulesUpdatedAt("2016-12-21T19:10:03+0100")
.setLastUsed(time)
.setName("Another way");
- ComponentDto project = newProjectDto(db.organizations().insert(), "project-uuid");
+ ComponentDto project = newProjectDto(org, "project-uuid");
qualityProfileDb.insertQualityProfiles(qualityProfileOnXoo1, qualityProfileOnXoo2, anotherQualityProfileOnXoo1);
qualityProfileDb.insertProjectWithQualityProfileAssociations(project, qualityProfileOnXoo1, qualityProfileOnXoo2);
@Test
public void search_for_default_qp_with_profile_name() {
+ String orgUuid = defaultOrganizationProvider.get().getUuid();
QualityProfileDto qualityProfileOnXoo1 = QualityProfileDto.createFor("sonar-way-xoo1-12345")
+ .setOrganizationUuid(orgUuid)
.setLanguage(xoo1.getKey())
.setName("Sonar way")
.setDefault(false);
QualityProfileDto qualityProfileOnXoo2 = QualityProfileDto.createFor("sonar-way-xoo2-12345")
+ .setOrganizationUuid(orgUuid)
.setLanguage(xoo2.getKey())
.setName("Sonar way")
.setDefault(true);
QualityProfileDto anotherQualityProfileOnXoo1 = QualityProfileDto.createFor("sonar-way-xoo1-45678")
+ .setOrganizationUuid(orgUuid)
.setLanguage(xoo1.getKey())
.setName("Another way")
.setDefault(true);
@Test
public void search_by_profile_name() {
+ OrganizationDto org = db.organizations().insert();
QualityProfileDto qualityProfileOnXoo1 = QualityProfileDto.createFor("sonar-way-xoo1-12345")
+ .setOrganizationUuid(org.getUuid())
.setLanguage(xoo1.getKey())
.setRulesUpdatedAtAsDate(new Date())
.setName("Sonar way");
QualityProfileDto qualityProfileOnXoo2 = QualityProfileDto.createFor("sonar-way-xoo2-12345")
+ .setOrganizationUuid(org.getUuid())
.setLanguage(xoo2.getKey())
.setRulesUpdatedAtAsDate(new Date())
.setName("Sonar way");
QualityProfileDto anotherQualityProfileOnXoo1 = QualityProfileDto.createFor("sonar-way-xoo1-45678")
+ .setOrganizationUuid(org.getUuid())
.setLanguage(xoo1.getKey())
.setRulesUpdatedAtAsDate(new Date())
.setName("Another way");
qualityProfileDb.insertQualityProfiles(qualityProfileOnXoo1, qualityProfileOnXoo2, anotherQualityProfileOnXoo1);
- ComponentDto project = componentDb.insertComponent(newProjectDto(db.organizations().insert(), "project-uuid"));
+ ComponentDto project = componentDb.insertComponent(newProjectDto(org, "project-uuid"));
String result = ws.newRequest()
.setParam(PARAM_PROJECT_KEY, project.key())
tester = new WsTester(new QProfilesWs(
mock(RuleActivationActions.class),
mock(BulkRuleActivationActions.class),
- new SetDefaultAction(LanguageTesting.newLanguages(xoo1Key, xoo2Key), new QProfileLookup(dbClient), new QProfileFactory(dbClient), wsSupport)));
+ new SetDefaultAction(LanguageTesting.newLanguages(xoo1Key, xoo2Key), new QProfileLookup(dbClient), new QProfileFactory(dbClient, defaultOrganizationProvider), wsSupport)));
}
@Test
private void createProfiles() {
dbClient.qualityProfileDao().insert(db.getSession(),
- QualityProfileDto.createFor("sonar-way-xoo1-12345").setLanguage(xoo1Key).setName("Sonar way").setDefault(true),
- QualityProfileDto.createFor("sonar-way-xoo2-23456").setLanguage(xoo2Key).setName("Sonar way"),
- QualityProfileDto.createFor("my-sonar-way-xoo2-34567").setLanguage(xoo2Key).setName("My Sonar way").setParentKee("sonar-way-xoo2-23456").setDefault(true));
+ QualityProfileDto.createFor("sonar-way-xoo1-12345")
+ .setOrganizationUuid("org-123")
+ .setLanguage(xoo1Key)
+ .setName("Sonar way")
+ .setDefault(true),
+
+ QualityProfileDto.createFor("sonar-way-xoo2-23456")
+ .setOrganizationUuid("org-123")
+ .setLanguage(xoo2Key)
+ .setName("Sonar way"),
+
+ QualityProfileDto.createFor("my-sonar-way-xoo2-34567")
+ .setOrganizationUuid("org-123")
+ .setLanguage(xoo2Key)
+ .setName("My Sonar way")
+ .setParentKee("sonar-way-xoo2-23456")
+ .setDefault(true));
db.commit();
}
// Create a profile and activate rule
logInAsQProfileAdministrator();
- db.qualityProfileDao().insert(dbSession, QProfileTesting.newXooP1());
+ db.qualityProfileDao().insert(dbSession, QProfileTesting.newXooP1("org-123"));
dbSession.commit();
dbSession.clearCache();
RuleActivation activation = new RuleActivation(RuleTesting.XOO_X1);
// create a profile and activate rule
logInAsQProfileAdministrator();
- db.qualityProfileDao().insert(dbSession, QProfileTesting.newXooP1());
+ db.qualityProfileDao().insert(dbSession, QProfileTesting.newXooP1("org-123"));
dbSession.commit();
dbSession.clearCache();
RuleActivation activation = new RuleActivation(RuleTesting.XOO_X1);
// Create profile and activate rule
logInAsQProfileAdministrator();
- db.qualityProfileDao().insert(dbSession, QProfileTesting.newXooP1());
+ db.qualityProfileDao().insert(dbSession, QProfileTesting.newXooP1("org-123"));
dbSession.commit();
dbSession.clearCache();
RuleActivation activation = new RuleActivation(RuleTesting.XOO_X1);
dao.insert(dbSession, customRule);
// Create a quality profile
- QualityProfileDto profileDto = QProfileTesting.newXooP1();
+ QualityProfileDto profileDto = QProfileTesting.newXooP1("org-123");
db.qualityProfileDao().insert(dbSession, profileDto);
dbSession.commit();
dbSession.clearCache();
ruleDao.insertRuleParam(dbSession, customRule, templateRuleParam3);
// Create a quality profile
- QualityProfileDto profileDto = QProfileTesting.newXooP1();
+ QualityProfileDto profileDto = QProfileTesting.newXooP1("org-123");
db.qualityProfileDao().insert(dbSession, profileDto);
dbSession.commit();
userSessionRule.addPermission(ADMINISTER_QUALITY_PROFILES, defaultOrganizationProvider.get().getUuid());
- QualityProfileDto profile1 = QProfileTesting.newXooP1();
- QualityProfileDto profile2 = QProfileTesting.newXooP2().setParentKee(QProfileTesting.XOO_P1_KEY);
+ QualityProfileDto profile1 = QProfileTesting.newXooP1("org-123");
+ QualityProfileDto profile2 = QProfileTesting.newXooP2("org-123").setParentKee(QProfileTesting.XOO_P1_KEY);
db.getDbClient().qualityProfileDao().insert(db.getSession(), profile1);
db.getDbClient().qualityProfileDao().insert(db.getSession(), profile2);
db.commit();
import org.sonar.db.DbClient;
import org.sonar.db.DbSession;
import org.sonar.db.DbTester;
+import org.sonar.db.organization.OrganizationDto;
+import org.sonar.db.organization.OrganizationTesting;
import org.sonar.db.qualityprofile.QualityProfileDto;
import org.sonar.server.rule.index.RuleQuery;
import org.sonar.server.ws.TestRequest;
RuleQueryFactory underTest = new RuleQueryFactory(dbClient);
FakeAction fakeAction = new FakeAction(underTest);
+ OrganizationDto organization = OrganizationTesting.newOrganizationDto();
@Test
public void create_empty_query() throws Exception {
@Test
public void create_query_add_language_from_profile() throws Exception {
String profileKey = "sonar-way";
- dbClient.qualityProfileDao().insert(dbSession, QualityProfileDto.createFor(profileKey).setName("Sonar Way").setLanguage("xoo"));
+ dbClient.qualityProfileDao().insert(dbSession, QualityProfileDto.createFor(profileKey)
+ .setOrganizationUuid(organization.getUuid())
+ .setName("Sonar Way")
+ .setLanguage("xoo"));
dbSession.commit();
RuleQuery result = execute(
@Test
public void show_rule() throws Exception {
- QualityProfileDto profile = QProfileTesting.newXooP1();
+ QualityProfileDto profile = QProfileTesting.newXooP1("org-123");
tester.get(QualityProfileDao.class).insert(session, profile);
RuleDto rule = RuleTesting.newXooX1();
@Test
public void get_tags() throws Exception {
- QualityProfileDto profile = QProfileTesting.newXooP1();
+ QualityProfileDto profile = QProfileTesting.newXooP1("org-123");
tester.get(QualityProfileDao.class).insert(session, profile);
RuleDto rule = RuleTesting.newXooX1().
@Test
public void search_all_active_rules() throws Exception {
- QualityProfileDto profile = QProfileTesting.newXooP1();
+ QualityProfileDto profile = QProfileTesting.newXooP1("org-123");
tester.get(QualityProfileDao.class).insert(dbSession, profile);
RuleDto rule = RuleTesting.newXooX1();
@Test
public void search_profile_active_rules() throws Exception {
- QualityProfileDto profile = QProfileTesting.newXooP1();
+ QualityProfileDto profile = QProfileTesting.newXooP1("org-123");
tester.get(QualityProfileDao.class).insert(dbSession, profile);
- QualityProfileDto profile2 = QProfileTesting.newXooP2();
+ QualityProfileDto profile2 = QProfileTesting.newXooP2("org-123");
tester.get(QualityProfileDao.class).insert(dbSession, profile2);
dbSession.commit();
@Test
public void search_profile_active_rules_with_inheritance() throws Exception {
- QualityProfileDto profile = QProfileTesting.newXooP1();
+ QualityProfileDto profile = QProfileTesting.newXooP1("org-123");
tester.get(QualityProfileDao.class).insert(dbSession, profile);
- QualityProfileDto profile2 = QProfileTesting.newXooP2().setParentKee(profile.getKee());
+ QualityProfileDto profile2 = QProfileTesting.newXooP2("org-123").setParentKee(profile.getKee());
tester.get(QualityProfileDao.class).insert(dbSession, profile2);
dbSession.commit();
@Test
public void search_all_active_rules_params() throws Exception {
- QualityProfileDto profile = QProfileTesting.newXooP1();
+ QualityProfileDto profile = QProfileTesting.newXooP1("org-123");
tester.get(QualityProfileDao.class).insert(dbSession, profile);
RuleDto rule = RuleTesting.newXooX1();
ruleDao.insert(dbSession, rule);
@Test
public void get_note_as_markdown_and_html() throws Exception {
- QualityProfileDto profile = QProfileTesting.newXooP1();
+ QualityProfileDto profile = QProfileTesting.newXooP1("org-123");
tester.get(QualityProfileDao.class).insert(dbSession, profile);
RuleDto rule = RuleTesting.newXooX1().setNoteData("this is *bold*");
ruleDao.insert(dbSession, rule);
@ClassRule
public static ServerTester tester = new ServerTester().withEsIndexes();
+ DefaultOrganizationProvider defaultOrganizationProvider = tester.get(DefaultOrganizationProvider.class);
+
@Rule
public UserSessionRule userSessionRule = UserSessionRule.forServerTester(tester).logIn()
- .addPermission(ADMINISTER_QUALITY_PROFILES, tester.get(DefaultOrganizationProvider.class).get().getUuid());
+ .addPermission(ADMINISTER_QUALITY_PROFILES, defaultOrganizationProvider.get().getUuid());
WsTester wsTester;
RuleParamDto regexParam = RuleParamDto.createFor(ruleDto).setName("regex").setType("STRING").setDescription("Reg *exp*").setDefaultValue(".*");
ruleDao.insertRuleParam(session, ruleDto, regexParam);
- QualityProfileDto profile = QualityProfileDto.createFor("profile").setName("Profile").setLanguage("xoo");
+ QualityProfileDto profile = QualityProfileDto.createFor("profile")
+ .setOrganizationUuid(defaultOrganizationProvider.get().getUuid())
+ .setName("Profile")
+ .setLanguage("xoo");
tester.get(QualityProfileDao.class).insert(session, profile);
ActiveRuleDto activeRuleDto = new ActiveRuleDto()
.setProfileId(profile.getId())
tags="bug,performance" system_tags="cwe"
created_at="1500000000000" updated_at="1600000000000"/>
- <rules_profiles id="100" name="Sonar Way" kee="sonar-way" language="xoo" parent_kee="[null]" is_default="[false]"/>
+ <rules_profiles id="100" name="Sonar Way" organization_uuid="org-123" kee="sonar-way" language="xoo" parent_kee="[null]" is_default="[false]"/>
<active_rules id="1" profile_id="100" rule_id="10" failure_level="3" inheritance="[null]"
created_at="1500000000000" updated_at="1600000000000"/>
tags="bug,performance" system_tags="cwe"
created_at="1500000000000" updated_at="1600000000000"/>
- <rules_profiles id="1" name="Parent" kee="parent" language="xoo" parent_kee="[null]" is_default="[false]"/>
+ <rules_profiles id="1" name="Parent" organization_uuid="org-123" kee="parent" language="xoo" parent_kee="[null]" is_default="[false]"/>
- <rules_profiles id="2" name="Child" kee="child" language="xoo" parent_kee="parent" is_default="[false]"/>
+ <rules_profiles id="2" name="Child" organization_uuid="org-123" kee="child" language="xoo" parent_kee="parent" is_default="[false]"/>
<active_rules id="1" profile_id="2" rule_id="10" failure_level="4" inheritance="INHERITED"
created_at="1500000000000" updated_at="1600000000000"/>
tags="bug,performance" system_tags="cwe"
created_at="1500000000000" updated_at="1600000000000"/>
- <rules_profiles id="1" name="Parent" kee="parent" language="xoo" parent_kee="[null]" is_default="[false]"/>
+ <rules_profiles id="1" name="Parent" organization_uuid="org-123" kee="parent" language="xoo" parent_kee="[null]" is_default="[false]"/>
- <rules_profiles id="2" name="Child" kee="child" language="xoo" parent_kee="parent" is_default="[false]"/>
+ <rules_profiles id="2" name="Child" organization_uuid="org-123" kee="child" language="xoo" parent_kee="parent" is_default="[false]"/>
<active_rules id="1" profile_id="2" rule_id="10" failure_level="2" inheritance="OVERRIDES"
created_at="1500000000000" updated_at="1600000000000"/>
tags="bug,performance" system_tags="cwe"
created_at="1500000000000" updated_at="1600000000000"/>
- <rules_profiles id="100" name="Sonar Way" kee="sonar-way" language="xoo" parent_kee="[null]" is_default="[false]"/>
+ <rules_profiles id="100" name="Sonar Way" organization_uuid="org-123" kee="sonar-way" language="xoo" parent_kee="[null]" is_default="[false]"/>
<active_rules id="1" profile_id="100" rule_id="10" failure_level="3" inheritance="[null]"
created_at="1500000000000" updated_at="1600000000000"/>
tags="[null]" system_tags="[null]"
created_at="2000000000000" updated_at="2100000000000"/>
- <rules_profiles id="1" name="Parent" kee="parent" language="xoo" parent_kee="[null]" is_default="[false]"/>
+ <rules_profiles id="1" name="Parent" organization_uuid="org-123" kee="parent" language="xoo" parent_kee="[null]" is_default="[false]"/>
- <rules_profiles id="2" name="Child" kee="child" language="xoo" parent_kee="parent" is_default="[false]"/>
+ <rules_profiles id="2" name="Child" organization_uuid="org-123" kee="child" language="xoo" parent_kee="parent" is_default="[false]"/>
<active_rules id="1" profile_id="2" rule_id="10" failure_level="4" inheritance="INHERITED"
created_at="1500000000000" updated_at="1600000000000"/>
<active_rules id="2" profile_id="1" rule_id="10" failure_level="0" inheritance="[null]"
created_at="1700000000000" updated_at="1800000000000"/>
- <rules_profiles id="3" name="Sonar Way" kee="sonar-way" language="xoo" parent_kee="[null]" is_default="[false]"/>
+ <rules_profiles id="3" name="Sonar Way" organization_uuid="org-123" kee="sonar-way" language="xoo" parent_kee="[null]" is_default="[false]"/>
<active_rules id="3" profile_id="3" rule_id="11" failure_level="3" inheritance="[null]"
created_at="2000000000000" updated_at="2100000000000"/>
<rules_parameters id="1" rule_id="1" default_value="default value one" description="parameter one" name="param1" param_type="STRING"/>
<rules_parameters id="2" rule_id="1" default_value="default value two" description="parameter two" name="param2" param_type="STRING"/>
- <rules_profiles id="1" version="1" used_profile="true" name="profile name" language="java" is_default="[false]"/>
+ <rules_profiles id="1" version="1" used_profile="true" organization_uuid="org-123" name="profile name" language="java" is_default="[false]"/>
<active_rules created_at="[null]" updated_at="[null]" id="1" rule_id="1" profile_id="1" failure_level="4" inheritance="[null]" />
<active_rule_parameters id="1" active_rule_id="1" rules_parameter_id="1" value="one" rules_parameter_key="[null]"/>
<active_rule_parameters id="2" active_rule_id="1" rules_parameter_id="2" value="two" rules_parameter_key="[null]"/>
<rules_parameters id="3" rule_id="1" name="param3" description="[null]" param_type="STRING"/>
- <rules_profiles id="1" version="1" used_profile="true" name="profile name" language="java" is_default="[false]"/>
+ <rules_profiles id="1" version="1" used_profile="true" organization_uuid="org-123" name="profile name" language="java" is_default="[false]"/>
<active_rules created_at="[null]" updated_at="[null]" id="1" rule_id="1" profile_id="1" failure_level="4" />
<active_rule_parameters id="1" active_rule_id="1" rules_parameter_id="1" value="one" />
<active_rule_parameters id="2" active_rule_id="1" rules_parameter_id="2" value="two" />
<rules_parameters id="1" rule_id="1" name="deprecated-prop" description="[null]" param_type="STRING"/>
- <rules_profiles id="1" version="1" used_profile="true" name="sonar way" language="java" is_default="[false]"/>
+ <rules_profiles id="1" version="1" organization_uuid="org-123" used_profile="true" name="sonar way" language="java" is_default="[false]"/>
<active_rules created_at="[null]" updated_at="[null]" id="1" rule_id="1" profile_id="1" failure_level="4" />
<active_rules created_at="[null]" updated_at="[null]" id="2" rule_id="2" profile_id="1" failure_level="0" />
<dataset>
- <rules_profiles id="1" name="Java One" language="java" parent_kee="[null]" kee="java-one" is_default="[false]"
+ <rules_profiles id="1" name="Java One" language="java" organization_uuid="org-123" parent_kee="[null]" kee="java-one" is_default="[false]"
created_at="2014-01-20" updated_at="2014-01-20"
rules_updated_at="2014-01-20T12:00:00+0000"/>
- <rules_profiles id="2" name="Java Two" language="java" parent_kee="[null]" kee="java-two" is_default="[false]"
+ <rules_profiles id="2" name="Java Two" language="java" organization_uuid="org-123" parent_kee="[null]" kee="java-two" is_default="[false]"
created_at="2014-01-20" updated_at="2014-01-20"
rules_updated_at="2014-01-20T12:00:00+0000"/>
- <rules_profiles id="3" name="Php One" language="php" parent_kee="[null]" kee="php-one" is_default="[false]"
+ <rules_profiles id="3" name="Php One" language="php" organization_uuid="org-123" parent_kee="[null]" kee="php-one" is_default="[false]"
created_at="2014-01-20" updated_at="2014-01-20"
rules_updated_at="2014-01-20T12:00:00+0000"/>
- <rules_profiles id="4" name="Cobol One" language="cbl" parent_kee="[null]" kee="cobol-one" is_default="[false]"
+ <rules_profiles id="4" name="Cobol One" language="cbl" organization_uuid="org-123" parent_kee="[null]" kee="cobol-one" is_default="[false]"
created_at="2014-01-20" updated_at="2014-01-20"
rules_updated_at="2014-01-20T12:00:00+0000"/>