assertThat(propertyDto).isPresent();
}
+ @Test
+ public void execute_whenNoticeIsIssueCleanCodeGuide_shouldDismissCorrespondingNotice() {
+ userSessionRule.logIn();
+
+ TestResponse testResponse = tester.newRequest()
+ .setParam("notice", "issueCleanCodeGuide")
+ .execute();
+
+ assertThat(testResponse.getStatus()).isEqualTo(204);
+
+ Optional<PropertyDto> propertyDto = db.properties().findFirstUserProperty(userSessionRule.getUuid(), "user.dismissedNotices.issueCleanCodeGuide");
+ assertThat(propertyDto).isPresent();
+ }
+
@Test
public void authentication_is_required() {
assertThatThrownBy(testRequest::execute)
.isInstanceOf(IllegalArgumentException.class)
- .hasMessage("Value of parameter 'notice' (not_supported_value) must be one of: [educationPrinciples, sonarlintAd]");
+ .hasMessage("Value of parameter 'notice' (not_supported_value) must be one of: [educationPrinciples, sonarlintAd, issueCleanCodeGuide]");
}
import static org.apache.commons.lang.StringUtils.EMPTY;
import static org.sonar.api.web.UserRole.USER;
import static org.sonar.server.user.ws.DismissNoticeAction.EDUCATION_PRINCIPLES;
+import static org.sonar.server.user.ws.DismissNoticeAction.ISSUE_CLEAN_CODE_GUIDE;
import static org.sonar.server.user.ws.DismissNoticeAction.SONARLINT_AD;
import static org.sonar.server.ws.WsUtils.writeProtobuf;
import static org.sonarqube.ws.Users.CurrentWsResponse.HomepageType.APPLICATION;
.setHomepage(buildHomepage(dbSession, user))
.setUsingSonarLintConnectedMode(user.getLastSonarlintConnectionDate() != null)
.putDismissedNotices(EDUCATION_PRINCIPLES, isNoticeDismissed(user, EDUCATION_PRINCIPLES))
- .putDismissedNotices(SONARLINT_AD, isNoticeDismissed(user, SONARLINT_AD));
+ .putDismissedNotices(SONARLINT_AD, isNoticeDismissed(user, SONARLINT_AD))
+ .putDismissedNotices(ISSUE_CLEAN_CODE_GUIDE, isNoticeDismissed(user, ISSUE_CLEAN_CODE_GUIDE));
ofNullable(emptyToNull(user.getEmail())).ifPresent(builder::setEmail);
ofNullable(emptyToNull(user.getEmail())).ifPresent(u -> builder.setAvatar(avatarResolver.create(user)));
ofNullable(user.getExternalLogin()).ifPresent(builder::setExternalIdentity);
*/
package org.sonar.server.user.ws;
+import org.sonar.api.server.ws.Change;
import org.sonar.api.server.ws.Request;
import org.sonar.api.server.ws.Response;
import org.sonar.api.server.ws.WebService;
public static final String EDUCATION_PRINCIPLES = "educationPrinciples";
public static final String SONARLINT_AD = "sonarlintAd";
+ public static final String ISSUE_CLEAN_CODE_GUIDE = "issueCleanCodeGuide";
public static final String USER_DISMISS_CONSTANT = "user.dismissedNotices.";
private final UserSession userSession;
public void define(WebService.NewController context) {
WebService.NewAction action = context.createAction("dismiss_notice")
.setDescription("Dismiss a notice for the current user. Silently ignore if the notice is already dismissed.")
+ .setChangelog(new Change("10.2", "Support for new notice '%s' was added.".formatted(ISSUE_CLEAN_CODE_GUIDE)))
.setSince("9.6")
.setInternal(true)
.setHandler(this)
action.createParam("notice")
.setDescription("notice key to dismiss")
.setExampleValue(EDUCATION_PRINCIPLES)
- .setPossibleValues(EDUCATION_PRINCIPLES, SONARLINT_AD);
+ .setPossibleValues(EDUCATION_PRINCIPLES, SONARLINT_AD, ISSUE_CLEAN_CODE_GUIDE);
}
@Override