]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-8754 support guarded in OrganizationDto and OrganizationDao
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Tue, 7 Feb 2017 16:58:11 +0000 (17:58 +0100)
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Fri, 10 Feb 2017 08:48:36 +0000 (09:48 +0100)
20 files changed:
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/CreateDefaultOrganizationTest.java
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/MakeColumnGuardedOfOrganizationsNotNullableTest.java
server/sonar-server/src/test/resources/org/sonar/server/computation/task/projectanalysis/step/LoadPeriodsStepTest/no_previous_version.xml
server/sonar-server/src/test/resources/org/sonar/server/computation/task/projectanalysis/step/LoadPeriodsStepTest/previous_version_deleted.xml
server/sonar-server/src/test/resources/org/sonar/server/computation/task/projectanalysis/step/LoadPeriodsStepTest/previous_version_is_last_one.xml
server/sonar-server/src/test/resources/org/sonar/server/computation/task/projectanalysis/step/LoadPeriodsStepTest/shared.xml
server/sonar-server/src/test/resources/org/sonar/server/issue/ServerIssueStorageTest/load_component_id_from_db.xml
server/sonar-server/src/test/resources/org/sonar/server/issue/ServerIssueStorageTest/load_project_id_from_db.xml
server/sonar-server/src/test/resources/org/sonar/server/issue/ServerIssueStorageTest/should_insert_new_issues.xml
server/sonar-server/src/test/resources/org/sonar/server/issue/ServerIssueStorageTest/should_update_issues.xml
server/sonar-server/src/test/resources/org/sonar/server/source/ws/HashActionTest/no_source.xml
server/sonar-server/src/test/resources/org/sonar/server/source/ws/HashActionTest/shared.xml
server/sonar-server/src/test/resources/org/sonar/server/source/ws/HashActionTest/show_hashes_on_test_file.xml
sonar-db/src/main/java/org/sonar/db/organization/OrganizationDto.java
sonar-db/src/main/resources/org/sonar/db/organization/OrganizationMapper.xml
sonar-db/src/main/resources/org/sonar/db/version/rows-h2.sql
sonar-db/src/test/java/org/sonar/db/organization/OrganizationDaoTest.java
sonar-db/src/test/resources/org/sonar/db/component/ComponentDaoTest/selectForIndexing.xml
sonar-db/src/test/resources/org/sonar/db/component/ComponentDaoTest/shared.xml
sonar-db/src/test/resources/org/sonar/db/component/ComponentDaoWithDuplicatedKeysTest/schema.sql

index e142e7a4fe605ede5e2a5a622e6f28d5eb89af3d..819dd109a421dcba2418cf003c3232d25cdbaca0 100644 (file)
@@ -19,6 +19,9 @@
  */
 package org.sonar.server.platform.db.migration.version.v62;
 
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
 import java.sql.SQLException;
 import org.junit.Rule;
 import org.junit.Test;
@@ -26,9 +29,9 @@ import org.junit.rules.ExpectedException;
 import org.sonar.api.utils.System2;
 import org.sonar.core.util.UuidFactory;
 import org.sonar.db.DbTester;
-import org.sonar.db.organization.OrganizationDto;
 
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.fail;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
@@ -48,7 +51,7 @@ public class CreateDefaultOrganizationTest {
   private CreateDefaultOrganization underTest = new CreateDefaultOrganization(dbTester.database(), system2, uuidFactory);
 
   @Test
-  public void execute_insert_data_in_organizations_and_internal_properties_when_it_does_not_exist() throws SQLException {
+  public void execute_insert_data_in_organizations_and_internal_properties_when_it_does_not_exist() throws Exception {
     long now = 1_222_999L;
     String uuid = "a uuid";
     when(system2.now()).thenReturn(now);
@@ -56,21 +59,30 @@ public class CreateDefaultOrganizationTest {
 
     underTest.execute();
 
-    OrganizationDto organizationDto = dbTester.getDbClient().organizationDao().selectByKey(dbTester.getSession(), DEFAULT_ORGANIZATION_KEY).get();
-    assertThat(organizationDto.getUuid()).isEqualTo(uuid);
-    assertThat(organizationDto.getKey()).isEqualTo(DEFAULT_ORGANIZATION_KEY);
-    assertThat(organizationDto.getName()).isEqualTo(DEFAULT_ORGANIZATION_NAME);
-    assertThat(organizationDto.getDescription()).isNull();
-    assertThat(organizationDto.getUrl()).isNull();
-    assertThat(organizationDto.getAvatarUrl()).isNull();
-    assertThat(organizationDto.getCreatedAt()).isEqualTo(now);
-    assertThat(organizationDto.getUpdatedAt()).isEqualTo(now);
+    try (Connection connection = dbTester.openConnection();
+      PreparedStatement preparedStatement = createSelectStatementByKey(connection, DEFAULT_ORGANIZATION_KEY);
+      ResultSet resultSet = preparedStatement.executeQuery()) {
+      if (resultSet.next()) {
+        assertThat(resultSet.getString(1)).isEqualTo(uuid);
+        assertThat(resultSet.getString(2)).isEqualTo(DEFAULT_ORGANIZATION_KEY);
+        assertThat(resultSet.getString(3)).isEqualTo(DEFAULT_ORGANIZATION_NAME);
+        assertThat(resultSet.getString(4)).isNull();
+        assertThat(resultSet.getString(5)).isNull();
+        assertThat(resultSet.getString(6)).isNull();
+        assertThat(resultSet.getLong(7)).isEqualTo(now);
+        assertThat(resultSet.getLong(8)).isEqualTo(now);
+
+        assertThat(resultSet.next()).isFalse();
+      } else {
+        fail("Can't retrieve organization " + uuid);
+      }
+    }
 
     verifyInternalProperty(uuid);
   }
 
   @Test
-  public void execute_inserts_internal_property_if_default_organization_already_exists() throws SQLException {
+  public void execute_inserts_internal_property_if_default_organization_already_exists() throws Exception {
     long past = 2_999_033L;
     String uuid = "uuidAAAA";
     insertExistingOrganization(uuid, past);
@@ -91,7 +103,7 @@ public class CreateDefaultOrganizationTest {
   }
 
   @Test
-  public void execute_has_no_effect_if_organization_and_internal_property_already_exist() throws SQLException {
+  public void execute_has_no_effect_if_organization_and_internal_property_already_exist() throws Exception {
     long past = 2_999_033L;
     String uuid = "uuidAAAA";
     insertExistingOrganization(uuid, past);
@@ -120,25 +132,51 @@ public class CreateDefaultOrganizationTest {
     dbTester.commit();
   }
 
-  private void insertExistingOrganization(String uuid, long past) {
-    when(system2.now()).thenReturn(past);
-    dbTester.getDbClient().organizationDao().insert(dbTester.getSession(),
-      new OrganizationDto()
-        .setUuid(uuid)
-        .setKey(DEFAULT_ORGANIZATION_KEY)
-        .setName("whatever"));
-    dbTester.commit();
+  private void insertExistingOrganization(String uuid, long past) throws Exception {
+    try (Connection connection = dbTester.openConnection();
+      PreparedStatement preparedStatement = connection.prepareStatement("insert into organizations (uuid,kee,name,created_at,updated_at) values (?,?,?,?,?)")) {
+      preparedStatement.setString(1, uuid);
+      preparedStatement.setString(2, DEFAULT_ORGANIZATION_KEY);
+      preparedStatement.setString(3, "whatever");
+      preparedStatement.setLong(4, past);
+      preparedStatement.setLong(5, past);
+      preparedStatement.execute();
+      if (!connection.getAutoCommit()) {
+        connection.commit();
+      }
+    }
+  }
+
+  private void verifyExistingOrganization(String uuid, long past) throws Exception {
+    try (Connection connection = dbTester.openConnection();
+      PreparedStatement preparedStatement = createSelectStatementByUuid(connection, uuid);
+      ResultSet resultSet = preparedStatement.executeQuery()) {
+      if (resultSet.next()) {
+        assertThat(resultSet.getString(1)).isEqualTo(uuid);
+        assertThat(resultSet.getString(2)).isEqualTo(DEFAULT_ORGANIZATION_KEY);
+        assertThat(resultSet.getString(3)).isEqualTo("whatever");
+        assertThat(resultSet.getString(4)).isNull();
+        assertThat(resultSet.getString(5)).isNull();
+        assertThat(resultSet.getString(6)).isNull();
+        assertThat(resultSet.getLong(7)).isEqualTo(past);
+        assertThat(resultSet.getLong(8)).isEqualTo(past);
+
+        assertThat(resultSet.next()).isFalse();
+      } else {
+        fail("Can't retrieve organization " + uuid);
+      }
+    }
+  }
+
+  private PreparedStatement createSelectStatementByUuid(Connection connection, String uuid) throws SQLException {
+    PreparedStatement preparedStatement = connection.prepareStatement("select uuid,kee,name,description,url,avatar_url,created_at,updated_at from organizations where uuid=?");
+    preparedStatement.setString(1, uuid);
+    return preparedStatement;
   }
 
-  private void verifyExistingOrganization(String uuid, long past) {
-    OrganizationDto organizationDto = dbTester.getDbClient().organizationDao().selectByKey(dbTester.getSession(), DEFAULT_ORGANIZATION_KEY).get();
-    assertThat(organizationDto.getUuid()).isEqualTo(uuid);
-    assertThat(organizationDto.getKey()).isEqualTo(DEFAULT_ORGANIZATION_KEY);
-    assertThat(organizationDto.getName()).isEqualTo("whatever");
-    assertThat(organizationDto.getDescription()).isNull();
-    assertThat(organizationDto.getUrl()).isNull();
-    assertThat(organizationDto.getAvatarUrl()).isNull();
-    assertThat(organizationDto.getCreatedAt()).isEqualTo(past);
-    assertThat(organizationDto.getUpdatedAt()).isEqualTo(past);
+  private PreparedStatement createSelectStatementByKey(Connection connection, String kee) throws SQLException {
+    PreparedStatement preparedStatement = connection.prepareStatement("select uuid,kee,name,description,url,avatar_url,created_at,updated_at from organizations where kee=?");
+    preparedStatement.setString(1, kee);
+    return preparedStatement;
   }
 }
index b60f89715700631e1722bf9966bffbe2c52fe147..6ea86eb242528959dcc497812af1dd53cc25ab09 100644 (file)
@@ -1,3 +1,22 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact 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;
index 0d3e4cf9395df4014b7a8d4f47f0bb3aa277fa76..74978f0071c737b3c250441ed484b69360b09143 100644 (file)
@@ -3,6 +3,7 @@
   <organizations uuid="org1"
                  kee="org1_key"
                  name="org1_name"
+                 guarded="[false]"
                  created_at="1000"
                  updated_at="2000"/>
 
index ce221c0ad9b0070f9b9553226723d106f31f9baa..afc4f39f650264b9526159c39d6d90ef6fa7b54e 100644 (file)
@@ -3,6 +3,7 @@
   <organizations uuid="org1"
                  kee="org1_key"
                  name="org1_name"
+                 guarded="[false]"
                  created_at="1000"
                  updated_at="2000"/>
 
index fa4f2dd141f2254c3bf90dcd14429b0f252a5478..78f7b2d2e4fbf12f1c3eb2eae2db0f5a3a04cbcf 100644 (file)
@@ -3,6 +3,7 @@
   <organizations uuid="org1"
                  kee="org1_key"
                  name="org1_name"
+                 guarded="[false]"
                  created_at="1000"
                  updated_at="2000"/>
 
index 8707b71e42afbd521a7e389e9dc4247be90d2296..df806896d91fe496e2fb79c365f2502b50a709fd 100644 (file)
@@ -3,6 +3,7 @@
   <organizations uuid="org1"
                  kee="org1_key"
                  name="org1_name"
+                 guarded="[false]"
                  created_at="1000"
                  updated_at="2000"/>
 
index 9403a26202ff3be30ce7b46140b52979fc610b33..912630ef352aebe7111e2dcf6f99967cb636cc7e 100644 (file)
@@ -3,6 +3,7 @@
   <organizations uuid="org1"
                  kee="org1_key"
                  name="org1_name"
+                 guarded="[false]"
                  created_at="1000"
                  updated_at="2000"/>
 
index 733373d875e2825d80cf6c5875f89706d205fedc..a2f644868a251e2cddb2b9d7b9aad150c4f9dcd3 100644 (file)
@@ -3,6 +3,7 @@
   <organizations uuid="org1"
                  kee="org1_key"
                  name="org1_name"
+                 guarded="[false]"
                  created_at="1000"
                  updated_at="2000"/>
 
index 9403a26202ff3be30ce7b46140b52979fc610b33..912630ef352aebe7111e2dcf6f99967cb636cc7e 100644 (file)
@@ -3,6 +3,7 @@
   <organizations uuid="org1"
                  kee="org1_key"
                  name="org1_name"
+                 guarded="[false]"
                  created_at="1000"
                  updated_at="2000"/>
 
index 619981235dd1ead597e3426258e26bb1045917cc..f5fd116300083394361110c577e9a8b8553409bf 100644 (file)
@@ -3,6 +3,7 @@
   <organizations uuid="org1"
                  kee="org1_key"
                  name="org1_name"
+                 guarded="[false]"
                  created_at="1000"
                  updated_at="2000"/>
 
index 4f4626059be7737719dc2bbe02c6b4ef752cbbc3..666faef481429226273722b9df0d43f1d9fa2090 100644 (file)
@@ -3,6 +3,7 @@
   <organizations uuid="org1"
                  kee="org1_key"
                  name="org1_name"
+                 guarded="[false]"
                  created_at="1000"
                  updated_at="2000"/>
 
index 921f35fb4710e121c0c6c1235b05c3910e9b78e1..1c8ccadae3b2ca2a7b203eac4913100a21ab11c1 100644 (file)
@@ -3,6 +3,7 @@
   <organizations uuid="org1"
                  kee="org1_key"
                  name="org1_name"
+                 guarded="[false]"
                  created_at="1000"
                  updated_at="2000"/>
 
index 2f0a227126a46399631ca654fff46ee76ab21fa0..e63a709b461d42a1a767052afba64a435bab62f2 100644 (file)
@@ -3,6 +3,7 @@
   <organizations uuid="org1"
                  kee="org1_key"
                  name="org1_name"
+                 guarded="[false]"
                  created_at="1000"
                  updated_at="2000"/>
 
index 095f40e7ef284aec7aebaea730ab40d3534afa48..2644132fc4091e55a2b35ee171597635c4b503e1 100644 (file)
@@ -34,6 +34,10 @@ public class OrganizationDto {
   private String url;
   /** avatar url can be null */
   private String avatarUrl;
+  /**
+   * Flag indicated whether being root is required to be able to delete this organization.
+   */
+  private boolean guarded = false;
   private long createdAt;
   private long updatedAt;
 
@@ -64,24 +68,6 @@ public class OrganizationDto {
     return this;
   }
 
-  public long getCreatedAt() {
-    return createdAt;
-  }
-
-  public OrganizationDto setCreatedAt(long createdAt) {
-    this.createdAt = createdAt;
-    return this;
-  }
-
-  public long getUpdatedAt() {
-    return updatedAt;
-  }
-
-  public OrganizationDto setUpdatedAt(long updatedAt) {
-    this.updatedAt = updatedAt;
-    return this;
-  }
-
   public String getDescription() {
     return description;
   }
@@ -109,6 +95,33 @@ public class OrganizationDto {
     return this;
   }
 
+  public boolean isGuarded() {
+    return guarded;
+  }
+
+  public OrganizationDto setGuarded(boolean guarded) {
+    this.guarded = guarded;
+    return this;
+  }
+
+  public long getCreatedAt() {
+    return createdAt;
+  }
+
+  public OrganizationDto setCreatedAt(long createdAt) {
+    this.createdAt = createdAt;
+    return this;
+  }
+
+  public long getUpdatedAt() {
+    return updatedAt;
+  }
+
+  public OrganizationDto setUpdatedAt(long updatedAt) {
+    this.updatedAt = updatedAt;
+    return this;
+  }
+
   @Override
   public String toString() {
     return "OrganizationDto{" +
@@ -118,6 +131,7 @@ public class OrganizationDto {
       ", description='" + description + '\'' +
       ", url='" + url + '\'' +
       ", avatarUrl='" + avatarUrl + '\'' +
+      ", guarded=" + guarded +
       ", createdAt=" + createdAt +
       ", updatedAt=" + updatedAt +
       '}';
index 5b5a44ce52616a121cbe1e2c93a5bec5972e49ce..fa7e3d41862264fbd1e4e9a3cf56b37f1eb29f74 100644 (file)
@@ -9,6 +9,7 @@
     org.description as "description",
     org.url as "url",
     org.avatar_url as "avatarUrl",
+    org.guarded as "guarded",
     org.created_at as "createdAt",
     org.updated_at as "updatedAt"
   </sql>
       description,
       url,
       avatar_url,
+      guarded,
       created_at,
       updated_at
     )
       #{organization.description, jdbcType=VARCHAR},
       #{organization.url, jdbcType=VARCHAR},
       #{organization.avatarUrl, jdbcType=VARCHAR},
+      #{organization.guarded, jdbcType=BOOLEAN},
       #{organization.createdAt, jdbcType=BIGINT},
       #{organization.updatedAt, jdbcType=BIGINT}
     )
index 00d131c627caf57103f448e80d6adcaed9cb5ef1..9ebdb68b1c924920c84698a102fcaa4b9d5918f9 100644 (file)
@@ -530,7 +530,7 @@ INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1512');
 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', true, '1418215735482', '1418215735482');
 ALTER TABLE USERS ALTER COLUMN ID RESTART WITH 2;
 
-INSERT INTO ORGANIZATIONS (UUID, KEE, NAME, CREATED_AT, UPDATED_AT) VALUES ('AVdqnciQUUs7Zd3KPvFD', 'default-organization', 'Default Organization', '1474962596482', '1474962596482');
+INSERT INTO ORGANIZATIONS (UUID, KEE, NAME, GUARDED, CREATED_AT, UPDATED_AT) VALUES ('AVdqnciQUUs7Zd3KPvFD', 'default-organization', 'Default Organization', false, '1474962596482', '1474962596482');
 INSERT INTO INTERNAL_PROPERTIES (KEE, IS_EMPTY, TEXT_VALUE, CREATED_AT) VALUES ('organization.default', false, 'AVdqnciQUUs7Zd3KPvFD', '1474962596482');
 
 INSERT INTO GROUPS(ID, ORGANIZATION_UUID, NAME, DESCRIPTION, CREATED_AT, UPDATED_AT) VALUES (1, 'AVdqnciQUUs7Zd3KPvFD', 'sonar-administrators', 'System administrators', '2011-09-26 22:27:51.0', '2011-09-26 22:27:51.0');
index 23bcce30f6667d674fe3987edcde9e147b7aa740..5a2df5b94c444f04ddcd8563f7c44c20ce870daa 100644 (file)
@@ -39,6 +39,8 @@ import org.sonar.api.utils.System2;
 import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
 import org.sonar.db.DbTester;
+import org.sonar.db.dialect.Dialect;
+import org.sonar.db.dialect.Oracle;
 import org.sonar.db.user.GroupDto;
 import org.sonar.db.user.UserDto;
 
@@ -62,16 +64,18 @@ public class OrganizationDaoTest {
     .setName("the name 1")
     .setDescription("the description 1")
     .setUrl("the url 1")
-    .setAvatarUrl("the avatar url 1");
+    .setAvatarUrl("the avatar url 1")
+    .setGuarded(false);
   private static final OrganizationDto ORGANIZATION_DTO_2 = new OrganizationDto()
     .setUuid("uuid 2")
     .setKey("the_key 2")
     .setName("the name 2")
     .setDescription("the description 2")
     .setUrl("the url 2")
-    .setAvatarUrl("the avatar url 2");
-  public static final String PERMISSION_1 = "foo";
-  public static final String PERMISSION_2 = "bar";
+    .setAvatarUrl("the avatar url 2")
+    .setGuarded(true);
+  private static final String PERMISSION_1 = "foo";
+  private static final String PERMISSION_2 = "bar";
 
   private System2 system2 = mock(System2.class);
 
@@ -117,11 +121,20 @@ public class OrganizationDaoTest {
     assertThat(row.get("avatarUrl")).isEqualTo(ORGANIZATION_DTO_1.getAvatarUrl());
     assertThat(row.get("createdAt")).isEqualTo(ORGANIZATION_DTO_1.getCreatedAt());
     assertThat(row.get("updatedAt")).isEqualTo(ORGANIZATION_DTO_1.getUpdatedAt());
+    assertThat(row.get("guarded")).isEqualTo(toBool(ORGANIZATION_DTO_1.isGuarded()));
     assertThat(row.get("defaultTemplate")).isNull();
     assertThat(row.get("projectDefaultTemplate")).isNull();
     assertThat(row.get("viewDefaultTemplate")).isNull();
   }
 
+  @Test
+  public void insert_persists_boolean_property_guarded_of_OrganizationDto() {
+    insertOrganization(ORGANIZATION_DTO_2);
+
+    Map<String, Object> row = selectSingleRow();
+    assertThat(row.get("guarded")).isEqualTo(toBool(ORGANIZATION_DTO_2.isGuarded()));
+  }
+
   @Test
   public void description_url_and_avatarUrl_are_optional() {
     when(system2.now()).thenReturn(SOME_DATE);
@@ -134,6 +147,7 @@ public class OrganizationDaoTest {
     assertThat(row.get("description")).isNull();
     assertThat(row.get("url")).isNull();
     assertThat(row.get("avatarUrl")).isNull();
+    assertThat(row.get("guarded")).isEqualTo(toBool(ORGANIZATION_DTO_1.isGuarded()));
     assertThat(row.get("createdAt")).isEqualTo(SOME_DATE);
     assertThat(row.get("updatedAt")).isEqualTo(SOME_DATE);
     assertThat(row.get("defaultTemplate")).isNull();
@@ -141,6 +155,14 @@ public class OrganizationDaoTest {
     assertThat(row.get("viewDefaultTemplate")).isNull();
   }
 
+  private Object toBool(boolean guarded) {
+    Dialect dialect = dbTester.database().getDialect();
+    if (dialect.getId().equals(Oracle.ID)) {
+      return guarded ? 1L : 0L;
+    }
+    return guarded;
+  }
+
   @Test
   public void insert_fails_if_row_with_uuid_already_exists() {
     insertOrganization(ORGANIZATION_DTO_1);
@@ -836,6 +858,7 @@ public class OrganizationDaoTest {
           "      name," +
           "      default_perm_template_project," +
           "      default_perm_template_view," +
+          "      guarded," +
           "      created_at," +
           "      updated_at" +
           "    )" +
@@ -847,6 +870,7 @@ public class OrganizationDaoTest {
           "      ?," +
           "      ?," +
           "      ?," +
+          "      ?," +
           "      ?" +
           "    )")) {
       preparedStatement.setString(1, organizationUuid);
@@ -854,8 +878,9 @@ public class OrganizationDaoTest {
       preparedStatement.setString(3, organizationUuid);
       preparedStatement.setString(4, project);
       preparedStatement.setString(5, view);
-      preparedStatement.setLong(6, 1000L);
-      preparedStatement.setLong(7, 2000L);
+      preparedStatement.setBoolean(6, false);
+      preparedStatement.setLong(7, 1000L);
+      preparedStatement.setLong(8, 2000L);
       preparedStatement.execute();
     } catch (SQLException e) {
       throw new RuntimeException("dirty insert failed", e);
@@ -878,6 +903,7 @@ public class OrganizationDaoTest {
     assertThat(dto.getName()).isEqualTo(ORGANIZATION_DTO_1.getName());
     assertThat(dto.getDescription()).isEqualTo(ORGANIZATION_DTO_1.getDescription());
     assertThat(dto.getUrl()).isEqualTo(ORGANIZATION_DTO_1.getUrl());
+    assertThat(dto.isGuarded()).isEqualTo(ORGANIZATION_DTO_1.isGuarded());
     assertThat(dto.getAvatarUrl()).isEqualTo(ORGANIZATION_DTO_1.getAvatarUrl());
     assertThat(dto.getCreatedAt()).isEqualTo(ORGANIZATION_DTO_1.getCreatedAt());
     assertThat(dto.getUpdatedAt()).isEqualTo(ORGANIZATION_DTO_1.getUpdatedAt());
@@ -889,6 +915,7 @@ public class OrganizationDaoTest {
     assertThat(dto.getName()).isEqualTo(expected.getName());
     assertThat(dto.getDescription()).isEqualTo(expected.getDescription());
     assertThat(dto.getUrl()).isEqualTo(expected.getUrl());
+    assertThat(dto.isGuarded()).isEqualTo(expected.isGuarded());
     assertThat(dto.getAvatarUrl()).isEqualTo(expected.getAvatarUrl());
     assertThat(dto.getCreatedAt()).isEqualTo(expected.getCreatedAt());
     assertThat(dto.getUpdatedAt()).isEqualTo(expected.getUpdatedAt());
@@ -897,6 +924,7 @@ public class OrganizationDaoTest {
   private Map<String, Object> selectSingleRow() {
     List<Map<String, Object>> rows = dbTester.select("select" +
       " uuid as \"uuid\", kee as \"key\", name as \"name\",  description as \"description\", url as \"url\", avatar_url as \"avatarUrl\"," +
+      " guarded as \"guarded\"," +
       " created_at as \"createdAt\", updated_at as \"updatedAt\"," +
       " default_perm_template_project as \"projectDefaultPermTemplate\"," +
       " default_perm_template_view as \"viewDefaultPermTemplate\"" +
index 7c4f24eda9336ad0f0e0d6e5978fc9757278b842..596dd4eec2fa172ca94de1641a8bc6714702e314 100644 (file)
@@ -3,6 +3,7 @@
   <organizations uuid="org1"
                  kee="org1_key"
                  name="org1_name"
+                 guarded="[false]"
                  created_at="1000"
                  updated_at="1000"/>
 
index f3656c5ba02a8bd2b27fc596c30e5646ddce8557..9456f3b138bd986087f2836823a9f54306fafe8c 100644 (file)
@@ -3,6 +3,7 @@
   <organizations uuid="org1"
                  kee="org1_key"
                  name="org1_name"
+                 guarded="[false]"
                  created_at="1000"
                  updated_at="1000"/>
 
index 678afc9442f7fc221cafe0731878238b229271ac..dc2e084f3b97e92ce7a8920028ae3ef383b8d59d 100644 (file)
@@ -5,6 +5,7 @@ CREATE TABLE "ORGANIZATIONS" (
   "DESCRIPTION" VARCHAR(256),
   "URL" VARCHAR(256),
   "AVATAR_URL" VARCHAR(256),
+  "GUARDED" BOOLEAN NOT NULL,
   "CREATED_AT" BIGINT NOT NULL,
   "UPDATED_AT" BIGINT NOT NULL
 );