From: Sébastien Lesaint Date: Thu, 16 Mar 2017 17:35:05 +0000 (+0100) Subject: SONAR-8888 move commit out of DefinedQProfileCreation#commit X-Git-Tag: 6.4-RC1~615 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=c5eb6f5c075c636e85d8c8505c709ef7596c3fda;p=sonarqube.git SONAR-8888 move commit out of DefinedQProfileCreation#commit --- diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/DefinedQProfileCreation.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/DefinedQProfileCreation.java index eec69901173..65a206abc02 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/DefinedQProfileCreation.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/DefinedQProfileCreation.java @@ -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 changes); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/DefinedQProfileCreationImpl.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/DefinedQProfileCreationImpl.java index 4058f522048..83197182126 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/DefinedQProfileCreationImpl.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/DefinedQProfileCreationImpl.java @@ -58,6 +58,5 @@ public class DefinedQProfileCreationImpl implements DefinedQProfileCreation { LoadedTemplateDto template = new LoadedTemplateDto(organization.getUuid(), qualityProfile.getLoadedTemplateType()); dbClient.loadedTemplateDao().insert(template, session); - session.commit(); } } diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/RegisterQualityProfiles.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/RegisterQualityProfiles.java index c994d504f2f..c003b4d5ba2 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/RegisterQualityProfiles.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/RegisterQualityProfiles.java @@ -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(); } } diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/DefinedQProfileCreationImplTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/DefinedQProfileCreationImplTest.java index 2698025c2fc..e18555b3b47 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/DefinedQProfileCreationImplTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/DefinedQProfileCreationImplTest.java @@ -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> parameters = callLogs.get(0).getRuleActivation().getParameters().entrySet(); assertThat(parameters)