Search in sources :

Example 1 with QProfileChangeDto

use of org.sonar.db.qualityprofile.QProfileChangeDto in project sonarqube by SonarSource.

the class ActiveRuleChange method toDto.

public QProfileChangeDto toDto(@Nullable String login) {
    QProfileChangeDto dto = new QProfileChangeDto();
    dto.setChangeType(type.name());
    dto.setProfileKey(getKey().qProfile());
    dto.setLogin(login);
    Map<String, String> data = new HashMap<>();
    data.put("key", getKey().toString());
    data.put("ruleKey", getKey().ruleKey().toString());
    parameters.entrySet().stream().filter(param -> !param.getKey().isEmpty()).forEach(param -> data.put("param_" + param.getKey(), param.getValue()));
    if (StringUtils.isNotEmpty(severity)) {
        data.put("severity", severity);
    }
    if (inheritance != null) {
        data.put("inheritance", inheritance.name());
    }
    dto.setData(data);
    return dto;
}
Also used : QProfileChangeDto(org.sonar.db.qualityprofile.QProfileChangeDto) StringUtils(org.apache.commons.lang.StringUtils) ActiveRuleKey(org.sonar.db.qualityprofile.ActiveRuleKey) Map(java.util.Map) MoreObjects(com.google.common.base.MoreObjects) HashMap(java.util.HashMap) Maps(com.google.common.collect.Maps) CheckForNull(javax.annotation.CheckForNull) Nullable(javax.annotation.Nullable) HashMap(java.util.HashMap) QProfileChangeDto(org.sonar.db.qualityprofile.QProfileChangeDto)

Example 2 with QProfileChangeDto

use of org.sonar.db.qualityprofile.QProfileChangeDto in project sonarqube by SonarSource.

the class ActiveRuleChangeTest method to_dto.

@Test
public void to_dto() {
    QProfileChangeDto result = underTest.toDto(MY_LOGIN);
    assertThat(result.getChangeType()).isEqualTo(ACTIVATED.name());
    assertThat(result.getProfileKey()).isEqualTo("QP1");
    assertThat(result.getLogin()).isEqualTo(MY_LOGIN);
}
Also used : QProfileChangeDto(org.sonar.db.qualityprofile.QProfileChangeDto) Test(org.junit.Test)

Example 3 with QProfileChangeDto

use of org.sonar.db.qualityprofile.QProfileChangeDto in project sonarqube by SonarSource.

the class ChangelogLoaderTest method insertChange.

private void insertChange(String key, ActiveRuleChange.Type type, long date, @Nullable String login, @Nullable Map<String, String> data) {
    QProfileChangeDto dto = QualityProfileTesting.newQProfileChangeDto().setProfileKey(A_PROFILE_KEY).setKey(key).setCreatedAt(date).setLogin(login).setChangeType(type.name()).setData(data);
    QualityProfileTesting.insert(dbTester, dto);
}
Also used : QProfileChangeDto(org.sonar.db.qualityprofile.QProfileChangeDto)

Aggregations

QProfileChangeDto (org.sonar.db.qualityprofile.QProfileChangeDto)3 MoreObjects (com.google.common.base.MoreObjects)1 Maps (com.google.common.collect.Maps)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 CheckForNull (javax.annotation.CheckForNull)1 Nullable (javax.annotation.Nullable)1 StringUtils (org.apache.commons.lang.StringUtils)1 Test (org.junit.Test)1 ActiveRuleKey (org.sonar.db.qualityprofile.ActiveRuleKey)1