]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-8888 move commit out of DefinedQProfileCreation#commit
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Thu, 16 Mar 2017 17:35:05 +0000 (18:35 +0100)
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Thu, 23 Mar 2017 16:38:34 +0000 (17:38 +0100)
server/sonar-server/src/main/java/org/sonar/server/qualityprofile/DefinedQProfileCreation.java
server/sonar-server/src/main/java/org/sonar/server/qualityprofile/DefinedQProfileCreationImpl.java
server/sonar-server/src/main/java/org/sonar/server/qualityprofile/RegisterQualityProfiles.java
server/sonar-server/src/test/java/org/sonar/server/qualityprofile/DefinedQProfileCreationImplTest.java

index eec69901173d063df7913bda25b19da89973d926..65a206abc023737bf8ac5b38170464ff3817886e 100644 (file)
@@ -27,6 +27,8 @@ public interface DefinedQProfileCreation {
   /**
    * Persists the specified {@link DefinedQProfile} of the specified organization and adds any {@link ActiveRuleChange}
    * to the specified list.
+   *
+   * The session is not commit.
    */
   void create(DbSession session, DefinedQProfile qualityProfile, OrganizationDto organization, List<ActiveRuleChange> changes);
 }
index 4058f522048e3c01cd92ddfb43b14eedf4e2e103..83197182126b6453b796ecc61957ab80c7bea825 100644 (file)
@@ -58,6 +58,5 @@ public class DefinedQProfileCreationImpl implements DefinedQProfileCreation {
 
     LoadedTemplateDto template = new LoadedTemplateDto(organization.getUuid(), qualityProfile.getLoadedTemplateType());
     dbClient.loadedTemplateDao().insert(template, session);
-    session.commit();
   }
 }
index c994d504f2f628b4a9613b9dfebf8727217f943f..c003b4d5ba2aef7ac0a2e3233e583d1494976aca 100644 (file)
@@ -90,6 +90,7 @@ public class RegisterQualityProfiles {
     LOGGER.debug("Register profile {} for organization {}", qualityProfile.getQProfileName(), organization.getKey());
 
     definedQProfileCreation.create(session, qualityProfile, organization, changes);
+    session.commit();
   }
 
 }
index 2698025c2fc5f209e369486980b2ae9abe41993d..e18555b3b47a86f68a9efd88ee9865a951e5c68b 100644 (file)
@@ -96,6 +96,7 @@ public class DefinedQProfileCreationImplTest {
     mockForSingleQPInsert(uuid, date);
 
     underTest.create(dbSession, definedQProfile, organization, activeRuleChanges);
+    dbSession.commit();
 
     QualityProfileDto dto = getPersistedQP(organization, FOO_LANGUAGE, "foo1");
     assertThat(dto.getId()).isNotNull();
@@ -124,6 +125,7 @@ public class DefinedQProfileCreationImplTest {
     mockForSingleQPInsert();
 
     underTest.create(dbSession, definedQProfile, organization, activeRuleChanges);
+    dbSession.commit();
 
     assertThat(getPersistedQP(organization, FOO_LANGUAGE, "foo1").isDefault()).isTrue();
     assertThat(activeRuleChanges).isEmpty();
@@ -143,6 +145,7 @@ public class DefinedQProfileCreationImplTest {
             .setOrganizationUuid(organization.getUuid()));
 
     underTest.create(dbSession, definedQProfile, organization, activeRuleChanges);
+    dbSession.commit();
 
     QualityProfileDto dto = getPersistedQP(organization, FOO_LANGUAGE, "foo1");
     assertThat(dto.getId()).isNotEqualTo(existing.getId());
@@ -169,6 +172,7 @@ public class DefinedQProfileCreationImplTest {
     mockForSingleQPInsert();
 
     underTest.create(dbSession, definedQProfile, organization, activeRuleChanges);
+    dbSession.commit();
 
     assertThat(callLogs)
       .hasSize(5);
@@ -187,6 +191,7 @@ public class DefinedQProfileCreationImplTest {
     mockForSingleQPInsert();
 
     underTest.create(dbSession, definedQProfile, organization, activeRuleChanges);
+    dbSession.commit();
 
     assertThat(callLogs)
       .hasSize(1);
@@ -214,6 +219,7 @@ public class DefinedQProfileCreationImplTest {
     mockForSingleQPInsert();
 
     underTest.create(dbSession, definedQProfile, organization, activeRuleChanges);
+    dbSession.commit();
 
     assertThat(callLogs)
       .extracting(CallLog::getRuleActivation)
@@ -240,6 +246,7 @@ public class DefinedQProfileCreationImplTest {
     mockForSingleQPInsert();
 
     underTest.create(dbSession, definedQProfile, organization, activeRuleChanges);
+    dbSession.commit();
 
     Set<Map.Entry<String, String>> parameters = callLogs.get(0).getRuleActivation().getParameters().entrySet();
     assertThat(parameters)