diff --git a/allure-generator/src/main/java/io/qameta/allure/allure1/Allure1Plugin.java b/allure-generator/src/main/java/io/qameta/allure/allure1/Allure1Plugin.java index dc85715ea..87976f42b 100644 --- a/allure-generator/src/main/java/io/qameta/allure/allure1/Allure1Plugin.java +++ b/allure-generator/src/main/java/io/qameta/allure/allure1/Allure1Plugin.java @@ -370,11 +370,12 @@ public static Status convert(final ru.yandex.qatools.allure.model.Status status) } private List getParameters(final TestCaseResult source) { - final TreeSet parametersSet = new TreeSet<>( - comparing(Parameter::getName, nullsFirst(naturalOrder())) - .thenComparing(Parameter::getValue, nullsFirst(naturalOrder())) - ); - parametersSet.addAll(convertList(source.getParameters(), this::hasArgumentType, this::convert)); + final List parameters = convertList(source.getParameters(), this::hasArgumentType, this::convert); + if (Objects.isNull(parameters)) { + return new ArrayList<>(); + } + final Set parametersSet = new TreeSet<>(PARAMETER_COMPARATOR); + parametersSet.addAll(parameters); return new ArrayList<>(parametersSet); } @@ -467,7 +468,7 @@ private Optional readXmlTestSuiteFile(final Path source) { try (InputStream is = Files.newInputStream(source)) { return Optional.of(xmlMapper.readValue(is, TestSuiteResult.class)); } catch (IOException e) { - LOGGER.error("Could not read xml result {}: {}", source, e); + LOGGER.error("Could not read xml result {}", source, e); } return Optional.empty(); } @@ -476,7 +477,7 @@ private Optional readJsonTestSuiteFile(final Path source) { try (InputStream is = Files.newInputStream(source)) { return Optional.of(jsonMapper.readValue(is, TestSuiteResult.class)); } catch (IOException e) { - LOGGER.error("Could not read json result {}: {}", source, e); + LOGGER.error("Could not read json result {}", source, e); return Optional.empty(); } } diff --git a/allure-generator/src/main/java/io/qameta/allure/allure2/Allure2Plugin.java b/allure-generator/src/main/java/io/qameta/allure/allure2/Allure2Plugin.java index 28550682e..41cbf1e84 100644 --- a/allure-generator/src/main/java/io/qameta/allure/allure2/Allure2Plugin.java +++ b/allure-generator/src/main/java/io/qameta/allure/allure2/Allure2Plugin.java @@ -92,6 +92,10 @@ public class Allure2Plugin implements Reader { nullsLast(comparing(Time::getStart, nullsLast(naturalOrder()))) ); + private static final Comparator PARAMETER_COMPARATOR = + comparing(Parameter::getName, nullsFirst(naturalOrder())) + .thenComparing(Parameter::getValue, nullsFirst(naturalOrder())); + private final ObjectMapper mapper = JsonMapper.builder() .enable(MapperFeature.USE_WRAPPER_NAME_AS_PROPERTY_NAME) .enable(MapperFeature.ACCEPT_CASE_INSENSITIVE_ENUMS) @@ -316,11 +320,16 @@ private Time convert(final Long start, final Long stop) { } private List getParameters(final TestResult result) { - final TreeSet parametersSet = new TreeSet<>( - comparing(Parameter::getName, nullsFirst(naturalOrder())) - .thenComparing(Parameter::getValue, nullsFirst(naturalOrder())) + final List parameters = convertList( + result.getParameters(), + p -> !HIDDEN.equals(p.getMode()), + this::convert ); - parametersSet.addAll(convertList(result.getParameters(), p -> !HIDDEN.equals(p.getMode()), this::convert)); + if (Objects.isNull(parameters)) { + return new ArrayList<>(); + } + final Set parametersSet = new TreeSet<>(PARAMETER_COMPARATOR); + parametersSet.addAll(parameters); return new ArrayList<>(parametersSet); } diff --git a/allure-generator/src/main/java/io/qameta/allure/environment/Allure1EnvironmentPlugin.java b/allure-generator/src/main/java/io/qameta/allure/environment/Allure1EnvironmentPlugin.java index d3977c796..3c87cbbdc 100644 --- a/allure-generator/src/main/java/io/qameta/allure/environment/Allure1EnvironmentPlugin.java +++ b/allure-generator/src/main/java/io/qameta/allure/environment/Allure1EnvironmentPlugin.java @@ -23,7 +23,6 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.function.Supplier; import static io.qameta.allure.allure1.Allure1Plugin.ENVIRONMENT_BLOCK_NAME; @@ -51,13 +50,11 @@ protected List getData(final List launches) { return launchEnvironments.stream() .collect(groupingBy(Map.Entry::getKey, LinkedHashMap::new, mapping(Map.Entry::getValue, toSet()))) .entrySet().stream() - .map(Allure1EnvironmentPlugin::aggregateItem) + .map(entry -> new EnvironmentItem() + .setName(entry.getKey()) + .setValues(new ArrayList<>(entry.getValue())) + ) .collect(toList()); } - private static EnvironmentItem aggregateItem(final Map.Entry> entry) { - return new EnvironmentItem() - .setName(entry.getKey()) - .setValues(new ArrayList<>(entry.getValue())); - } } diff --git a/allure-generator/src/main/java/io/qameta/allure/retry/RetryTrendItem.java b/allure-generator/src/main/java/io/qameta/allure/retry/RetryTrendItem.java index f4fe1631c..e758c7930 100644 --- a/allure-generator/src/main/java/io/qameta/allure/retry/RetryTrendItem.java +++ b/allure-generator/src/main/java/io/qameta/allure/retry/RetryTrendItem.java @@ -27,6 +27,7 @@ public class RetryTrendItem extends TrendItem { private static final String RETRY_KEY = "retry"; + @SuppressWarnings("PMD.ConstructorCallsOverridableMethod") public RetryTrendItem() { this.setMetric(RETRY_KEY, 0L); this.setMetric(RUN_KEY, 0L); diff --git a/build.gradle.kts b/build.gradle.kts index 099a98d7d..7965b4fa6 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -95,7 +95,7 @@ subprojects { dependency("commons-beanutils:commons-beanutils:1.9.4") dependency("commons-io:commons-io:2.16.0") dependency("javax.xml.bind:jaxb-api:2.3.1") - dependency("net.sourceforge.pmd:pmd-java:6.55.0") + dependency("net.sourceforge.pmd:pmd-java:7.0.0") dependency("org.allurefw:allure1-model:1.0") dependency("org.apache.commons:commons-collections4:4.4") dependency("org.apache.commons:commons-lang3:3.14.0") @@ -173,6 +173,7 @@ subprojects { toolVersion = dependencyManagement.managedVersions["net.sourceforge.pmd:pmd-java"]!! ruleSets = listOf() ruleSetFiles = rootProject.files("gradle/quality-configs/pmd/pmd.xml") + targetJdk = TargetJdk.VERSION_1_7 } spotbugs { diff --git a/gradle/quality-configs/pmd/pmd.xml b/gradle/quality-configs/pmd/pmd.xml index 03e8b5871..eae465ea0 100644 --- a/gradle/quality-configs/pmd/pmd.xml +++ b/gradle/quality-configs/pmd/pmd.xml @@ -26,13 +26,10 @@ - - - @@ -48,6 +45,7 @@ + @@ -60,16 +58,13 @@ + - - - - @@ -106,13 +101,12 @@ - + - diff --git a/plugins/xctest-plugin/src/main/java/io/qameta/allure/xctest/ResultsUtils.java b/plugins/xctest-plugin/src/main/java/io/qameta/allure/xctest/ResultsUtils.java index e4f6718f5..60f36d4c4 100644 --- a/plugins/xctest-plugin/src/main/java/io/qameta/allure/xctest/ResultsUtils.java +++ b/plugins/xctest-plugin/src/main/java/io/qameta/allure/xctest/ResultsUtils.java @@ -46,10 +46,10 @@ private ResultsUtils() { public static TestResult getTestResult(final Map props) { return new TestResult() .setUid(UUID.randomUUID().toString()) - .setName(ResultsUtils.getTestName(props)) - .setStatus(ResultsUtils.getTestStatus(props)) - .setFullName(ResultsUtils.getFullName(props)) - .setTime(ResultsUtils.getTestTime(props)) + .setName(getTestName(props)) + .setStatus(getTestStatus(props)) + .setFullName(getFullName(props)) + .setTime(getTestTime(props)) .setTestStage(new StageResult()); } @@ -102,8 +102,8 @@ private static Time getStepTime(final Map props) { } private static long parseTime(final String time) { - final Double doubleTime = Double.parseDouble(time); - final int seconds = doubleTime.intValue(); - return seconds * 1000; + final double doubleTime = Double.parseDouble(time); + final int seconds = (int) doubleTime; + return seconds * 1000L; } }