*/
package org.sonar.server.debt;
-import com.google.common.collect.Ordering;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.nio.charset.StandardCharsets;
import org.apache.commons.lang.StringUtils;
import org.sonar.api.rule.RuleKey;
import org.sonar.api.server.ServerSide;
-import org.sonar.api.server.debt.DebtCharacteristic;
import org.xml.sax.InputSource;
/**
'}';
}
}
-
- private static class SortByOrder extends Ordering<DebtCharacteristic> {
- @Override
- public int compare(@Nullable DebtCharacteristic left, @Nullable DebtCharacteristic right) {
- if (left == null || left.order() == null || right == null || right.order() == null) {
- return -1;
- }
- return left.order() - right.order();
- }
- }
-
- private static class SortByName extends Ordering<DebtCharacteristic> {
- @Override
- public int compare(@Nullable DebtCharacteristic left, @Nullable DebtCharacteristic right) {
- if (left == null || right == null) {
- return -1;
- }
- return StringUtils.defaultString(left.name()).compareTo(StringUtils.defaultString(right.name()));
- }
- }
}
import org.sonar.api.i18n.I18n;
import org.sonar.api.issue.Issue;
import org.sonar.api.rule.RuleKey;
-import org.sonar.api.server.debt.internal.DefaultDebtCharacteristic;
import org.sonar.api.user.User;
import org.sonar.api.user.UserFinder;
import org.sonar.api.utils.DateUtils;
import org.sonar.db.component.ComponentDao;
import org.sonar.db.component.ComponentDto;
import org.sonar.db.component.ComponentTesting;
-import org.sonar.server.debt.DebtModelService;
import org.sonar.server.issue.ActionService;
import org.sonar.server.issue.IssueChangelog;
import org.sonar.server.issue.IssueChangelogService;
public interface DebtCharacteristic {
/**
- * Only used when a characteristic is disabled (id is -1 in dto) by the user. see {@link org.sonar.server.rule.index.RuleNormalizer}
+ * Only used when a characteristic is disabled (id is -1 in dto) by the user.
*/
String NONE = "NONE";
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.api.server.debt.internal;
-
-import org.apache.commons.lang.builder.ToStringBuilder;
-import org.apache.commons.lang.builder.ToStringStyle;
-import org.sonar.api.server.debt.DebtCharacteristic;
-
-import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
-
-import java.util.Date;
-
-/**
- * @since 4.3
- */
-public class DefaultDebtCharacteristic implements DebtCharacteristic {
-
- private Integer id;
- private String key;
- private String name;
- private Integer order;
- private Integer parentId;
- private Date createdAt;
- private Date updatedAt;
-
- public Integer id() {
- return id;
- }
-
- public DefaultDebtCharacteristic setId(Integer id) {
- this.id = id;
- return this;
- }
-
- @Override
- public String key() {
- return key;
- }
-
- public DefaultDebtCharacteristic setKey(String key) {
- this.key = key;
- return this;
- }
-
- @Override
- public String name() {
- return name;
- }
-
- public DefaultDebtCharacteristic setName(String name) {
- this.name = name;
- return this;
- }
-
- @Override
- @CheckForNull
- public Integer order() {
- return order;
- }
-
- public DefaultDebtCharacteristic setOrder(@Nullable Integer order) {
- this.order = order;
- return this;
- }
-
- @CheckForNull
- public Integer parentId() {
- return parentId;
- }
-
- public DefaultDebtCharacteristic setParentId(@Nullable Integer parentId) {
- this.parentId = parentId;
- return this;
- }
-
- public Date createdAt() {
- return createdAt;
- }
-
- public DefaultDebtCharacteristic setCreatedAt(Date createdAt) {
- this.createdAt = createdAt;
- return this;
- }
-
- @CheckForNull
- public Date updatedAt() {
- return updatedAt;
- }
-
- public DefaultDebtCharacteristic setUpdatedAt(@Nullable Date updatedAt) {
- this.updatedAt = updatedAt;
- return this;
- }
-
- @Override
- public boolean isSub(){
- return parentId != null;
- }
-
- @Override
- public String toString() {
- return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
- }
-
-}
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.api.server.debt.internal;
-
-import org.junit.Test;
-
-import java.util.Date;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class DefaultDebtCharacteristicTest {
-
- @Test
- public void setter_and_getter_on_characteristic() {
- DefaultDebtCharacteristic debtCharacteristic = new DefaultDebtCharacteristic()
- .setId(1)
- .setKey("PORTABILITY")
- .setName("Portability")
- .setOrder(1)
- .setCreatedAt(new Date())
- .setUpdatedAt(new Date());
-
- assertThat(debtCharacteristic.id()).isEqualTo(1);
- assertThat(debtCharacteristic.key()).isEqualTo("PORTABILITY");
- assertThat(debtCharacteristic.name()).isEqualTo("Portability");
- assertThat(debtCharacteristic.order()).isEqualTo(1);
- assertThat(debtCharacteristic.parentId()).isNull();
- assertThat(debtCharacteristic.isSub()).isFalse();
- assertThat(debtCharacteristic.createdAt()).isNotNull();
- assertThat(debtCharacteristic.updatedAt()).isNotNull();
- }
-
- @Test
- public void setter_and_getter_on_sub_characteristic() {
- DefaultDebtCharacteristic debtCharacteristic = new DefaultDebtCharacteristic()
- .setId(1)
- .setKey("COMPILER")
- .setName("Compiler")
- .setParentId(2)
- .setCreatedAt(new Date())
- .setUpdatedAt(new Date());
-
- assertThat(debtCharacteristic.id()).isEqualTo(1);
- assertThat(debtCharacteristic.key()).isEqualTo("COMPILER");
- assertThat(debtCharacteristic.name()).isEqualTo("Compiler");
- assertThat(debtCharacteristic.order()).isNull();
- assertThat(debtCharacteristic.parentId()).isEqualTo(2);
- assertThat(debtCharacteristic.isSub()).isTrue();
- assertThat(debtCharacteristic.createdAt()).isNotNull();
- assertThat(debtCharacteristic.updatedAt()).isNotNull();
- }
-
- @Test
- public void to_string() {
- assertThat(new DefaultDebtCharacteristic()
- .setId(1)
- .setKey("PORTABILITY")
- .setName("Portability")
- .setOrder(1)
- .setCreatedAt(new Date())
- .setUpdatedAt(new Date())).isNotNull();
- }
-}