import org.sonar.db.qualityprofile.ActiveRuleDto;
import org.sonar.db.qualityprofile.QualityProfileDto;
import org.sonar.server.exceptions.BadRequestException;
-import org.sonar.server.exceptions.NotFoundException;
import org.sonar.server.qualityprofile.ws.QProfileReference;
import static org.sonar.server.qualityprofile.ActiveRuleChange.Type.DEACTIVATED;
return db.qualityProfileDao().selectDefaultProfiles(session, organization, languageKeys);
}
- public void setDefault(String profileKey) {
- DbSession dbSession = db.openSession(false);
- try {
- setDefault(dbSession, profileKey);
- } finally {
- dbSession.close();
- }
- }
-
- void setDefault(DbSession dbSession, String profileKey) {
- checkRequest(StringUtils.isNotBlank(profileKey), "Profile key must be set");
- QualityProfileDto profile = db.qualityProfileDao().selectByKey(dbSession, profileKey);
- if (profile == null) {
- throw new NotFoundException("Quality profile not found: " + profileKey);
- }
- setDefault(dbSession, profile);
- dbSession.commit();
- }
-
- private void setDefault(DbSession session, QualityProfileDto profile) {
- QualityProfileDto previousDefault = db.qualityProfileDao().selectDefaultProfile(session, profile.getLanguage());
- if (previousDefault != null) {
- db.qualityProfileDao().update(session, previousDefault.setDefault(false));
- }
- db.qualityProfileDao().update(session, profile.setDefault(true));
- }
-
/**
* @deprecated replaced by {@link org.sonar.server.qualityprofile.ws.QProfileWsSupport#getProfile(DbSession, QProfileReference)}
*/
import org.sonar.api.server.ws.Response;
import org.sonar.api.server.ws.WebService;
import org.sonar.api.server.ws.WebService.NewAction;
-import org.sonar.server.exceptions.NotFoundException;
-import org.sonar.server.qualityprofile.QProfile;
-import org.sonar.server.qualityprofile.QProfileFactory;
-import org.sonar.server.qualityprofile.QProfileLookup;
-import org.sonar.server.util.LanguageParamUtils;
+import org.sonar.db.DbClient;
+import org.sonar.db.DbSession;
+import org.sonar.db.qualityprofile.QualityProfileDto;
+import org.sonar.server.user.UserSession;
-import static com.google.common.base.Preconditions.checkArgument;
-import static org.apache.commons.lang.StringUtils.isEmpty;
+import static org.sonar.db.permission.OrganizationPermission.ADMINISTER_QUALITY_PROFILES;
public class SetDefaultAction implements QProfileWsAction {
- private static final String PARAM_LANGUAGE = "language";
- private static final String PARAM_PROFILE_NAME = "profileName";
- private static final String PARAM_PROFILE_KEY = "profileKey";
-
private final Languages languages;
- private final QProfileLookup profileLookup;
- private final QProfileFactory profileFactory;
+ private final DbClient dbClient;
+ private final UserSession userSession;
private final QProfileWsSupport qProfileWsSupport;
- public SetDefaultAction(Languages languages, QProfileLookup profileLookup, QProfileFactory profileFactory,
- QProfileWsSupport qProfileWsSupport) {
+ public SetDefaultAction(Languages languages, DbClient dbClient, UserSession userSession, QProfileWsSupport qProfileWsSupport) {
this.languages = languages;
- this.profileLookup = profileLookup;
- this.profileFactory = profileFactory;
+ this.dbClient = dbClient;
+ this.userSession = userSession;
this.qProfileWsSupport = qProfileWsSupport;
}
.setPost(true)
.setHandler(this);
- setDefault.createParam(PARAM_LANGUAGE)
- .setDescription("The key of a language supported by the platform. If specified, profileName must be set to select the default profile for the selected language.")
- .setExampleValue("js")
- .setPossibleValues(LanguageParamUtils.getLanguageKeys(languages));
-
- setDefault.createParam(PARAM_PROFILE_NAME)
- .setDescription("The name of a quality profile. If specified, language must be set. The matching profile will be used as default for the selected language.")
- .setExampleValue("Sonar way");
+ QProfileWsSupport.createOrganizationParam(setDefault)
+ .setSince("6.4");
- setDefault.createParam(PARAM_PROFILE_KEY)
- .setDescription("The key of a quality profile. If specified, language and profileName must not be set. The matching profile will be used as default for its language.")
- .setExampleValue("sonar-way-js-12345");
+ QProfileReference.defineParams(setDefault, languages);
}
@Override
- public void handle(Request request, Response response) throws Exception {
- qProfileWsSupport.checkQProfileAdminPermission();
-
- String language = request.param(PARAM_LANGUAGE);
- String profileName = request.param(PARAM_PROFILE_NAME);
- String profileKey = request.param(PARAM_PROFILE_KEY);
-
- checkArgument(
- (!isEmpty(language) && !isEmpty(profileName)) ^ !isEmpty(profileKey), "Either profileKey or profileName + language must be set");
-
- if (profileKey == null) {
- profileKey = getProfileKeyFromLanguageAndName(language, profileName);
+ public void handle(Request request, Response response) {
+ userSession.checkLoggedIn();
+ QProfileReference reference = QProfileReference.from(request);
+ try (DbSession dbSession = dbClient.openSession(false)) {
+ QualityProfileDto qualityProfile = qProfileWsSupport.getProfile(dbSession, reference);
+ userSession.checkPermission(ADMINISTER_QUALITY_PROFILES, qualityProfile.getOrganizationUuid());
+ setDefault(dbSession, qualityProfile);
+ dbSession.commit();
}
-
- profileFactory.setDefault(profileKey);
-
response.noContent();
}
- private String getProfileKeyFromLanguageAndName(String language, String profileName) {
- QProfile profile = profileLookup.profile(profileName, language);
- if (profile == null) {
- throw new NotFoundException(String.format("Unable to find a profile for language '%s' with name '%s'", language, profileName));
+ public void setDefault(DbSession session, QualityProfileDto qualityProfile) {
+ QualityProfileDto previousDefault = dbClient.qualityProfileDao().selectDefaultProfile(session, qualityProfile.getLanguage());
+ if (previousDefault != null) {
+ dbClient.qualityProfileDao().update(session, previousDefault.setDefault(false));
}
- return profile.key();
+ dbClient.qualityProfileDao().update(session, qualityProfile.setDefault(true));
}
}
import org.sonar.db.organization.OrganizationDto;
import org.sonar.db.organization.OrganizationTesting;
import org.sonar.db.qualityprofile.QualityProfileDto;
+import org.sonar.db.qualityprofile.QualityProfileTesting;
import org.sonar.db.rule.RuleDto;
import org.sonar.db.rule.RuleParamDto;
import org.sonar.db.rule.RuleTesting;
import org.sonar.server.exceptions.BadRequestException;
-import org.sonar.server.exceptions.NotFoundException;
import org.sonar.server.qualityprofile.index.ActiveRuleIndexer;
import org.sonar.server.rule.index.RuleIndex;
import org.sonar.server.rule.index.RuleIndexer;
private ActiveRuleIndexer activeRuleIndexer;
private RuleIndexer ruleIndexer;
private QProfileFactory factory;
- private OrganizationDto organization = OrganizationTesting.newOrganizationDto();
+ private OrganizationDto organization;
@Before
public void before() {
factory = tester.get(QProfileFactory.class);
activeRuleIndexer = tester.get(ActiveRuleIndexer.class);
ruleIndexer = tester.get(RuleIndexer.class);
+ organization = OrganizationTesting.newOrganizationDto();
+ db.organizationDao().insert(dbSession, organization);
}
@After
activeRuleIndexer.index(changes);
dbSession.clearCache();
- assertThat(db.qualityProfileDao().selectAll(dbSession, getDefaultOrganization(tester, db, dbSession))).isEmpty();
+ assertThat(db.qualityProfileDao().selectAll(dbSession, organization)).isEmpty();
assertThat(db.activeRuleDao().selectAll(dbSession)).isEmpty();
assertThat(db.activeRuleDao().selectAllParams(dbSession)).isEmpty();
assertThat(db.activeRuleDao().selectByProfileKey(dbSession, XOO_P1_KEY)).isEmpty();
@Test
public void do_not_delete_default_profile() {
- db.qualityProfileDao().insert(dbSession, QProfileTesting.newXooP1(organization));
- factory.setDefault(dbSession, XOO_P1_KEY);
+ QualityProfileDto profile = QualityProfileTesting.newQualityProfileDto()
+ .setOrganizationUuid(organization.getUuid())
+ .setDefault(true);
+ db.qualityProfileDao().insert(dbSession, profile);
+
dbSession.commit();
- dbSession.clearCache();
try {
- List<ActiveRuleChange> changes = factory.delete(dbSession, XOO_P1_KEY, false);
+ List<ActiveRuleChange> changes = factory.delete(dbSession, profile.getKey(), false);
dbSession.commit();
activeRuleIndexer.index(changes);
fail();
} catch (BadRequestException e) {
- assertThat(e).hasMessage("The profile marked as default can not be deleted: XOO_P1");
+ assertThat(e).hasMessage("The profile marked as default can not be deleted: " + profile.getKey());
assertThat(db.qualityProfileDao().selectAll(dbSession, organization)).hasSize(1);
}
}
@Test
public void do_not_delete_if_default_descendant() {
- db.qualityProfileDao().insert(dbSession,
- QProfileTesting.newXooP1(organization),
- QProfileTesting.newXooP2(organization),
- QProfileTesting.newXooP3(organization));
-
- 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));
- factory.setDefault(dbSession, XOO_P3_KEY);
+ QualityProfileDto parent = QualityProfileTesting.newQualityProfileDto()
+ .setOrganizationUuid(organization.getUuid());
+ QualityProfileDto childNonDefault = QualityProfileTesting.newQualityProfileDto()
+ .setOrganizationUuid(organization.getUuid());
+ QualityProfileDto childDefault = QualityProfileTesting.newQualityProfileDto()
+ .setOrganizationUuid(organization.getUuid())
+ .setDefault(true);
+ db.qualityProfileDao().insert(dbSession, parent, childNonDefault, childDefault);
+
+ List<ActiveRuleChange> changes = tester.get(RuleActivator.class).setParent(dbSession, childNonDefault.getKey(), parent.getKey());
+ changes.addAll(tester.get(RuleActivator.class).setParent(dbSession, childDefault.getKey(), parent.getKey()));
dbSession.commit();
dbSession.clearCache();
activeRuleIndexer.index(changes);
try {
- changes = factory.delete(dbSession, XOO_P1_KEY, false);
+ changes = factory.delete(dbSession, parent.getKey(), false);
dbSession.commit();
activeRuleIndexer.index(changes);
fail();
} catch (BadRequestException e) {
- assertThat(e).hasMessage("The profile marked as default can not be deleted: XOO_P3");
+ assertThat(e).hasMessage("The profile marked as default can not be deleted: " + childDefault.getKey());
assertThat(db.qualityProfileDao().selectAll(dbSession, organization)).hasSize(3);
}
}
activeRuleIndexer.index(changes);
}
- @Test
- public void set_default_profile() {
- db.qualityProfileDao().insert(dbSession, QProfileTesting.newXooP1("org-123"));
- dbSession.commit();
- dbSession.clearCache();
-
- assertThat(db.qualityProfileDao().selectByKey(dbSession, XOO_P1_KEY).isDefault()).isFalse();
-
- factory.setDefault(XOO_P1_KEY);
- dbSession.clearCache();
-
- assertThat(db.qualityProfileDao().selectByKey(dbSession, XOO_P1_KEY).isDefault()).isTrue();
- }
-
- @Test
- public void fail_if_unknown_profile_to_be_set_as_default() {
- thrown.expect(NotFoundException.class);
- thrown.expectMessage("Quality profile not found: " + XOO_P1_KEY);
-
- factory.setDefault(XOO_P1_KEY);
- }
-
private void initRules() {
// create pre-defined rules
RuleDto xooRule1 = RuleTesting.newXooX1();
import org.sonar.db.DbClient;
import org.sonar.db.DbSession;
import org.sonar.db.loadedtemplate.LoadedTemplateDto;
+import org.sonar.db.organization.OrganizationDto;
import org.sonar.db.qualityprofile.ActiveRuleDao;
import org.sonar.db.qualityprofile.ActiveRuleDto;
import org.sonar.db.qualityprofile.ActiveRuleKey;
import org.sonar.db.qualityprofile.QualityProfileDto;
import org.sonar.db.qualityprofile.QualityProfileTesting;
import org.sonar.server.es.SearchOptions;
+import org.sonar.server.organization.DefaultOrganizationProvider;
import org.sonar.server.platform.Platform;
import org.sonar.server.rule.index.RuleIndex;
import org.sonar.server.rule.index.RuleQuery;
public void do_not_reset_default_profile_if_still_valid() {
tester = new ServerTester().withEsIndexes().withStartupTasks().addXoo().addComponents(new SimpleProfileDefinition("one", true), new SimpleProfileDefinition("two", false));
tester.start();
-
- QualityProfileDao profileDao = dbClient().qualityProfileDao();
dbSession = dbClient().openSession(false);
- QualityProfileDto profileTwo = profileDao.selectByNameAndLanguage("two", "xoo", dbSession);
- tester.get(QProfileFactory.class).setDefault(dbSession, profileTwo.getKee());
+
+ DefaultOrganizationProvider defaultOrganizationProvider = tester.get(DefaultOrganizationProvider.class);
+ OrganizationDto organization = dbClient().organizationDao().selectByUuid(dbSession, defaultOrganizationProvider.get().getUuid()).get();
+
+ QualityProfileDao dao = dbClient().qualityProfileDao();
+ dao.update(dbSession, dao.selectDefaultProfile(dbSession, "xoo")
+ .setDefault(false));
+ dao.update(dbSession, dao.selectByNameAndLanguage(organization, "two", "xoo", dbSession)
+ .setDefault(true));
dbSession.commit();
verifyDefaultProfile("xoo", "two");
WebService.Action setDefault = controller.action("set_default");
assertThat(setDefault).isNotNull();
assertThat(setDefault.isPost()).isTrue();
- assertThat(setDefault.params()).hasSize(3);
+ assertThat(setDefault.params()).hasSize(4);
+ assertThat(setDefault.param("organization").since()).isEqualTo("6.4");
}
@Test
import org.junit.rules.ExpectedException;
import org.sonar.db.DbClient;
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.db.qualityprofile.QualityProfileTesting;
import org.sonar.server.exceptions.ForbiddenException;
import org.sonar.server.exceptions.NotFoundException;
import org.sonar.server.exceptions.UnauthorizedException;
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.tester.UserSessionRule;
-import org.sonar.server.ws.WsTester;
+import org.sonar.server.ws.TestResponse;
+import org.sonar.server.ws.WsActionTester;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.mock;
import static org.sonar.db.permission.OrganizationPermission.ADMINISTER_QUALITY_PROFILES;
public class SetDefaultActionTest {
private String xoo1Key = "xoo1";
private String xoo2Key = "xoo2";
- private WsTester tester;
- private DefaultOrganizationProvider defaultOrganizationProvider = TestDefaultOrganizationProvider.from(db);
- private DbClient dbClient = db.getDbClient();
- private QProfileWsSupport wsSupport = new QProfileWsSupport(dbClient, userSessionRule, defaultOrganizationProvider);
+ private WsActionTester tester;
+ private DefaultOrganizationProvider defaultOrganizationProvider;
+ private DbClient dbClient;
+ private QProfileWsSupport wsSupport;
+ private OrganizationDto organization;
+ private SetDefaultAction underTest;
+
+ /** Single, default quality profile for language xoo1 */
+ private QualityProfileDto xoo1Profile;
+ /** Parent quality profile for language xoo2 (not a default) */
+ private QualityProfileDto xoo2Profile;
+ /** Child quality profile for language xoo2, set as default */
+ private QualityProfileDto xoo2Profile2;
@Before
public void setUp() {
- createProfiles();
+ defaultOrganizationProvider = TestDefaultOrganizationProvider.from(db);
+ dbClient = db.getDbClient();
+ wsSupport = new QProfileWsSupport(dbClient, userSessionRule, defaultOrganizationProvider);
+ organization = OrganizationTesting.newOrganizationDto();
+ db.organizations().insert(organization);
+ underTest = new SetDefaultAction(LanguageTesting.newLanguages(xoo1Key, xoo2Key), dbClient, userSessionRule, wsSupport);
+
+ String organizationUuid = organization.getUuid();
+ xoo1Profile = QualityProfileTesting.newQualityProfileDto()
+ .setOrganizationUuid(organizationUuid)
+ .setLanguage(xoo1Key)
+ .setDefault(true);
+ xoo2Profile = QualityProfileTesting.newQualityProfileDto()
+ .setOrganizationUuid(organizationUuid)
+ .setLanguage(xoo2Key);
+ xoo2Profile2 = QualityProfileTesting.newQualityProfileDto()
+ .setOrganizationUuid(organizationUuid)
+ .setLanguage(xoo2Key)
+ .setParentKee(xoo2Profile.getKee())
+ .setDefault(true);
+ dbClient.qualityProfileDao().insert(db.getSession(), xoo1Profile, xoo2Profile, xoo2Profile2);
+ db.commit();
- tester = new WsTester(new QProfilesWs(
- mock(RuleActivationActions.class),
- mock(BulkRuleActivationActions.class),
- new SetDefaultAction(LanguageTesting.newLanguages(xoo1Key, xoo2Key), new QProfileLookup(dbClient), new QProfileFactory(dbClient), wsSupport)));
+ tester = new WsActionTester(underTest);
}
@Test
public void set_default_profile_using_key() throws Exception {
logInAsQProfileAdministrator();
- checkDefaultProfile(xoo1Key, "sonar-way-xoo1-12345");
- checkDefaultProfile(xoo2Key, "my-sonar-way-xoo2-34567");
+ checkDefaultProfile(xoo1Key, xoo1Profile.getKey());
+ checkDefaultProfile(xoo2Key, xoo2Profile2.getKey());
+
+ TestResponse response = tester.newRequest()
+ .setMethod("POST")
+ .setParam("profileKey", xoo2Profile.getKee()).execute();
- tester.newPostRequest("api/qualityprofiles", "set_default").setParam("profileKey", "sonar-way-xoo2-23456").execute().assertNoContent();
+ assertThat(response.getInput()).isEmpty();
- checkDefaultProfile(xoo1Key, "sonar-way-xoo1-12345");
- checkDefaultProfile(xoo2Key, "sonar-way-xoo2-23456");
- assertThat(dbClient.qualityProfileDao().selectByKey(db.getSession(), "sonar-way-xoo2-23456").isDefault()).isTrue();
- assertThat(dbClient.qualityProfileDao().selectByKey(db.getSession(), "my-sonar-way-xoo2-34567").isDefault()).isFalse();
+ checkDefaultProfile(xoo1Key, xoo1Profile.getKey());
+ checkDefaultProfile(xoo2Key, xoo2Profile.getKee());
// One more time!
- tester.newPostRequest("api/qualityprofiles", "set_default").setParam("profileKey", "sonar-way-xoo2-23456").execute().assertNoContent();
- checkDefaultProfile(xoo1Key, "sonar-way-xoo1-12345");
- checkDefaultProfile(xoo2Key, "sonar-way-xoo2-23456");
+ TestResponse response2 = tester.newRequest()
+ .setMethod("POST")
+ .setParam("profileKey", xoo2Profile.getKee()).execute();
+
+ assertThat(response2.getInput()).isEmpty();
+ checkDefaultProfile(xoo1Key, xoo1Profile.getKey());
+ checkDefaultProfile(xoo2Key, xoo2Profile.getKee());
}
@Test
public void set_default_profile_using_language_and_name() throws Exception {
logInAsQProfileAdministrator();
- tester.newPostRequest("api/qualityprofiles", "set_default").setParam("language", xoo2Key).setParam("profileName", "Sonar way").execute().assertNoContent();
+ checkDefaultProfile(xoo1Key, xoo1Profile.getKey());
+ checkDefaultProfile(xoo2Key, xoo2Profile2.getKey());
+
+ TestResponse response = tester.newRequest().setMethod("POST")
+ .setParam("language", xoo2Profile.getLanguage())
+ .setParam("profileName", xoo2Profile.getName())
+ .setParam("organization", organization.getKey())
+ .execute();
- checkDefaultProfile(xoo1Key, "sonar-way-xoo1-12345");
- checkDefaultProfile(xoo2Key, "sonar-way-xoo2-23456");
+ assertThat(response.getInput()).isEmpty();
+
+ checkDefaultProfile(xoo1Key, xoo1Profile.getKey());
+ checkDefaultProfile(xoo2Key, xoo2Profile.getKee());
}
@Test
- public void fail_to_set_default_profile_using_key() throws Exception {
+ public void fail_to_set_default_profile_using_invalid_key() throws Exception {
logInAsQProfileAdministrator();
expectedException.expect(NotFoundException.class);
- expectedException.expectMessage("Quality profile not found: unknown-profile-666");
+ expectedException.expectMessage("Quality Profile with key 'unknown-profile-666' does not exist");
- tester.newPostRequest("api/qualityprofiles", "set_default").setParam("profileKey", "unknown-profile-666").execute();
+ tester.newRequest().setMethod("POST")
+ .setParam("profileKey", "unknown-profile-666")
+ .execute();
- checkDefaultProfile(xoo1Key, "sonar-way-xoo1-12345");
- checkDefaultProfile(xoo2Key, "my-sonar-way-xoo2-34567");
+ checkDefaultProfile(xoo1Key, xoo1Profile.getKey());
+ checkDefaultProfile(xoo2Key, xoo2Profile2.getKey());
}
@Test
- public void fail_to_set_default_profile_using_language_and_name() throws Exception {
+ public void fail_to_set_default_profile_using_language_and_invalid_name() throws Exception {
logInAsQProfileAdministrator();
try {
- tester.newPostRequest("api/qualityprofiles", "set_default").setParam("language", xoo2Key).setParam("profileName", "Unknown").execute();
+ TestResponse response = tester.newRequest().setMethod("POST")
+ .setParam("language", xoo2Key)
+ .setParam("profileName", "Unknown")
+ .execute();
Fail.failBecauseExceptionWasNotThrown(NotFoundException.class);
} catch (NotFoundException nfe) {
- assertThat(nfe).hasMessage("Unable to find a profile for language 'xoo2' with name 'Unknown'");
- checkDefaultProfile(xoo1Key, "sonar-way-xoo1-12345");
- checkDefaultProfile(xoo2Key, "my-sonar-way-xoo2-34567");
+ assertThat(nfe).hasMessage("Quality Profile for language 'xoo2' and name 'Unknown' does not exist");
+ checkDefaultProfile(xoo1Key, xoo1Profile.getKey());
+ checkDefaultProfile(xoo2Key, xoo2Profile2.getKey());
}
}
+ @Test
+ public void fail_if_parameter_profile_key_is_combined_with_parameter_organization() throws Exception {
+ userSessionRule.logIn();
+
+ expectedException.expect(IllegalArgumentException.class);
+ expectedException.expectMessage("When providing a quality profile key, neither of organization/language/name must be set");
+
+ tester.newRequest().setMethod("POST")
+ .setParam("profileKey", xoo2Profile.getKee())
+ .setParam("organization", organization.getKey())
+ .execute();
+ }
+
@Test
public void throw_ForbiddenException_if_not_profile_administrator() throws Exception {
userSessionRule.logIn();
expectedException.expect(ForbiddenException.class);
expectedException.expectMessage("Insufficient privileges");
- tester.newPostRequest("api/qualityprofiles", "set_default").setParam("profileKey", "sonar-way-xoo2-23456").execute().assertNoContent();
+ tester.newRequest().setMethod("POST")
+ .setParam("profileKey", xoo2Profile.getKee())
+ .execute();
}
@Test
expectedException.expect(UnauthorizedException.class);
expectedException.expectMessage("Authentication is required");
- tester.newPostRequest("api/qualityprofiles", "set_default").setParam("profileKey", "sonar-way-xoo2-23456").execute().assertNoContent();
+ tester.newRequest().setMethod("POST")
+ .setParam("profileKey", xoo2Profile.getKee())
+ .execute();
}
private void logInAsQProfileAdministrator() {
userSessionRule
.logIn()
- .addPermission(ADMINISTER_QUALITY_PROFILES, defaultOrganizationProvider.get().getUuid());
- }
-
- private void createProfiles() {
- dbClient.qualityProfileDao().insert(db.getSession(),
- 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();
+ .addPermission(ADMINISTER_QUALITY_PROFILES, organization.getUuid());
}
private void checkDefaultProfile(String language, String key) {