From d07420e0fb678bd8561ded6ed62057029c3eae62 Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Mon, 17 Feb 2014 10:18:32 +0100 Subject: [PATCH] Do not use anymore deprecated WorkUnit --- .../issue/CountUnresolvedIssuesDecorator.java | 4 +- .../sonar/batch/debt/DebtModelLoaderTest.java | 7 +- .../DefaultTechnicalDebtManager.java | 9 +- .../TechnicalDebtXMLImporter.java | 34 ++++-- .../technicaldebt/db/CharacteristicDto.java | 48 ++++++-- .../DefaultTechnicalDebtManagerTest.java | 25 ++-- .../DefaultTechnicalDebtModelTest.java | 8 +- .../TechnicalDebtModelSynchronizerTest.java | 14 ++- .../TechnicalDebtXMLImporterTest.java | 16 +-- ...re_requirement_on_root_characteristics.xml | 2 +- .../shouldImportXML_badly-formatted.xml | 2 +- ...tXML_with_deprecated_constant_per_file.xml | 2 +- ..._with_deprecated_linear_with_threshold.xml | 2 +- .../shouldImportXML_with_linear.xml | 2 +- ...houldImportXML_with_linear_with_offset.xml | 2 +- .../shouldLogWarningIfRuleNotFound.xml | 2 +- .../api/technicaldebt/batch/Requirement.java | 29 +++++ .../batch/internal/DefaultRequirement.java | 59 +++++----- .../technicaldebt/server/Characteristic.java | 35 ++++++ .../internal/DefaultCharacteristic.java | 107 +++++++++++++++++- .../internal/DefaultRequirementTest.java | 11 +- .../internal/DefaultCharacteristicTest.java | 22 +++- 22 files changed, 348 insertions(+), 94 deletions(-) diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/CountUnresolvedIssuesDecorator.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/CountUnresolvedIssuesDecorator.java index 196d647bf79..1d0dca11f8f 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/CountUnresolvedIssuesDecorator.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/CountUnresolvedIssuesDecorator.java @@ -260,13 +260,13 @@ public class CountUnresolvedIssuesDecorator implements Decorator { } @VisibleForTesting - int countIssuesAfterDate(Collection issues, @Nullable Date targetDate) { + int countIssuesAfterDate(Collection issues, @Nullable Date date) { if (issues == null) { return 0; } int count = 0; for (Issue issue : issues) { - if (isAfter(issue, targetDate)) { + if (isAfter(issue, date)) { count++; } } diff --git a/sonar-batch/src/test/java/org/sonar/batch/debt/DebtModelLoaderTest.java b/sonar-batch/src/test/java/org/sonar/batch/debt/DebtModelLoaderTest.java index 1640363b8ef..faa25f1d1a9 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/debt/DebtModelLoaderTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/debt/DebtModelLoaderTest.java @@ -31,6 +31,7 @@ import org.sonar.api.rules.RuleFinder; import org.sonar.api.rules.RuleQuery; import org.sonar.api.technicaldebt.batch.internal.DefaultCharacteristic; import org.sonar.api.technicaldebt.batch.internal.DefaultRequirement; +import org.sonar.api.utils.WorkDuration; import org.sonar.api.utils.WorkUnit; import org.sonar.core.technicaldebt.DefaultTechnicalDebtModel; import org.sonar.core.technicaldebt.db.CharacteristicDao; @@ -108,8 +109,10 @@ public class DebtModelLoaderTest { DefaultRequirement requirement = result.requirementsByRule(ruleKey); assertThat(requirement.ruleKey()).isEqualTo(ruleKey); assertThat(requirement.function()).isEqualTo("linear"); - assertThat(requirement.factor()).isEqualTo(WorkUnit.create(2d, WorkUnit.DAYS)); - assertThat(requirement.offset()).isEqualTo(WorkUnit.create(0d, WorkUnit.DAYS)); + assertThat(requirement.factorValue()).isEqualTo(2); + assertThat(requirement.factorUnit()).isEqualTo(WorkDuration.UNIT.DAYS); + assertThat(requirement.offsetValue()).isEqualTo(0); + assertThat(requirement.offsetUnit()).isEqualTo(WorkDuration.UNIT.DAYS); } } diff --git a/sonar-core/src/main/java/org/sonar/core/technicaldebt/DefaultTechnicalDebtManager.java b/sonar-core/src/main/java/org/sonar/core/technicaldebt/DefaultTechnicalDebtManager.java index 78d3157cd24..823064f6204 100644 --- a/sonar-core/src/main/java/org/sonar/core/technicaldebt/DefaultTechnicalDebtManager.java +++ b/sonar-core/src/main/java/org/sonar/core/technicaldebt/DefaultTechnicalDebtManager.java @@ -27,7 +27,6 @@ import org.sonar.api.rules.RuleFinder; import org.sonar.api.technicaldebt.server.Characteristic; import org.sonar.api.technicaldebt.server.TechnicalDebtManager; import org.sonar.api.technicaldebt.server.internal.DefaultCharacteristic; -import org.sonar.api.utils.WorkUnit; import org.sonar.core.technicaldebt.db.CharacteristicDao; import org.sonar.core.technicaldebt.db.CharacteristicDto; @@ -92,6 +91,8 @@ public class DefaultTechnicalDebtManager implements TechnicalDebtManager { } private static Characteristic toCharacteristic(CharacteristicDto dto, @Nullable RuleKey ruleKey) { + Double factorValue = dto.getFactorValue(); + Double offsetValue = dto.getOffsetValue(); return new DefaultCharacteristic() .setId(dto.getId()) .setKey(dto.getKey()) @@ -101,8 +102,10 @@ public class DefaultTechnicalDebtManager implements TechnicalDebtManager { .setRootId(dto.getRootId()) .setRuleKey(ruleKey) .setFunction(dto.getFunction()) - .setFactor(WorkUnit.create(dto.getFactorValue(), dto.getFactorUnit())) - .setOffset(WorkUnit.create(dto.getOffsetValue(), dto.getOffsetUnit())); + .setFactorValue(factorValue != null ? factorValue.intValue() : null) + .setFactorUnit(DefaultCharacteristic.toUnit(dto.getFactorUnit())) + .setOffsetValue(offsetValue != null ? offsetValue.intValue() : null) + .setOffsetUnit(DefaultCharacteristic.toUnit(dto.getOffsetUnit())); } } diff --git a/sonar-core/src/main/java/org/sonar/core/technicaldebt/TechnicalDebtXMLImporter.java b/sonar-core/src/main/java/org/sonar/core/technicaldebt/TechnicalDebtXMLImporter.java index 33ea98e5b7d..817fe76a6ca 100644 --- a/sonar-core/src/main/java/org/sonar/core/technicaldebt/TechnicalDebtXMLImporter.java +++ b/sonar-core/src/main/java/org/sonar/core/technicaldebt/TechnicalDebtXMLImporter.java @@ -36,8 +36,10 @@ import org.sonar.api.rules.Rule; import org.sonar.api.technicaldebt.batch.internal.DefaultCharacteristic; import org.sonar.api.technicaldebt.batch.internal.DefaultRequirement; import org.sonar.api.utils.ValidationMessages; -import org.sonar.api.utils.WorkUnit; +import org.sonar.api.utils.WorkDuration; +import org.sonar.core.technicaldebt.db.CharacteristicDto; +import javax.annotation.CheckForNull; import javax.xml.stream.XMLInputFactory; import javax.xml.stream.XMLStreamException; @@ -184,7 +186,7 @@ public class TechnicalDebtXMLImporter implements ServerExtension { private Property processProperty(SMInputCursor cursor, ValidationMessages messages) throws XMLStreamException { SMInputCursor c = cursor.childElementCursor(); String key = null; - Double value = null; + int value = 0; String textValue = null; while (c.getNext() != null) { String node = c.getLocalName(); @@ -194,7 +196,9 @@ public class TechnicalDebtXMLImporter implements ServerExtension { } else if (StringUtils.equals(node, PROPERTY_VALUE)) { String s = c.collectDescendantText().trim(); try { - value = NumberUtils.createDouble(s); + // The value is still a double for the moment + Double valueDouble = NumberUtils.createDouble(s); + value = valueDouble.intValue(); } catch (NumberFormatException ex) { messages.addErrorText(String.format("Cannot import value '%s' for field %s - Expected a numeric value instead", s, key)); } @@ -205,16 +209,24 @@ public class TechnicalDebtXMLImporter implements ServerExtension { return new Property(key, value, textValue); } + @CheckForNull private DefaultRequirement processFunctionsOnRequirement(DefaultRequirement requirement, Properties properties, ValidationMessages messages) { Property function = properties.function(); Property factor = properties.factor(); Property offset = properties.offset(); if (function != null) { + // Requirements should always have values, so we init it with default values + requirement.setFactorValue(0); + requirement.setFactorUnit(WorkDuration.UNIT.DAYS); + requirement.setOffsetValue(0); + requirement.setOffsetUnit(WorkDuration.UNIT.DAYS); + String functionKey = function.getTextValue(); if ("linear_threshold".equals(functionKey)) { function.setTextValue(DefaultRequirement.FUNCTION_LINEAR); - offset.setValue(0d); + offset.setValue(0); + offset.setTextValue(CharacteristicDto.DAYS); messages.addWarningText(String.format("Linear with threshold function is no more used, function of the requirement '%s' is replaced by linear.", requirement.ruleKey())); } else if ("constant_resource".equals(functionKey)) { messages.addWarningText(String.format("Constant/file function is no more used, requirements '%s' are ignored.", requirement.ruleKey())); @@ -223,10 +235,12 @@ public class TechnicalDebtXMLImporter implements ServerExtension { requirement.setFunction(function.getTextValue()); if (factor != null) { - requirement.setFactor(WorkUnit.create(factor.getValue(), factor.getTextValue())); + requirement.setFactorValue(factor.getValue()); + requirement.setFactorUnit(DefaultRequirement.toUnit(factor.getTextValue())); } if (offset != null) { - requirement.setOffset(WorkUnit.create(offset.getValue(), offset.getTextValue())); + requirement.setOffsetValue(offset.getValue()); + requirement.setOffsetUnit(DefaultRequirement.toUnit(offset.getTextValue())); } return requirement; } @@ -270,16 +284,16 @@ public class TechnicalDebtXMLImporter implements ServerExtension { private static class Property { String key; - Double value; + int value; String textValue; - private Property(String key, Double value, String textValue) { + private Property(String key, int value, String textValue) { this.key = key; this.value = value; this.textValue = textValue; } - private Property setValue(Double value) { + private Property setValue(int value) { this.value = value; return this; } @@ -293,7 +307,7 @@ public class TechnicalDebtXMLImporter implements ServerExtension { return key; } - private Double getValue() { + private int getValue() { return value; } diff --git a/sonar-core/src/main/java/org/sonar/core/technicaldebt/db/CharacteristicDto.java b/sonar-core/src/main/java/org/sonar/core/technicaldebt/db/CharacteristicDto.java index 86357657a2e..ae72bbf0e81 100644 --- a/sonar-core/src/main/java/org/sonar/core/technicaldebt/db/CharacteristicDto.java +++ b/sonar-core/src/main/java/org/sonar/core/technicaldebt/db/CharacteristicDto.java @@ -23,7 +23,7 @@ package org.sonar.core.technicaldebt.db; import org.sonar.api.rule.RuleKey; import org.sonar.api.technicaldebt.batch.internal.DefaultCharacteristic; import org.sonar.api.technicaldebt.batch.internal.DefaultRequirement; -import org.sonar.api.utils.WorkUnit; +import org.sonar.api.utils.WorkDuration; import javax.annotation.CheckForNull; import javax.annotation.Nullable; @@ -33,6 +33,10 @@ import java.util.Date; public class CharacteristicDto implements Serializable { + public static final String DAYS = "d"; + public static final String MINUTES = "mn"; + public static final String HOURS = "h"; + private Integer id; private String kee; private String name; @@ -227,8 +231,10 @@ public class CharacteristicDto implements Serializable { .setCharacteristic(characteristic) .setRootCharacteristic(rootCharacteristic) .setFunction(functionKey) - .setFactor(WorkUnit.create(factorValue, factorUnit)) - .setOffset(WorkUnit.create(offsetValue, offsetUnit)) + .setFactorValue(factorValue.intValue()) + .setFactorUnit(toUnit(factorUnit)) + .setOffsetValue(offsetValue.intValue()) + .setOffsetUnit(toUnit(offsetUnit)) .setCreatedAt(createdAt) .setUpdatedAt(updatedAt); } @@ -239,13 +245,41 @@ public class CharacteristicDto implements Serializable { .setParentId(characteristicId) .setRootId(rootCharacteristicId) .setFunction(requirement.function()) - .setFactorValue(requirement.factor().getValue()) - .setFactorUnit(requirement.factor().getUnit()) - .setOffsetValue(requirement.offset().getValue()) - .setOffsetUnit(requirement.offset().getUnit()) + .setFactorValue((double) requirement.factorValue()) + .setFactorUnit(fromUnit(requirement.factorUnit())) + .setOffsetValue((double) requirement.offsetValue()) + .setOffsetUnit(fromUnit(requirement.offsetUnit())) .setEnabled(true) .setCreatedAt(requirement.createdAt()) .setUpdatedAt(requirement.updatedAt()); } + public static WorkDuration.UNIT toUnit(@Nullable String requirementUnit) { + if (requirementUnit != null) { + if (requirementUnit.equals(DAYS)) { + return WorkDuration.UNIT.DAYS; + } else if (requirementUnit.equals(HOURS)) { + return WorkDuration.UNIT.HOURS; + } else if (requirementUnit.equals(MINUTES)) { + return WorkDuration.UNIT.MINUTES; + } + throw new IllegalStateException("Invalid unit : " + requirementUnit); + } + return null; + } + + public static String fromUnit(@Nullable WorkDuration.UNIT unit) { + if (unit != null) { + if (unit.equals(WorkDuration.UNIT.DAYS)) { + return DAYS; + } else if (unit.equals(WorkDuration.UNIT.HOURS)) { + return HOURS; + } else if (unit.equals(WorkDuration.UNIT.MINUTES)) { + return MINUTES; + } + throw new IllegalStateException("Invalid unit : " + unit); + } + return null; + } + } diff --git a/sonar-core/src/test/java/org/sonar/core/technicaldebt/DefaultTechnicalDebtManagerTest.java b/sonar-core/src/test/java/org/sonar/core/technicaldebt/DefaultTechnicalDebtManagerTest.java index 2e66f1ebd55..f6369fe9209 100644 --- a/sonar-core/src/test/java/org/sonar/core/technicaldebt/DefaultTechnicalDebtManagerTest.java +++ b/sonar-core/src/test/java/org/sonar/core/technicaldebt/DefaultTechnicalDebtManagerTest.java @@ -29,7 +29,7 @@ import org.sonar.api.rule.RuleKey; import org.sonar.api.rules.Rule; import org.sonar.api.rules.RuleFinder; import org.sonar.api.technicaldebt.server.Characteristic; -import org.sonar.api.utils.WorkUnit; +import org.sonar.api.utils.WorkDuration; import org.sonar.core.technicaldebt.db.CharacteristicDao; import org.sonar.core.technicaldebt.db.CharacteristicDto; @@ -80,7 +80,10 @@ public class DefaultTechnicalDebtManagerTest { rule.setId(1); when(dao.selectByRuleId(rule.getId())).thenReturn( - new CharacteristicDto().setId(3).setRuleId(10).setParentId(2).setRootId(1).setFunction("linear").setFactorValue(30.0).setFactorUnit("mn")); + new CharacteristicDto().setId(3).setRuleId(10).setParentId(2).setRootId(1).setFunction("linear") + .setFactorValue(30.0).setFactorUnit("mn") + .setOffsetValue(0.0).setOffsetUnit("d") + ); Characteristic result = finder.findRequirementByRule(rule); @@ -89,8 +92,10 @@ public class DefaultTechnicalDebtManagerTest { assertThat(result.rootId()).isEqualTo(1); assertThat(result.ruleKey()).isEqualTo(RuleKey.of("repo", "key")); assertThat(result.function()).isEqualTo("linear"); - assertThat(result.factor()).isEqualTo(WorkUnit.create(30d, WorkUnit.MINUTES)); - assertThat(result.offset()).isEqualTo(WorkUnit.create(0d, WorkUnit.DAYS)); + assertThat(result.factorValue()).isEqualTo(30); + assertThat(result.factorUnit()).isEqualTo(WorkDuration.UNIT.MINUTES); + assertThat(result.offsetValue()).isEqualTo(0); + assertThat(result.offsetUnit()).isEqualTo(WorkDuration.UNIT.DAYS); } @Test @@ -140,7 +145,10 @@ public class DefaultTechnicalDebtManagerTest { when(ruleFinder.findById(1)).thenReturn(rule); when(dao.selectByRuleId(rule.getId())).thenReturn( - new CharacteristicDto().setId(3).setRuleId(10).setParentId(2).setRootId(1).setFunction("linear").setFactorValue(30.0).setFactorUnit("mn")); + new CharacteristicDto().setId(3).setRuleId(10).setParentId(2).setRootId(1).setFunction("linear") + .setFactorValue(30.0).setFactorUnit("mn") + .setOffsetValue(0.0).setOffsetUnit("d") + ); Characteristic result = finder.findRequirementByRuleId(1); @@ -149,8 +157,11 @@ public class DefaultTechnicalDebtManagerTest { assertThat(result.rootId()).isEqualTo(1); assertThat(result.ruleKey()).isEqualTo(RuleKey.of("repo", "key")); assertThat(result.function()).isEqualTo("linear"); - assertThat(result.factor()).isEqualTo(WorkUnit.create(30d, WorkUnit.MINUTES)); - assertThat(result.offset()).isEqualTo(WorkUnit.create(0d, WorkUnit.DAYS)); + assertThat(result.factorValue()).isEqualTo(30); + assertThat(result.factorUnit()).isEqualTo(WorkDuration.UNIT.MINUTES); + assertThat(result.offsetValue()).isEqualTo(0); + assertThat(result.offsetUnit()).isEqualTo(WorkDuration.UNIT.DAYS); + } @Test diff --git a/sonar-core/src/test/java/org/sonar/core/technicaldebt/DefaultTechnicalDebtModelTest.java b/sonar-core/src/test/java/org/sonar/core/technicaldebt/DefaultTechnicalDebtModelTest.java index dcf61654fc3..246269c48c3 100644 --- a/sonar-core/src/test/java/org/sonar/core/technicaldebt/DefaultTechnicalDebtModelTest.java +++ b/sonar-core/src/test/java/org/sonar/core/technicaldebt/DefaultTechnicalDebtModelTest.java @@ -25,7 +25,7 @@ import org.junit.Test; import org.sonar.api.rule.RuleKey; import org.sonar.api.technicaldebt.batch.internal.DefaultCharacteristic; import org.sonar.api.technicaldebt.batch.internal.DefaultRequirement; -import org.sonar.api.utils.WorkUnit; +import org.sonar.api.utils.WorkDuration; import static org.fest.assertions.Assertions.assertThat; @@ -92,8 +92,10 @@ public class DefaultTechnicalDebtModelTest { .setCharacteristic(characteristic) .setRuleKey(ruleKey) .setFunction("linear") - .setFactor(WorkUnit.create(2d, WorkUnit.HOURS)) - .setOffset(WorkUnit.create(0d, WorkUnit.HOURS)); + .setFactorValue(2) + .setFactorUnit(WorkDuration.UNIT.HOURS) + .setOffsetValue(0) + .setOffsetUnit(WorkDuration.UNIT.HOURS); sqaleModel.addRootCharacteristic(rootCharacteristic); diff --git a/sonar-core/src/test/java/org/sonar/core/technicaldebt/TechnicalDebtModelSynchronizerTest.java b/sonar-core/src/test/java/org/sonar/core/technicaldebt/TechnicalDebtModelSynchronizerTest.java index 774f80d890d..9baa526ce67 100644 --- a/sonar-core/src/test/java/org/sonar/core/technicaldebt/TechnicalDebtModelSynchronizerTest.java +++ b/sonar-core/src/test/java/org/sonar/core/technicaldebt/TechnicalDebtModelSynchronizerTest.java @@ -35,7 +35,7 @@ import org.sonar.api.rules.Rule; import org.sonar.api.technicaldebt.batch.internal.DefaultCharacteristic; import org.sonar.api.technicaldebt.batch.internal.DefaultRequirement; import org.sonar.api.utils.ValidationMessages; -import org.sonar.api.utils.WorkUnit; +import org.sonar.api.utils.WorkDuration; import org.sonar.core.persistence.MyBatis; import org.sonar.core.technicaldebt.db.CharacteristicDao; import org.sonar.core.technicaldebt.db.CharacteristicDto; @@ -142,7 +142,11 @@ public class TechnicalDebtModelSynchronizerTest { RuleKey ruleKey = RuleKey.of("checkstyle", "import"); when(ruleCache.getByRuleKey(ruleKey)).thenReturn(rule); new DefaultRequirement().setRuleKey(ruleKey) - .setFunction("linear").setFactor(WorkUnit.create(30d, WorkUnit.MINUTES)).setCharacteristic(javaCharacteristic).setRootCharacteristic(javaRootCharacteristic); + .setFunction("linear") + .setFactorValue(30) + .setFactorUnit(WorkDuration.UNIT.MINUTES) + .setCharacteristic(javaCharacteristic) + .setRootCharacteristic(javaRootCharacteristic); Reader javaModelReader = mock(Reader.class); when(xmlImporter.importXML(eq(javaModelReader), any(ValidationMessages.class), eq(ruleCache))).thenReturn(javaModel); @@ -195,7 +199,11 @@ public class TechnicalDebtModelSynchronizerTest { // New requirement new DefaultRequirement().setRuleKey(ruleKey2) - .setFunction("linear").setFactor(WorkUnit.create(1d, WorkUnit.HOURS)).setCharacteristic(javaCharacteristic).setRootCharacteristic(javaRootCharacteristic); + .setFunction("linear") + .setFactorValue(1) + .setFactorUnit(WorkDuration.UNIT.HOURS) + .setCharacteristic(javaCharacteristic) + .setRootCharacteristic(javaRootCharacteristic); Reader javaModelReader = mock(Reader.class); when(technicalDebtModelRepository.createReaderForXMLFile("java")).thenReturn(javaModelReader); diff --git a/sonar-core/src/test/java/org/sonar/core/technicaldebt/TechnicalDebtXMLImporterTest.java b/sonar-core/src/test/java/org/sonar/core/technicaldebt/TechnicalDebtXMLImporterTest.java index 5dad54e0430..05138280dbf 100644 --- a/sonar-core/src/test/java/org/sonar/core/technicaldebt/TechnicalDebtXMLImporterTest.java +++ b/sonar-core/src/test/java/org/sonar/core/technicaldebt/TechnicalDebtXMLImporterTest.java @@ -32,7 +32,7 @@ import org.sonar.api.rules.RuleQuery; import org.sonar.api.technicaldebt.batch.internal.DefaultCharacteristic; import org.sonar.api.technicaldebt.batch.internal.DefaultRequirement; import org.sonar.api.utils.ValidationMessages; -import org.sonar.api.utils.WorkUnit; +import org.sonar.api.utils.WorkDuration; import java.io.IOException; @@ -89,7 +89,7 @@ public class TechnicalDebtXMLImporterTest { ValidationMessages messages = ValidationMessages.create(); DefaultTechnicalDebtModel sqale = new TechnicalDebtXMLImporter().importXML(xml, messages, technicalDebtRuleCache); - checkXmlCorrectlyImported(sqale, WorkUnit.create(1.0, "h"), messages); + checkXmlCorrectlyImported(sqale, 1, WorkDuration.UNIT.HOURS, messages); } @Test @@ -101,7 +101,7 @@ public class TechnicalDebtXMLImporterTest { ValidationMessages messages = ValidationMessages.create(); DefaultTechnicalDebtModel sqale = new TechnicalDebtXMLImporter().importXML(xml, messages, technicalDebtRuleCache); - checkXmlCorrectlyImported(sqale, WorkUnit.create(0.0, "h"), messages); + checkXmlCorrectlyImported(sqale, 0, WorkDuration.UNIT.DAYS, messages); assertThat(messages.getWarnings()).hasSize(1); } @@ -189,10 +189,10 @@ public class TechnicalDebtXMLImporterTest { } private void checkXmlCorrectlyImported(DefaultTechnicalDebtModel sqale, ValidationMessages messages) { - checkXmlCorrectlyImported(sqale, WorkUnit.create(0d, WorkUnit.DAYS), messages); + checkXmlCorrectlyImported(sqale, 0, WorkDuration.UNIT.DAYS, messages); } - private void checkXmlCorrectlyImported(DefaultTechnicalDebtModel sqale, WorkUnit offset, ValidationMessages messages) { + private void checkXmlCorrectlyImported(DefaultTechnicalDebtModel sqale, Integer offsetValue, WorkDuration.UNIT offsetUnit, ValidationMessages messages) { assertThat(messages.getErrors()).isEmpty(); // characteristics @@ -211,8 +211,10 @@ public class TechnicalDebtXMLImporterTest { assertThat(requirement.ruleKey().repository()).isEqualTo("checkstyle"); assertThat(requirement.ruleKey().rule()).isEqualTo("Regexp"); assertThat(requirement.function()).isEqualTo("linear"); - assertThat(requirement.factor()).isEqualTo(WorkUnit.create(3.2, "h")); - assertThat(requirement.offset()).isEqualTo(offset); + assertThat(requirement.factorValue()).isEqualTo(3); + assertThat(requirement.factorUnit()).isEqualTo(WorkDuration.UNIT.HOURS); + assertThat(requirement.offsetValue()).isEqualTo(offsetValue); + assertThat(requirement.offsetUnit()).isEqualTo(offsetUnit); assertThat(requirement.characteristic().key()).isEqualTo("MEMORY_EFFICIENCY"); assertThat(requirement.rootCharacteristic().key()).isEqualTo("EFFICIENCY"); } diff --git a/sonar-core/src/test/resources/org/sonar/core/technicaldebt/TechnicalDebtXMLImporterTest/ignore_requirement_on_root_characteristics.xml b/sonar-core/src/test/resources/org/sonar/core/technicaldebt/TechnicalDebtXMLImporterTest/ignore_requirement_on_root_characteristics.xml index af9e9f4748e..bcf3ed867d3 100644 --- a/sonar-core/src/test/resources/org/sonar/core/technicaldebt/TechnicalDebtXMLImporterTest/ignore_requirement_on_root_characteristics.xml +++ b/sonar-core/src/test/resources/org/sonar/core/technicaldebt/TechnicalDebtXMLImporterTest/ignore_requirement_on_root_characteristics.xml @@ -7,7 +7,7 @@ Regexp remediationFactor - 3.2 + 3.0 h diff --git a/sonar-core/src/test/resources/org/sonar/core/technicaldebt/TechnicalDebtXMLImporterTest/shouldImportXML_badly-formatted.xml b/sonar-core/src/test/resources/org/sonar/core/technicaldebt/TechnicalDebtXMLImporterTest/shouldImportXML_badly-formatted.xml index db64d45ba5f..6c7d153992c 100644 --- a/sonar-core/src/test/resources/org/sonar/core/technicaldebt/TechnicalDebtXMLImporterTest/shouldImportXML_badly-formatted.xml +++ b/sonar-core/src/test/resources/org/sonar/core/technicaldebt/TechnicalDebtXMLImporterTest/shouldImportXML_badly-formatted.xml @@ -25,7 +25,7 @@ remediationFactor - 3.2 + 3.0 h diff --git a/sonar-core/src/test/resources/org/sonar/core/technicaldebt/TechnicalDebtXMLImporterTest/shouldImportXML_with_deprecated_constant_per_file.xml b/sonar-core/src/test/resources/org/sonar/core/technicaldebt/TechnicalDebtXMLImporterTest/shouldImportXML_with_deprecated_constant_per_file.xml index ca49d873ca5..4b8ae3f6475 100644 --- a/sonar-core/src/test/resources/org/sonar/core/technicaldebt/TechnicalDebtXMLImporterTest/shouldImportXML_with_deprecated_constant_per_file.xml +++ b/sonar-core/src/test/resources/org/sonar/core/technicaldebt/TechnicalDebtXMLImporterTest/shouldImportXML_with_deprecated_constant_per_file.xml @@ -11,7 +11,7 @@ Regexp remediationFactor - 3.2 + 3.0 h diff --git a/sonar-core/src/test/resources/org/sonar/core/technicaldebt/TechnicalDebtXMLImporterTest/shouldImportXML_with_deprecated_linear_with_threshold.xml b/sonar-core/src/test/resources/org/sonar/core/technicaldebt/TechnicalDebtXMLImporterTest/shouldImportXML_with_deprecated_linear_with_threshold.xml index 1a9fbfd0c6a..9ebc69b94a6 100644 --- a/sonar-core/src/test/resources/org/sonar/core/technicaldebt/TechnicalDebtXMLImporterTest/shouldImportXML_with_deprecated_linear_with_threshold.xml +++ b/sonar-core/src/test/resources/org/sonar/core/technicaldebt/TechnicalDebtXMLImporterTest/shouldImportXML_with_deprecated_linear_with_threshold.xml @@ -20,7 +20,7 @@ remediationFactor - 3.2 + 3.0 h diff --git a/sonar-core/src/test/resources/org/sonar/core/technicaldebt/TechnicalDebtXMLImporterTest/shouldImportXML_with_linear.xml b/sonar-core/src/test/resources/org/sonar/core/technicaldebt/TechnicalDebtXMLImporterTest/shouldImportXML_with_linear.xml index 554df10e640..f641a5185ec 100644 --- a/sonar-core/src/test/resources/org/sonar/core/technicaldebt/TechnicalDebtXMLImporterTest/shouldImportXML_with_linear.xml +++ b/sonar-core/src/test/resources/org/sonar/core/technicaldebt/TechnicalDebtXMLImporterTest/shouldImportXML_with_linear.xml @@ -15,7 +15,7 @@ Regexp remediationFactor - 3.2 + 3.0 h diff --git a/sonar-core/src/test/resources/org/sonar/core/technicaldebt/TechnicalDebtXMLImporterTest/shouldImportXML_with_linear_with_offset.xml b/sonar-core/src/test/resources/org/sonar/core/technicaldebt/TechnicalDebtXMLImporterTest/shouldImportXML_with_linear_with_offset.xml index b20a3afd279..d12f70d0e2d 100644 --- a/sonar-core/src/test/resources/org/sonar/core/technicaldebt/TechnicalDebtXMLImporterTest/shouldImportXML_with_linear_with_offset.xml +++ b/sonar-core/src/test/resources/org/sonar/core/technicaldebt/TechnicalDebtXMLImporterTest/shouldImportXML_with_linear_with_offset.xml @@ -15,7 +15,7 @@ Regexp remediationFactor - 3.2 + 3.0 h diff --git a/sonar-core/src/test/resources/org/sonar/core/technicaldebt/TechnicalDebtXMLImporterTest/shouldLogWarningIfRuleNotFound.xml b/sonar-core/src/test/resources/org/sonar/core/technicaldebt/TechnicalDebtXMLImporterTest/shouldLogWarningIfRuleNotFound.xml index cf4edb394e5..2898f458e3f 100644 --- a/sonar-core/src/test/resources/org/sonar/core/technicaldebt/TechnicalDebtXMLImporterTest/shouldLogWarningIfRuleNotFound.xml +++ b/sonar-core/src/test/resources/org/sonar/core/technicaldebt/TechnicalDebtXMLImporterTest/shouldLogWarningIfRuleNotFound.xml @@ -10,7 +10,7 @@ Foo remediationFactor - 3.2 + 3.0 h 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 index 6e4116edc63..60e41eb5e96 100644 --- 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 @@ -21,6 +21,7 @@ package org.sonar.api.technicaldebt.batch; import org.sonar.api.rule.RuleKey; +import org.sonar.api.utils.WorkDuration; import org.sonar.api.utils.WorkUnit; import java.util.Date; @@ -40,10 +41,38 @@ public interface Requirement { 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/DefaultRequirement.java b/sonar-plugin-api/src/main/java/org/sonar/api/technicaldebt/batch/internal/DefaultRequirement.java index d8fca31d1f2..c8828e61eb9 100644 --- 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 @@ -22,11 +22,14 @@ package org.sonar.api.technicaldebt.batch.internal; import org.apache.commons.lang.builder.ToStringBuilder; import org.apache.commons.lang.builder.ToStringStyle; +import org.picocontainer.annotations.Nullable; import org.sonar.api.rule.RuleKey; import org.sonar.api.technicaldebt.batch.Requirement; import org.sonar.api.utils.WorkDuration; import org.sonar.api.utils.WorkUnit; +import javax.annotation.CheckForNull; + import java.util.Date; public class DefaultRequirement implements Requirement { @@ -45,17 +48,10 @@ public class DefaultRequirement implements Requirement { private WorkDuration.UNIT factorUnit; private int offsetValue; private WorkDuration.UNIT offsetUnit; - private WorkUnit factor; - private WorkUnit offset; private Date createdAt; private Date updatedAt; - public DefaultRequirement() { - this.factor = WorkUnit.create(0d, WorkUnit.DAYS); - this.offset = WorkUnit.create(0d, WorkUnit.DAYS); - } - public Integer id() { return id; } @@ -107,8 +103,7 @@ public class DefaultRequirement implements Requirement { */ @Deprecated public WorkUnit factor() { - return factor; -// return WorkUnit.create((double) factorValue, fromUnit(factorUnit)); + return WorkUnit.create((double) factorValue, fromUnit(factorUnit)); } /** @@ -116,24 +111,8 @@ public class DefaultRequirement implements Requirement { */ @Deprecated public DefaultRequirement setFactor(WorkUnit factor) { - this.factor = factor; - return this; - } - - /** - * @deprecated since 4.2 - */ - @Deprecated - public WorkUnit offset() { - return offset; - } - - /** - * @deprecated since 4.2 - */ - @Deprecated - public DefaultRequirement setOffset(WorkUnit offset) { - this.offset = offset; + this.factorValue = (int) factor.getValue(); + this.factorUnit = toUnit(factor.getUnit()); return this; } @@ -146,15 +125,34 @@ public class DefaultRequirement implements Requirement { return this; } + @CheckForNull public WorkDuration.UNIT factorUnit() { return factorUnit; } - public DefaultRequirement setFactorUnit(WorkDuration.UNIT factorUnit) { + public DefaultRequirement setFactorUnit(@Nullable WorkDuration.UNIT factorUnit) { this.factorUnit = factorUnit; return this; } + /** + * @deprecated since 4.2 + */ + @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; + } + public int offsetValue() { return offsetValue; } @@ -164,11 +162,12 @@ public class DefaultRequirement implements Requirement { return this; } + @CheckForNull public WorkDuration.UNIT offsetUnit() { return offsetUnit; } - public DefaultRequirement setOffsetUnit(WorkDuration.UNIT offsetUnit) { + public DefaultRequirement setOffsetUnit(@Nullable WorkDuration.UNIT offsetUnit) { this.offsetUnit = offsetUnit; return this; } @@ -191,7 +190,7 @@ public class DefaultRequirement implements Requirement { return this; } - private static WorkDuration.UNIT toUnit(String requirementUnit){ + public static WorkDuration.UNIT toUnit(String requirementUnit){ if (requirementUnit.equals(WorkUnit.DAYS)) { return WorkDuration.UNIT.DAYS; } else if (requirementUnit.equals(WorkUnit.HOURS)) { 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 index dc227360496..0b016e172bc 100644 --- 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 @@ -21,6 +21,7 @@ package org.sonar.api.technicaldebt.server; import org.sonar.api.rule.RuleKey; +import org.sonar.api.utils.WorkDuration; import org.sonar.api.utils.WorkUnit; import javax.annotation.CheckForNull; @@ -48,10 +49,44 @@ public interface Characteristic { 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(); 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 index 3bac7310762..c27f94cab74 100644 --- 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 @@ -24,6 +24,7 @@ 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.WorkDuration; import org.sonar.api.utils.WorkUnit; import javax.annotation.CheckForNull; @@ -42,8 +43,10 @@ public class DefaultCharacteristic implements Characteristic { private Integer rootId; private RuleKey ruleKey; private String function; - private WorkUnit factor; - private WorkUnit offset; + private Integer factorValue; + private WorkDuration.UNIT factorUnit; + private Integer offsetValue; + private WorkDuration.UNIT offsetUnit; public Integer id() { return id; @@ -124,26 +127,118 @@ public class DefaultCharacteristic implements Characteristic { return this; } + /** + * @deprecated since 4.2 + */ + @Deprecated @CheckForNull public WorkUnit factor() { - return 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) { - this.factor = factor; + if (factor != null) { + this.factorValue = (int) factor.getValue(); + this.factorUnit = toUnit(factor.getUnit()); + } return this; } @CheckForNull + public Integer factorValue() { + return factorValue; + } + + public DefaultCharacteristic setFactorValue(@Nullable Integer factorValue) { + this.factorValue = factorValue; + return this; + } + + @CheckForNull + public WorkDuration.UNIT factorUnit() { + return factorUnit; + } + + public DefaultCharacteristic setFactorUnit(@Nullable WorkDuration.UNIT factorUnit) { + this.factorUnit = factorUnit; + return this; + } + + /** + * @deprecated since 4.2 + */ + @Deprecated public WorkUnit offset() { - return 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) { - this.offset = offset; + if (offset != null) { + this.offsetValue = (int) offset.getValue(); + this.offsetUnit = toUnit(offset.getUnit()); + } return this; } + @CheckForNull + public Integer offsetValue() { + return offsetValue; + } + + public DefaultCharacteristic setOffsetValue(@Nullable Integer offsetValue) { + this.offsetValue = offsetValue; + return this; + } + + @CheckForNull + public WorkDuration.UNIT offsetUnit() { + return offsetUnit; + } + + public DefaultCharacteristic setOffsetUnit(@Nullable WorkDuration.UNIT offsetUnit) { + this.offsetUnit = offsetUnit; + return this; + } + + public static WorkDuration.UNIT toUnit(@Nullable String requirementUnit) { + if (requirementUnit != null) { + if (requirementUnit.equals(WorkUnit.DAYS)) { + return WorkDuration.UNIT.DAYS; + } else if (requirementUnit.equals(WorkUnit.HOURS)) { + return WorkDuration.UNIT.HOURS; + } else if (requirementUnit.equals(WorkUnit.MINUTES)) { + return WorkDuration.UNIT.MINUTES; + } + throw new IllegalStateException("Invalid unit : " + requirementUnit); + } + return null; + } + + private static String fromUnit(WorkDuration.UNIT unit){ + if (unit.equals(WorkDuration.UNIT.DAYS)) { + return WorkUnit.DAYS; + } else if (unit.equals(WorkDuration.UNIT.HOURS)) { + return WorkUnit.HOURS; + } else if (unit.equals(WorkDuration.UNIT.MINUTES)) { + return WorkUnit.MINUTES; + } + throw new IllegalStateException("Invalid unit : " + unit); + } + public boolean isRoot() { return parentId == null; } 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 index 918b5918f18..343ec3285cc 100644 --- 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 @@ -22,6 +22,7 @@ package org.sonar.api.technicaldebt.batch.internal; import org.junit.Test; import org.sonar.api.rule.RuleKey; +import org.sonar.api.utils.WorkDuration; import org.sonar.api.utils.WorkUnit; import java.text.SimpleDateFormat; @@ -47,8 +48,10 @@ public class DefaultRequirementTest { .setCharacteristic(characteristic) .setRootCharacteristic(root) .setFunction("linear_offset") - .setFactor(WorkUnit.create(2d, WorkUnit.MINUTES)) - .setOffset(WorkUnit.create(1d, WorkUnit.HOURS)) + .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")); @@ -57,7 +60,11 @@ public class DefaultRequirementTest { 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")); 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 index 6cdb209c18f..193e5c5b145 100644 --- 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 @@ -22,6 +22,7 @@ package org.sonar.api.technicaldebt.server.internal; import org.junit.Test; import org.sonar.api.rule.RuleKey; +import org.sonar.api.utils.WorkDuration; import org.sonar.api.utils.WorkUnit; import static org.fest.assertions.Assertions.assertThat; @@ -44,7 +45,11 @@ public class DefaultCharacteristicTest { assertThat(characteristic.order()).isEqualTo(5); assertThat(characteristic.ruleKey()).isNull(); assertThat(characteristic.function()).isNull(); + assertThat(characteristic.factorValue()).isNull(); + assertThat(characteristic.factorUnit()).isNull(); assertThat(characteristic.factor()).isNull(); + assertThat(characteristic.offsetValue()).isNull(); + assertThat(characteristic.offsetUnit()).isNull(); assertThat(characteristic.offset()).isNull(); assertThat(characteristic.parentId()).isEqualTo(2); assertThat(characteristic.rootId()).isEqualTo(2); @@ -56,8 +61,10 @@ public class DefaultCharacteristicTest { .setId(1) .setRuleKey(RuleKey.of("repo", "rule")) .setFunction("linear_offset") - .setFactor(WorkUnit.create(2d, WorkUnit.MINUTES)) - .setOffset(WorkUnit.create(1d, WorkUnit.HOURS)) + .setFactorValue(2) + .setFactorUnit(WorkDuration.UNIT.MINUTES) + .setOffsetValue(1) + .setOffsetUnit(WorkDuration.UNIT.HOURS) .setRootId(3) .setParentId(2); @@ -67,7 +74,11 @@ public class DefaultCharacteristicTest { 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.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.parentId()).isEqualTo(2); assertThat(requirement.rootId()).isEqualTo(3); @@ -92,15 +103,16 @@ public class DefaultCharacteristicTest { .setId(1) .setRuleKey(RuleKey.of("repo", "rule")) .setFunction("linear_offset") - .setFactor(WorkUnit.create(2d, WorkUnit.MINUTES)) - .setOffset(WorkUnit.create(1d, WorkUnit.HOURS)) + .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")); -- 2.39.5