public class DbVersion63 implements DbVersion {
@Override
public Stream<Object> getSupportComponents() {
- return Stream.of(DefaultOrganizationUuidImpl.class);
+ return Stream.of(DefaultOrganizationUuidProviderImpl.class);
}
@Override
+++ /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.v63;
-
-import java.sql.SQLException;
-import org.sonar.server.platform.db.migration.step.DataChange;
-
-public interface DefaultOrganizationUuid {
- /**
- * Retrieves the uuid of the default organization from table INTERNAL_PROPERTIES.
- *
- * @throws IllegalStateException if uuid of the default organization can't be retrieved
- */
- String get(DataChange.Context context) throws SQLException;
-
- /**
- * Retrieves the uuid of the default organization from table INTERNAL_PROPERTIES and ensure the specified organization
- * exists in table ORGANIZATIONS.
- *
- * @throws IllegalStateException if uuid of the default organization can't be retrieved
- * @throws IllegalStateException if the default organization does not exist
- */
- String getAndCheck(DataChange.Context context) throws SQLException;
-}
+++ /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.v63;
-
-import java.sql.SQLException;
-import org.sonar.server.platform.db.migration.step.DataChange;
-import org.sonar.server.platform.db.migration.step.Select;
-
-import static com.google.common.base.Preconditions.checkState;
-
-/**
- * Component which can be injected in steps which provides access to the UUID of the default organization, it reads
- * directly from the BD.
- */
-public class DefaultOrganizationUuidImpl implements DefaultOrganizationUuid {
-
- private static final String INTERNAL_PROPERTY_DEFAULT_ORGANIZATION = "organization.default";
-
- @Override
- public String get(DataChange.Context context) throws SQLException {
- Select select = context.prepareSelect("select text_value from internal_properties where kee=?");
- select.setString(1, INTERNAL_PROPERTY_DEFAULT_ORGANIZATION);
- String uuid = select.get(row -> row.getString(1));
- checkState(uuid != null, "Default organization uuid is missing");
- return uuid;
- }
-
- @Override
- public String getAndCheck(DataChange.Context context) throws SQLException {
- String organizationUuid = get(context);
- Select select = context.prepareSelect("select uuid from organizations where uuid=?")
- .setString(1, organizationUuid);
- checkState(select.get(row -> row.getString(1)) != null,
- "Default organization with uuid '%s' does not exist in table ORGANIZATIONS",
- organizationUuid);
- return organizationUuid;
- }
-}
--- /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.v63;
+
+import java.sql.SQLException;
+import org.sonar.server.platform.db.migration.step.DataChange;
+
+public interface DefaultOrganizationUuidProvider {
+ /**
+ * Retrieves the uuid of the default organization from table INTERNAL_PROPERTIES.
+ *
+ * @throws IllegalStateException if uuid of the default organization can't be retrieved
+ */
+ String get(DataChange.Context context) throws SQLException;
+
+ /**
+ * Retrieves the uuid of the default organization from table INTERNAL_PROPERTIES and ensure the specified organization
+ * exists in table ORGANIZATIONS.
+ *
+ * @throws IllegalStateException if uuid of the default organization can't be retrieved
+ * @throws IllegalStateException if the default organization does not exist
+ */
+ String getAndCheck(DataChange.Context context) throws SQLException;
+}
--- /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.v63;
+
+import java.sql.SQLException;
+import org.sonar.server.platform.db.migration.step.DataChange;
+import org.sonar.server.platform.db.migration.step.Select;
+
+import static com.google.common.base.Preconditions.checkState;
+
+/**
+ * Component which can be injected in steps which provides access to the UUID of the default organization, it reads
+ * directly from the BD.
+ */
+public class DefaultOrganizationUuidProviderImpl implements DefaultOrganizationUuidProvider {
+
+ private static final String INTERNAL_PROPERTY_DEFAULT_ORGANIZATION = "organization.default";
+
+ @Override
+ public String get(DataChange.Context context) throws SQLException {
+ Select select = context.prepareSelect("select text_value from internal_properties where kee=?");
+ select.setString(1, INTERNAL_PROPERTY_DEFAULT_ORGANIZATION);
+ String uuid = select.get(row -> row.getString(1));
+ checkState(uuid != null, "Default organization uuid is missing");
+ return uuid;
+ }
+
+ @Override
+ public String getAndCheck(DataChange.Context context) throws SQLException {
+ String organizationUuid = get(context);
+ Select select = context.prepareSelect("select uuid from organizations where uuid=?")
+ .setString(1, organizationUuid);
+ checkState(select.get(row -> row.getString(1)) != null,
+ "Default organization with uuid '%s' does not exist in table ORGANIZATIONS",
+ organizationUuid);
+ return organizationUuid;
+ }
+}
import org.sonar.server.platform.db.migration.step.DataChange;
public class MakeDefaultOrganizationGuarded extends DataChange {
- private final DefaultOrganizationUuid defaultOrganizationUuid;
+ private final DefaultOrganizationUuidProvider defaultOrganizationUuid;
- public MakeDefaultOrganizationGuarded(Database db, DefaultOrganizationUuid defaultOrganizationUuid) {
+ public MakeDefaultOrganizationGuarded(Database db, DefaultOrganizationUuidProvider defaultOrganizationUuid) {
super(db);
this.defaultOrganizationUuid = defaultOrganizationUuid;
}
private static final String DEFAULT_VIEW_TEMPLATE_PROPERTY = "sonar.permission.template.VW.default";
private static final String DEFAULT_DEV_TEMPLATE_PROPERTY = "sonar.permission.template.DEV.default";
- private final DefaultOrganizationUuid defaultOrganizationUuid;
+ private final DefaultOrganizationUuidProvider defaultOrganizationUuid;
- public PopulateDefaultPermTemplateColumnsOfOrganizations(Database db, DefaultOrganizationUuid defaultOrganizationUuid) {
+ public PopulateDefaultPermTemplateColumnsOfOrganizations(Database db, DefaultOrganizationUuidProvider defaultOrganizationUuid) {
super(db);
this.defaultOrganizationUuid = defaultOrganizationUuid;
}
import org.sonar.server.platform.db.migration.step.MassUpdate;
public class PopulateOrganizationUuidToProjects extends DataChange {
- private final DefaultOrganizationUuid defaultOrganizationUuid;
+ private final DefaultOrganizationUuidProvider defaultOrganizationUuid;
- public PopulateOrganizationUuidToProjects(Database db, DefaultOrganizationUuid defaultOrganizationUuid) {
+ public PopulateOrganizationUuidToProjects(Database db, DefaultOrganizationUuidProvider defaultOrganizationUuid) {
super(db);
this.defaultOrganizationUuid = defaultOrganizationUuid;
}
import org.sonar.db.Database;
import org.sonar.server.platform.db.migration.step.DataChange;
import org.sonar.server.platform.db.migration.step.MassUpdate;
-import org.sonar.server.platform.db.migration.version.v63.DefaultOrganizationUuid;
+import org.sonar.server.platform.db.migration.version.v63.DefaultOrganizationUuidProvider;
public class PopulateOrganizationMembersTable extends DataChange {
private static final String INSERT_ORGANIZATION_MEMBERS_SQL = "INSERT INTO organization_members (user_id, organization_uuid) VALUES (?, ?)";
- private final DefaultOrganizationUuid defaultOrganizationUuid;
+ private final DefaultOrganizationUuidProvider defaultOrganizationUuid;
- public PopulateOrganizationMembersTable(Database db, DefaultOrganizationUuid defaultOrganizationUuid) {
+ public PopulateOrganizationMembersTable(Database db, DefaultOrganizationUuidProvider defaultOrganizationUuid) {
super(db);
this.defaultOrganizationUuid = defaultOrganizationUuid;
}
import org.sonar.server.platform.db.migration.step.MassUpdate;
import org.sonar.server.platform.db.migration.step.Select;
import org.sonar.server.platform.db.migration.step.SqlStatement;
-import org.sonar.server.platform.db.migration.version.v63.DefaultOrganizationUuid;
+import org.sonar.server.platform.db.migration.version.v63.DefaultOrganizationUuidProvider;
import static java.util.Optional.ofNullable;
public class PopulateRulesMetadata extends DataChange {
- private final DefaultOrganizationUuid defaultOrganizationUuid;
+ private final DefaultOrganizationUuidProvider defaultOrganizationUuid;
private final System2 system2;
- public PopulateRulesMetadata(Database db, DefaultOrganizationUuid defaultOrganizationUuid, System2 system2) {
+ public PopulateRulesMetadata(Database db, DefaultOrganizationUuidProvider defaultOrganizationUuid, System2 system2) {
super(db);
this.defaultOrganizationUuid = defaultOrganizationUuid;
this.system2 = system2;
import org.sonar.server.platform.db.migration.step.DataChange;
import org.sonar.server.platform.db.migration.step.MassUpdate;
import org.sonar.server.platform.db.migration.step.Select;
-import org.sonar.server.platform.db.migration.version.v63.DefaultOrganizationUuid;
+import org.sonar.server.platform.db.migration.version.v63.DefaultOrganizationUuidProvider;
import static com.google.common.base.Preconditions.checkState;
import static java.lang.String.format;
private static final String DEFAULT_GROUP_SETTING = "sonar.defaultGroup";
private final System2 system2;
- private final DefaultOrganizationUuid defaultOrganizationUuid;
+ private final DefaultOrganizationUuidProvider defaultOrganizationUuid;
- public RestoreSonarUsersGroups(Database db, System2 system2, DefaultOrganizationUuid defaultOrganizationUuid) {
+ public RestoreSonarUsersGroups(Database db, System2 system2, DefaultOrganizationUuidProvider defaultOrganizationUuid) {
super(db);
this.system2 = system2;
this.defaultOrganizationUuid = defaultOrganizationUuid;
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;
+import org.sonar.server.platform.db.migration.version.v63.DefaultOrganizationUuidProvider;
public class SetQualityProfileOrganizationUuidToDefault extends DataChange {
- private final DefaultOrganizationUuid defaultOrganizationUuid;
+ private final DefaultOrganizationUuidProvider defaultOrganizationUuid;
- public SetQualityProfileOrganizationUuidToDefault(Database db, DefaultOrganizationUuid defaultOrganizationUuid) {
+ public SetQualityProfileOrganizationUuidToDefault(Database db, DefaultOrganizationUuidProvider defaultOrganizationUuid) {
super(db);
this.defaultOrganizationUuid = defaultOrganizationUuid;
}
import org.sonar.db.Database;
import org.sonar.server.platform.db.migration.step.DataChange;
import org.sonar.server.platform.db.migration.step.Select;
-import org.sonar.server.platform.db.migration.version.v63.DefaultOrganizationUuid;
+import org.sonar.server.platform.db.migration.version.v63.DefaultOrganizationUuidProvider;
import static com.google.common.base.Preconditions.checkState;
private static final String PERMISSION_USER = "user";
private static final String PERMISSION_CODEVIEWER = "codeviewer";
- private DefaultOrganizationUuid defaultOrganizationUuid;
+ private DefaultOrganizationUuidProvider defaultOrganizationUuidProvider;
- public SupportPrivateProjectInDefaultPermissionTemplate(Database db, DefaultOrganizationUuid defaultOrganizationUuid) {
+ public SupportPrivateProjectInDefaultPermissionTemplate(Database db, DefaultOrganizationUuidProvider defaultOrganizationUuidProvider) {
super(db);
- this.defaultOrganizationUuid = defaultOrganizationUuid;
+ this.defaultOrganizationUuidProvider = defaultOrganizationUuidProvider;
}
@Override
protected void execute(Context context) throws SQLException {
- String defaultOrganizationUuid = this.defaultOrganizationUuid.get(context);
+ String defaultOrganizationUuid = this.defaultOrganizationUuidProvider.get(context);
ResolvedOrganizationProperties organizationProperties = readOrganizationProperties(context, defaultOrganizationUuid);
import org.sonar.db.Database;
import org.sonar.server.platform.db.migration.step.DataChange;
import org.sonar.server.platform.db.migration.step.MassUpdate;
-import org.sonar.server.platform.db.migration.version.v63.DefaultOrganizationUuid;
+import org.sonar.server.platform.db.migration.version.v63.DefaultOrganizationUuidProvider;
import static java.lang.String.format;
import static java.nio.charset.StandardCharsets.UTF_8;
public class UpgradeQualityTemplateLoadedTemplates extends DataChange {
private static final String QUALITY_PROFILE_TYPE = "QUALITY_PROFILE";
- private final DefaultOrganizationUuid defaultOrganizationUuid;
+ private final DefaultOrganizationUuidProvider defaultOrganizationUuid;
- public UpgradeQualityTemplateLoadedTemplates(Database db, DefaultOrganizationUuid defaultOrganizationUuid) {
+ public UpgradeQualityTemplateLoadedTemplates(Database db, DefaultOrganizationUuidProvider defaultOrganizationUuid) {
super(db);
this.defaultOrganizationUuid = defaultOrganizationUuid;
}
@Test
public void verify_support_components() {
assertThat(underTest.getSupportComponents())
- .containsOnly(DefaultOrganizationUuidImpl.class);
+ .containsOnly(DefaultOrganizationUuidProviderImpl.class);
}
@Test
+++ /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.v63;
-
-import java.sql.Connection;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.sonar.api.utils.System2;
-import org.sonar.db.CoreDbTester;
-import org.sonar.server.platform.db.migration.step.DataChange;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class DefaultOrganizationUuidImplTest {
- private static final String AN_ORG_UUID = "org1";
-
- @Rule
- public CoreDbTester dbTester = CoreDbTester.createForSchema(DefaultOrganizationUuidImplTest.class, "internal_properties.sql");
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
- private DefaultOrganizationUuid underTest = new DefaultOrganizationUuidImpl();
-
- @Test
- public void get_fails_with_ISE_if_default_organization_internal_property_is_not_set() throws Exception {
- expectedException.expect(IllegalStateException.class);
- expectedException.expectMessage("Default organization uuid is missing");
-
- callGet(underTest);
- }
-
- @Test
- public void get_returns_uuid_from_table_INTERNAL_PROPERTIES() throws Exception {
- dbTester.executeInsert("internal_properties", "kee", "organization.default", "is_empty", false, "text_value", AN_ORG_UUID);
-
- assertThat(callGet(underTest)).isEqualTo(AN_ORG_UUID);
- }
-
- private String callGet(DefaultOrganizationUuid defaultOrganizationUuid) throws Exception {
- try (Connection connection = dbTester.openConnection()) {
- DataChange.Context context = new DataChange.Context(dbTester.database(), connection, connection);
- return defaultOrganizationUuid.get(context);
- }
- }
-
-}
--- /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.v63;
+
+import java.sql.Connection;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.sonar.db.CoreDbTester;
+import org.sonar.server.platform.db.migration.step.DataChange;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class DefaultOrganizationUuidProviderImplTest {
+ private static final String AN_ORG_UUID = "org1";
+
+ @Rule
+ public CoreDbTester dbTester = CoreDbTester.createForSchema(DefaultOrganizationUuidProviderImplTest.class, "internal_properties.sql");
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
+
+ private DefaultOrganizationUuidProvider underTest = new DefaultOrganizationUuidProviderImpl();
+
+ @Test
+ public void get_fails_with_ISE_if_default_organization_internal_property_is_not_set() throws Exception {
+ expectedException.expect(IllegalStateException.class);
+ expectedException.expectMessage("Default organization uuid is missing");
+
+ callGet(underTest);
+ }
+
+ @Test
+ public void get_returns_uuid_from_table_INTERNAL_PROPERTIES() throws Exception {
+ dbTester.executeInsert("internal_properties", "kee", "organization.default", "is_empty", false, "text_value", AN_ORG_UUID);
+
+ assertThat(callGet(underTest)).isEqualTo(AN_ORG_UUID);
+ }
+
+ private String callGet(DefaultOrganizationUuidProvider defaultOrganizationUuid) throws Exception {
+ try (Connection connection = dbTester.openConnection()) {
+ DataChange.Context context = new DataChange.Context(dbTester.database(), connection, connection);
+ return defaultOrganizationUuid.get(context);
+ }
+ }
+
+}
@Rule
public ExpectedException expectedException = ExpectedException.none();
- private MakeDefaultOrganizationGuarded underTest = new MakeDefaultOrganizationGuarded(db.database(), new DefaultOrganizationUuidImpl());
+ private MakeDefaultOrganizationGuarded underTest = new MakeDefaultOrganizationGuarded(db.database(), new DefaultOrganizationUuidProviderImpl());
@Test
public void fails_with_ISE_when_no_default_organization_is_set() throws SQLException {
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-import org.sonar.api.utils.System2;
import org.sonar.db.CoreDbTester;
import static org.assertj.core.api.Assertions.assertThat;
public ExpectedException expectedException = ExpectedException.none();
private PopulateDefaultPermTemplateColumnsOfOrganizations underTest = new PopulateDefaultPermTemplateColumnsOfOrganizations(dbTester.database(),
- new DefaultOrganizationUuidImpl());
+ new DefaultOrganizationUuidProviderImpl());
@Test
public void fails_with_ISE_when_no_default_organization_is_set() throws SQLException {
import java.sql.SQLException;
import org.junit.Rule;
import org.junit.Test;
-import org.sonar.api.utils.System2;
import org.sonar.db.CoreDbTester;
import static java.lang.String.valueOf;
@Rule
public CoreDbTester dbTester = CoreDbTester.createForSchema(PopulateOrganizationUuidToProjectsTest.class, "projects_with_nullable_organization.sql");
- private PopulateOrganizationUuidToProjects underTest = new PopulateOrganizationUuidToProjects(dbTester.database(), new TestDefaultOrganizationUuid(ORGANIZATION_UUID));
+ private PopulateOrganizationUuidToProjects underTest = new PopulateOrganizationUuidToProjects(dbTester.database(), new TestDefaultOrganizationUuidProvider(ORGANIZATION_UUID));
@Test
public void execute_has_no_effect_when_table_is_empty() throws SQLException {
+++ /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.v63;
-
-import java.sql.SQLException;
-import org.sonar.server.platform.db.migration.step.DataChange;
-
-import static java.util.Objects.requireNonNull;
-
-/**
- * Implementation of {@link DefaultOrganizationUuid} which never fails and returns the specified organization uuid.
- */
-public class TestDefaultOrganizationUuid implements DefaultOrganizationUuid {
- private final String organizationUuid;
-
- public TestDefaultOrganizationUuid(String organizationUuid) {
- this.organizationUuid = requireNonNull(organizationUuid, "organizationUuid can't be null");
- }
-
- @Override
- public String get(DataChange.Context context) throws SQLException {
- return organizationUuid;
- }
-
- @Override
- public String getAndCheck(DataChange.Context context) throws SQLException {
- return organizationUuid;
- }
-}
--- /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.v63;
+
+import java.sql.SQLException;
+import org.sonar.server.platform.db.migration.step.DataChange;
+
+import static java.util.Objects.requireNonNull;
+
+/**
+ * Implementation of {@link DefaultOrganizationUuidProvider} which never fails and returns the specified organization uuid.
+ */
+public class TestDefaultOrganizationUuidProvider implements DefaultOrganizationUuidProvider {
+ private final String organizationUuid;
+
+ public TestDefaultOrganizationUuidProvider(String organizationUuid) {
+ this.organizationUuid = requireNonNull(organizationUuid, "organizationUuid can't be null");
+ }
+
+ @Override
+ public String get(DataChange.Context context) throws SQLException {
+ return organizationUuid;
+ }
+
+ @Override
+ public String getAndCheck(DataChange.Context context) throws SQLException {
+ return organizationUuid;
+ }
+}
import org.junit.rules.ExpectedException;
import org.sonar.core.util.stream.MoreCollectors;
import org.sonar.db.CoreDbTester;
-import org.sonar.server.platform.db.migration.version.v63.DefaultOrganizationUuidImpl;
+import org.sonar.server.platform.db.migration.version.v63.DefaultOrganizationUuidProviderImpl;
import static java.lang.String.format;
import static org.apache.commons.lang.math.RandomUtils.nextLong;
@Rule
public CoreDbTester db = CoreDbTester.createForSchema(PopulateOrganizationMembersTableTest.class, "initial.sql");
- private PopulateOrganizationMembersTable underTest = new PopulateOrganizationMembersTable(db.database(), new DefaultOrganizationUuidImpl());
+ private PopulateOrganizationMembersTable underTest = new PopulateOrganizationMembersTable(db.database(), new DefaultOrganizationUuidProviderImpl());
@Test
public void fails_with_ISE_when_no_default_organization_is_set() throws SQLException {
import org.junit.rules.ExpectedException;
import org.sonar.api.utils.System2;
import org.sonar.db.CoreDbTester;
-import org.sonar.server.platform.db.migration.version.v63.DefaultOrganizationUuidImpl;
+import org.sonar.server.platform.db.migration.version.v63.DefaultOrganizationUuidProviderImpl;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
public ExpectedException expectedException = ExpectedException.none();
private System2 system2 = mock(System2.class);
- private PopulateRulesMetadata underTest = new PopulateRulesMetadata(db.database(), new DefaultOrganizationUuidImpl(), system2);
+ private PopulateRulesMetadata underTest = new PopulateRulesMetadata(db.database(), new DefaultOrganizationUuidProviderImpl(), system2);
@Test
public void fails_with_ISE_when_no_default_organization_is_set() throws SQLException {
import org.sonar.api.utils.System2;
import org.sonar.api.utils.log.LogTester;
import org.sonar.db.CoreDbTester;
-import org.sonar.server.platform.db.migration.version.v63.DefaultOrganizationUuidImpl;
+import org.sonar.server.platform.db.migration.version.v63.DefaultOrganizationUuidProviderImpl;
import static java.lang.String.format;
import static org.apache.commons.lang.math.RandomUtils.nextLong;
private System2 system2 = mock(System2.class);
- private RestoreSonarUsersGroups underTest = new RestoreSonarUsersGroups(db.database(), system2, new DefaultOrganizationUuidImpl());
+ private RestoreSonarUsersGroups underTest = new RestoreSonarUsersGroups(db.database(), system2, new DefaultOrganizationUuidProviderImpl());
@Before
public void setUp() throws Exception {
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;
+import org.sonar.server.platform.db.migration.version.v63.DefaultOrganizationUuidProvider;
+import org.sonar.server.platform.db.migration.version.v63.TestDefaultOrganizationUuidProvider;
public class SetQualityProfileOrganizationUuidToDefaultTest {
@Rule
public CoreDbTester db = CoreDbTester.createForSchema(SetQualityProfileOrganizationUuidToDefaultTest.class, "initial.sql");
- private DefaultOrganizationUuid defaultOrganization = new TestDefaultOrganizationUuid(DEFAULT_ORG);
+ private DefaultOrganizationUuidProvider defaultOrganization = new TestDefaultOrganizationUuidProvider(DEFAULT_ORG);
public SetQualityProfileOrganizationUuidToDefault underTest = new SetQualityProfileOrganizationUuidToDefault(db.database(), defaultOrganization);
import org.junit.rules.ExpectedException;
import org.sonar.core.util.stream.MoreCollectors;
import org.sonar.db.CoreDbTester;
-import org.sonar.server.platform.db.migration.version.v63.DefaultOrganizationUuidImpl;
+import org.sonar.server.platform.db.migration.version.v63.DefaultOrganizationUuidProviderImpl;
import static java.lang.String.valueOf;
import static org.apache.commons.lang.math.RandomUtils.nextLong;
@Rule
public ExpectedException expectedException = ExpectedException.none();
- private SupportPrivateProjectInDefaultPermissionTemplate underTest = new SupportPrivateProjectInDefaultPermissionTemplate(db.database(), new DefaultOrganizationUuidImpl());
+ private SupportPrivateProjectInDefaultPermissionTemplate underTest = new SupportPrivateProjectInDefaultPermissionTemplate(db.database(), new DefaultOrganizationUuidProviderImpl());
@Test
public void fails_with_ISE_when_no_default_organization_is_set() throws SQLException {
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.sonar.db.CoreDbTester;
-import org.sonar.server.platform.db.migration.version.v63.DefaultOrganizationUuidImpl;
+import org.sonar.server.platform.db.migration.version.v63.DefaultOrganizationUuidProviderImpl;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.apache.commons.codec.digest.DigestUtils.md5Hex;
@Rule
public ExpectedException expectedException = ExpectedException.none();
- private UpgradeQualityTemplateLoadedTemplates underTest = new UpgradeQualityTemplateLoadedTemplates(db.database(), new DefaultOrganizationUuidImpl());
+ private UpgradeQualityTemplateLoadedTemplates underTest = new UpgradeQualityTemplateLoadedTemplates(db.database(), new DefaultOrganizationUuidProviderImpl());
@Test
public void fails_with_ISE_when_no_default_organization_is_set() throws SQLException {
+++ /dev/null
-CREATE TABLE "INTERNAL_PROPERTIES" (
- "KEE" VARCHAR(50) NOT NULL PRIMARY KEY,
- "IS_EMPTY" BOOLEAN NOT NULL,
- "TEXT_VALUE" VARCHAR(4000),
- "CLOB_VALUE" CLOB,
- "CREATED_AT" BIGINT
-);
-CREATE UNIQUE INDEX "UNIQ_INTERNAL_PROPERTIES" ON "INTERNAL_PROPERTIES" ("KEE");
--- /dev/null
+CREATE TABLE "INTERNAL_PROPERTIES" (
+ "KEE" VARCHAR(50) NOT NULL PRIMARY KEY,
+ "IS_EMPTY" BOOLEAN NOT NULL,
+ "TEXT_VALUE" VARCHAR(4000),
+ "CLOB_VALUE" CLOB,
+ "CREATED_AT" BIGINT
+);
+CREATE UNIQUE INDEX "UNIQ_INTERNAL_PROPERTIES" ON "INTERNAL_PROPERTIES" ("KEE");