From e2bf4b506020297b7bda20d320bf4b61a4315825 Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Tue, 8 Mar 2016 10:21:35 +0100 Subject: [PATCH] SONAR-7364 remove SQALE characteristics from scanner API --- .../java/it/plugins/checks/Validation.java | 3 +- .../api/batch/debt/DebtCharacteristic.java | 2 + .../internal/DefaultDebtCharacteristic.java | 119 ------ .../batch/debt/internal/DefaultDebtModel.java | 64 +--- .../java/org/sonar/api/measures/Measure.java | 44 --- .../sonar/api/measures/MeasuresFilters.java | 66 +--- .../technicaldebt/batch/Characteristic.java | 54 --- .../api/technicaldebt/batch/Requirement.java | 82 ---- .../batch/internal/DefaultCharacteristic.java | 198 ---------- .../batch/internal/DefaultRequirement.java | 258 ------------- .../batch/internal/package-info.java | 23 -- .../api/technicaldebt/batch/package-info.java | 23 -- .../technicaldebt/server/Characteristic.java | 111 ------ .../internal/DefaultCharacteristic.java | 349 ------------------ .../server/internal/package-info.java | 23 -- .../technicaldebt/server/package-info.java | 23 -- .../DefaultDebtCharacteristicTest.java | 80 ---- .../debt/internal/DefaultDebtModelTest.java | 68 +--- .../internal/DefaultCharacteristicTest.java | 119 ------ .../internal/DefaultRequirementTest.java | 137 ------- .../internal/DefaultCharacteristicTest.java | 149 -------- 21 files changed, 18 insertions(+), 1977 deletions(-) delete mode 100644 sonar-plugin-api/src/main/java/org/sonar/api/batch/debt/internal/DefaultDebtCharacteristic.java delete mode 100644 sonar-plugin-api/src/main/java/org/sonar/api/technicaldebt/batch/Characteristic.java delete mode 100644 sonar-plugin-api/src/main/java/org/sonar/api/technicaldebt/batch/Requirement.java delete mode 100644 sonar-plugin-api/src/main/java/org/sonar/api/technicaldebt/batch/internal/DefaultCharacteristic.java delete mode 100644 sonar-plugin-api/src/main/java/org/sonar/api/technicaldebt/batch/internal/DefaultRequirement.java delete mode 100644 sonar-plugin-api/src/main/java/org/sonar/api/technicaldebt/batch/internal/package-info.java delete mode 100644 sonar-plugin-api/src/main/java/org/sonar/api/technicaldebt/batch/package-info.java delete mode 100644 sonar-plugin-api/src/main/java/org/sonar/api/technicaldebt/server/Characteristic.java delete mode 100644 sonar-plugin-api/src/main/java/org/sonar/api/technicaldebt/server/internal/DefaultCharacteristic.java delete mode 100644 sonar-plugin-api/src/main/java/org/sonar/api/technicaldebt/server/internal/package-info.java delete mode 100644 sonar-plugin-api/src/main/java/org/sonar/api/technicaldebt/server/package-info.java delete mode 100644 sonar-plugin-api/src/test/java/org/sonar/api/batch/debt/internal/DefaultDebtCharacteristicTest.java delete mode 100644 sonar-plugin-api/src/test/java/org/sonar/api/technicaldebt/batch/internal/DefaultCharacteristicTest.java delete mode 100644 sonar-plugin-api/src/test/java/org/sonar/api/technicaldebt/batch/internal/DefaultRequirementTest.java delete mode 100644 sonar-plugin-api/src/test/java/org/sonar/api/technicaldebt/server/internal/DefaultCharacteristicTest.java diff --git a/it/it-tests/src/test/java/it/plugins/checks/Validation.java b/it/it-tests/src/test/java/it/plugins/checks/Validation.java index db43f61bcaf..e923ec8b6a8 100644 --- a/it/it-tests/src/test/java/it/plugins/checks/Validation.java +++ b/it/it-tests/src/test/java/it/plugins/checks/Validation.java @@ -38,8 +38,7 @@ import static org.hamcrest.CoreMatchers.notNullValue; * * TODO must have syntax highlighting * TODO must have duplications - * TODO must have issues with SQALE characteristic and debt - * TODO must have rules with characteristic + * TODO must have issues with debt * TODO must have tests * TODO must have coverage */ diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/debt/DebtCharacteristic.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/debt/DebtCharacteristic.java index 5abf694b343..da04f8e2ad7 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/debt/DebtCharacteristic.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/debt/DebtCharacteristic.java @@ -23,7 +23,9 @@ import javax.annotation.CheckForNull; /** * @since 4.3 + * @deprecated since 5.1 debt model will soon be unavailable on batch side */ +@Deprecated public interface DebtCharacteristic { String key(); diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/debt/internal/DefaultDebtCharacteristic.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/debt/internal/DefaultDebtCharacteristic.java deleted file mode 100644 index c1ebf30f9e6..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/debt/internal/DefaultDebtCharacteristic.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * 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.batch.debt.internal; - -import org.apache.commons.lang.builder.ToStringBuilder; -import org.apache.commons.lang.builder.ToStringStyle; -import org.sonar.api.batch.debt.DebtCharacteristic; - -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; - -import java.util.Date; - -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); - } -} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/debt/internal/DefaultDebtModel.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/debt/internal/DefaultDebtModel.java index ade9292de35..747b10894ee 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/debt/internal/DefaultDebtModel.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/debt/internal/DefaultDebtModel.java @@ -19,89 +19,37 @@ */ package org.sonar.api.batch.debt.internal; -import com.google.common.base.Predicate; -import com.google.common.collect.ArrayListMultimap; -import com.google.common.collect.Iterables; -import com.google.common.collect.Multimap; +import java.util.Collections; import java.util.List; import javax.annotation.CheckForNull; import org.sonar.api.batch.debt.DebtCharacteristic; import org.sonar.api.batch.debt.DebtModel; -import static com.google.common.collect.Lists.newArrayList; - public class DefaultDebtModel implements DebtModel { - /** - * Sub-characteristics list can be retrieved with the characteristic key - * Characteristics list can be retrieved by with the null key - */ - private Multimap characteristicsByKey; - - public DefaultDebtModel() { - characteristicsByKey = ArrayListMultimap.create(); - } - - public DefaultDebtModel addCharacteristic(DebtCharacteristic characteristic) { - characteristicsByKey.put(null, characteristic); - return this; - } - - - public DefaultDebtModel addSubCharacteristic(DebtCharacteristic subCharacteristic, String characteristicKey) { - characteristicsByKey.put(characteristicKey, subCharacteristic); - return this; - } - @Override public List characteristics() { - return newArrayList(characteristicsByKey.get(null)); + return Collections.emptyList(); } @Override public List subCharacteristics(String characteristicKey) { - return newArrayList(characteristicsByKey.get(characteristicKey)); + return Collections.emptyList(); } @Override public List allCharacteristics() { - return newArrayList(characteristicsByKey.values()); + return Collections.emptyList(); } @Override @CheckForNull public DebtCharacteristic characteristicByKey(final String key) { - return Iterables.find(characteristicsByKey.values(), new MatchDebtCharacteristicKey(key), null); + return null; } @CheckForNull public DebtCharacteristic characteristicById(int id) { - return Iterables.find(characteristicsByKey.values(), new MatchDebtCharacteristicId(id), null); - } - - private static class MatchDebtCharacteristicKey implements Predicate { - private final String key; - - public MatchDebtCharacteristicKey(String key) { - this.key = key; - } - - @Override - public boolean apply(DebtCharacteristic input) { - return key.equals(input.key()); - } - } - - private static class MatchDebtCharacteristicId implements Predicate { - private final int id; - - public MatchDebtCharacteristicId(int id) { - this.id = id; - } - - @Override - public boolean apply(DebtCharacteristic input) { - return id == ((DefaultDebtCharacteristic) input).id(); - } + return null; } } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/Measure.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/Measure.java index e56da3f3589..3cd739d1cdb 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/Measure.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/measures/Measure.java @@ -26,8 +26,6 @@ import javax.annotation.CheckForNull; import javax.annotation.Nullable; import org.apache.commons.lang.builder.ReflectionToStringBuilder; import org.apache.commons.lang.math.NumberUtils; -import org.sonar.api.technicaldebt.batch.Characteristic; -import org.sonar.api.technicaldebt.batch.Requirement; /** * A class to handle measures. @@ -60,8 +58,6 @@ public class Measure implements Serializable { protected Double variation4; protected Double variation5; protected String url; - protected Characteristic characteristic; - protected Requirement requirement; protected Integer personId; protected PersistenceMode persistenceMode = PersistenceMode.FULL; private boolean fromCore; @@ -620,42 +616,6 @@ public class Measure implements Serializable { return this; } - /** - * @since 4.1 - */ - @CheckForNull - public final Characteristic getCharacteristic() { - return characteristic; - } - - /** - * @since 4.1 - */ - public final Measure setCharacteristic(@Nullable Characteristic characteristic) { - this.characteristic = characteristic; - return this; - } - - /** - * @since 4.1 - * @deprecated since 4.3. - */ - @Deprecated - @CheckForNull - public final Requirement getRequirement() { - return requirement; - } - - /** - * @since 4.1 - * @deprecated since 4.3 - */ - @Deprecated - public final Measure setRequirement(@Nullable Requirement requirement) { - this.requirement = requirement; - return this; - } - /** * @since 2.14 */ @@ -731,16 +691,12 @@ public class Measure implements Serializable { if (metricKey != null ? !metricKey.equals(measure.metricKey) : (measure.metricKey != null)) { return false; } - if (characteristic != null ? !characteristic.equals(measure.characteristic) : (measure.characteristic != null)) { - return false; - } return !(personId != null ? !personId.equals(measure.personId) : (measure.personId != null)); } @Override public int hashCode() { int result = metricKey != null ? metricKey.hashCode() : 0; - result = 31 * result + (characteristic != null ? characteristic.hashCode() : 0); result = 31 * result + (personId != null ? personId.hashCode() : 0); return result; } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/MeasuresFilters.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/MeasuresFilters.java index 3650f65ec1e..470593c856f 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/MeasuresFilters.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/measures/MeasuresFilters.java @@ -19,14 +19,11 @@ */ package org.sonar.api.measures; -import org.sonar.api.rule.RuleKey; -import org.sonar.api.rules.Rule; -import org.sonar.api.technicaldebt.batch.Characteristic; -import org.sonar.api.technicaldebt.batch.Requirement; - import java.util.ArrayList; import java.util.Collection; import java.util.List; +import org.sonar.api.rule.RuleKey; +import org.sonar.api.rules.Rule; /** * @since 1.10 @@ -65,7 +62,6 @@ public final class MeasuresFilters { for (Measure measure : measures) { if (measure.getClass().equals(Measure.class) && measure.getMetricKey().equals(metricKey) && - measure.getCharacteristic() == null && measure.getPersonId() == null) { return measure; } @@ -75,64 +71,6 @@ public final class MeasuresFilters { }; } - public static MeasuresFilter characteristic(final Metric metric, final Characteristic characteristic) { - return new MetricFilter(metric) { - - @Override - public Measure filter(Collection measures) { - if (measures == null) { - return null; - } - for (Measure measure : measures) { - if (measure.getClass().equals(Measure.class) && - measure.getMetric().equals(metric) && - measure.getPersonId() == null && - isSameCharacteristic(measure, characteristic)) { - return measure; - } - } - return null; - } - }; - } - - private static boolean isSameCharacteristic(Measure measure, final Characteristic characteristic) { - Characteristic measureCharacteristic = measure.getCharacteristic(); - return measureCharacteristic != null && - measureCharacteristic.equals(characteristic); - } - - /** - * @deprecated since 4.3 - */ - @Deprecated - public static MeasuresFilter requirement(final Metric metric, final Requirement requirement) { - return new MetricFilter(metric) { - - @Override - public Measure filter(Collection measures) { - if (measures == null) { - return null; - } - for (Measure measure : measures) { - if (measure.getClass().equals(Measure.class) && - measure.getMetric().equals(metric) && - measure.getPersonId() == null && - isSameRequirement(measure, requirement)) { - return measure; - } - } - return null; - } - }; - } - - private static boolean isSameRequirement(Measure measure, final Requirement requirement) { - Requirement measureRequirement = measure.getRequirement(); - return measureRequirement != null && - measureRequirement.equals(requirement); - } - /** * @since 2.0 */ diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/technicaldebt/batch/Characteristic.java b/sonar-plugin-api/src/main/java/org/sonar/api/technicaldebt/batch/Characteristic.java deleted file mode 100644 index 381fadc9434..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/technicaldebt/batch/Characteristic.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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.technicaldebt.batch; - -import javax.annotation.CheckForNull; - -import java.io.Serializable; -import java.util.Date; -import java.util.List; - -/** - * @since 4.1 - * @deprecated since 4.3 - */ -@Deprecated -public interface Characteristic extends Serializable { - - Integer id(); - - String key(); - - String name(); - - Integer order(); - - @CheckForNull - Characteristic parent(); - - List children(); - - boolean isRoot(); - - Date createdAt(); - - Date updatedAt(); - -} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/technicaldebt/batch/Requirement.java b/sonar-plugin-api/src/main/java/org/sonar/api/technicaldebt/batch/Requirement.java deleted file mode 100644 index 64e0d8fb1ca..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/technicaldebt/batch/Requirement.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * 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.technicaldebt.batch; - -import org.sonar.api.rule.RuleKey; -import org.sonar.api.utils.WorkUnit; -import org.sonar.api.utils.internal.WorkDuration; - -import java.io.Serializable; -import java.util.Date; - -/** - * @since 4.1 - * @deprecated since 4.3 - */ -@Deprecated -public interface Requirement extends Serializable { - - Integer id(); - - RuleKey ruleKey(); - - Characteristic characteristic(); - - Characteristic rootCharacteristic(); - - String function(); - - /** - * @deprecated since 4.2 - */ - @Deprecated - WorkUnit factor(); - - /** - * @since 4.2 - */ - int factorValue(); - - /** - * @since 4.2 - */ - WorkDuration.UNIT factorUnit(); - - /** - * @deprecated since 4.2 - */ - @Deprecated - WorkUnit offset(); - - /** - * @since 4.2 - */ - int offsetValue(); - - /** - * @since 4.2 - */ - WorkDuration.UNIT offsetUnit(); - - Date createdAt(); - - Date updatedAt(); - -} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/technicaldebt/batch/internal/DefaultCharacteristic.java b/sonar-plugin-api/src/main/java/org/sonar/api/technicaldebt/batch/internal/DefaultCharacteristic.java deleted file mode 100644 index 59b54e1ffbd..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/technicaldebt/batch/internal/DefaultCharacteristic.java +++ /dev/null @@ -1,198 +0,0 @@ -/* - * 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.technicaldebt.batch.internal; - -import org.apache.commons.lang.StringUtils; -import org.apache.commons.lang.builder.ToStringBuilder; -import org.apache.commons.lang.builder.ToStringStyle; -import org.sonar.api.technicaldebt.batch.Characteristic; - -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; - -import java.util.Date; -import java.util.List; - -import static com.google.common.collect.Lists.newArrayList; - -/** - * @deprecated since 4.3 - */ -@Deprecated -public class DefaultCharacteristic implements Characteristic { - - private Integer id; - private String key; - private String name; - private Integer order; - private DefaultCharacteristic parent; - private DefaultCharacteristic root; - private List children; - private List requirements; - - private Date createdAt; - private Date updatedAt; - - public DefaultCharacteristic() { - this.children = newArrayList(); - this.requirements = newArrayList(); - } - - @Override - public Integer id() { - return id; - } - - public DefaultCharacteristic setId(Integer id) { - this.id = id; - return this; - } - - @Override - public String key() { - return key; - } - - public DefaultCharacteristic setKey(String key) { - this.key = StringUtils.trimToNull(key); - return this; - } - - @Override - public String name() { - return name; - } - - public DefaultCharacteristic setName(String name) { - this.name = name; - return this; - } - - public DefaultCharacteristic setName(String s, boolean asKey) { - this.name = StringUtils.trimToNull(s); - if (asKey) { - this.key = StringUtils.upperCase(this.name); - this.key = StringUtils.replaceChars(this.key, ' ', '_'); - } - return this; - } - - @Override - @CheckForNull - public Integer order() { - return order; - } - - public DefaultCharacteristic setOrder(@Nullable Integer order) { - this.order = order; - return this; - } - - @Override - @CheckForNull - public DefaultCharacteristic parent() { - return parent; - } - - public DefaultCharacteristic setParent(@Nullable DefaultCharacteristic parent) { - if (parent != null) { - this.parent = parent; - parent.addChild(this); - } - return this; - } - - @CheckForNull - public DefaultCharacteristic root() { - return root; - } - - public DefaultCharacteristic setRoot(@Nullable DefaultCharacteristic root) { - this.root = root; - return this; - } - - @Override - public List children() { - return children; - } - - private DefaultCharacteristic addChild(DefaultCharacteristic child) { - this.children.add(child); - return this; - } - - public List requirements() { - return requirements; - } - - public DefaultCharacteristic addRequirement(DefaultRequirement requirement) { - this.requirements.add(requirement); - return this; - } - - @Override - public boolean isRoot() { - return parent == null; - } - - @Override - public Date createdAt() { - return createdAt; - } - - public DefaultCharacteristic setCreatedAt(Date createdAt) { - this.createdAt = createdAt; - return this; - } - - @Override - @CheckForNull - public Date updatedAt() { - return updatedAt; - } - - public DefaultCharacteristic setUpdatedAt(@Nullable Date updatedAt) { - this.updatedAt = updatedAt; - return this; - } - - @Override - public String toString() { - return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - DefaultCharacteristic that = (DefaultCharacteristic) o; - return key.equals(that.key); - } - - @Override - public int hashCode() { - return key.hashCode(); - } -} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/technicaldebt/batch/internal/DefaultRequirement.java b/sonar-plugin-api/src/main/java/org/sonar/api/technicaldebt/batch/internal/DefaultRequirement.java deleted file mode 100644 index 337c69642cc..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/technicaldebt/batch/internal/DefaultRequirement.java +++ /dev/null @@ -1,258 +0,0 @@ -/* - * 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.technicaldebt.batch.internal; - -import java.util.Date; -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; -import org.apache.commons.lang.builder.ToStringBuilder; -import org.apache.commons.lang.builder.ToStringStyle; -import org.sonar.api.rule.RuleKey; -import org.sonar.api.technicaldebt.batch.Requirement; -import org.sonar.api.utils.WorkUnit; -import org.sonar.api.utils.internal.WorkDuration; - -/** - * @deprecated since 4.3 - */ -@Deprecated -public class DefaultRequirement implements Requirement { - - public static final String FUNCTION_LINEAR = "linear"; - public static final String FUNCTION_LINEAR_WITH_OFFSET = "linear_offset"; - public static final String CONSTANT_ISSUE = "constant_issue"; - - private Integer id; - private RuleKey ruleKey; - private DefaultCharacteristic characteristic; - private DefaultCharacteristic rootCharacteristic; - - private String function; - private int factorValue; - private WorkDuration.UNIT factorUnit; - private int offsetValue; - private WorkDuration.UNIT offsetUnit; - - private Date createdAt; - private Date updatedAt; - - @Override - public Integer id() { - return id; - } - - public DefaultRequirement setId(Integer id) { - this.id = id; - return this; - } - - @Override - public RuleKey ruleKey() { - return ruleKey; - } - - public DefaultRequirement setRuleKey(RuleKey ruleKey) { - this.ruleKey = ruleKey; - return this; - } - - @Override - public DefaultCharacteristic characteristic() { - return characteristic; - } - - public DefaultRequirement setCharacteristic(DefaultCharacteristic characteristic) { - this.characteristic = characteristic; - this.characteristic.addRequirement(this); - return this; - } - - @Override - public DefaultCharacteristic rootCharacteristic() { - return rootCharacteristic; - } - - public DefaultRequirement setRootCharacteristic(DefaultCharacteristic rootCharacteristic) { - this.rootCharacteristic = rootCharacteristic; - return this; - } - - @Override - public String function() { - return function; - } - - public DefaultRequirement setFunction(String function) { - this.function = function; - return this; - } - - /** - * @deprecated since 4.2 - */ - @Override - @Deprecated - public WorkUnit factor() { - return WorkUnit.create((double) factorValue, fromUnit(factorUnit)); - } - - /** - * @deprecated since 4.2 - */ - @Deprecated - public DefaultRequirement setFactor(WorkUnit factor) { - this.factorValue = (int) factor.getValue(); - this.factorUnit = toUnit(factor.getUnit()); - return this; - } - - @Override - public int factorValue() { - return factorValue; - } - - public DefaultRequirement setFactorValue(int factorValue) { - this.factorValue = factorValue; - return this; - } - - @Override - @CheckForNull - public WorkDuration.UNIT factorUnit() { - return factorUnit; - } - - public DefaultRequirement setFactorUnit(@Nullable WorkDuration.UNIT factorUnit) { - this.factorUnit = factorUnit; - return this; - } - - /** - * @deprecated since 4.2 - */ - @Override - @Deprecated - public WorkUnit offset() { - return WorkUnit.create((double) offsetValue, fromUnit(offsetUnit)); - } - - /** - * @deprecated since 4.2 - */ - @Deprecated - public DefaultRequirement setOffset(WorkUnit offset) { - this.offsetValue = (int) offset.getValue(); - this.offsetUnit = toUnit(offset.getUnit()); - return this; - } - - @Override - public int offsetValue() { - return offsetValue; - } - - public DefaultRequirement setOffsetValue(int offsetValue) { - this.offsetValue = offsetValue; - return this; - } - - @Override - @CheckForNull - public WorkDuration.UNIT offsetUnit() { - return offsetUnit; - } - - public DefaultRequirement setOffsetUnit(@Nullable WorkDuration.UNIT offsetUnit) { - this.offsetUnit = offsetUnit; - return this; - } - - @Override - public Date createdAt() { - return createdAt; - } - - public DefaultRequirement setCreatedAt(Date createdAt) { - this.createdAt = createdAt; - return this; - } - - @Override - public Date updatedAt() { - return updatedAt; - } - - public DefaultRequirement setUpdatedAt(Date updatedAt) { - this.updatedAt = updatedAt; - return this; - } - - public static WorkDuration.UNIT toUnit(String requirementUnit) { - if (WorkUnit.DAYS.equals(requirementUnit)) { - return WorkDuration.UNIT.DAYS; - } else if (WorkUnit.HOURS.equals(requirementUnit)) { - return WorkDuration.UNIT.HOURS; - } else if (WorkUnit.MINUTES.equals(requirementUnit)) { - return WorkDuration.UNIT.MINUTES; - } - throw new IllegalStateException("Invalid unit : " + requirementUnit); - } - - private static String fromUnit(WorkDuration.UNIT unit) { - if (WorkDuration.UNIT.DAYS.equals(unit)) { - return WorkUnit.DAYS; - } else if (WorkDuration.UNIT.HOURS.equals(unit)) { - return WorkUnit.HOURS; - } else if (WorkDuration.UNIT.MINUTES.equals(unit)) { - return WorkUnit.MINUTES; - } - throw new IllegalStateException("Invalid unit : " + unit); - } - - @Override - public String toString() { - return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - - DefaultRequirement that = (DefaultRequirement) o; - - if (!characteristic.equals(that.characteristic)) { - return false; - } - return ruleKey.equals(that.ruleKey); - - } - - @Override - public int hashCode() { - int result = ruleKey.hashCode(); - result = 31 * result + characteristic.hashCode(); - return result; - } -} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/technicaldebt/batch/internal/package-info.java b/sonar-plugin-api/src/main/java/org/sonar/api/technicaldebt/batch/internal/package-info.java deleted file mode 100644 index 5ad783342bb..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/technicaldebt/batch/internal/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * 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. - */ -@ParametersAreNonnullByDefault -package org.sonar.api.technicaldebt.batch.internal; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/technicaldebt/batch/package-info.java b/sonar-plugin-api/src/main/java/org/sonar/api/technicaldebt/batch/package-info.java deleted file mode 100644 index 1242c477252..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/technicaldebt/batch/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * 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. - */ -@ParametersAreNonnullByDefault -package org.sonar.api.technicaldebt.batch; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/technicaldebt/server/Characteristic.java b/sonar-plugin-api/src/main/java/org/sonar/api/technicaldebt/server/Characteristic.java deleted file mode 100644 index 55df83f1707..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/technicaldebt/server/Characteristic.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * 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.technicaldebt.server; - -import org.sonar.api.rule.RuleKey; -import org.sonar.api.utils.WorkUnit; -import org.sonar.api.utils.internal.WorkDuration; - -import javax.annotation.CheckForNull; - -/** - * @since 4.1 - * @deprecated since 4.3. - */ -@Deprecated -public interface Characteristic { - - Integer id(); - - String key(); - - String name(); - - Integer order(); - - @CheckForNull - Integer parentId(); - - /** - * @deprecated since 4.3. return null - */ - @Deprecated - @CheckForNull - Integer rootId(); - - /** - * @deprecated since 4.3. return null - */ - @Deprecated - RuleKey ruleKey(); - - /** - * @deprecated since 4.3. return null - */ - @Deprecated - String function(); - - /** - * @deprecated since 4.2 - */ - @Deprecated - @CheckForNull - WorkUnit factor(); - - /** - * @since 4.2 - */ - @CheckForNull - Integer factorValue(); - - /** - * @since 4.2 - */ - @CheckForNull - WorkDuration.UNIT factorUnit(); - - /** - * @deprecated since 4.2 - */ - @Deprecated - @CheckForNull - WorkUnit offset(); - - /** - * @since 4.2 - */ - @CheckForNull - Integer offsetValue(); - - /** - * @since 4.2 - */ - @CheckForNull - WorkDuration.UNIT offsetUnit(); - - boolean isRoot(); - - /** - * @deprecated since 4.3 - */ - @Deprecated - boolean isRequirement(); - -} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/technicaldebt/server/internal/DefaultCharacteristic.java b/sonar-plugin-api/src/main/java/org/sonar/api/technicaldebt/server/internal/DefaultCharacteristic.java deleted file mode 100644 index b588d3c6881..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/technicaldebt/server/internal/DefaultCharacteristic.java +++ /dev/null @@ -1,349 +0,0 @@ -/* - * 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.technicaldebt.server.internal; - -import org.apache.commons.lang.builder.ToStringBuilder; -import org.apache.commons.lang.builder.ToStringStyle; -import org.sonar.api.rule.RuleKey; -import org.sonar.api.technicaldebt.server.Characteristic; -import org.sonar.api.utils.WorkUnit; -import org.sonar.api.utils.internal.WorkDuration; - -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; - -/** - * @since 4.1 - * @deprecated since 4.3. - */ -@Deprecated -public class DefaultCharacteristic implements Characteristic { - - private Integer id; - private String key; - private String name; - private Integer order; - private Integer parentId; - private Integer rootId; - private RuleKey ruleKey; - private String function; - private Integer factorValue; - private WorkDuration.UNIT factorUnit; - private Integer offsetValue; - private WorkDuration.UNIT offsetUnit; - - @Override - public Integer id() { - return id; - } - - public DefaultCharacteristic setId(Integer id) { - this.id = id; - return this; - } - - @Override - @CheckForNull - public String key() { - return key; - } - - public DefaultCharacteristic setKey(@Nullable String key) { - this.key = key; - return this; - } - - @Override - @CheckForNull - public String name() { - return name; - } - - public DefaultCharacteristic setName(@Nullable String name) { - this.name = name; - return this; - } - - @Override - @CheckForNull - public Integer order() { - return order; - } - - public DefaultCharacteristic setOrder(@Nullable Integer order) { - this.order = order; - return this; - } - - @Override - @CheckForNull - public Integer parentId() { - return parentId; - } - - public DefaultCharacteristic setParentId(@Nullable Integer parentId) { - this.parentId = parentId; - return this; - } - - @Override - @CheckForNull - public Integer rootId() { - return rootId; - } - - public DefaultCharacteristic setRootId(@Nullable Integer rootId) { - this.rootId = rootId; - return this; - } - - /** - * @deprecated since 4.2 - */ - @Override - @Deprecated - @CheckForNull - public RuleKey ruleKey() { - return ruleKey; - } - - /** - * @deprecated since 4.2 - */ - @Deprecated - public DefaultCharacteristic setRuleKey(@Nullable RuleKey ruleKey) { - this.ruleKey = ruleKey; - return this; - } - - /** - * @deprecated since 4.2 - */ - @Override - @Deprecated - @CheckForNull - public String function() { - return function; - } - - /** - * @deprecated since 4.2 - */ - @Deprecated - public DefaultCharacteristic setFunction(@Nullable String function) { - this.function = function; - return this; - } - - /** - * @deprecated since 4.2 - */ - @Override - @Deprecated - @CheckForNull - public WorkUnit factor() { - if (factorValue != null && factorUnit != null) { - return WorkUnit.create((double) factorValue, fromUnit(factorUnit)); - } - return null; - } - - /** - * @deprecated since 4.2 - */ - @Deprecated - public DefaultCharacteristic setFactor(@Nullable WorkUnit factor) { - if (factor != null) { - this.factorValue = (int) factor.getValue(); - this.factorUnit = toUnit(factor.getUnit()); - } - return this; - } - - /** - * @deprecated since 4.3 - */ - @Override - @Deprecated - @CheckForNull - public Integer factorValue() { - return factorValue; - } - - /** - * @deprecated since 4.3 - */ - @Deprecated - public DefaultCharacteristic setFactorValue(@Nullable Integer factorValue) { - this.factorValue = factorValue; - return this; - } - - @Override - @CheckForNull - public WorkDuration.UNIT factorUnit() { - return factorUnit; - } - - /** - * @deprecated since 4.3 - */ - @Deprecated - public DefaultCharacteristic setFactorUnit(@Nullable WorkDuration.UNIT factorUnit) { - this.factorUnit = factorUnit; - return this; - } - - /** - * @deprecated since 4.2 - */ - @Override - @Deprecated - public WorkUnit offset() { - if (offsetValue != null && offsetUnit != null) { - return WorkUnit.create((double) offsetValue, fromUnit(offsetUnit)); - } - return null; - } - - /** - * @deprecated since 4.2 - */ - @Deprecated - public DefaultCharacteristic setOffset(@Nullable WorkUnit offset) { - if (offset != null) { - this.offsetValue = (int) offset.getValue(); - this.offsetUnit = toUnit(offset.getUnit()); - } - return this; - } - - /** - * @deprecated since 4.3 - */ - @Override - @Deprecated - @CheckForNull - public Integer offsetValue() { - return offsetValue; - } - - /** - * @deprecated since 4.3 - */ - @Deprecated - public DefaultCharacteristic setOffsetValue(@Nullable Integer offsetValue) { - this.offsetValue = offsetValue; - return this; - } - - /** - * @deprecated since 4.3 - */ - @Override - @Deprecated - @CheckForNull - public WorkDuration.UNIT offsetUnit() { - return offsetUnit; - } - - /** - * @deprecated since 4.3 - */ - @Deprecated - public DefaultCharacteristic setOffsetUnit(@Nullable WorkDuration.UNIT offsetUnit) { - this.offsetUnit = offsetUnit; - return this; - } - - /** - * @deprecated since 4.3 - */ - @Deprecated - public static WorkDuration.UNIT toUnit(@Nullable String requirementUnit) { - if (requirementUnit != null) { - if (WorkUnit.DAYS.equals(requirementUnit)) { - return WorkDuration.UNIT.DAYS; - } else if (WorkUnit.HOURS.equals(requirementUnit)) { - return WorkDuration.UNIT.HOURS; - } else if (WorkUnit.MINUTES.equals(requirementUnit)) { - return WorkDuration.UNIT.MINUTES; - } - throw new IllegalStateException("Invalid unit : " + requirementUnit); - } - return null; - } - - private static String fromUnit(WorkDuration.UNIT unit) { - if (WorkDuration.UNIT.DAYS.equals(unit)) { - return WorkUnit.DAYS; - } else if (WorkDuration.UNIT.HOURS.equals(unit)) { - return WorkUnit.HOURS; - } else if (WorkDuration.UNIT.MINUTES.equals(unit)) { - return WorkUnit.MINUTES; - } - throw new IllegalStateException("Invalid unit : " + unit); - } - - @Override - public boolean isRoot() { - return parentId == null; - } - - /** - * @deprecated since 4.3 - */ - @Override - @Deprecated - public boolean isRequirement() { - return ruleKey != null; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - - DefaultCharacteristic that = (DefaultCharacteristic) o; - - if ((key != null) ? !key.equals(that.key) : (that.key != null)) { - return false; - } - return !((ruleKey != null) ? !ruleKey.equals(that.ruleKey) : (that.ruleKey != null)); - - } - - @Override - public int hashCode() { - int result = (key != null) ? key.hashCode() : 0; - result = 31 * result + ((ruleKey != null) ? ruleKey.hashCode() : 0); - return result; - } - - @Override - public String toString() { - return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); - } - -} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/technicaldebt/server/internal/package-info.java b/sonar-plugin-api/src/main/java/org/sonar/api/technicaldebt/server/internal/package-info.java deleted file mode 100644 index ef5b314cc86..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/technicaldebt/server/internal/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * 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. - */ -@ParametersAreNonnullByDefault -package org.sonar.api.technicaldebt.server.internal; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/technicaldebt/server/package-info.java b/sonar-plugin-api/src/main/java/org/sonar/api/technicaldebt/server/package-info.java deleted file mode 100644 index 2161be91aaa..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/technicaldebt/server/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * 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. - */ -@ParametersAreNonnullByDefault -package org.sonar.api.technicaldebt.server; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/batch/debt/internal/DefaultDebtCharacteristicTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/batch/debt/internal/DefaultDebtCharacteristicTest.java deleted file mode 100644 index ef7cd0ed713..00000000000 --- a/sonar-plugin-api/src/test/java/org/sonar/api/batch/debt/internal/DefaultDebtCharacteristicTest.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * 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.batch.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(); - } -} diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/batch/debt/internal/DefaultDebtModelTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/batch/debt/internal/DefaultDebtModelTest.java index ebcf1e69e15..09aeb8eec44 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/batch/debt/internal/DefaultDebtModelTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/batch/debt/internal/DefaultDebtModelTest.java @@ -19,74 +19,20 @@ */ package org.sonar.api.batch.debt.internal; -import org.junit.Before; import org.junit.Test; import static org.assertj.core.api.Assertions.assertThat; public class DefaultDebtModelTest { - private DefaultDebtModel debtModel; - - @Before - public void setUp() { - debtModel = new DefaultDebtModel() - .addCharacteristic( - new DefaultDebtCharacteristic().setId(1) - .setKey("MEMORY_EFFICIENCY") - .setName("Memory use") - .setOrder(1) - ) - .addSubCharacteristic( - new DefaultDebtCharacteristic().setId(2) - .setKey("EFFICIENCY") - .setName("Efficiency") - .setParentId(1), - "MEMORY_EFFICIENCY" - ); - } - - @Test - public void all_characteristics() { - assertThat(debtModel.allCharacteristics()).hasSize(2); - } + DefaultDebtModel underTest = new DefaultDebtModel(); @Test - public void characteristics() { - assertThat(debtModel.characteristics()).hasSize(1); - } - - @Test - public void sub_characteristics() { - assertThat(debtModel.subCharacteristics("MEMORY_EFFICIENCY")).hasSize(1); - } - - @Test - public void characteristic_by_id() { - DefaultDebtCharacteristic debtCharacteristic = (DefaultDebtCharacteristic) debtModel.characteristicById(1); - assertThat(debtCharacteristic).isNotNull(); - assertThat(debtCharacteristic.id()).isEqualTo(1); - assertThat(debtCharacteristic.key()).isEqualTo("MEMORY_EFFICIENCY"); - assertThat(debtCharacteristic.name()).isEqualTo("Memory use"); - assertThat(debtCharacteristic.order()).isEqualTo(1); - assertThat(debtCharacteristic.parentId()).isNull(); - assertThat(debtCharacteristic.isSub()).isFalse(); - - - assertThat(debtModel.characteristicById(555)).isNull(); - } - - @Test - public void characteristic_by_key() { - DefaultDebtCharacteristic debtCharacteristic = (DefaultDebtCharacteristic) debtModel.characteristicByKey("EFFICIENCY"); - assertThat(debtCharacteristic).isNotNull(); - assertThat(debtCharacteristic.id()).isEqualTo(2); - assertThat(debtCharacteristic.key()).isEqualTo("EFFICIENCY"); - assertThat(debtCharacteristic.name()).isEqualTo("Efficiency"); - assertThat(debtCharacteristic.order()).isNull(); - assertThat(debtCharacteristic.parentId()).isEqualTo(1); - assertThat(debtCharacteristic.isSub()).isTrue(); - - assertThat(debtModel.characteristicByKey("UNKNOWN")).isNull(); + public void is_Deprecated() { + assertThat(underTest.characteristicByKey("xxx")).isNull(); + assertThat(underTest.characteristicById(1)).isNull(); + assertThat(underTest.characteristics()).isEmpty(); + assertThat(underTest.allCharacteristics()).isEmpty(); + assertThat(underTest.subCharacteristics("xxx")).isEmpty(); } } diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/technicaldebt/batch/internal/DefaultCharacteristicTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/technicaldebt/batch/internal/DefaultCharacteristicTest.java deleted file mode 100644 index 73475b0f5fe..00000000000 --- a/sonar-plugin-api/src/test/java/org/sonar/api/technicaldebt/batch/internal/DefaultCharacteristicTest.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * 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.technicaldebt.batch.internal; - -import org.junit.Test; -import org.sonar.api.rule.RuleKey; - -import java.text.SimpleDateFormat; - -import static org.assertj.core.api.Assertions.assertThat; - -public class DefaultCharacteristicTest { - - @Test - public void test_setters_and_getters_for_characteristic() throws Exception { - DefaultCharacteristic root = new DefaultCharacteristic().setKey("REUSABILITY"); - - DefaultCharacteristic characteristic = new DefaultCharacteristic() - .setId(1) - .setKey("MODULARITY") - .setName("Modularity") - .setOrder(5) - .setParent(root) - .setRoot(root) - .setCreatedAt(new SimpleDateFormat("yyyy-MM-dd").parse("2013-08-19")) - .setUpdatedAt(new SimpleDateFormat("yyyy-MM-dd").parse("2013-08-19")); - - assertThat(characteristic.id()).isEqualTo(1); - assertThat(characteristic.key()).isEqualTo("MODULARITY"); - assertThat(characteristic.name()).isEqualTo("Modularity"); - assertThat(characteristic.order()).isEqualTo(5); - assertThat(characteristic.parent()).isEqualTo(root); - assertThat(characteristic.root()).isEqualTo(root); - assertThat(characteristic.createdAt()).isEqualTo(new SimpleDateFormat("yyyy-MM-dd").parse("2013-08-19")); - assertThat(characteristic.updatedAt()).isEqualTo(new SimpleDateFormat("yyyy-MM-dd").parse("2013-08-19")); - } - - @Test - public void set_name_as_key() { - DefaultCharacteristic characteristic = new DefaultCharacteristic() - .setId(1) - .setName("Compiler related portability", true); - - assertThat(characteristic.key()).isEqualTo("COMPILER_RELATED_PORTABILITY"); - assertThat(characteristic.name()).isEqualTo("Compiler related portability"); - } - - @Test - public void add_requirement() { - DefaultRequirement requirement = new DefaultRequirement().setRuleKey(RuleKey.of("repo", "rule")); - - DefaultCharacteristic characteristic = new DefaultCharacteristic() - .setId(1) - .setKey("MODULARITY") - .addRequirement(requirement); - - assertThat(characteristic.requirements()).hasSize(1); - } - - @Test - public void add_child() { - DefaultCharacteristic root = new DefaultCharacteristic() - .setId(1) - .setKey("REUSABILITY"); - - DefaultCharacteristic characteristic = new DefaultCharacteristic() - .setId(1) - .setKey("MODULARITY") - .setParent(root); - - assertThat(root.children()).hasSize(1); - assertThat(characteristic.parent()).isEqualTo(root); - } - - - - @Test - public void is_root() { - DefaultCharacteristic characteristic = new DefaultCharacteristic() - .setId(1) - .setKey("NETWORK_USE") - .setName("Network use") - .setOrder(5) - .setParent(null) - .setRoot(null); - - assertThat(characteristic.isRoot()).isTrue(); - } - - @Test - public void test_equals() throws Exception { - assertThat(new DefaultCharacteristic().setKey("NETWORK_USE")).isEqualTo(new DefaultCharacteristic().setKey("NETWORK_USE")); - assertThat(new DefaultCharacteristic().setKey("NETWORK_USE")).isNotEqualTo(new DefaultCharacteristic().setKey("MAINTABILITY")); - } - - @Test - public void test_hascode() throws Exception { - assertThat(new DefaultCharacteristic().setKey("NETWORK_USE").hashCode()).isEqualTo(new DefaultCharacteristic().setKey("NETWORK_USE").hashCode()); - assertThat(new DefaultCharacteristic().setKey("NETWORK_USE").hashCode()).isNotEqualTo(new DefaultCharacteristic().setKey("MAINTABILITY").hashCode()); - } - -} diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/technicaldebt/batch/internal/DefaultRequirementTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/technicaldebt/batch/internal/DefaultRequirementTest.java deleted file mode 100644 index dc7b07c93b4..00000000000 --- a/sonar-plugin-api/src/test/java/org/sonar/api/technicaldebt/batch/internal/DefaultRequirementTest.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * 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.technicaldebt.batch.internal; - -import org.junit.Test; -import org.sonar.api.rule.RuleKey; -import org.sonar.api.utils.WorkUnit; -import org.sonar.api.utils.internal.WorkDuration; - -import java.text.SimpleDateFormat; - -import static org.assertj.core.api.Assertions.assertThat; - -public class DefaultRequirementTest { - - @Test - public void test_setters_and_getters_for_characteristic() throws Exception { - DefaultCharacteristic root = new DefaultCharacteristic().setId(1).setKey("REUSABILITY"); - - DefaultCharacteristic characteristic = new DefaultCharacteristic() - .setId(1) - .setKey("MODULARITY") - .setName("Modularity") - .setParent(root) - .setRoot(root); - - DefaultRequirement requirement = new DefaultRequirement() - .setId(3) - .setRuleKey(RuleKey.of("repo", "rule")) - .setCharacteristic(characteristic) - .setRootCharacteristic(root) - .setFunction("linear_offset") - .setFactorValue(2) - .setFactorUnit(WorkDuration.UNIT.MINUTES) - .setOffsetValue(1) - .setOffsetUnit(WorkDuration.UNIT.HOURS) - .setCreatedAt(new SimpleDateFormat("yyyy-MM-dd").parse("2013-08-19")) - .setUpdatedAt(new SimpleDateFormat("yyyy-MM-dd").parse("2013-08-19")); - - assertThat(requirement.id()).isEqualTo(3); - assertThat(requirement.ruleKey()).isEqualTo(RuleKey.of("repo", "rule")); - assertThat(requirement.characteristic()).isEqualTo(characteristic); - assertThat(requirement.rootCharacteristic()).isEqualTo(root); - assertThat(requirement.function()).isEqualTo("linear_offset"); - assertThat(requirement.factorValue()).isEqualTo(2); - assertThat(requirement.factorUnit()).isEqualTo(WorkDuration.UNIT.MINUTES); - assertThat(requirement.factor()).isEqualTo(WorkUnit.create(2d, WorkUnit.MINUTES)); - assertThat(requirement.offsetValue()).isEqualTo(1); - assertThat(requirement.offsetUnit()).isEqualTo(WorkDuration.UNIT.HOURS); - assertThat(requirement.offset()).isEqualTo(WorkUnit.create(1d, WorkUnit.HOURS)); - assertThat(requirement.createdAt()).isEqualTo(new SimpleDateFormat("yyyy-MM-dd").parse("2013-08-19")); - assertThat(requirement.updatedAt()).isEqualTo(new SimpleDateFormat("yyyy-MM-dd").parse("2013-08-19")); - } - - @Test - public void test_equals() throws Exception { - DefaultCharacteristic characteristic = new DefaultCharacteristic() - .setId(1) - .setKey("MODULARITY"); - - assertThat(new DefaultRequirement().setRuleKey(RuleKey.of("repo", "rule")).setCharacteristic(characteristic)) - .isEqualTo(new DefaultRequirement().setRuleKey(RuleKey.of("repo", "rule")).setCharacteristic(characteristic)); - assertThat(new DefaultRequirement().setRuleKey(RuleKey.of("repo", "rule")).setCharacteristic(characteristic)) - .isNotEqualTo(new DefaultRequirement().setRuleKey(RuleKey.of("repo2", "rule2")).setCharacteristic(characteristic)); - - assertThat(new DefaultRequirement().setRuleKey(RuleKey.of("repo", "rule")).setCharacteristic(characteristic)) - .isNotEqualTo(new DefaultRequirement().setRuleKey(RuleKey.of("repo", "rule")).setCharacteristic( - new DefaultCharacteristic() - .setId(2) - .setKey("REUSABILITY"))); - - } - - @Test - public void test_hashcode() throws Exception { - DefaultCharacteristic characteristic = new DefaultCharacteristic() - .setId(1) - .setKey("MODULARITY") - .setName("Modularity") - .setOrder(5); - - assertThat(new DefaultRequirement().setRuleKey(RuleKey.of("repo", "rule")).setCharacteristic(characteristic).hashCode()) - .isEqualTo(new DefaultRequirement().setRuleKey(RuleKey.of("repo", "rule")).setCharacteristic(characteristic).hashCode()); - assertThat(new DefaultRequirement().setRuleKey(RuleKey.of("repo", "rule")).setCharacteristic(characteristic).hashCode()) - .isNotEqualTo(new DefaultRequirement().setRuleKey(RuleKey.of("repo2", "rule2")).setCharacteristic(characteristic).hashCode()); - } - - @Test - public void test_deprecated_setters_and_getters_for_characteristic() throws Exception { - DefaultCharacteristic root = new DefaultCharacteristic().setId(1).setKey("REUSABILITY"); - - DefaultCharacteristic characteristic = new DefaultCharacteristic() - .setId(1) - .setKey("MODULARITY") - .setName("Modularity") - .setParent(root) - .setRoot(root); - - DefaultRequirement requirement = new DefaultRequirement() - .setId(3) - .setRuleKey(RuleKey.of("repo", "rule")) - .setCharacteristic(characteristic) - .setRootCharacteristic(root) - .setFunction("linear_offset") - .setFactor(WorkUnit.create(2d, WorkUnit.MINUTES)) - .setOffset(WorkUnit.create(1d, WorkUnit.HOURS)); - - assertThat(requirement.factor()).isEqualTo(WorkUnit.create(2d, WorkUnit.MINUTES)); - assertThat(requirement.offset()).isEqualTo(WorkUnit.create(1d, WorkUnit.HOURS)); - - assertThat(new DefaultRequirement() - .setId(3) - .setRuleKey(RuleKey.of("repo", "rule")) - .setCharacteristic(characteristic) - .setRootCharacteristic(root) - .setFunction("linear_offset") - .setFactor(WorkUnit.create(2d, WorkUnit.DAYS)) - .factor()).isEqualTo(WorkUnit.create(2d, WorkUnit.DAYS)); - } -} diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/technicaldebt/server/internal/DefaultCharacteristicTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/technicaldebt/server/internal/DefaultCharacteristicTest.java deleted file mode 100644 index 864da64e99d..00000000000 --- a/sonar-plugin-api/src/test/java/org/sonar/api/technicaldebt/server/internal/DefaultCharacteristicTest.java +++ /dev/null @@ -1,149 +0,0 @@ -/* - * 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.technicaldebt.server.internal; - -import org.junit.Test; -import org.sonar.api.rule.RuleKey; -import org.sonar.api.utils.WorkUnit; -import org.sonar.api.utils.internal.WorkDuration; - -import static org.assertj.core.api.Assertions.assertThat; - -public class DefaultCharacteristicTest { - - @Test - public void test_setters_and_getters_for_characteristic() throws Exception { - DefaultCharacteristic characteristic = new DefaultCharacteristic() - .setId(1) - .setKey("NETWORK_USE") - .setName("Network use") - .setOrder(5) - .setParentId(2) - .setRootId(2); - - assertThat(characteristic.id()).isEqualTo(1); - assertThat(characteristic.key()).isEqualTo("NETWORK_USE"); - assertThat(characteristic.name()).isEqualTo("Network use"); - assertThat(characteristic.order()).isEqualTo(5); - assertThat(characteristic.ruleKey()).isNull(); - assertThat(characteristic.function()).isNull(); - assertThat(characteristic.factorValue()).isNull(); - assertThat(characteristic.factorUnit()).isNull(); - assertThat(characteristic.offsetValue()).isNull(); - assertThat(characteristic.offsetUnit()).isNull(); - assertThat(characteristic.parentId()).isEqualTo(2); - assertThat(characteristic.rootId()).isEqualTo(2); - } - - @Test - public void test_setters_and_getters_for_requirement() throws Exception { - DefaultCharacteristic requirement = new DefaultCharacteristic() - .setId(1) - .setRuleKey(RuleKey.of("repo", "rule")) - .setFunction("linear_offset") - .setFactorValue(2) - .setFactorUnit(WorkDuration.UNIT.MINUTES) - .setOffsetValue(1) - .setOffsetUnit(WorkDuration.UNIT.HOURS) - .setRootId(3) - .setParentId(2); - - assertThat(requirement.id()).isEqualTo(1); - assertThat(requirement.key()).isNull(); - assertThat(requirement.name()).isNull(); - assertThat(requirement.order()).isNull(); - assertThat(requirement.ruleKey()).isEqualTo(RuleKey.of("repo", "rule")); - assertThat(requirement.function()).isEqualTo("linear_offset"); - assertThat(requirement.factorValue()).isEqualTo(2); - assertThat(requirement.factorUnit()).isEqualTo(WorkDuration.UNIT.MINUTES); - assertThat(requirement.offsetValue()).isEqualTo(1); - assertThat(requirement.offsetUnit()).isEqualTo(WorkDuration.UNIT.HOURS); - assertThat(requirement.parentId()).isEqualTo(2); - assertThat(requirement.rootId()).isEqualTo(3); - } - - @Test - public void is_root() { - DefaultCharacteristic characteristic = new DefaultCharacteristic() - .setId(1) - .setKey("NETWORK_USE") - .setName("Network use") - .setOrder(5) - .setParentId(null) - .setRootId(null); - - assertThat(characteristic.isRoot()).isTrue(); - } - - @Test - public void is_requirement() { - DefaultCharacteristic requirement = new DefaultCharacteristic() - .setId(1) - .setRuleKey(RuleKey.of("repo", "rule")) - .setFunction("linear_offset") - .setFactorValue(2) - .setFactorUnit(WorkDuration.UNIT.MINUTES) - .setOffsetValue(1) - .setOffsetUnit(WorkDuration.UNIT.HOURS) - .setRootId(3) - .setParentId(2); - - assertThat(requirement.isRequirement()).isTrue(); - } - - @Test - public void test_equals() throws Exception { - assertThat(new DefaultCharacteristic().setKey("NETWORK_USE")).isEqualTo(new DefaultCharacteristic().setKey("NETWORK_USE")); - assertThat(new DefaultCharacteristic().setKey("NETWORK_USE")).isNotEqualTo(new DefaultCharacteristic().setKey("MAINTABILITY")); - - assertThat(new DefaultCharacteristic().setRuleKey(RuleKey.of("repo", "rule"))).isEqualTo(new DefaultCharacteristic().setRuleKey(RuleKey.of("repo", "rule"))); - assertThat(new DefaultCharacteristic().setRuleKey(RuleKey.of("repo", "rule"))).isNotEqualTo(new DefaultCharacteristic().setRuleKey(RuleKey.of("repo2", "rule2"))); - } - - @Test - public void test_hascode() throws Exception { - assertThat(new DefaultCharacteristic().setKey("NETWORK_USE").hashCode()).isEqualTo(new DefaultCharacteristic().setKey("NETWORK_USE").hashCode()); - assertThat(new DefaultCharacteristic().setKey("NETWORK_USE").hashCode()).isNotEqualTo(new DefaultCharacteristic().setKey("MAINTABILITY").hashCode()); - - assertThat(new DefaultCharacteristic().setRuleKey(RuleKey.of("repo", "rule")).hashCode()).isEqualTo(new DefaultCharacteristic().setRuleKey(RuleKey.of("repo", "rule")).hashCode()); - assertThat(new DefaultCharacteristic().setRuleKey(RuleKey.of("repo", "rule")).hashCode()).isNotEqualTo(new DefaultCharacteristic().setRuleKey(RuleKey.of("repo2", "rule2")).hashCode()); - } - - @Test - public void test_deprecated_setters_and_getters_for_characteristic() throws Exception { - DefaultCharacteristic requirement = new DefaultCharacteristic() - .setId(1) - .setRuleKey(RuleKey.of("repo", "rule")) - .setFunction("linear_offset") - .setFactor(WorkUnit.create(2d, WorkUnit.MINUTES)) - .setOffset(WorkUnit.create(1d, WorkUnit.HOURS)); - - assertThat(requirement.factor()).isEqualTo(WorkUnit.create(2d, WorkUnit.MINUTES)); - assertThat(requirement.offset()).isEqualTo(WorkUnit.create(1d, WorkUnit.HOURS)); - - assertThat(new DefaultCharacteristic() - .setId(1) - .setRuleKey(RuleKey.of("repo", "rule")) - .setFunction("linear") - .setFactor(WorkUnit.create(2d, WorkUnit.DAYS)) - .factor()).isEqualTo(WorkUnit.create(2d, WorkUnit.DAYS)); - } - -} -- 2.39.5