Kaynağa Gözat

SONAR-11513 drop Guava Optional from ActiveRulesHolder

tags/7.5
Sébastien Lesaint 5 yıl önce
ebeveyn
işleme
a11e761461

+ 2
- 3
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/commonrule/CommonRule.java Dosyayı Görüntüle

@@ -19,14 +19,13 @@
*/
package org.sonar.ce.task.projectanalysis.issue.commonrule;

import com.google.common.base.Optional;
import java.util.Optional;
import javax.annotation.CheckForNull;
import org.sonar.api.rule.RuleKey;
import org.sonar.ce.task.projectanalysis.component.Component;
import org.sonar.core.issue.DefaultIssue;
import org.sonar.ce.task.projectanalysis.component.Component;
import org.sonar.ce.task.projectanalysis.qualityprofile.ActiveRule;
import org.sonar.ce.task.projectanalysis.qualityprofile.ActiveRulesHolder;
import org.sonar.core.issue.DefaultIssue;

import static org.apache.commons.lang.StringUtils.isNotBlank;
import static org.sonar.server.rule.CommonRuleKeys.commonRepositoryForLang;

+ 1
- 1
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/qualityprofile/ActiveRulesHolder.java Dosyayı Görüntüle

@@ -19,7 +19,7 @@
*/
package org.sonar.ce.task.projectanalysis.qualityprofile;

import com.google.common.base.Optional;
import java.util.Optional;
import org.sonar.api.rule.RuleKey;

public interface ActiveRulesHolder {

+ 2
- 2
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/qualityprofile/ActiveRulesHolderImpl.java Dosyayı Görüntüle

@@ -19,11 +19,11 @@
*/
package org.sonar.ce.task.projectanalysis.qualityprofile;

import com.google.common.base.Optional;
import com.google.common.collect.ImmutableMap;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import org.sonar.api.rule.RuleKey;

import static com.google.common.base.Preconditions.checkState;
@@ -36,7 +36,7 @@ public class ActiveRulesHolderImpl implements ActiveRulesHolder {
@Override
public Optional<ActiveRule> get(RuleKey ruleKey) {
checkState(activeRulesByKey != null, "Active rules have not been initialized yet");
return Optional.fromNullable(activeRulesByKey.get(ruleKey));
return Optional.ofNullable(activeRulesByKey.get(ruleKey));
}

public Collection<ActiveRule> getAll() {

+ 2
- 2
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/IssueCreationDateCalculatorTest.java Dosyayı Görüntüle

@@ -19,10 +19,10 @@
*/
package org.sonar.ce.task.projectanalysis.issue;

import com.google.common.base.Optional;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import org.junit.Before;
import org.junit.Test;
import org.junit.rules.ExpectedException;
@@ -86,7 +86,7 @@ public class IssueCreationDateCalculatorTest {

when(ruleRepository.findByKey(ruleKey)).thenReturn(java.util.Optional.of(rule));
when(activeRulesHolder.get(any(RuleKey.class)))
.thenReturn(Optional.absent());
.thenReturn(Optional.empty());
when(activeRulesHolder.get(ruleKey))
.thenReturn(Optional.of(activeRule));
when(issue.getRuleKey())

+ 1
- 1
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/qualityprofile/ActiveRulesHolderImplTest.java Dosyayı Görüntüle

@@ -19,8 +19,8 @@
*/
package org.sonar.ce.task.projectanalysis.qualityprofile;

import com.google.common.base.Optional;
import java.util.Collections;
import java.util.Optional;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;

+ 2
- 2
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/qualityprofile/ActiveRulesHolderRule.java Dosyayı Görüntüle

@@ -19,9 +19,9 @@
*/
package org.sonar.ce.task.projectanalysis.qualityprofile;

import com.google.common.base.Optional;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import org.junit.rules.ExternalResource;
import org.sonar.api.rule.RuleKey;

@@ -31,7 +31,7 @@ public class ActiveRulesHolderRule extends ExternalResource implements ActiveRul

@Override
public Optional<ActiveRule> get(RuleKey ruleKey) {
return Optional.fromNullable(activeRulesByKey.get(ruleKey));
return Optional.ofNullable(activeRulesByKey.get(ruleKey));
}

public ActiveRulesHolderRule put(ActiveRule activeRule) {

+ 1
- 1
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/qualityprofile/AlwaysActiveRulesHolderImpl.java Dosyayı Görüntüle

@@ -19,7 +19,7 @@
*/
package org.sonar.ce.task.projectanalysis.qualityprofile;

import com.google.common.base.Optional;
import java.util.Optional;
import org.sonar.api.rule.RuleKey;
import org.sonar.api.rule.Severity;


+ 1
- 1
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/LoadQualityProfilesStepTest.java Dosyayı Görüntüle

@@ -19,7 +19,7 @@
*/
package org.sonar.ce.task.projectanalysis.step;

import com.google.common.base.Optional;
import java.util.Optional;
import org.assertj.core.data.MapEntry;
import org.junit.Rule;
import org.junit.Test;

Loading…
İptal
Kaydet