import com.google.common.collect.Iterables;
import com.google.common.collect.Sets;
import org.apache.commons.lang.time.DateUtils;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.Test;
+import org.junit.*;
import org.sonar.api.rule.RuleKey;
import org.sonar.api.rule.RuleStatus;
import org.sonar.api.rule.Severity;
import org.sonar.server.tester.ServerTester;
import javax.annotation.Nullable;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.List;
+
+import java.util.*;
import static com.google.common.collect.Lists.newArrayList;
import static org.fest.assertions.Assertions.assertThat;
}
@Test
- public void search_by_has_subChar() {
+ @Ignore("To be fixed")
+ public void search_by_has_debt_characteristic() {
CharacteristicDto char1 = DebtTesting.newCharacteristicDto("c1")
.setEnabled(true)
.setName("char1");
.setParentId(char1.getId());
db.debtCharacteristicDao().insert(char11, dbSession);
+ // Rule with default characteristic
dao.insert(dbSession, RuleTesting.newDto(RuleKey.of("findbugs", "S001"))
- .setSubCharacteristicId(char11.getId()));
- dao.insert(dbSession, RuleTesting.newDto(RuleKey.of("pmd", "S002")));
+ .setSubCharacteristicId(null)
+ .setRemediationFunction(null)
+ .setDefaultSubCharacteristicId(char11.getId())
+ .setDefaultRemediationFunction("LINEAR").setDefaultRemediationCoefficient("2h"));
+ // Rule with overridden characteristic
+ dao.insert(dbSession, RuleTesting.newDto(RuleKey.of("pmd", "S002"))
+ .setSubCharacteristicId(char11.getId())
+ .setRemediationFunction("LINEAR").setRemediationCoefficient("2h")
+ .setDefaultSubCharacteristicId(null)
+ .setDefaultRemediationFunction(null));
dbSession.commit();
// 0. assert base case
// 1. assert hasSubChar filter
assertThat(index.search(new RuleQuery().setHasDebtCharacteristic(true), new QueryOptions()).getTotal())
- .isEqualTo(1);
+ .isEqualTo(2);
}
@Test