From d19bd49013657aea7a4f1342ca06fc2868835641 Mon Sep 17 00:00:00 2001 From: Dmitry Baev Date: Sun, 4 Jul 2021 14:25:08 +0300 Subject: [PATCH 1/9] bump gradle --- .github/workflows/build.yml | 2 +- build.gradle.kts | 2 +- gradle.properties | 1 + gradle/wrapper/gradle-wrapper.properties | 2 +- gradlew.bat | 178 +++++++++++------------ settings.gradle.kts | 15 ++ 6 files changed, 108 insertions(+), 92 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2d2896536..6009acaf8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -27,7 +27,7 @@ jobs: java-version: ${{ matrix.java-version }} - name: Build with Gradle - run: ./gradlew build -x test + run: ./gradlew build -x test --scan - name: Run tests if: always() diff --git a/build.gradle.kts b/build.gradle.kts index 5f44c0812..c30768a48 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -26,7 +26,7 @@ val qualityConfigsDir by extra("$gradleScriptDir/quality-configs") val spotlessDtr by extra("$qualityConfigsDir/spotless") tasks.withType(Wrapper::class) { - gradleVersion = "6.8.3" + gradleVersion = "7.1.1" } plugins { diff --git a/gradle.properties b/gradle.properties index 6b2b860c6..fc3b66841 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,6 +2,7 @@ version=2.15-SNAPSHOT org.gradle.daemon=true org.gradle.parallel=true +org.gradle.warning.mode=none test.maxHeapSize=512m test.maxParallelForks=4 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 442d9132e..05679dc3c 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew.bat b/gradlew.bat index 107acd32c..ac1b06f93 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,89 +1,89 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/settings.gradle.kts b/settings.gradle.kts index d2093d40a..ee1dc6eae 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -34,3 +34,18 @@ include("allure-spring-web") include("allure-test-filter") include("allure-testng") +plugins { + id("com.gradle.enterprise") version "3.6.2" +} + +val isCiServer = System.getenv().containsKey("CI") + +if (isCiServer) { + gradleEnterprise { + buildScan { + termsOfServiceUrl = "https://gradle.com/terms-of-service" + termsOfServiceAgree = "yes" + tag("CI") + } + } +} From 5712a10eb33748002415010c5f82e8c81c8b82b9 Mon Sep 17 00:00:00 2001 From: Dmitry Baev Date: Sun, 4 Jul 2021 16:41:13 +0300 Subject: [PATCH 2/9] model refactoring --- .../allure/FileSystemResultsReader.java | 2 +- .../allure/FileSystemResultsWriter.java | 2 +- .../allure/internal}/Allure2ModelJackson.java | 10 +- .../internal/ParameterModeSerializer.java | 40 ++ .../allure/internal}/StageDeserializer.java | 3 +- .../allure/internal/StageSerializer.java | 40 ++ .../allure/internal}/StatusDeserializer.java | 5 +- .../allure/internal/StatusSerializer.java | 40 ++ .../io/qameta/allure/util/ResultsUtils.java | 12 +- .../junitplatform/AllureJunitPlatform.java | 10 +- .../io/qameta/allure/model/Attachment.java | 95 +-- .../qameta/allure/model/ExecutableItem.java | 435 +------------ .../io/qameta/allure/model/FixtureResult.java | 356 +++++------ .../java/io/qameta/allure/model/Label.java | 58 +- .../java/io/qameta/allure/model/Link.java | 82 +-- .../io/qameta/allure/model/Parameter.java | 135 +++- .../java/io/qameta/allure/model/Stage.java | 40 +- .../java/io/qameta/allure/model/Status.java | 38 +- .../io/qameta/allure/model/StatusDetails.java | 118 ++-- .../io/qameta/allure/model/StepResult.java | 358 +++++------ .../io/qameta/allure/model/TestResult.java | 601 +++++++----------- .../allure/model/TestResultContainer.java | 417 +++--------- .../io/qameta/allure/model/TestRunResult.java | 98 --- .../qameta/allure/model/WithAttachments.java | 15 +- .../io/qameta/allure/model/WithLinks.java | 14 +- .../qameta/allure/model/WithParameters.java | 15 +- .../io/qameta/allure/model/WithStatus.java | 14 +- .../allure/model/WithStatusDetails.java | 15 +- .../io/qameta/allure/model/WithSteps.java | 15 +- .../io/qameta/allure/testng/AllureTestNg.java | 82 +-- 30 files changed, 1264 insertions(+), 1901 deletions(-) rename {allure-model/src/main/java/io/qameta/allure/model => allure-java-commons/src/main/java/io/qameta/allure/internal}/Allure2ModelJackson.java (81%) create mode 100644 allure-java-commons/src/main/java/io/qameta/allure/internal/ParameterModeSerializer.java rename {allure-model/src/main/java/io/qameta/allure/model => allure-java-commons/src/main/java/io/qameta/allure/internal}/StageDeserializer.java (95%) create mode 100644 allure-java-commons/src/main/java/io/qameta/allure/internal/StageSerializer.java rename {allure-model/src/main/java/io/qameta/allure/model => allure-java-commons/src/main/java/io/qameta/allure/internal}/StatusDeserializer.java (90%) create mode 100644 allure-java-commons/src/main/java/io/qameta/allure/internal/StatusSerializer.java delete mode 100644 allure-model/src/main/java/io/qameta/allure/model/TestRunResult.java diff --git a/allure-java-commons/src/main/java/io/qameta/allure/FileSystemResultsReader.java b/allure-java-commons/src/main/java/io/qameta/allure/FileSystemResultsReader.java index a504eb158..d141c9d38 100644 --- a/allure-java-commons/src/main/java/io/qameta/allure/FileSystemResultsReader.java +++ b/allure-java-commons/src/main/java/io/qameta/allure/FileSystemResultsReader.java @@ -16,7 +16,7 @@ package io.qameta.allure; import com.fasterxml.jackson.databind.ObjectMapper; -import io.qameta.allure.model.Allure2ModelJackson; +import io.qameta.allure.internal.Allure2ModelJackson; import io.qameta.allure.model.TestResult; import io.qameta.allure.model.TestResultContainer; diff --git a/allure-java-commons/src/main/java/io/qameta/allure/FileSystemResultsWriter.java b/allure-java-commons/src/main/java/io/qameta/allure/FileSystemResultsWriter.java index 3e318ed7e..3e361b07b 100644 --- a/allure-java-commons/src/main/java/io/qameta/allure/FileSystemResultsWriter.java +++ b/allure-java-commons/src/main/java/io/qameta/allure/FileSystemResultsWriter.java @@ -16,7 +16,7 @@ package io.qameta.allure; import com.fasterxml.jackson.databind.ObjectMapper; -import io.qameta.allure.model.Allure2ModelJackson; +import io.qameta.allure.internal.Allure2ModelJackson; import io.qameta.allure.model.TestResult; import io.qameta.allure.model.TestResultContainer; diff --git a/allure-model/src/main/java/io/qameta/allure/model/Allure2ModelJackson.java b/allure-java-commons/src/main/java/io/qameta/allure/internal/Allure2ModelJackson.java similarity index 81% rename from allure-model/src/main/java/io/qameta/allure/model/Allure2ModelJackson.java rename to allure-java-commons/src/main/java/io/qameta/allure/internal/Allure2ModelJackson.java index 6832b5b58..f838d2945 100644 --- a/allure-model/src/main/java/io/qameta/allure/model/Allure2ModelJackson.java +++ b/allure-java-commons/src/main/java/io/qameta/allure/internal/Allure2ModelJackson.java @@ -13,10 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package io.qameta.allure.model; +package io.qameta.allure.internal; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.module.SimpleModule; +import io.qameta.allure.model.Parameter; +import io.qameta.allure.model.Stage; +import io.qameta.allure.model.Status; import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL; import static com.fasterxml.jackson.databind.MapperFeature.USE_WRAPPER_NAME_AS_PROPERTY_NAME; @@ -40,8 +43,9 @@ public static ObjectMapper createMapper() { .setSerializationInclusion(NON_NULL) .configure(INDENT_OUTPUT, Boolean.getBoolean(INDENT_OUTPUT_PROPERTY_NAME)) .registerModule(new SimpleModule() - .addDeserializer(Status.class, new StatusDeserializer()) - .addDeserializer(Stage.class, new StageDeserializer()) + .addSerializer(Status.class, new StatusSerializer()) + .addSerializer(Stage.class, new StageSerializer()) + .addSerializer(Parameter.Mode.class, new ParameterModeSerializer()) ); } } diff --git a/allure-java-commons/src/main/java/io/qameta/allure/internal/ParameterModeSerializer.java b/allure-java-commons/src/main/java/io/qameta/allure/internal/ParameterModeSerializer.java new file mode 100644 index 000000000..adda8a1f0 --- /dev/null +++ b/allure-java-commons/src/main/java/io/qameta/allure/internal/ParameterModeSerializer.java @@ -0,0 +1,40 @@ +/* + * Copyright 2019 Qameta Software OÜ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.qameta.allure.internal; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import io.qameta.allure.model.Parameter; + +import java.io.IOException; +import java.util.Locale; + +/** + * @author charlie (Dmitry Baev). + */ +public class ParameterModeSerializer extends StdSerializer { + protected ParameterModeSerializer() { + super(Parameter.Mode.class); + } + + @Override + public void serialize(final Parameter.Mode value, + final JsonGenerator gen, + final SerializerProvider provider) throws IOException { + gen.writeString(value.name().toLowerCase(Locale.ENGLISH)); + } +} diff --git a/allure-model/src/main/java/io/qameta/allure/model/StageDeserializer.java b/allure-java-commons/src/main/java/io/qameta/allure/internal/StageDeserializer.java similarity index 95% rename from allure-model/src/main/java/io/qameta/allure/model/StageDeserializer.java rename to allure-java-commons/src/main/java/io/qameta/allure/internal/StageDeserializer.java index 29a9c8b4e..e58a4ec49 100644 --- a/allure-model/src/main/java/io/qameta/allure/model/StageDeserializer.java +++ b/allure-java-commons/src/main/java/io/qameta/allure/internal/StageDeserializer.java @@ -13,11 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package io.qameta.allure.model; +package io.qameta.allure.internal; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import io.qameta.allure.model.Stage; import java.io.IOException; import java.util.stream.Stream; diff --git a/allure-java-commons/src/main/java/io/qameta/allure/internal/StageSerializer.java b/allure-java-commons/src/main/java/io/qameta/allure/internal/StageSerializer.java new file mode 100644 index 000000000..b24389788 --- /dev/null +++ b/allure-java-commons/src/main/java/io/qameta/allure/internal/StageSerializer.java @@ -0,0 +1,40 @@ +/* + * Copyright 2019 Qameta Software OÜ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.qameta.allure.internal; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import io.qameta.allure.model.Stage; + +import java.io.IOException; +import java.util.Locale; + +/** + * @author charlie (Dmitry Baev). + */ +public class StageSerializer extends StdSerializer { + protected StageSerializer() { + super(Stage.class); + } + + @Override + public void serialize(final Stage value, + final JsonGenerator gen, + final SerializerProvider provider) throws IOException { + gen.writeString(value.name().toLowerCase(Locale.ENGLISH)); + } +} diff --git a/allure-model/src/main/java/io/qameta/allure/model/StatusDeserializer.java b/allure-java-commons/src/main/java/io/qameta/allure/internal/StatusDeserializer.java similarity index 90% rename from allure-model/src/main/java/io/qameta/allure/model/StatusDeserializer.java rename to allure-java-commons/src/main/java/io/qameta/allure/internal/StatusDeserializer.java index 5b3508db2..e581ff5ac 100644 --- a/allure-model/src/main/java/io/qameta/allure/model/StatusDeserializer.java +++ b/allure-java-commons/src/main/java/io/qameta/allure/internal/StatusDeserializer.java @@ -13,11 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package io.qameta.allure.model; +package io.qameta.allure.internal; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import io.qameta.allure.model.Status; import java.io.IOException; import java.util.stream.Stream; @@ -34,7 +35,7 @@ protected StatusDeserializer() { public Status deserialize(final JsonParser p, final DeserializationContext ctxt) throws IOException { final String value = p.readValueAs(String.class); return Stream.of(Status.values()) - .filter(status -> status.value().equalsIgnoreCase(value)) + .filter(status -> status.name().equalsIgnoreCase(value)) .findAny() .orElse(null); } diff --git a/allure-java-commons/src/main/java/io/qameta/allure/internal/StatusSerializer.java b/allure-java-commons/src/main/java/io/qameta/allure/internal/StatusSerializer.java new file mode 100644 index 000000000..8d7a2e868 --- /dev/null +++ b/allure-java-commons/src/main/java/io/qameta/allure/internal/StatusSerializer.java @@ -0,0 +1,40 @@ +/* + * Copyright 2019 Qameta Software OÜ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.qameta.allure.internal; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import io.qameta.allure.model.Status; + +import java.io.IOException; +import java.util.Locale; + +/** + * @author charlie (Dmitry Baev). + */ +public class StatusSerializer extends StdSerializer { + protected StatusSerializer() { + super(Status.class); + } + + @Override + public void serialize(final Status value, + final JsonGenerator gen, + final SerializerProvider provider) throws IOException { + gen.writeString(value.name().toLowerCase(Locale.ENGLISH)); + } +} diff --git a/allure-java-commons/src/main/java/io/qameta/allure/util/ResultsUtils.java b/allure-java-commons/src/main/java/io/qameta/allure/util/ResultsUtils.java index 4f6e01a45..c49cba794 100644 --- a/allure-java-commons/src/main/java/io/qameta/allure/util/ResultsUtils.java +++ b/allure-java-commons/src/main/java/io/qameta/allure/util/ResultsUtils.java @@ -48,6 +48,7 @@ import java.util.Optional; import java.util.Properties; import java.util.Set; +import java.util.function.Consumer; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -372,20 +373,17 @@ private static String getStackTraceAsString(final Throwable throwable) { return stringWriter.toString(); } - /** - * @deprecated use {@link #getJavadocDescription(ClassLoader, Method)} instead. - */ - @Deprecated public static void processDescription(final ClassLoader classLoader, final Method method, - final io.qameta.allure.model.ExecutableItem item) { + final Consumer setDescription, + final Consumer setDescriptionHtml) { if (method.isAnnotationPresent(Description.class)) { if (method.getAnnotation(Description.class).useJavaDoc()) { getJavadocDescription(classLoader, method) - .ifPresent(item::setDescriptionHtml); + .ifPresent(setDescriptionHtml); } else { final String description = method.getAnnotation(Description.class).value(); - item.setDescription(description); + setDescription.accept(description); } } } diff --git a/allure-junit-platform/src/main/java/io/qameta/allure/junitplatform/AllureJunitPlatform.java b/allure-junit-platform/src/main/java/io/qameta/allure/junitplatform/AllureJunitPlatform.java index 64d8d6dee..e45225bfe 100644 --- a/allure-junit-platform/src/main/java/io/qameta/allure/junitplatform/AllureJunitPlatform.java +++ b/allure-junit-platform/src/main/java/io/qameta/allure/junitplatform/AllureJunitPlatform.java @@ -89,19 +89,14 @@ }) public class AllureJunitPlatform implements TestExecutionListener { - private static final Logger LOGGER = LoggerFactory.getLogger(AllureJunitPlatform.class); - public static final String ALLURE_FIXTURE = "allure.fixture"; - public static final String PREPARE = "prepare"; public static final String TEAR_DOWN = "tear_down"; - public static final String EVENT_START = "start"; public static final String EVENT_STOP = "stop"; public static final String EVENT_FAILURE = "failure"; - public static final String JUNIT_PLATFORM_UNIQUE_ID = "junit.platform.uniqueid"; - + private static final Logger LOGGER = LoggerFactory.getLogger(AllureJunitPlatform.class); private static final String STDOUT = "stdout"; private static final String STDERR = "stderr"; private static final String TEXT_PLAIN = "text/plain"; @@ -416,7 +411,8 @@ private void startTestCase(final TestIdentifier testIdentifier) { testMethod.ifPresent(method -> ResultsUtils.processDescription( method.getDeclaringClass().getClassLoader(), method, - result + result::setDescription, + result::setDescriptionHtml )); getLifecycle().scheduleTestCase(result); diff --git a/allure-model/src/main/java/io/qameta/allure/model/Attachment.java b/allure-model/src/main/java/io/qameta/allure/model/Attachment.java index fcf57ab6d..750bc7239 100644 --- a/allure-model/src/main/java/io/qameta/allure/model/Attachment.java +++ b/allure-model/src/main/java/io/qameta/allure/model/Attachment.java @@ -18,37 +18,35 @@ import java.io.Serializable; /** - * POJO that stores attachment information. + * The model object that used to link attachment files, stored in results directory, + * to test results. + * + * @author baev (Dmitry Baev) + * @see io.qameta.allure.model.WithAttachments + * @since 2.0 */ public class Attachment implements Serializable { private static final long serialVersionUID = 1L; - protected String name; - - protected String source; - - protected String type; + private String name; + private String source; + private String type; /** - * Gets the value of the name property. - * - * @return - * possible object is - * {@link String } - * + * Gets name. + * + * @return the name */ public String getName() { return name; } /** - * Sets the value of the name property. - * - * @param value - * allowed object is - * {@link String } - * + * Sets name. + * + * @param value the value + * @return self for method chaining */ public Attachment setName(final String value) { this.name = value; @@ -56,24 +54,19 @@ public Attachment setName(final String value) { } /** - * Gets the value of the source property. - * - * @return - * possible object is - * {@link String } - * + * Gets source. + * + * @return the source */ public String getSource() { return source; } /** - * Sets the value of the source property. - * - * @param value - * allowed object is - * {@link String } - * + * Sets source. + * + * @param value the value + * @return self for method chaining */ public Attachment setSource(final String value) { this.source = value; @@ -81,51 +74,23 @@ public Attachment setSource(final String value) { } /** - * Gets the value of the type property. - * - * @return - * possible object is - * {@link String } - * + * Gets type. + * + * @return the type */ public String getType() { return type; } /** - * Sets the value of the type property. - * - * @param value - * allowed object is - * {@link String } - * + * Sets type. + * + * @param value the value + * @return self for method chaining */ public Attachment setType(final String value) { this.type = value; return this; } - /** - * @deprecated use set method - */ - @Deprecated - public Attachment withName(final String value) { - return setName(value); - } - - /** - * @deprecated use set method - */ - @Deprecated - public Attachment withSource(final String value) { - return setSource(value); - } - - /** - * @deprecated use set method - */ - @Deprecated - public Attachment withType(final String value) { - return setType(value); - } } diff --git a/allure-model/src/main/java/io/qameta/allure/model/ExecutableItem.java b/allure-model/src/main/java/io/qameta/allure/model/ExecutableItem.java index e6de82585..b73cfee17 100644 --- a/allure-model/src/main/java/io/qameta/allure/model/ExecutableItem.java +++ b/allure-model/src/main/java/io/qameta/allure/model/ExecutableItem.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Qameta Software OÜ + * Copyright 2021 Qameta Software OÜ * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,435 +15,16 @@ */ package io.qameta.allure.model; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - /** - * POJO that stores common information about executable items. + * Marker interface for model objects that holds information about + * executable items, like test results, fixture results or steps. * - * @deprecated scheduled to removal in 3.0 release. + * @author charlie (Dmitry Baev). + * @see TestResult + * @see FixtureResult + * @see StepResult */ -@Deprecated -@SuppressWarnings("PMD.ExcessivePublicCount") -public abstract class ExecutableItem implements Serializable, WithAttachments, +public interface ExecutableItem extends WithAttachments, WithParameters, WithStatusDetails, WithSteps { - private static final long serialVersionUID = 1L; - - protected String name; - - protected Status status; - - protected StatusDetails statusDetails; - - protected Stage stage; - - protected String description; - - protected String descriptionHtml; - - protected List steps; - - protected List attachments; - - protected List parameters; - - protected Long start; - - protected Long stop; - - /** - * Gets the value of the name property. - * - * @return possible object is - * {@link String } - */ - public String getName() { - return name; - } - - /** - * Sets the value of the name property. - * - * @param value allowed object is - * {@link String } - */ - public ExecutableItem setName(final String value) { - this.name = value; - return this; - } - - /** - * Gets the value of the status property. - * - * @return possible object is - * {@link Status } - */ - @Override - public Status getStatus() { - return status; - } - - /** - * Sets the value of the status property. - * - * @param value allowed object is - * {@link Status } - */ - public ExecutableItem setStatus(final Status value) { - this.status = value; - return this; - } - - /** - * Gets the value of the statusDetails property. - * - * @return possible object is - * {@link StatusDetails } - */ - @Override - public StatusDetails getStatusDetails() { - return statusDetails; - } - - /** - * Sets the value of the statusDetails property. - * - * @param value allowed object is - * {@link StatusDetails } - */ - public ExecutableItem setStatusDetails(final StatusDetails value) { - this.statusDetails = value; - return this; - } - - /** - * Gets the value of the stage property. - * - * @return possible object is - * {@link Stage } - */ - public Stage getStage() { - return stage; - } - - /** - * Sets the value of the stage property. - * - * @param value allowed object is - * {@link Stage } - */ - public ExecutableItem setStage(final Stage value) { - this.stage = value; - return this; - } - - /** - * Gets the value of the description property. - * - * @return possible object is - * {@link String } - */ - public String getDescription() { - return description; - } - - /** - * Sets the value of the description property. - * - * @param value allowed object is - * {@link String } - */ - public ExecutableItem setDescription(final String value) { - this.description = value; - return this; - } - - /** - * Gets the value of the descriptionHtml property. - * - * @return possible object is - * {@link String } - */ - public String getDescriptionHtml() { - return descriptionHtml; - } - - /** - * Sets the value of the descriptionHtml property. - * - * @param value allowed object is - * {@link String } - */ - public ExecutableItem setDescriptionHtml(final String value) { - this.descriptionHtml = value; - return this; - } - - /** - * Gets the value of the start property. - * - * @return possible object is - * {@link Long } - */ - public Long getStart() { - return start; - } - - /** - * Sets the value of the start property. - * - * @param value allowed object is - * {@link Long } - */ - public ExecutableItem setStart(final Long value) { - this.start = value; - return this; - } - - /** - * Gets the value of the stop property. - * - * @return possible object is - * {@link Long } - */ - public Long getStop() { - return stop; - } - - /** - * Sets the value of the stop property. - * - * @param value allowed object is - * {@link Long } - */ - public ExecutableItem setStop(final Long value) { - this.stop = value; - return this; - } - - @Override - public List getSteps() { - if (steps == null) { - steps = new ArrayList<>(); - } - return steps; - } - - public ExecutableItem setSteps(final List steps) { - this.steps = steps; - return this; - } - - public ExecutableItem setSteps(final StepResult... values) { - if (values != null) { - for (StepResult value : values) { - getSteps().add(value); - } - } - return this; - } - - public ExecutableItem setSteps(final Collection values) { - if (values != null) { - getSteps().addAll(values); - } - return this; - } - - @Override - public List getAttachments() { - if (attachments == null) { - attachments = new ArrayList<>(); - } - return attachments; - } - - public ExecutableItem setAttachments(final List attachments) { - this.attachments = attachments; - return this; - } - - public ExecutableItem setAttachments(final Attachment... values) { - if (values != null) { - for (Attachment value : values) { - getAttachments().add(value); - } - } - return this; - } - - public ExecutableItem setAttachments(final Collection values) { - if (values != null) { - getAttachments().addAll(values); - } - return this; - } - - @Override - public List getParameters() { - if (parameters == null) { - parameters = new ArrayList<>(); - } - return parameters; - } - - public ExecutableItem setParameters(final List parameters) { - this.parameters = parameters; - return this; - } - - public ExecutableItem setParameters(final Parameter... values) { - if (values != null) { - for (Parameter value : values) { - getParameters().add(value); - } - } - return this; - } - - public ExecutableItem setParameters(final Collection values) { - if (values != null) { - getParameters().addAll(values); - } - return this; - } - - /** - * @deprecated use set method. Scheduled to removal in 3.0 release. - */ - @Deprecated - public ExecutableItem withName(final String value) { - return setName(value); - } - - /** - * @deprecated use set method. Scheduled to removal in 3.0 release. - */ - @Deprecated - public ExecutableItem withStatus(final Status value) { - return setStatus(value); - } - - /** - * @deprecated use set method. Scheduled to removal in 3.0 release. - */ - @Deprecated - public ExecutableItem withStatusDetails(final StatusDetails value) { - return setStatusDetails(value); - } - - /** - * @deprecated use set method. Scheduled to removal in 3.0 release. - */ - @Deprecated - public ExecutableItem withStage(final Stage value) { - return setStage(value); - } - - /** - * @deprecated use set method. Scheduled to removal in 3.0 release. - */ - @Deprecated - public ExecutableItem withDescription(final String value) { - return setDescription(value); - } - - /** - * @deprecated use set method. Scheduled to removal in 3.0 release. - */ - @Deprecated - public ExecutableItem withDescriptionHtml(final String value) { - return setDescriptionHtml(value); - } - - /** - * @deprecated use set method. Scheduled to removal in 3.0 release. - */ - @Deprecated - public ExecutableItem withStart(final Long value) { - return setStart(value); - } - - /** - * @deprecated use set method. Scheduled to removal in 3.0 release. - */ - @Deprecated - public ExecutableItem withStop(final Long value) { - return setStop(value); - } - - /** - * @deprecated use set method. Scheduled to removal in 3.0 release. - */ - @Deprecated - public ExecutableItem withSteps(final StepResult... values) { - return setSteps(values); - } - - /** - * @deprecated use set method. Scheduled to removal in 3.0 release. - */ - @Deprecated - public ExecutableItem withSteps(final Collection values) { - return setSteps(values); - } - - /** - * @deprecated use set method. Scheduled to removal in 3.0 release. - */ - @Deprecated - public ExecutableItem withSteps(final List steps) { - return setSteps(steps); - } - - /** - * @deprecated use set method. Scheduled to removal in 3.0 release. - */ - @Deprecated - public ExecutableItem withAttachments(final Attachment... values) { - return setAttachments(values); - } - - /** - * @deprecated use set method. Scheduled to removal in 3.0 release. - */ - @Deprecated - public ExecutableItem withAttachments(final Collection values) { - return setAttachments(values); - } - - /** - * @deprecated use set method. Scheduled to removal in 3.0 release. - */ - @Deprecated - public ExecutableItem withAttachments(final List attachments) { - return setAttachments(attachments); - } - - /** - * @deprecated use set method. Scheduled to removal in 3.0 release. - */ - @Deprecated - public ExecutableItem withParameters(final Parameter... values) { - return setParameters(values); - } - - /** - * @deprecated use set method. Scheduled to removal in 3.0 release. - */ - @Deprecated - public ExecutableItem withParameters(final Collection values) { - return setParameters(values); - } - - /** - * @deprecated use set method. Scheduled to removal in 3.0 release. - */ - @Deprecated - public ExecutableItem withParameters(final List parameters) { - return setParameters(parameters); - } } diff --git a/allure-model/src/main/java/io/qameta/allure/model/FixtureResult.java b/allure-model/src/main/java/io/qameta/allure/model/FixtureResult.java index ff1eb229e..604ebd4a7 100644 --- a/allure-model/src/main/java/io/qameta/allure/model/FixtureResult.java +++ b/allure-model/src/main/java/io/qameta/allure/model/FixtureResult.java @@ -16,306 +16,280 @@ package io.qameta.allure.model; import java.io.Serializable; -import java.util.Collection; import java.util.List; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.Objects; /** - * POJO that stores fixture result information. + * The model object that stores information about executed test fixtures (set up and tear down methods). + * In order to link test fixture to test result {@link TestResultContainer} is used. + * + * @author baev (Dmitry Baev) + * @see io.qameta.allure.model.TestResult + * @see io.qameta.allure.model.TestResultContainer + * @since 2.0 */ -@SuppressWarnings("deprecation") -public class FixtureResult extends ExecutableItem implements Serializable { +public class FixtureResult implements Serializable, ExecutableItem { private static final long serialVersionUID = 1L; - @Override - public FixtureResult setName(final String value) { - super.setName(value); - return this; - } - - @Override - public FixtureResult setStatus(final Status value) { - super.setStatus(value); - return this; - } - - @Override - public FixtureResult setStatusDetails(final StatusDetails value) { - super.setStatusDetails(value); - return this; - } - - @Override - public FixtureResult setStage(final Stage value) { - super.setStage(value); - return this; - } - - @Override - public FixtureResult setDescription(final String value) { - super.setDescription(value); - return this; - } - - @Override - public FixtureResult setDescriptionHtml(final String value) { - super.setDescriptionHtml(value); - return this; - } - - @Override - public FixtureResult setStart(final Long value) { - super.setStart(value); - return this; - } - - @Override - public FixtureResult setStop(final Long value) { - super.setStop(value); - return this; - } - - @Override - @JsonProperty - public FixtureResult setSteps(final List steps) { - super.setSteps(steps); - return this; - } + private String name; + private Status status; + private StatusDetails statusDetails; + private Stage stage; + private String description; + private String descriptionHtml; + private List steps; + private List attachments; + private List parameters; + private Long start; + private Long stop; /** - * @deprecated use {@link #setSteps(List)} instead. + * Gets name. + * + * @return the name */ - @Deprecated - @Override - @JsonIgnore - public FixtureResult setSteps(final StepResult... values) { - super.setSteps(values); - return this; + public String getName() { + return name; } /** - * @deprecated use {@link #setSteps(List)} instead. + * Sets name. + * + * @param value the value + * @return self for method chaining */ - @Deprecated - @Override - @JsonIgnore - public FixtureResult setSteps(final Collection values) { - super.setSteps(values); - return this; - } - - @Override - @JsonProperty - public FixtureResult setAttachments(final List attachments) { - super.setAttachments(attachments); + public FixtureResult setName(final String value) { + this.name = value; return this; } /** - * @deprecated use {@link #setAttachments(List)} instead. + * Gets status. + * + * @return the status */ - @Deprecated @Override - @JsonIgnore - public FixtureResult setAttachments(final Attachment... values) { - super.setAttachments(values); - return this; + public Status getStatus() { + return status; } /** - * @deprecated use {@link #setAttachments(List)} instead. + * Sets status. + * + * @param value the value + * @return self for method chaining */ - @Deprecated - @Override - @JsonIgnore - public FixtureResult setAttachments(final Collection values) { - super.setAttachments(values); + public FixtureResult setStatus(final Status value) { + this.status = value; return this; } + /** + * Gets status details. + * + * @return the status details + */ @Override - @JsonProperty - public FixtureResult setParameters(final List parameters) { - super.setParameters(parameters); - return this; + public StatusDetails getStatusDetails() { + return statusDetails; } /** - * @deprecated use {@link #setParameters(List)} instead. + * Sets status details. + * + * @param value the value + * @return self for method chaining */ - @Override - @Deprecated - @JsonIgnore - public FixtureResult setParameters(final Parameter... values) { - super.setParameters(values); + public FixtureResult setStatusDetails(final StatusDetails value) { + this.statusDetails = value; return this; } /** - * @deprecated use {@link #setParameters(List)} instead. + * Gets stage. + * + * @return the stage */ - @Deprecated - @Override - @JsonIgnore - public FixtureResult setParameters(final Collection values) { - super.setParameters(values); - return this; + public Stage getStage() { + return stage; } /** - * @deprecated use set method. Scheduled to removal in 3.0 release. + * Sets stage. + * + * @param value the value + * @return self for method chaining */ - @Deprecated - @Override - public FixtureResult withName(final String value) { - return setName(value); + public FixtureResult setStage(final Stage value) { + this.stage = value; + return this; } /** - * @deprecated use set method. Scheduled to removal in 3.0 release. + * Gets description. + * + * @return the description */ - @Deprecated - @Override - public FixtureResult withStatus(final Status value) { - return setStatus(value); + public String getDescription() { + return description; } /** - * @deprecated use set method. Scheduled to removal in 3.0 release. + * Sets description. + * + * @param value the value + * @return self for method chaining */ - @Deprecated - @Override - public FixtureResult withStatusDetails(final StatusDetails value) { - return setStatusDetails(value); + public FixtureResult setDescription(final String value) { + this.description = value; + return this; } /** - * @deprecated use set method. Scheduled to removal in 3.0 release. + * Gets description html. + * + * @return the description html */ - @Deprecated - @Override - public FixtureResult withStage(final Stage value) { - return setStage(value); + public String getDescriptionHtml() { + return descriptionHtml; } /** - * @deprecated use set method. Scheduled to removal in 3.0 release. + * Sets description html. + * + * @param value the value + * @return self for method chaining */ - @Deprecated - @Override - public FixtureResult withDescription(final String value) { - return setDescription(value); + public FixtureResult setDescriptionHtml(final String value) { + this.descriptionHtml = value; + return this; } /** - * @deprecated use set method. Scheduled to removal in 3.0 release. + * Gets steps. + * + * @return the steps */ - @Deprecated @Override - public FixtureResult withDescriptionHtml(final String value) { - return setDescriptionHtml(value); + public List getSteps() { + return steps; } /** - * @deprecated use set method. Scheduled to removal in 3.0 release. + * Sets steps. + * + * @param steps the steps + * @return self for method chaining */ - @Deprecated - @Override - public FixtureResult withStart(final Long value) { - return setStart(value); + public FixtureResult setSteps(final List steps) { + this.steps = steps; + return this; } /** - * @deprecated use set method. Scheduled to removal in 3.0 release. + * Gets attachments. + * + * @return the attachments */ - @Deprecated @Override - public FixtureResult withStop(final Long value) { - return setStop(value); + public List getAttachments() { + return attachments; } /** - * @deprecated use set method. Scheduled to removal in 3.0 release. + * Sets attachments. + * + * @param attachments the attachments + * @return self for method chaining */ - @Deprecated - @Override - public FixtureResult withSteps(final StepResult... values) { - return setSteps(values); + public FixtureResult setAttachments(final List attachments) { + this.attachments = attachments; + return this; } /** - * @deprecated use set method. Scheduled to removal in 3.0 release. + * Gets parameters. + * + * @return the parameters */ - @Deprecated @Override - public FixtureResult withSteps(final Collection values) { - return setSteps(values); + public List getParameters() { + return parameters; } /** - * @deprecated use set method. Scheduled to removal in 3.0 release. + * Sets parameters. + * + * @param parameters the parameters + * @return self for method chaining */ - @Deprecated - @Override - public FixtureResult withSteps(final List steps) { - return setSteps(steps); + public FixtureResult setParameters(final List parameters) { + this.parameters = parameters; + return this; } /** - * @deprecated use set method. Scheduled to removal in 3.0 release. + * Gets start. + * + * @return the start */ - @Deprecated - @Override - public FixtureResult withAttachments(final Attachment... values) { - return setAttachments(values); + public Long getStart() { + return start; } /** - * @deprecated use set method. Scheduled to removal in 3.0 release. + * Sets start. + * + * @param value the value + * @return self for method chaining */ - @Deprecated - @Override - public FixtureResult withAttachments(final Collection values) { - return setAttachments(values); + public FixtureResult setStart(final Long value) { + this.start = value; + return this; } /** - * @deprecated use set method. Scheduled to removal in 3.0 release. + * Gets stop. + * + * @return the stop */ - @Deprecated - @Override - public FixtureResult withAttachments(final List attachments) { - return setAttachments(attachments); + public Long getStop() { + return stop; } /** - * @deprecated use set method. Scheduled to removal in 3.0 release. + * Sets stop. + * + * @param value the value + * @return self for method chaining */ - @Deprecated - @Override - public FixtureResult withParameters(final Parameter... values) { - return setParameters(values); + public FixtureResult setStop(final Long value) { + this.stop = value; + return this; } /** - * @deprecated use set method. Scheduled to removal in 3.0 release. + * {@inheritDoc} */ - @Deprecated @Override - public FixtureResult withParameters(final Collection values) { - return setParameters(values); + public boolean equals(final Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final FixtureResult that = (FixtureResult) o; + return Objects.equals(name, that.name) + && status == that.status; } /** - * @deprecated use set method. Scheduled to removal in 3.0 release. + * {@inheritDoc} */ - @Deprecated @Override - public FixtureResult withParameters(final List parameters) { - return setParameters(parameters); + public int hashCode() { + return Objects.hash(name, status); } - } diff --git a/allure-model/src/main/java/io/qameta/allure/model/Label.java b/allure-model/src/main/java/io/qameta/allure/model/Label.java index f9f5d19dc..d8b400379 100644 --- a/allure-model/src/main/java/io/qameta/allure/model/Label.java +++ b/allure-model/src/main/java/io/qameta/allure/model/Label.java @@ -16,33 +16,37 @@ package io.qameta.allure.model; import java.io.Serializable; +import java.util.Objects; /** - * POJO that stores label information. + * The model object that could be used to pass additional metadata to test results. + * Note that labels with empty (blank) name will be omitted during report generation. + * + * @author baev (Dmitry Baev) + * @see io.qameta.allure.model.TestResult + * @since 2.0 */ public class Label implements Serializable { private static final long serialVersionUID = 1L; - protected String name; - - protected String value; + private String name; + private String value; /** - * Gets the value of the name property. + * Gets name. * - * @return possible object is - * {@link String } + * @return the name */ public String getName() { return name; } /** - * Sets the value of the name property. + * Sets name. * - * @param value allowed object is - * {@link String } + * @param value the value + * @return self for method chaining */ public Label setName(final String value) { this.name = value; @@ -50,20 +54,19 @@ public Label setName(final String value) { } /** - * Gets the value of the value property. + * Gets value. * - * @return possible object is - * {@link String } + * @return the value */ public String getValue() { return value; } /** - * Sets the value of the value property. + * Sets value. * - * @param value allowed object is - * {@link String } + * @param value the value + * @return self for method chaining */ public Label setValue(final String value) { this.value = value; @@ -71,18 +74,25 @@ public Label setValue(final String value) { } /** - * @deprecated use set method + * {@inheritDoc} */ - @Deprecated - public Label withName(final String value) { - return setName(value); + @Override + public boolean equals(final Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final Label label = (Label) o; + return Objects.equals(name, label.name) && Objects.equals(value, label.value); } /** - * @deprecated use set method + * {@inheritDoc} */ - @Deprecated - public Label withValue(final String value) { - return setValue(value); + @Override + public int hashCode() { + return Objects.hash(name, value); } } diff --git a/allure-model/src/main/java/io/qameta/allure/model/Link.java b/allure-model/src/main/java/io/qameta/allure/model/Link.java index 57d241e5c..a5de7c71d 100644 --- a/allure-model/src/main/java/io/qameta/allure/model/Link.java +++ b/allure-model/src/main/java/io/qameta/allure/model/Link.java @@ -16,35 +16,38 @@ package io.qameta.allure.model; import java.io.Serializable; +import java.util.Objects; /** - * POJO that stores link information. + * Model object that could be used to pass links to external resources to test results. + * + * @author baev (Dmitry Baev) + * @see io.qameta.allure.model.WithLinks + * @see io.qameta.allure.model.TestResult + * @since 2.0 */ public class Link implements Serializable { private static final long serialVersionUID = 1L; - protected String name; - - protected String url; - - protected String type; + private String name; + private String url; + private String type; /** - * Gets the value of the name property. + * Gets name. * - * @return possible object is - * {@link String } + * @return the name */ public String getName() { return name; } /** - * Sets the value of the name property. + * Sets name. * - * @param value allowed object is - * {@link String } + * @param value the value + * @return self for method chaining */ public Link setName(final String value) { this.name = value; @@ -52,20 +55,19 @@ public Link setName(final String value) { } /** - * Gets the value of the url property. + * Gets url. * - * @return possible object is - * {@link String } + * @return the url */ public String getUrl() { return url; } /** - * Sets the value of the url property. + * Sets url. * - * @param value allowed object is - * {@link String } + * @param value the value + * @return self for method chaining */ public Link setUrl(final String value) { this.url = value; @@ -73,20 +75,19 @@ public Link setUrl(final String value) { } /** - * Gets the value of the type property. + * Gets type. * - * @return possible object is - * {@link String } + * @return the type */ public String getType() { return type; } /** - * Sets the value of the type property. + * Sets type. * - * @param value allowed object is - * {@link String } + * @param value the value + * @return self for method chaining */ public Link setType(final String value) { this.type = value; @@ -94,26 +95,27 @@ public Link setType(final String value) { } /** - * @deprecated use set method - */ - @Deprecated - public Link withName(final String value) { - return setName(value); - } - - /** - * @deprecated use set method + * {@inheritDoc} */ - @Deprecated - public Link withUrl(final String value) { - return setUrl(value); + @Override + public boolean equals(final Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final Link link = (Link) o; + return Objects.equals(name, link.name) + && Objects.equals(url, link.url) + && Objects.equals(type, link.type); } /** - * @deprecated use set method + * {@inheritDoc} */ - @Deprecated - public Link withType(final String value) { - return setType(value); + @Override + public int hashCode() { + return Objects.hash(name, url, type); } } diff --git a/allure-model/src/main/java/io/qameta/allure/model/Parameter.java b/allure-model/src/main/java/io/qameta/allure/model/Parameter.java index e89a395ca..b41727380 100644 --- a/allure-model/src/main/java/io/qameta/allure/model/Parameter.java +++ b/allure-model/src/main/java/io/qameta/allure/model/Parameter.java @@ -16,33 +16,48 @@ package io.qameta.allure.model; import java.io.Serializable; +import java.util.Objects; /** - * POJO that stores parameter information. + * The model object that could be used to pass information about test parameters to test results. + * Note that parameters with empty (blank) name will be omitted during report generation. + *

+ * Parameters are used in history key generation for test results. In general words, + * if test's results have the same parameters they will be considered as retries. But if + * at least one parameter is differ (or, for example, missed) results will be considered + * as separate results. + *

+ * You can exclude parameters from history key calculation by setting {@link #excluded} property + * to true. + * + * @author baev (Dmitry Baev) + * @see io.qameta.allure.model.TestResult + * @see io.qameta.allure.model.WithParameters + * @since 2.0 */ public class Parameter implements Serializable { private static final long serialVersionUID = 1L; - protected String name; - - protected String value; + private String name; + private String value; + private Boolean excluded; + private Mode mode; /** - * Gets the value of the name property. + * Gets name. * - * @return possible object is - * {@link String } + * @return the name */ public String getName() { return name; } /** - * Sets the value of the name property. + * Sets name. * - * @param value allowed object is - * {@link String } + * @param value the value + * @return self for method chaining. */ public Parameter setName(final String value) { this.name = value; @@ -50,20 +65,19 @@ public Parameter setName(final String value) { } /** - * Gets the value of the value property. + * Gets value. * - * @return possible object is - * {@link String } + * @return the value */ public String getValue() { return value; } /** - * Sets the value of the value property. + * Sets value. * - * @param value allowed object is - * {@link String } + * @param value the value + * @return self for method chaining. */ public Parameter setValue(final String value) { this.value = value; @@ -71,18 +85,91 @@ public Parameter setValue(final String value) { } /** - * @deprecated use set method + * Gets excluded. + * + * @return the excluded */ - @Deprecated - public Parameter withName(final String value) { - return setName(value); + public Boolean getExcluded() { + return excluded; } /** - * @deprecated use set method + * Sets excluded. + * + * @param excluded the excluded + * @return self for method chaining. */ - @Deprecated - public Parameter withValue(final String value) { - return setValue(value); + public Parameter setExcluded(final Boolean excluded) { + this.excluded = excluded; + return this; + } + + /** + * Gets mode. + * + * @return the mode + */ + public Mode getMode() { + return mode; + } + + /** + * Sets mode. + * + * @param mode the mode + * @return self for method chaining. + */ + public Parameter setMode(final Mode mode) { + this.mode = mode; + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public boolean equals(final Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final Parameter parameter = (Parameter) o; + return Objects.equals(name, parameter.name) + && Objects.equals(value, parameter.value); + } + + /** + * {@inheritDoc} + */ + @Override + public int hashCode() { + return Objects.hash(name, value); + } + + /** + * The parameter render mode. + * + * @author baev (Dmitry Baev) + * @since 2.15 + */ + public enum Mode { + + /** + * Completely hide parameter from report. + */ + HIDDEN, + + /** + * Display parameter, but mask it's value. + */ + MASKED, + + /** + * Default mode. Displays both parameter name and value. + */ + DEFAULT + } } diff --git a/allure-model/src/main/java/io/qameta/allure/model/Stage.java b/allure-model/src/main/java/io/qameta/allure/model/Stage.java index 34a22513f..14b0b199b 100644 --- a/allure-model/src/main/java/io/qameta/allure/model/Stage.java +++ b/allure-model/src/main/java/io/qameta/allure/model/Stage.java @@ -15,17 +15,33 @@ */ package io.qameta.allure.model; -import com.fasterxml.jackson.annotation.JsonValue; - /** * Test stages. + * + * @author baev (Dmitry Baev) + * @since 2.0 */ public enum Stage { + /** + * Scheduled stage. + */ SCHEDULED("scheduled"), + /** + * Running stage. + */ RUNNING("running"), + /** + * Finished stage. + */ FINISHED("finished"), + /** + * Pending stage. + */ PENDING("pending"), + /** + * Interrupted stage. + */ INTERRUPTED("interrupted"); private final String value; @@ -34,11 +50,12 @@ public enum Stage { value = v; } - @JsonValue - public String value() { - return value; - } - + /** + * From value stage. + * + * @param v the v + * @return the stage + */ public static Stage fromValue(final String v) { for (Stage c : Stage.values()) { if (c.value.equals(v)) { @@ -48,4 +65,13 @@ public static Stage fromValue(final String v) { throw new IllegalArgumentException(v); } + /** + * Value string. + * + * @return the string + */ + public String value() { + return value; + } + } diff --git a/allure-model/src/main/java/io/qameta/allure/model/Status.java b/allure-model/src/main/java/io/qameta/allure/model/Status.java index fd6e31fa0..4f6c73d55 100644 --- a/allure-model/src/main/java/io/qameta/allure/model/Status.java +++ b/allure-model/src/main/java/io/qameta/allure/model/Status.java @@ -15,16 +15,30 @@ */ package io.qameta.allure.model; -import com.fasterxml.jackson.annotation.JsonValue; - /** * Test statuses. + * + * @author baev (Dmitry Baev) + * @see io.qameta.allure.model.WithStatus + * @since 2.0 */ public enum Status { + /** + * Marks tests that have some failed checks (assertions). + */ FAILED("failed"), + /** + * Marks tests with unexpected failures during test execution. + */ BROKEN("broken"), + /** + * Marks passed tests. + */ PASSED("passed"), + /** + * Marks skipped/interrupted tests. + */ SKIPPED("skipped"); private final String value; @@ -33,11 +47,12 @@ public enum Status { value = v; } - @JsonValue - public String value() { - return value; - } - + /** + * From value status. + * + * @param v the v + * @return the status + */ public static Status fromValue(final String v) { for (Status c : Status.values()) { if (c.value.equals(v)) { @@ -47,4 +62,13 @@ public static Status fromValue(final String v) { throw new IllegalArgumentException(v); } + /** + * Value string. + * + * @return the string + */ + public String value() { + return value; + } + } diff --git a/allure-model/src/main/java/io/qameta/allure/model/StatusDetails.java b/allure-model/src/main/java/io/qameta/allure/model/StatusDetails.java index 855a639f4..940ffd9d1 100644 --- a/allure-model/src/main/java/io/qameta/allure/model/StatusDetails.java +++ b/allure-model/src/main/java/io/qameta/allure/model/StatusDetails.java @@ -16,33 +16,39 @@ package io.qameta.allure.model; import java.io.Serializable; +import java.util.Objects; /** - * POJO that stores status details. + * The type Status details. + * + * @author baev (Dmitry Baev) + * @see io.qameta.allure.model.WithStatusDetails + * @since 2.0 */ public class StatusDetails implements Serializable { private static final long serialVersionUID = 1L; - protected boolean known; - - protected boolean muted; - - protected boolean flaky; - - protected String message; - - protected String trace; + private boolean known; + private boolean muted; + private boolean flaky; + private String message; + private String trace; /** - * Gets the value of the known property. + * Is known boolean. + * + * @return the boolean */ public boolean isKnown() { return known; } /** - * Sets the value of the known property. + * Sets known. + * + * @param value the value + * @return self for method chaining */ public StatusDetails setKnown(final boolean value) { this.known = value; @@ -50,14 +56,19 @@ public StatusDetails setKnown(final boolean value) { } /** - * Gets the value of the muted property. + * Is muted boolean. + * + * @return the boolean */ public boolean isMuted() { return muted; } /** - * Sets the value of the muted property. + * Sets muted. + * + * @param value the value + * @return self for method chaining */ public StatusDetails setMuted(final boolean value) { this.muted = value; @@ -65,14 +76,19 @@ public StatusDetails setMuted(final boolean value) { } /** - * Gets the value of the flaky property. + * Is flaky boolean. + * + * @return the boolean */ public boolean isFlaky() { return flaky; } /** - * Sets the value of the flaky property. + * Sets flaky. + * + * @param value the value + * @return self for method chaining */ public StatusDetails setFlaky(final boolean value) { this.flaky = value; @@ -80,20 +96,19 @@ public StatusDetails setFlaky(final boolean value) { } /** - * Gets the value of the message property. + * Gets message. * - * @return possible object is - * {@link String } + * @return the message */ public String getMessage() { return message; } /** - * Sets the value of the message property. + * Sets message. * - * @param value allowed object is - * {@link String } + * @param value the value + * @return self for method chaining */ public StatusDetails setMessage(final String value) { this.message = value; @@ -101,20 +116,19 @@ public StatusDetails setMessage(final String value) { } /** - * Gets the value of the trace property. + * Gets trace. * - * @return possible object is - * {@link String } + * @return the trace */ public String getTrace() { return trace; } /** - * Sets the value of the trace property. + * Sets trace. * - * @param value allowed object is - * {@link String } + * @param value the value + * @return self for method chaining */ public StatusDetails setTrace(final String value) { this.trace = value; @@ -122,42 +136,26 @@ public StatusDetails setTrace(final String value) { } /** - * @deprecated use set method - */ - @Deprecated - public StatusDetails withKnown(final boolean value) { - return setKnown(value); - } - - /** - * @deprecated use set method - */ - @Deprecated - public StatusDetails withMuted(final boolean value) { - return setMuted(value); - } - - /** - * @deprecated use set method - */ - @Deprecated - public StatusDetails withFlaky(final boolean value) { - return setFlaky(value); - } - - /** - * @deprecated use set method + * {@inheritDoc} */ - @Deprecated - public StatusDetails withMessage(final String value) { - return setMessage(value); + @Override + public boolean equals(final Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final StatusDetails that = (StatusDetails) o; + return Objects.equals(message, that.message) + && Objects.equals(trace, that.trace); } /** - * @deprecated use set method + * {@inheritDoc} */ - @Deprecated - public StatusDetails withTrace(final String value) { - return setTrace(value); + @Override + public int hashCode() { + return Objects.hash(message, trace); } } diff --git a/allure-model/src/main/java/io/qameta/allure/model/StepResult.java b/allure-model/src/main/java/io/qameta/allure/model/StepResult.java index b114c0bbc..863fce5ff 100644 --- a/allure-model/src/main/java/io/qameta/allure/model/StepResult.java +++ b/allure-model/src/main/java/io/qameta/allure/model/StepResult.java @@ -16,305 +16,283 @@ package io.qameta.allure.model; import java.io.Serializable; -import java.util.Collection; import java.util.List; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.Objects; /** - * POJO that stores step information. + * The model object that stores information about test steps that was run. + * + * @author baev (Dmitry Baev) + * @see io.qameta.allure.model.ExecutableItem + * @see io.qameta.allure.model.WithAttachments + * @see io.qameta.allure.model.WithParameters + * @see io.qameta.allure.model.WithStatus + * @see io.qameta.allure.model.WithStatusDetails + * @see io.qameta.allure.model.WithSteps + * @since 2.0 */ -@SuppressWarnings("deprecation") -public class StepResult extends ExecutableItem implements Serializable { +public class StepResult implements Serializable, ExecutableItem { private static final long serialVersionUID = 1L; - @Override - public StepResult setName(final String value) { - super.setName(value); - return this; - } - - @Override - public StepResult setStatus(final Status value) { - super.setStatus(value); - return this; - } - - @Override - public StepResult setStatusDetails(final StatusDetails value) { - super.setStatusDetails(value); - return this; - } - - @Override - public StepResult setStage(final Stage value) { - super.setStage(value); - return this; - } - - @Override - public StepResult setDescription(final String value) { - super.setDescription(value); - return this; - } - - @Override - public StepResult setDescriptionHtml(final String value) { - super.setDescriptionHtml(value); - return this; - } - - @Override - public StepResult setStart(final Long value) { - super.setStart(value); - return this; - } - - @Override - public StepResult setStop(final Long value) { - super.setStop(value); - return this; - } - - @Override - @JsonProperty - public StepResult setSteps(final List steps) { - super.setSteps(steps); - return this; - } + private String name; + private Status status; + private StatusDetails statusDetails; + private Stage stage; + private String description; + private String descriptionHtml; + private List steps; + private List attachments; + private List parameters; + private Long start; + private Long stop; /** - * @deprecated use {@link #setSteps(List)} instead. + * Gets name. + * + * @return the name */ - @Deprecated - @Override - @JsonIgnore - public StepResult setSteps(final StepResult... values) { - super.setSteps(values); - return this; + public String getName() { + return name; } /** - * @deprecated use {@link #setSteps(List)} instead. + * Sets name. + * + * @param value the value + * @return self for method chaining */ - @Deprecated - @Override - @JsonIgnore - public StepResult setSteps(final Collection values) { - super.setSteps(values); - return this; - } - - @Override - @JsonProperty - public StepResult setAttachments(final List attachments) { - super.setAttachments(attachments); + public StepResult setName(final String value) { + this.name = value; return this; } /** - * @deprecated use {@link #setAttachments(List)} instead. + * Gets status. + * + * @return the status */ - @Deprecated @Override - @JsonIgnore - public StepResult setAttachments(final Attachment... values) { - super.setAttachments(values); - return this; + public Status getStatus() { + return status; } /** - * @deprecated use {@link #setAttachments(List)} instead. + * Sets status. + * + * @param value the value + * @return self for method chaining */ - @Deprecated - @Override - @JsonIgnore - public StepResult setAttachments(final Collection values) { - super.setAttachments(values); + public StepResult setStatus(final Status value) { + this.status = value; return this; } + /** + * Gets status details. + * + * @return the status details + */ @Override - @JsonProperty - public StepResult setParameters(final List parameters) { - super.setParameters(parameters); - return this; + public StatusDetails getStatusDetails() { + return statusDetails; } /** - * @deprecated use {@link #setParameters(List)} instead. + * Sets status details. + * + * @param value the value + * @return self for method chaining */ - @Deprecated - @Override - @JsonIgnore - public StepResult setParameters(final Parameter... values) { - super.setParameters(values); + public StepResult setStatusDetails(final StatusDetails value) { + this.statusDetails = value; return this; } /** - * @deprecated use {@link #setParameters(List)} instead. + * Gets stage. + * + * @return the stage */ - @Deprecated - @Override - @JsonIgnore - public StepResult setParameters(final Collection values) { - super.setParameters(values); - return this; + public Stage getStage() { + return stage; } /** - * @deprecated use set method. Scheduled to removal in 3.0 release. + * Sets stage. + * + * @param value the value + * @return self for method chaining */ - @Deprecated - @Override - public StepResult withName(final String value) { - return setName(value); + public StepResult setStage(final Stage value) { + this.stage = value; + return this; } /** - * @deprecated use set method. Scheduled to removal in 3.0 release. + * Gets description. + * + * @return the description */ - @Deprecated - @Override - public StepResult withStatus(final Status value) { - return setStatus(value); + public String getDescription() { + return description; } /** - * @deprecated use set method. Scheduled to removal in 3.0 release. + * Sets description. + * + * @param value the value + * @return self for method chaining */ - @Deprecated - @Override - public StepResult withStatusDetails(final StatusDetails value) { - return setStatusDetails(value); + public StepResult setDescription(final String value) { + this.description = value; + return this; } /** - * @deprecated use set method. Scheduled to removal in 3.0 release. + * Gets description html. + * + * @return the description html */ - @Deprecated - @Override - public StepResult withStage(final Stage value) { - return setStage(value); + public String getDescriptionHtml() { + return descriptionHtml; } /** - * @deprecated use set method. Scheduled to removal in 3.0 release. + * Sets description html. + * + * @param value the value + * @return self for method chaining */ - @Deprecated - @Override - public StepResult withDescription(final String value) { - return setDescription(value); + public StepResult setDescriptionHtml(final String value) { + this.descriptionHtml = value; + return this; } /** - * @deprecated use set method. Scheduled to removal in 3.0 release. + * Gets steps. + * + * @return the steps */ - @Deprecated @Override - public StepResult withDescriptionHtml(final String value) { - return setDescriptionHtml(value); + public List getSteps() { + return steps; } /** - * @deprecated use set method. Scheduled to removal in 3.0 release. + * Sets steps. + * + * @param steps the steps + * @return self for method chaining */ - @Deprecated - @Override - public StepResult withStart(final Long value) { - return setStart(value); + public StepResult setSteps(final List steps) { + this.steps = steps; + return this; } /** - * @deprecated use set method. Scheduled to removal in 3.0 release. + * Gets attachments. + * + * @return the attachments */ - @Deprecated @Override - public StepResult withStop(final Long value) { - return setStop(value); + public List getAttachments() { + return attachments; } /** - * @deprecated use set method. Scheduled to removal in 3.0 release. + * Sets attachments. + * + * @param attachments the attachments + * @return self for method chaining */ - @Deprecated - @Override - public StepResult withSteps(final StepResult... values) { - return setSteps(values); + public StepResult setAttachments(final List attachments) { + this.attachments = attachments; + return this; } /** - * @deprecated use set method. Scheduled to removal in 3.0 release. + * Gets parameters. + * + * @return the parameters */ - @Deprecated @Override - public StepResult withSteps(final Collection values) { - return setSteps(values); + public List getParameters() { + return parameters; } /** - * @deprecated use set method. Scheduled to removal in 3.0 release. + * Sets parameters. + * + * @param parameters the parameters + * @return self for method chaining */ - @Deprecated - @Override - public StepResult withSteps(final List steps) { - return setSteps(steps); + public StepResult setParameters(final List parameters) { + this.parameters = parameters; + return this; } /** - * @deprecated use set method. Scheduled to removal in 3.0 release. + * Gets start. + * + * @return the start */ - @Deprecated - @Override - public StepResult withAttachments(final Attachment... values) { - return setAttachments(values); + public Long getStart() { + return start; } /** - * @deprecated use set method. Scheduled to removal in 3.0 release. + * Sets start. + * + * @param value the value + * @return self for method chaining */ - @Deprecated - @Override - public StepResult withAttachments(final Collection values) { - return setAttachments(values); + public StepResult setStart(final Long value) { + this.start = value; + return this; } /** - * @deprecated use set method. Scheduled to removal in 3.0 release. + * Gets stop. + * + * @return the stop */ - @Deprecated - @Override - public StepResult withAttachments(final List attachments) { - return setAttachments(attachments); + public Long getStop() { + return stop; } /** - * @deprecated use set method. Scheduled to removal in 3.0 release. + * Sets stop. + * + * @param value the value + * @return self for method chaining */ - @Deprecated - @Override - public StepResult withParameters(final Parameter... values) { - return setParameters(values); + public StepResult setStop(final Long value) { + this.stop = value; + return this; } /** - * @deprecated use set method. Scheduled to removal in 3.0 release. + * {@inheritDoc} */ - @Deprecated @Override - public StepResult withParameters(final Collection values) { - return setParameters(values); + public boolean equals(final Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final StepResult that = (StepResult) o; + return Objects.equals(name, that.name) + && status == that.status; } /** - * @deprecated use set method. Scheduled to removal in 3.0 release. + * {@inheritDoc} */ - @Deprecated @Override - public StepResult withParameters(final List parameters) { - return setParameters(parameters); + public int hashCode() { + return Objects.hash(name, status); } } diff --git a/allure-model/src/main/java/io/qameta/allure/model/TestResult.java b/allure-model/src/main/java/io/qameta/allure/model/TestResult.java index 438af01ba..444438268 100644 --- a/allure-model/src/main/java/io/qameta/allure/model/TestResult.java +++ b/allure-model/src/main/java/io/qameta/allure/model/TestResult.java @@ -17,49 +17,60 @@ import java.io.Serializable; import java.util.ArrayList; -import java.util.Collection; import java.util.List; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.Objects; /** - * POJO that stores test result information. + * The model object that stores information about test that was run. + * Test results are the main entity of Allure. + * + * @author baev (Dmitry Baev) + * @see io.qameta.allure.model.ExecutableItem + * @see io.qameta.allure.model.WithAttachments + * @see io.qameta.allure.model.WithLinks + * @see io.qameta.allure.model.WithParameters + * @see io.qameta.allure.model.WithStatus + * @see io.qameta.allure.model.WithStatusDetails + * @see io.qameta.allure.model.WithSteps + * @since 2.0 */ -@SuppressWarnings({"PMD.TooManyMethods", "PMD.ExcessivePublicCount", "deprecation"}) -public class TestResult extends ExecutableItem implements Serializable, WithLinks { +@SuppressWarnings({"PMD.TooManyMethods", "PMD.ExcessivePublicCount"}) +public class TestResult implements Serializable, ExecutableItem, WithLinks { private static final long serialVersionUID = 1L; - protected String uuid; - - protected String historyId; - - protected String testCaseId; - - protected String rerunOf; - - protected String fullName; - - protected List

+ * During report generation all {@link #befores} and {@link #afters} is added to each + * test result that {@link TestResult#getUuid()} matches values, specified in {@link #children}. + *

+ * Containers that have empty {@link #children} are simply ignored. + * + * @author baev (Dmitry Baev) + * @see io.qameta.allure.model.TestResult + * @see io.qameta.allure.model.WithLinks + * @since 2.0 */ @SuppressWarnings("PMD.ExcessivePublicCount") public class TestResultContainer implements Serializable, WithLinks { private static final long serialVersionUID = 1L; - protected String uuid; - - protected String name; - - protected List children; - - protected String description; - - protected String descriptionHtml; - - protected List befores; - - protected List afters; - - protected List links; - - protected Long start; - - protected Long stop; + private String uuid; + private String name; + private List children; + private String description; + private String descriptionHtml; + private List befores; + private List afters; + private List links; + private Long start; + private Long stop; /** - * Gets the value of the uuid property. + * Gets uuid. * - * @return possible object is - * {@link String } + * @return the uuid */ public String getUuid() { return uuid; } /** - * Sets the value of the uuid property. + * Sets uuid. * - * @param value allowed object is - * {@link String } + * @param value the value + * @return self for method chaining */ public TestResultContainer setUuid(final String value) { this.uuid = value; @@ -73,20 +70,19 @@ public TestResultContainer setUuid(final String value) { } /** - * Gets the value of the name property. + * Gets name. * - * @return possible object is - * {@link String } + * @return the name */ public String getName() { return name; } /** - * Sets the value of the name property. + * Sets name. * - * @param value allowed object is - * {@link String } + * @param value the value + * @return self for method chaining */ public TestResultContainer setName(final String value) { this.name = value; @@ -94,20 +90,19 @@ public TestResultContainer setName(final String value) { } /** - * Gets the value of the description property. + * Gets description. * - * @return possible object is - * {@link String } + * @return the description */ public String getDescription() { return description; } /** - * Sets the value of the description property. + * Sets description. * - * @param value allowed object is - * {@link String } + * @param value the value + * @return self for method chaining */ public TestResultContainer setDescription(final String value) { this.description = value; @@ -115,20 +110,19 @@ public TestResultContainer setDescription(final String value) { } /** - * Gets the value of the descriptionHtml property. + * Gets description html. * - * @return possible object is - * {@link String } + * @return the description html */ public String getDescriptionHtml() { return descriptionHtml; } /** - * Sets the value of the descriptionHtml property. + * Sets description html. * - * @param value allowed object is - * {@link String } + * @param value the value + * @return self for method chaining */ public TestResultContainer setDescriptionHtml(final String value) { this.descriptionHtml = value; @@ -136,20 +130,19 @@ public TestResultContainer setDescriptionHtml(final String value) { } /** - * Gets the value of the start property. + * Gets start. * - * @return possible object is - * {@link Long } + * @return the start */ public Long getStart() { return start; } /** - * Sets the value of the start property. + * Sets start. * - * @param value allowed object is - * {@link Long } + * @param value the value + * @return self for method chaining */ public TestResultContainer setStart(final Long value) { this.start = value; @@ -157,26 +150,30 @@ public TestResultContainer setStart(final Long value) { } /** - * Gets the value of the stop property. + * Gets stop. * - * @return possible object is - * {@link Long } + * @return the stop */ public Long getStop() { return stop; } /** - * Sets the value of the stop property. + * Sets stop. * - * @param value allowed object is - * {@link Long } + * @param value the value + * @return self for method chaining */ public TestResultContainer setStop(final Long value) { this.stop = value; return this; } + /** + * Gets children. + * + * @return the children + */ public List getChildren() { if (children == null) { children = new ArrayList<>(); @@ -184,38 +181,22 @@ public List getChildren() { return children; } - @JsonProperty - public TestResultContainer setChildren(final List children) { - this.children = children; - return this; - } - /** - * @deprecated use {@link #setChildren(List)} instead. + * Sets children. + * + * @param children the children + * @return self for method chaining */ - @Deprecated - @JsonIgnore - public TestResultContainer setChildren(final String... values) { - if (values != null) { - for (String value : values) { - getChildren().add(value); - } - } + public TestResultContainer setChildren(final List children) { + this.children = children; return this; } /** - * @deprecated use {@link #setChildren(List)} instead. + * Gets befores. + * + * @return the befores */ - @Deprecated - @JsonIgnore - public TestResultContainer setChildren(final Collection values) { - if (values != null) { - getChildren().addAll(values); - } - return this; - } - public List getBefores() { if (befores == null) { befores = new ArrayList<>(); @@ -223,38 +204,22 @@ public List getBefores() { return befores; } - @JsonProperty - public TestResultContainer setBefores(final List befores) { - this.befores = befores; - return this; - } - /** - * @deprecated use {@link #setBefores(List)} instead. + * Sets befores. + * + * @param befores the befores + * @return self for method chaining */ - @Deprecated - @JsonIgnore - public TestResultContainer setBefores(final FixtureResult... values) { - if (values != null) { - for (FixtureResult value : values) { - getBefores().add(value); - } - } + public TestResultContainer setBefores(final List befores) { + this.befores = befores; return this; } /** - * @deprecated use {@link #setBefores(List)} instead. + * Gets afters. + * + * @return the afters */ - @Deprecated - @JsonIgnore - public TestResultContainer setBefores(final Collection values) { - if (values != null) { - getBefores().addAll(values); - } - return this; - } - public List getAfters() { if (afters == null) { afters = new ArrayList<>(); @@ -262,38 +227,22 @@ public List getAfters() { return afters; } - @JsonProperty - public TestResultContainer setAfters(final List afters) { - this.afters = afters; - return this; - } - /** - * @deprecated use {@link #setAfters(List)} instead. + * Sets afters. + * + * @param afters the afters + * @return self for method chaining */ - @Deprecated - @JsonIgnore - public TestResultContainer setAfters(final FixtureResult... values) { - if (values != null) { - for (FixtureResult value : values) { - getAfters().add(value); - } - } + public TestResultContainer setAfters(final List afters) { + this.afters = afters; return this; } /** - * @deprecated use {@link #setAfters(List)} instead. + * Gets links. + * + * @return the links */ - @Deprecated - @JsonIgnore - public TestResultContainer setAfters(final Collection values) { - if (values != null) { - getAfters().addAll(values); - } - return this; - } - @Override public List getLinks() { if (links == null) { @@ -302,197 +251,37 @@ public List getLinks() { return links; } - @JsonProperty + /** + * Sets links. + * + * @param links the links + * @return self for method chaining + */ public TestResultContainer setLinks(final List links) { this.links = links; return this; } /** - * @deprecated use {@link #setLinks(List)} instead. + * {@inheritDoc} */ - @Deprecated - @JsonIgnore - public TestResultContainer setLinks(final Link... values) { - if (values != null) { - for (Link value : values) { - getLinks().add(value); - } + @Override + public boolean equals(final Object o) { + if (this == o) { + return true; } - return this; - } - - /** - * @deprecated use {@link #setLinks(List)} instead. - */ - @Deprecated - @JsonIgnore - public TestResultContainer setLinks(final Collection values) { - if (values != null) { - getLinks().addAll(values); + if (o == null || getClass() != o.getClass()) { + return false; } - return this; + final TestResultContainer that = (TestResultContainer) o; + return Objects.equals(uuid, that.uuid) && Objects.equals(name, that.name); } /** - * @deprecated use set method + * {@inheritDoc} */ - @Deprecated - @JsonIgnore - public TestResultContainer withUuid(final String value) { - return setUuid(value); - } - - /** - * @deprecated use set method - */ - @Deprecated - @JsonIgnore - public TestResultContainer withName(final String value) { - return setName(value); - } - - /** - * @deprecated use set method - */ - @Deprecated - @JsonIgnore - public TestResultContainer withDescription(final String value) { - return setDescription(value); - } - - /** - * @deprecated use set method - */ - @Deprecated - @JsonIgnore - public TestResultContainer withDescriptionHtml(final String value) { - return setDescriptionHtml(value); - } - - /** - * @deprecated use set method - */ - @Deprecated - @JsonIgnore - public TestResultContainer withStart(final Long value) { - return setStart(value); - } - - /** - * @deprecated use set method - */ - @Deprecated - @JsonIgnore - public TestResultContainer withStop(final Long value) { - return setStop(value); - } - - /** - * @deprecated use set method - */ - @Deprecated - @JsonIgnore - public TestResultContainer withChildren(final String... values) { - return setChildren(values); - } - - /** - * @deprecated use set method - */ - @Deprecated - @JsonIgnore - public TestResultContainer withChildren(final Collection values) { - return setChildren(values); - } - - /** - * @deprecated use set method - */ - @Deprecated - @JsonIgnore - public TestResultContainer withChildren(final List children) { - return setChildren(children); - } - - /** - * @deprecated use set method - */ - @Deprecated - @JsonIgnore - public TestResultContainer withBefores(final FixtureResult... values) { - return setBefores(values); - } - - /** - * @deprecated use set method - */ - @Deprecated - @JsonIgnore - public TestResultContainer withBefores(final Collection values) { - return setBefores(values); - } - - /** - * @deprecated use set method - */ - @Deprecated - @JsonIgnore - public TestResultContainer withBefores(final List befores) { - return setBefores(befores); - } - - /** - * @deprecated use set method - */ - @Deprecated - @JsonIgnore - public TestResultContainer withAfters(final FixtureResult... values) { - return setAfters(values); - } - - /** - * @deprecated use set method - */ - @Deprecated - @JsonIgnore - public TestResultContainer withAfters(final Collection values) { - return setAfters(values); - } - - /** - * @deprecated use set method - */ - @Deprecated - @JsonIgnore - public TestResultContainer withAfters(final List afters) { - return setAfters(afters); - } - - /** - * @deprecated use set method - */ - @Deprecated - @JsonIgnore - public TestResultContainer withLinks(final Link... values) { - return setLinks(values); - } - - /** - * @deprecated use set method - */ - @Deprecated - @JsonIgnore - public TestResultContainer withLinks(final Collection values) { - return setLinks(values); - } - - /** - * @deprecated use set method - */ - @Deprecated - @JsonIgnore - public TestResultContainer withLinks(final List links) { - return setLinks(links); + @Override + public int hashCode() { + return Objects.hash(uuid, name); } } diff --git a/allure-model/src/main/java/io/qameta/allure/model/TestRunResult.java b/allure-model/src/main/java/io/qameta/allure/model/TestRunResult.java deleted file mode 100644 index 829ed4e74..000000000 --- a/allure-model/src/main/java/io/qameta/allure/model/TestRunResult.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright 2019 Qameta Software OÜ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.qameta.allure.model; - -import java.io.Serializable; - -/** - * POJO that stores information about test run. - * @deprecated scheduled for removal in 3.0 release - */ -@Deprecated -public class TestRunResult implements Serializable { - - private static final long serialVersionUID = 1L; - - protected String uuid; - - protected String name; - - /** - * Gets the value of the uuid property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getUuid() { - return uuid; - } - - /** - * Sets the value of the uuid property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public TestRunResult setUuid(final String value) { - this.uuid = value; - return this; - } - - /** - * Gets the value of the name property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getName() { - return name; - } - - /** - * Sets the value of the name property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public TestRunResult setName(final String value) { - this.name = value; - return this; - } - - /** - * @deprecated use set method - */ - @Deprecated - public TestRunResult withUuid(final String value) { - return setUuid(value); - } - - /** - * @deprecated use set method - */ - @Deprecated - public TestRunResult withName(final String value) { - return setName(value); - } -} diff --git a/allure-model/src/main/java/io/qameta/allure/model/WithAttachments.java b/allure-model/src/main/java/io/qameta/allure/model/WithAttachments.java index ece54c8de..970ba3262 100644 --- a/allure-model/src/main/java/io/qameta/allure/model/WithAttachments.java +++ b/allure-model/src/main/java/io/qameta/allure/model/WithAttachments.java @@ -18,11 +18,22 @@ import java.util.List; /** - * @author charlie (Dmitry Baev baev@qameta.io). - * @since 1.0-BETA1 + * The marker interface for model objects with attachments. + * + * @author baev (Dmitry Baev). + * @see TestResult + * @see FixtureResult + * @see StepResult + * @see ExecutableItem + * @since 2.0 */ public interface WithAttachments { + /** + * Gets attachments. + * + * @return the attachments + */ List getAttachments(); } diff --git a/allure-model/src/main/java/io/qameta/allure/model/WithLinks.java b/allure-model/src/main/java/io/qameta/allure/model/WithLinks.java index e0169bbd2..35d93ae89 100644 --- a/allure-model/src/main/java/io/qameta/allure/model/WithLinks.java +++ b/allure-model/src/main/java/io/qameta/allure/model/WithLinks.java @@ -18,10 +18,22 @@ import java.util.List; /** - * @author charlie (Dmitry Baev). + * The marker interface for model objects with links. + * + * @author baev (Dmitry Baev). + * @see TestResult + * @see FixtureResult + * @see StepResult + * @see ExecutableItem + * @since 2.0 */ public interface WithLinks { + /** + * Gets links. + * + * @return the links + */ List getLinks(); } diff --git a/allure-model/src/main/java/io/qameta/allure/model/WithParameters.java b/allure-model/src/main/java/io/qameta/allure/model/WithParameters.java index a89b0bfc3..59634c8fd 100644 --- a/allure-model/src/main/java/io/qameta/allure/model/WithParameters.java +++ b/allure-model/src/main/java/io/qameta/allure/model/WithParameters.java @@ -18,11 +18,22 @@ import java.util.List; /** - * @author charlie (Dmitry Baev). - * @since 1.0-BETA2 + * The marker interface for model objects that could be parameterised. + * + * @author baev (Dmitry Baev). + * @see TestResult + * @see FixtureResult + * @see StepResult + * @see ExecutableItem + * @since 2.0 */ public interface WithParameters { + /** + * Gets parameters. + * + * @return the parameters + */ List getParameters(); } diff --git a/allure-model/src/main/java/io/qameta/allure/model/WithStatus.java b/allure-model/src/main/java/io/qameta/allure/model/WithStatus.java index c2e64e315..14ce4ecd8 100644 --- a/allure-model/src/main/java/io/qameta/allure/model/WithStatus.java +++ b/allure-model/src/main/java/io/qameta/allure/model/WithStatus.java @@ -16,10 +16,22 @@ package io.qameta.allure.model; /** - * @author charlie (Dmitry Baev). + * The marker interface for model objects with status. + * + * @author baev (Dmitry Baev). + * @see TestResult + * @see FixtureResult + * @see StepResult + * @see ExecutableItem + * @since 2.0 */ public interface WithStatus { + /** + * Gets status. + * + * @return the status + */ Status getStatus(); } diff --git a/allure-model/src/main/java/io/qameta/allure/model/WithStatusDetails.java b/allure-model/src/main/java/io/qameta/allure/model/WithStatusDetails.java index bca413090..409886584 100644 --- a/allure-model/src/main/java/io/qameta/allure/model/WithStatusDetails.java +++ b/allure-model/src/main/java/io/qameta/allure/model/WithStatusDetails.java @@ -16,10 +16,23 @@ package io.qameta.allure.model; /** - * @author charlie (Dmitry Baev). + * The marker interface for model objects with status details. + * + * @author baev (Dmitry Baev). + * @see TestResult + * @see FixtureResult + * @see StepResult + * @see ExecutableItem + * @see WithStatus + * @since 2.0 */ public interface WithStatusDetails extends WithStatus { + /** + * Gets status details. + * + * @return the status details + */ StatusDetails getStatusDetails(); } diff --git a/allure-model/src/main/java/io/qameta/allure/model/WithSteps.java b/allure-model/src/main/java/io/qameta/allure/model/WithSteps.java index 71816082d..11952fa58 100644 --- a/allure-model/src/main/java/io/qameta/allure/model/WithSteps.java +++ b/allure-model/src/main/java/io/qameta/allure/model/WithSteps.java @@ -18,11 +18,22 @@ import java.util.List; /** - * @author charlie (Dmitry Baev). - * @since 1.0-BETA1 + * The marker interface for model objects with steps. + * + * @author baev (Dmitry Baev). + * @see TestResult + * @see FixtureResult + * @see StepResult + * @see ExecutableItem + * @since 2.0 */ public interface WithSteps { + /** + * Gets steps. + * + * @return the steps + */ List getSteps(); } diff --git a/allure-testng/src/main/java/io/qameta/allure/testng/AllureTestNg.java b/allure-testng/src/main/java/io/qameta/allure/testng/AllureTestNg.java index 9183a589b..4f1f55d73 100644 --- a/allure-testng/src/main/java/io/qameta/allure/testng/AllureTestNg.java +++ b/allure-testng/src/main/java/io/qameta/allure/testng/AllureTestNg.java @@ -87,6 +87,7 @@ import static io.qameta.allure.util.ResultsUtils.createTestMethodLabel; import static io.qameta.allure.util.ResultsUtils.createThreadLabel; import static io.qameta.allure.util.ResultsUtils.firstNonEmpty; +import static io.qameta.allure.util.ResultsUtils.getJavadocDescription; import static io.qameta.allure.util.ResultsUtils.getMd5Digest; import static io.qameta.allure.util.ResultsUtils.getProvidedLabels; import static io.qameta.allure.util.ResultsUtils.getStatusDetails; @@ -112,35 +113,29 @@ public class AllureTestNg implements private static final Logger LOGGER = LoggerFactory.getLogger(AllureTestNg.class); private static final String ALLURE_UUID = "ALLURE_UUID"; - + private static final List> INJECTED_TYPES = Arrays.asList( + ITestContext.class, ITestResult.class, XmlTest.class, Method.class, Object[].class + ); /** * Store current testng result uuid to attach before/after methods into. */ private final ThreadLocal currentTestResult = ThreadLocal .withInitial(Current::new); - /** * Store current container uuid for fake containers around before/after methods. */ private final ThreadLocal currentTestContainer = ThreadLocal .withInitial(() -> UUID.randomUUID().toString()); - /** * Store uuid for current executable item to catch steps and attachments. */ private final ThreadLocal currentExecutable = ThreadLocal .withInitial(() -> UUID.randomUUID().toString()); - /** * Store uuid for class test containers. */ private final Map classContainerUuidStorage = new ConcurrentHashMap<>(); private final ReadWriteLock lock = new ReentrantReadWriteLock(); - - private static final List> INJECTED_TYPES = Arrays.asList( - ITestContext.class, ITestResult.class, XmlTest.class, Method.class, Object[].class - ); - private final AllureLifecycle lifecycle; private final AllureTestNgTestFilter testFilter; @@ -158,6 +153,20 @@ public AllureTestNg() { this(Allure.getLifecycle()); } + private static String safeExtractSuiteName(final ITestClass testClass) { + final Optional xmlTest = Optional.ofNullable(testClass.getXmlTest()); + return xmlTest.map(XmlTest::getSuite).map(XmlSuite::getName).orElse("Undefined suite"); + } + + private static String safeExtractTestTag(final ITestClass testClass) { + final Optional xmlTest = Optional.ofNullable(testClass.getXmlTest()); + return xmlTest.map(XmlTest::getName).orElse("Undefined testng tag"); + } + + private static String safeExtractTestClassName(final ITestClass testClass) { + return firstNonEmpty(testClass.getTestName(), testClass.getName()).orElse("Undefined class name"); + } + public AllureLifecycle getLifecycle() { return lifecycle; } @@ -314,7 +323,10 @@ protected void startTestCase(final ITestContext context, .setParameters(parameters) .setLinks(getLinks(method, iClass)) .setLabels(labels); - processDescription(getClass().getClassLoader(), method.getConstructorOrMethod().getMethod(), result); + + getJavadocDescription(getClass().getClassLoader(), method.getConstructorOrMethod().getMethod()) + .ifPresent(result::setDescription); + getLifecycle().scheduleTestCase(parentUuid, result); getLifecycle().startTestCase(uuid); } @@ -395,7 +407,6 @@ public void beforeInvocation(final IInvokedMethod method, final ITestResult test } } - private void ifSuiteFixtureStarted(final ISuite suite, final ITestNGMethod testMethod) { if (testMethod.isBeforeSuiteConfiguration()) { startBefore(getUniqueUuid(suite), testMethod); @@ -469,14 +480,19 @@ private String getQualifiedName(final ITestNGMethod method) { return method.getRealClass().getName() + "." + method.getMethodName(); } - @SuppressWarnings("deprecation") private FixtureResult getFixtureResult(final ITestNGMethod method) { final FixtureResult fixtureResult = new FixtureResult() - .withName(getMethodName(method)) - .withStart(System.currentTimeMillis()) - .withDescription(method.getDescription()) - .withStage(Stage.RUNNING); - processDescription(getClass().getClassLoader(), method.getConstructorOrMethod().getMethod(), fixtureResult); + .setName(getMethodName(method)) + .setStart(System.currentTimeMillis()) + .setDescription(method.getDescription()) + .setStage(Stage.RUNNING); + + processDescription( + getClass().getClassLoader(), + method.getConstructorOrMethod().getMethod(), + fixtureResult::setDescription, + fixtureResult::setDescriptionHtml + ); return fixtureResult; } @@ -649,20 +665,6 @@ private String getUniqueUuid(final IAttributes suite) { return Objects.toString(suite.getAttribute(ALLURE_UUID)); } - private static String safeExtractSuiteName(final ITestClass testClass) { - final Optional xmlTest = Optional.ofNullable(testClass.getXmlTest()); - return xmlTest.map(XmlTest::getSuite).map(XmlSuite::getName).orElse("Undefined suite"); - } - - private static String safeExtractTestTag(final ITestClass testClass) { - final Optional xmlTest = Optional.ofNullable(testClass.getXmlTest()); - return xmlTest.map(XmlTest::getName).orElse("Undefined testng tag"); - } - - private static String safeExtractTestClassName(final ITestClass testClass) { - return firstNonEmpty(testClass.getTestName(), testClass.getName()).orElse("Undefined class name"); - } - private List getParameters(final ITestContext context, final ITestNGMethod method, final Object... parameters) { @@ -792,6 +794,15 @@ private Current refreshContext() { return currentTestResult.get(); } + /** + * The stage of current result context. + */ + private enum CurrentStage { + BEFORE, + TEST, + AFTER + } + /** * Describes current test result. */ @@ -824,13 +835,4 @@ public String getUuid() { return uuid; } } - - /** - * The stage of current result context. - */ - private enum CurrentStage { - BEFORE, - TEST, - AFTER - } } From 3659fd7f47d22861da2e230578fe9dcac26975d6 Mon Sep 17 00:00:00 2001 From: Dmitry Baev Date: Sun, 4 Jul 2021 19:22:35 +0300 Subject: [PATCH 3/9] shadow jackson --- allure-java-commons/build.gradle.kts | 59 ++++++++++++--- allure-model/build.gradle.kts | 1 - build.gradle.kts | 107 +++++++++++++++------------ gradle.properties | 3 + settings.gradle.kts | 17 ++++- 5 files changed, 128 insertions(+), 59 deletions(-) diff --git a/allure-java-commons/build.gradle.kts b/allure-java-commons/build.gradle.kts index 5c7d7d2bb..09ef8f24e 100644 --- a/allure-java-commons/build.gradle.kts +++ b/allure-java-commons/build.gradle.kts @@ -1,3 +1,7 @@ +plugins { + id("com.github.johnrengelman.shadow") version "7.0.0" +} + description = "Allure Java Commons" val agent: Configuration by configurations.creating @@ -7,7 +11,7 @@ dependencies { api("org.slf4j:slf4j-api") api(project(":allure-model")) compileOnly("org.aspectj:aspectjrt") - implementation("com.fasterxml.jackson.core:jackson-databind") + internal("com.fasterxml.jackson.core:jackson-databind") testImplementation("io.github.benas:random-beans") testImplementation("io.github.glytching:junit-extensions") testImplementation("org.apache.commons:commons-lang3") @@ -21,17 +25,52 @@ dependencies { testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine") } -tasks.jar { - manifest { - attributes(mapOf( - "Automatic-Module-Name" to "io.qameta.allure.commons" - )) +configurations.forEach { configuration -> + configuration.outgoing.apply { + val removed = artifacts.removeIf { it.classifier.isNullOrEmpty() } + if (removed) { + artifact(tasks.shadowJar) { + classifier = "" + } + } } } -tasks.test { - useJUnitPlatform() - doFirst { - jvmArgs("-javaagent:${agent.singleFile}") +tasks { + jar { + dependsOn(shadowJar) + enabled = false + } + + shadowJar { + archiveClassifier.set("") + relocate("com.fasterxml.jackson", "io.qameta.allure.shadow.jackson") + dependencies { + include(dependency("com.fasterxml.jackson.core::")) + } + exclude("**/module-info.class") + exclude("META-INF/LICENSE*.md") + mergeServiceFiles() + manifest { + attributes(mapOf( + "Specification-Title" to project.name, + "Implementation-Title" to project.name, + "Implementation-Version" to project.version, + "Automatic-Module-Name" to "io.qameta.allure.commons" + )) + } + } + + assemble { + dependsOn(shadowJar) + } + + test { + dependsOn(shadowJar) + useJUnitPlatform() + doFirst { + jvmArgs("-javaagent:${agent.singleFile}") + } } } + diff --git a/allure-model/build.gradle.kts b/allure-model/build.gradle.kts index 5d8287fdf..dcc2389fc 100644 --- a/allure-model/build.gradle.kts +++ b/allure-model/build.gradle.kts @@ -4,7 +4,6 @@ val agent: Configuration by configurations.creating dependencies { agent("org.aspectj:aspectjweaver") - implementation("com.fasterxml.jackson.core:jackson-databind:2.12.3") testImplementation("io.github.benas:random-beans") testImplementation("org.assertj:assertj-core") testImplementation("org.junit.jupiter:junit-jupiter-api") diff --git a/build.gradle.kts b/build.gradle.kts index c30768a48..251b7ea55 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,19 +1,4 @@ -import com.diffplug.gradle.spotless.SpotlessExtension import io.qameta.allure.gradle.task.AllureReport -import ru.vyarus.gradle.plugin.quality.QualityExtension - -buildscript { - repositories { - maven("https://plugins.gradle.org/m2/") - mavenLocal() - mavenCentral() - } - - dependencies { - classpath("com.diffplug.spotless:spotless-plugin-gradle:5.13.0") - classpath("ru.vyarus:gradle-quality-plugin:4.6.0") - } -} val linkHomepage by extra("https://qameta.io/allure") val linkCi by extra("https://ci.qameta.in/job/allure-java_deploy/") @@ -34,9 +19,11 @@ plugins { `java-library` `maven-publish` signing - id("io.spring.dependency-management") version "1.0.11.RELEASE" - id("io.github.gradle-nexus.publish-plugin") version "1.1.0" - id("io.qameta.allure") version "2.8.1" + id("com.diffplug.spotless") + id("io.github.gradle-nexus.publish-plugin") + id("io.qameta.allure") + id("io.spring.dependency-management") + id("ru.vyarus.quality") } java { @@ -102,47 +89,64 @@ configure(subprojects) { entry("slf4j-simple") } } + generatedPomCustomization { + enabled(false) + } } - tasks.compileJava { - options.encoding = "UTF-8" + // Excluding shadowed jars from pom.xml https://github.com/gradle/gradle/issues/10861#issuecomment-576562961 + val internal by configurations.creating { + isVisible = false + isCanBeConsumed = false + isCanBeResolved = false } + configurations.compileClasspath.get().extendsFrom(internal) + configurations.runtimeClasspath.get().extendsFrom(internal) + configurations.testCompileClasspath.get().extendsFrom(internal) + configurations.testRuntimeClasspath.get().extendsFrom(internal) - tasks.compileTestJava { - options.encoding = "UTF-8" - options.compilerArgs.add("-parameters") - } + tasks { + compileJava { + options.encoding = "UTF-8" + } - tasks.jar { - manifest { - attributes(mapOf( - "Implementation-Title" to project.name, - "Implementation-Version" to project.version - )) + compileTestJava { + options.encoding = "UTF-8" + options.compilerArgs.add("-parameters") } - } - tasks.test { - systemProperty("org.slf4j.simpleLogger.defaultLogLevel", "debug") - systemProperty("allure.model.indentOutput", "true") - systemProperty("junit.jupiter.execution.parallel.enabled", true) - systemProperty("junit.jupiter.execution.parallel.mode.default", true) - testLogging { - listOf(org.gradle.api.tasks.testing.logging.TestLogEvent.FAILED) + jar { + manifest { + attributes(mapOf( + "Specification-Title" to project.name, + "Implementation-Title" to project.name, + "Implementation-Version" to project.version + )) + } } - maxHeapSize = project.property("test.maxHeapSize").toString() - maxParallelForks = Integer.parseInt(project.property("test.maxParallelForks") as String) - } - tasks.processTestResources { - filesMatching("**/allure.properties") { - filter { - it.replace("#project.description#", project.description ?: project.name) + test { + systemProperty("org.slf4j.simpleLogger.defaultLogLevel", "debug") + systemProperty("allure.model.indentOutput", "true") + systemProperty("junit.jupiter.execution.parallel.enabled", true) + systemProperty("junit.jupiter.execution.parallel.mode.default", true) + testLogging { + listOf(org.gradle.api.tasks.testing.logging.TestLogEvent.FAILED) + } + maxHeapSize = project.property("test.maxHeapSize").toString() + maxParallelForks = Integer.parseInt(project.property("test.maxParallelForks") as String) + } + + processTestResources { + filesMatching("**/allure.properties") { + filter { + it.replace("#project.description#", project.description ?: project.name) + } } } } - configure { + quality { configDir = qualityConfigsDir checkstyleVersion = "8.36.1" pmdVersion = "6.27.0" @@ -160,7 +164,7 @@ configure(subprojects) { } } - configure { + spotless { java { target("src/**/*.java") removeUnusedImports() @@ -224,6 +228,11 @@ configure(subprojects) { create("maven") { from(components["java"]) suppressAllPomMetadataWarnings() + versionMapping { + allVariants { + fromResolutionResult() + } + } pom { name.set(project.name) description.set("Module ${project.name} of Allure Framework.") @@ -264,6 +273,10 @@ configure(subprojects) { sign(publishing.publications["maven"]) } + tasks.withType().configureEach { + onlyIf { !project.version.toString().endsWith("-SNAPSHOT") } + } + repositories { mavenLocal() mavenCentral() diff --git a/gradle.properties b/gradle.properties index fc3b66841..8f2c540cd 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,3 +6,6 @@ org.gradle.warning.mode=none test.maxHeapSize=512m test.maxParallelForks=4 + +# https://kotlinlang.org/docs/gradle.html#dependency-on-the-standard-library +kotlin.stdlib.default.dependency=false \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts index ee1dc6eae..f6d13d198 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -34,8 +34,23 @@ include("allure-spring-web") include("allure-test-filter") include("allure-testng") +pluginManagement { + repositories { + gradlePluginPortal() + } + plugins { + id("com.gradle.enterprise") version "3.6.2" + id("com.diffplug.spotless") version "5.13.0" + kotlin("jvm") version "1.5.0" + id("ru.vyarus.quality") version "4.6.0" + id("io.spring.dependency-management") version "1.0.11.RELEASE" + id("io.github.gradle-nexus.publish-plugin") version "1.1.0" + id("io.qameta.allure") version "2.8.1" + } +} + plugins { - id("com.gradle.enterprise") version "3.6.2" + id("com.gradle.enterprise") } val isCiServer = System.getenv().containsKey("CI") From 0a007283ed5210e77a0a7d1d1a4e8c72f4e903d1 Mon Sep 17 00:00:00 2001 From: Dmitry Baev Date: Sun, 4 Jul 2021 21:12:09 +0300 Subject: [PATCH 4/9] fix compilation --- .../qameta/allure/junitplatform/AllureJunitPlatform.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/allure-junit-platform/src/main/java/io/qameta/allure/junitplatform/AllureJunitPlatform.java b/allure-junit-platform/src/main/java/io/qameta/allure/junitplatform/AllureJunitPlatform.java index e45225bfe..a4164acdd 100644 --- a/allure-junit-platform/src/main/java/io/qameta/allure/junitplatform/AllureJunitPlatform.java +++ b/allure-junit-platform/src/main/java/io/qameta/allure/junitplatform/AllureJunitPlatform.java @@ -46,6 +46,7 @@ import java.lang.reflect.AnnotatedElement; import java.lang.reflect.Method; import java.math.BigInteger; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashSet; @@ -81,7 +82,6 @@ * @author ehborisov */ @SuppressWarnings({ - "deprecation", "ClassFanOutComplexity", "MultipleStringLiterals", "ClassDataAbstractionCoupling", @@ -281,7 +281,7 @@ private void stopTestContainer(final TestIdentifier testIdentifier) { } final String uuid = maybeUuid.get(); final TestPlan context = testPlanStorage.get(); - final Set children = Optional.ofNullable(context) + final List children = Optional.ofNullable(context) .map(tp -> tp.getDescendants(testIdentifier)) .orElseGet(Collections::emptySet) .stream() @@ -289,7 +289,8 @@ private void stopTestContainer(final TestIdentifier testIdentifier) { .map(tests::get) .filter(Optional::isPresent) .map(Optional::get) - .collect(Collectors.toCollection(HashSet::new)); + .distinct() + .collect(Collectors.toCollection(ArrayList::new)); if (testIdentifier.isTest()) { tests.get(testIdentifier).ifPresent(children::add); From 8505fafa7eedd638dafccdc853e2f0752e9e242f Mon Sep 17 00:00:00 2001 From: Dmitry Baev Date: Sun, 4 Jul 2021 22:57:37 +0300 Subject: [PATCH 5/9] bom and reader modules added --- allure-bom/build.gradle.kts | 33 +++++ allure-java-commons/build.gradle.kts | 7 +- .../io/qameta/allure/AllureConstants.java | 12 -- .../io/qameta/allure/AllureResultsReader.java | 44 ------ .../java/io/qameta/allure/AllureUtils.java | 46 ------ .../allure/FileSystemResultsReader.java | 120 --------------- .../allure/internal/Allure2ModelJackson.java | 58 +++++++- .../internal/ParameterModeSerializer.java | 40 ----- .../allure/internal/StatusDeserializer.java | 42 ------ allure-reader/build.gradle.kts | 29 ++++ .../allure/reader/AllureEnumDeserializer.java | 32 ++-- .../reader/AllureObjectMapperFactory.java | 31 ++++ .../reader/ParameterModeDeserializer.java | 26 +--- .../allure/reader/StageDeserializer.java | 19 +-- .../allure/reader/StatusDeserializer.java | 19 +-- allure-test-filter/build.gradle.kts | 68 +++++++-- .../testfilter/FileTestPlanSupplier.java | 7 +- .../allure/testfilter/TestPlanV1_0.java | 2 +- build.gradle.kts | 137 ++++++++++-------- settings.gradle.kts | 11 +- 20 files changed, 324 insertions(+), 459 deletions(-) create mode 100644 allure-bom/build.gradle.kts delete mode 100644 allure-java-commons/src/main/java/io/qameta/allure/AllureResultsReader.java delete mode 100644 allure-java-commons/src/main/java/io/qameta/allure/AllureUtils.java delete mode 100644 allure-java-commons/src/main/java/io/qameta/allure/FileSystemResultsReader.java delete mode 100644 allure-java-commons/src/main/java/io/qameta/allure/internal/ParameterModeSerializer.java delete mode 100644 allure-java-commons/src/main/java/io/qameta/allure/internal/StatusDeserializer.java create mode 100644 allure-reader/build.gradle.kts rename allure-java-commons/src/main/java/io/qameta/allure/internal/StageDeserializer.java => allure-reader/src/main/java/io/qameta/allure/reader/AllureEnumDeserializer.java (57%) create mode 100644 allure-reader/src/main/java/io/qameta/allure/reader/AllureObjectMapperFactory.java rename allure-java-commons/src/main/java/io/qameta/allure/ReadError.java => allure-reader/src/main/java/io/qameta/allure/reader/ParameterModeDeserializer.java (54%) rename allure-java-commons/src/main/java/io/qameta/allure/internal/StageSerializer.java => allure-reader/src/main/java/io/qameta/allure/reader/StageDeserializer.java (54%) rename allure-java-commons/src/main/java/io/qameta/allure/internal/StatusSerializer.java => allure-reader/src/main/java/io/qameta/allure/reader/StatusDeserializer.java (54%) diff --git a/allure-bom/build.gradle.kts b/allure-bom/build.gradle.kts new file mode 100644 index 000000000..9593300aa --- /dev/null +++ b/allure-bom/build.gradle.kts @@ -0,0 +1,33 @@ +plugins { + `java-platform` +} + +description = "Allure Java (Bill of Materials)" + +dependencies { + constraints { + rootProject.subprojects.sorted() + .forEach { api("${it.group}:${it.name}:${it.version}") } + } +} + +tasks.withType(Jar::class) { + enabled = false +} + +configurations.archives { + artifacts.removeAll{ it.extension == "jar" } +} + +publishing.publications.named("maven") { + pom { + from(components["javaPlatform"]) + description.set("This Bill of Materials POM can be used to ease dependency management " + + "when referencing multiple Allure artifacts using Gradle or Maven.") + packaging = "pom" + withXml { + val filteredContent = asString().replace("\\s*compile".toRegex(), "") + asString().clear().append(filteredContent) + } + } +} diff --git a/allure-java-commons/build.gradle.kts b/allure-java-commons/build.gradle.kts index 09ef8f24e..0c4f06028 100644 --- a/allure-java-commons/build.gradle.kts +++ b/allure-java-commons/build.gradle.kts @@ -1,5 +1,5 @@ plugins { - id("com.github.johnrengelman.shadow") version "7.0.0" + id("com.github.johnrengelman.shadow") } description = "Allure Java Commons" @@ -27,7 +27,7 @@ dependencies { configurations.forEach { configuration -> configuration.outgoing.apply { - val removed = artifacts.removeIf { it.classifier.isNullOrEmpty() } + val removed = artifacts.removeAll { it.classifier.isNullOrEmpty() } if (removed) { artifact(tasks.shadowJar) { classifier = "" @@ -44,7 +44,7 @@ tasks { shadowJar { archiveClassifier.set("") - relocate("com.fasterxml.jackson", "io.qameta.allure.shadow.jackson") + relocate("com.fasterxml.jackson", "io.qameta.allure.internal.shadowed.jackson") dependencies { include(dependency("com.fasterxml.jackson.core::")) } @@ -73,4 +73,3 @@ tasks { } } } - diff --git a/allure-java-commons/src/main/java/io/qameta/allure/AllureConstants.java b/allure-java-commons/src/main/java/io/qameta/allure/AllureConstants.java index 481e6ae6a..7e432af99 100644 --- a/allure-java-commons/src/main/java/io/qameta/allure/AllureConstants.java +++ b/allure-java-commons/src/main/java/io/qameta/allure/AllureConstants.java @@ -30,18 +30,6 @@ public final class AllureConstants { public static final String TEST_RESULT_CONTAINER_FILE_GLOB = "*-container.json"; - /** - * @deprecated scheduled to remove in 3.0 - */ - @Deprecated - public static final String TEST_RUN_FILE_SUFFIX = "-testrun.json"; - - /** - * @deprecated scheduled to remove in 3.0 - */ - @Deprecated - public static final String TEST_RUN_FILE_GLOB = "*-testrun.json"; - public static final String ATTACHMENT_FILE_SUFFIX = "-attachment"; public static final String ATTACHMENT_FILE_GLOB = "*-attachment*"; diff --git a/allure-java-commons/src/main/java/io/qameta/allure/AllureResultsReader.java b/allure-java-commons/src/main/java/io/qameta/allure/AllureResultsReader.java deleted file mode 100644 index a4f22e354..000000000 --- a/allure-java-commons/src/main/java/io/qameta/allure/AllureResultsReader.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2019 Qameta Software OÜ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.qameta.allure; - -import io.qameta.allure.model.TestResult; -import io.qameta.allure.model.TestResultContainer; - -import java.io.IOException; -import java.io.InputStream; -import java.util.List; -import java.util.stream.Stream; - -/** - * @author charlie (Dmitry Baev). - * - * @deprecated scheduled to remove in 3.0 - */ -@Deprecated -public interface AllureResultsReader { - - Stream readTestResults(); - - Stream readTestResultsContainers(); - - Stream findAllAttachments(); - - InputStream readAttachment(String source) throws IOException; - - List getErrors(); - -} diff --git a/allure-java-commons/src/main/java/io/qameta/allure/AllureUtils.java b/allure-java-commons/src/main/java/io/qameta/allure/AllureUtils.java deleted file mode 100644 index a48951f2c..000000000 --- a/allure-java-commons/src/main/java/io/qameta/allure/AllureUtils.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2019 Qameta Software OÜ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.qameta.allure; - -import java.util.UUID; - -/** - * @author charlie (Dmitry Baev). - * @deprecated scheduled to remove in 3.0. - */ -@Deprecated -public final class AllureUtils { - - private AllureUtils() { - throw new IllegalStateException("Do not instance"); - } - - public static String generateTestResultName() { - return generateTestResultName(UUID.randomUUID().toString()); - } - - public static String generateTestResultName(final String uuid) { - return uuid + AllureConstants.TEST_RESULT_FILE_SUFFIX; - } - - public static String generateTestResultContainerName() { - return generateTestResultContainerName(UUID.randomUUID().toString()); - } - - public static String generateTestResultContainerName(final String uuid) { - return uuid + AllureConstants.TEST_RESULT_CONTAINER_FILE_SUFFIX; - } -} diff --git a/allure-java-commons/src/main/java/io/qameta/allure/FileSystemResultsReader.java b/allure-java-commons/src/main/java/io/qameta/allure/FileSystemResultsReader.java deleted file mode 100644 index d141c9d38..000000000 --- a/allure-java-commons/src/main/java/io/qameta/allure/FileSystemResultsReader.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright 2019 Qameta Software OÜ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.qameta.allure; - -import com.fasterxml.jackson.databind.ObjectMapper; -import io.qameta.allure.internal.Allure2ModelJackson; -import io.qameta.allure.model.TestResult; -import io.qameta.allure.model.TestResultContainer; - -import java.io.IOException; -import java.io.InputStream; -import java.nio.file.DirectoryStream; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; -import java.util.stream.Collectors; -import java.util.stream.Stream; -import java.util.stream.StreamSupport; - -import static io.qameta.allure.AllureConstants.ATTACHMENT_FILE_GLOB; -import static io.qameta.allure.AllureConstants.TEST_RESULT_CONTAINER_FILE_GLOB; -import static io.qameta.allure.AllureConstants.TEST_RESULT_FILE_GLOB; -import static java.nio.file.Files.newDirectoryStream; - -/** - * @author charlie (Dmitry Baev). - * @deprecated scheduled to remove in 3.0 - */ -@Deprecated -public class FileSystemResultsReader implements AllureResultsReader { - - private final Path resultsDirectory; - - private final ObjectMapper mapper; - - private final List errors = new ArrayList<>(); - - public FileSystemResultsReader(final Path resultsDirectory) { - this.resultsDirectory = resultsDirectory; - this.mapper = Allure2ModelJackson.createMapper(); - } - - @Override - public Stream readTestResults() { - return listFiles(resultsDirectory, TEST_RESULT_FILE_GLOB) - .map(this::readTestResult) - .filter(Optional::isPresent) - .map(Optional::get); - } - - @Override - public Stream readTestResultsContainers() { - return listFiles(resultsDirectory, TEST_RESULT_CONTAINER_FILE_GLOB) - .map(this::readTestResultContainer) - .filter(Optional::isPresent) - .map(Optional::get); - } - - @Override - public Stream findAllAttachments() { - return listFiles(resultsDirectory, ATTACHMENT_FILE_GLOB) - .map(Path::getFileName) - .map(Path::toString); - } - - @Override - public InputStream readAttachment(final String source) throws IOException { - return Files.newInputStream(resultsDirectory.resolve(source)); - } - - @Override - public List getErrors() { - return errors; - } - - private Optional readTestResult(final Path file) { - try (InputStream is = Files.newInputStream(file)) { - return Optional.ofNullable(mapper.readValue(is, TestResult.class)); - } catch (IOException e) { - errors.add(new ReadError(e, "Could not read result file {}", file)); - return Optional.empty(); - } - } - - private Optional readTestResultContainer(final Path file) { - try (InputStream is = Files.newInputStream(file)) { - return Optional.ofNullable(mapper.readValue(is, TestResultContainer.class)); - } catch (IOException e) { - errors.add(new ReadError(e, "Could not read result container file {}", file)); - return Optional.empty(); - } - } - - private Stream listFiles(final Path directory, final String glob) { - try (DirectoryStream directoryStream = newDirectoryStream(directory, glob)) { - return StreamSupport.stream(directoryStream.spliterator(), false) - .filter(Files::isRegularFile) - .collect(Collectors.toList()) - .stream(); - } catch (IOException e) { - errors.add(new ReadError(e, "Could not list files in directory {}", directory)); - return Stream.empty(); - } - } -} diff --git a/allure-java-commons/src/main/java/io/qameta/allure/internal/Allure2ModelJackson.java b/allure-java-commons/src/main/java/io/qameta/allure/internal/Allure2ModelJackson.java index f838d2945..db9e137c5 100644 --- a/allure-java-commons/src/main/java/io/qameta/allure/internal/Allure2ModelJackson.java +++ b/allure-java-commons/src/main/java/io/qameta/allure/internal/Allure2ModelJackson.java @@ -15,18 +15,26 @@ */ package io.qameta.allure.internal; +import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.module.SimpleModule; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; import io.qameta.allure.model.Parameter; import io.qameta.allure.model.Stage; import io.qameta.allure.model.Status; +import java.io.IOException; +import java.util.Locale; + import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL; import static com.fasterxml.jackson.databind.MapperFeature.USE_WRAPPER_NAME_AS_PROPERTY_NAME; import static com.fasterxml.jackson.databind.SerializationFeature.INDENT_OUTPUT; /** - * @author charlie (Dmitry Baev). + * The type Allure 2 model jackson. + * + * @author baev (Dmitry Baev). */ @SuppressWarnings("PMD.ClassNamingConventions") public final class Allure2ModelJackson { @@ -48,4 +56,52 @@ public static ObjectMapper createMapper() { .addSerializer(Parameter.Mode.class, new ParameterModeSerializer()) ); } + + /** + * Parameter mode serializer. + */ + private static class ParameterModeSerializer extends StdSerializer { + protected ParameterModeSerializer() { + super(Parameter.Mode.class); + } + + @Override + public void serialize(final Parameter.Mode value, + final JsonGenerator gen, + final SerializerProvider provider) throws IOException { + gen.writeString(value.name().toLowerCase(Locale.ENGLISH)); + } + } + + /** + * Stage serializer. + */ + private static class StageSerializer extends StdSerializer { + protected StageSerializer() { + super(Stage.class); + } + + @Override + public void serialize(final Stage value, + final JsonGenerator gen, + final SerializerProvider provider) throws IOException { + gen.writeString(value.name().toLowerCase(Locale.ENGLISH)); + } + } + + /** + * Status serializer. + */ + private static class StatusSerializer extends StdSerializer { + protected StatusSerializer() { + super(Status.class); + } + + @Override + public void serialize(final Status value, + final JsonGenerator gen, + final SerializerProvider provider) throws IOException { + gen.writeString(value.name().toLowerCase(Locale.ENGLISH)); + } + } } diff --git a/allure-java-commons/src/main/java/io/qameta/allure/internal/ParameterModeSerializer.java b/allure-java-commons/src/main/java/io/qameta/allure/internal/ParameterModeSerializer.java deleted file mode 100644 index adda8a1f0..000000000 --- a/allure-java-commons/src/main/java/io/qameta/allure/internal/ParameterModeSerializer.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2019 Qameta Software OÜ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.qameta.allure.internal; - -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.ser.std.StdSerializer; -import io.qameta.allure.model.Parameter; - -import java.io.IOException; -import java.util.Locale; - -/** - * @author charlie (Dmitry Baev). - */ -public class ParameterModeSerializer extends StdSerializer { - protected ParameterModeSerializer() { - super(Parameter.Mode.class); - } - - @Override - public void serialize(final Parameter.Mode value, - final JsonGenerator gen, - final SerializerProvider provider) throws IOException { - gen.writeString(value.name().toLowerCase(Locale.ENGLISH)); - } -} diff --git a/allure-java-commons/src/main/java/io/qameta/allure/internal/StatusDeserializer.java b/allure-java-commons/src/main/java/io/qameta/allure/internal/StatusDeserializer.java deleted file mode 100644 index e581ff5ac..000000000 --- a/allure-java-commons/src/main/java/io/qameta/allure/internal/StatusDeserializer.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2019 Qameta Software OÜ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.qameta.allure.internal; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import io.qameta.allure.model.Status; - -import java.io.IOException; -import java.util.stream.Stream; - -/** - * @author charlie (Dmitry Baev). - */ -public class StatusDeserializer extends StdDeserializer { - protected StatusDeserializer() { - super(Status.class); - } - - @Override - public Status deserialize(final JsonParser p, final DeserializationContext ctxt) throws IOException { - final String value = p.readValueAs(String.class); - return Stream.of(Status.values()) - .filter(status -> status.name().equalsIgnoreCase(value)) - .findAny() - .orElse(null); - } -} diff --git a/allure-reader/build.gradle.kts b/allure-reader/build.gradle.kts new file mode 100644 index 000000000..73ca0bf02 --- /dev/null +++ b/allure-reader/build.gradle.kts @@ -0,0 +1,29 @@ +description = "Allure Model Reader Module" + +val agent: Configuration by configurations.creating + +dependencies { + agent("org.aspectj:aspectjweaver") + api(project(":allure-model")) + implementation("com.fasterxml.jackson.core:jackson-databind") + testImplementation("org.assertj:assertj-core") + testImplementation("org.junit.jupiter:junit-jupiter-api") + testImplementation("org.mockito:mockito-core") + testImplementation("org.slf4j:slf4j-simple") + testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine") +} + +tasks.jar { + manifest { + attributes(mapOf( + "Automatic-Module-Name" to "io.qameta.allure.reader" + )) + } +} + +tasks.test { + useJUnitPlatform() + doFirst { + jvmArgs("-javaagent:${agent.singleFile}") + } +} diff --git a/allure-java-commons/src/main/java/io/qameta/allure/internal/StageDeserializer.java b/allure-reader/src/main/java/io/qameta/allure/reader/AllureEnumDeserializer.java similarity index 57% rename from allure-java-commons/src/main/java/io/qameta/allure/internal/StageDeserializer.java rename to allure-reader/src/main/java/io/qameta/allure/reader/AllureEnumDeserializer.java index e58a4ec49..1d6eff361 100644 --- a/allure-java-commons/src/main/java/io/qameta/allure/internal/StageDeserializer.java +++ b/allure-reader/src/main/java/io/qameta/allure/reader/AllureEnumDeserializer.java @@ -13,30 +13,44 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package io.qameta.allure.internal; +package io.qameta.allure.reader; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import io.qameta.allure.model.Stage; import java.io.IOException; +import java.util.Objects; import java.util.stream.Stream; /** * @author charlie (Dmitry Baev). */ -public class StageDeserializer extends StdDeserializer { - protected StageDeserializer() { - super(Stage.class); +/* package-private */ abstract class AllureEnumDeserializer> extends StdDeserializer { + + private final Class type; + + protected AllureEnumDeserializer(final Class vc) { + super(vc); + type = vc; } @Override - public Stage deserialize(final JsonParser p, final DeserializationContext ctxt) throws IOException { + public T deserialize(final JsonParser p, + final DeserializationContext ctxt) throws IOException { final String value = p.readValueAs(String.class); - return Stream.of(Stage.values()) - .filter(status -> status.value().equalsIgnoreCase(value)) - .findAny() + if (Objects.isNull(value)) { + return null; + } + + final String trimmed = value.trim(); + if (trimmed.isEmpty()) { + return null; + } + + return Stream.of(type.getEnumConstants()) + .filter(e -> e.name().equalsIgnoreCase(trimmed)) + .findFirst() .orElse(null); } } diff --git a/allure-reader/src/main/java/io/qameta/allure/reader/AllureObjectMapperFactory.java b/allure-reader/src/main/java/io/qameta/allure/reader/AllureObjectMapperFactory.java new file mode 100644 index 000000000..ade158110 --- /dev/null +++ b/allure-reader/src/main/java/io/qameta/allure/reader/AllureObjectMapperFactory.java @@ -0,0 +1,31 @@ +package io.qameta.allure.reader; + +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.MapperFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.module.SimpleModule; +import io.qameta.allure.model.Parameter; +import io.qameta.allure.model.Stage; +import io.qameta.allure.model.Status; + +/** + * @author charlie (Dmitry Baev). + */ +public final class AllureObjectMapperFactory { + + private AllureObjectMapperFactory() { + throw new IllegalStateException("do not instance"); + } + + public static ObjectMapper createMapper() { + return new ObjectMapper() + .enable(MapperFeature.USE_WRAPPER_NAME_AS_PROPERTY_NAME) + .enable(MapperFeature.ACCEPT_CASE_INSENSITIVE_ENUMS) + .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) + .registerModule(new SimpleModule() + .addDeserializer(Status.class, new StatusDeserializer()) + .addDeserializer(Stage.class, new StageDeserializer()) + .addDeserializer(Parameter.Mode.class, new ParameterModeDeserializer()) + ); + } +} diff --git a/allure-java-commons/src/main/java/io/qameta/allure/ReadError.java b/allure-reader/src/main/java/io/qameta/allure/reader/ParameterModeDeserializer.java similarity index 54% rename from allure-java-commons/src/main/java/io/qameta/allure/ReadError.java rename to allure-reader/src/main/java/io/qameta/allure/reader/ParameterModeDeserializer.java index 474ea15f6..68a68cd84 100644 --- a/allure-java-commons/src/main/java/io/qameta/allure/ReadError.java +++ b/allure-reader/src/main/java/io/qameta/allure/reader/ParameterModeDeserializer.java @@ -13,31 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package io.qameta.allure; +package io.qameta.allure.reader; -import java.util.Objects; +import io.qameta.allure.model.Parameter; /** * @author charlie (Dmitry Baev). - * @deprecated scheduled to remove in 3.0 */ -@Deprecated -public class ReadError { - - private final String message; - - private final Throwable exception; - - public ReadError(final Throwable exception, final String message, final Object... args) { - this.message = Objects.nonNull(args) ? String.format(message, args) : message; - this.exception = exception; - } - - public String getMessage() { - return message; - } - - public Throwable getException() { - return exception; +public class ParameterModeDeserializer extends AllureEnumDeserializer { + public ParameterModeDeserializer() { + super(Parameter.Mode.class); } } diff --git a/allure-java-commons/src/main/java/io/qameta/allure/internal/StageSerializer.java b/allure-reader/src/main/java/io/qameta/allure/reader/StageDeserializer.java similarity index 54% rename from allure-java-commons/src/main/java/io/qameta/allure/internal/StageSerializer.java rename to allure-reader/src/main/java/io/qameta/allure/reader/StageDeserializer.java index b24389788..f8de06408 100644 --- a/allure-java-commons/src/main/java/io/qameta/allure/internal/StageSerializer.java +++ b/allure-reader/src/main/java/io/qameta/allure/reader/StageDeserializer.java @@ -13,28 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package io.qameta.allure.internal; +package io.qameta.allure.reader; -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.ser.std.StdSerializer; import io.qameta.allure.model.Stage; -import java.io.IOException; -import java.util.Locale; - /** * @author charlie (Dmitry Baev). */ -public class StageSerializer extends StdSerializer { - protected StageSerializer() { +public class StageDeserializer extends AllureEnumDeserializer { + public StageDeserializer() { super(Stage.class); } - - @Override - public void serialize(final Stage value, - final JsonGenerator gen, - final SerializerProvider provider) throws IOException { - gen.writeString(value.name().toLowerCase(Locale.ENGLISH)); - } } diff --git a/allure-java-commons/src/main/java/io/qameta/allure/internal/StatusSerializer.java b/allure-reader/src/main/java/io/qameta/allure/reader/StatusDeserializer.java similarity index 54% rename from allure-java-commons/src/main/java/io/qameta/allure/internal/StatusSerializer.java rename to allure-reader/src/main/java/io/qameta/allure/reader/StatusDeserializer.java index 8d7a2e868..5b86f6b35 100644 --- a/allure-java-commons/src/main/java/io/qameta/allure/internal/StatusSerializer.java +++ b/allure-reader/src/main/java/io/qameta/allure/reader/StatusDeserializer.java @@ -13,28 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package io.qameta.allure.internal; +package io.qameta.allure.reader; -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.ser.std.StdSerializer; import io.qameta.allure.model.Status; -import java.io.IOException; -import java.util.Locale; - /** * @author charlie (Dmitry Baev). */ -public class StatusSerializer extends StdSerializer { - protected StatusSerializer() { +public class StatusDeserializer extends AllureEnumDeserializer { + public StatusDeserializer() { super(Status.class); } - - @Override - public void serialize(final Status value, - final JsonGenerator gen, - final SerializerProvider provider) throws IOException { - gen.writeString(value.name().toLowerCase(Locale.ENGLISH)); - } } diff --git a/allure-test-filter/build.gradle.kts b/allure-test-filter/build.gradle.kts index 7b2972876..86c73354c 100644 --- a/allure-test-filter/build.gradle.kts +++ b/allure-test-filter/build.gradle.kts @@ -1,11 +1,15 @@ +plugins { + id("com.github.johnrengelman.shadow") +} + description = "Allure Test Filter" val agent: Configuration by configurations.creating dependencies { agent("org.aspectj:aspectjweaver") - implementation("com.fasterxml.jackson.core:jackson-databind") implementation(project(":allure-java-commons")) + internal("com.fasterxml.jackson.core:jackson-databind") testAnnotationProcessor("org.slf4j:slf4j-simple") testAnnotationProcessor(project(":allure-descriptions-javadoc")) testImplementation("io.github.glytching:junit-extensions") @@ -18,22 +22,56 @@ dependencies { testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine") } -tasks.jar { - manifest { - attributes(mapOf( - "Automatic-Module-Name" to "io.qameta.allure.testfilter" - )) - } - from("src/main/services") { - into("META-INF/services") +configurations.forEach { configuration -> + configuration.outgoing.apply { + val removed = artifacts.removeAll { it.classifier.isNullOrEmpty() } + if (removed) { + artifact(tasks.shadowJar) { + classifier = "" + } + } } } -tasks.test { - systemProperty("junit.jupiter.execution.parallel.enabled", "false") - useJUnitPlatform() - exclude("**/features/*") - doFirst { - jvmArgs("-javaagent:${agent.singleFile}") +tasks { + jar { + dependsOn(shadowJar) + enabled = false + } + + shadowJar { + archiveClassifier.set("") + relocate("com.fasterxml.jackson", "io.qameta.allure.internal.shadowed.jackson") + dependencies { + // we only need relocate to use jackson, shadowed in allure-java-commons + include(dependency("x:x:x")) + } + mergeServiceFiles() + manifest { + attributes(mapOf( + "Specification-Title" to project.name, + "Implementation-Title" to project.name, + "Implementation-Version" to project.version, + "Automatic-Module-Name" to "io.qameta.allure.testfilter" + )) + } + from("src/main/services") { + into("META-INF/services") + } + } + + assemble { + dependsOn(shadowJar) + } + + test { + dependsOn(shadowJar) + systemProperty("junit.jupiter.execution.parallel.enabled", "false") + useJUnitPlatform() + exclude("**/features/*") + doFirst { + jvmArgs("-javaagent:${agent.singleFile}") + } } } + diff --git a/allure-test-filter/src/main/java/io/qameta/allure/testfilter/FileTestPlanSupplier.java b/allure-test-filter/src/main/java/io/qameta/allure/testfilter/FileTestPlanSupplier.java index 204805b51..901b685da 100644 --- a/allure-test-filter/src/main/java/io/qameta/allure/testfilter/FileTestPlanSupplier.java +++ b/allure-test-filter/src/main/java/io/qameta/allure/testfilter/FileTestPlanSupplier.java @@ -15,7 +15,7 @@ */ package io.qameta.allure.testfilter; -import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -44,11 +44,8 @@ public class FileTestPlanSupplier implements TestPlanSupplier { */ private static final String[] ENV_TESTPLAN_PATH = {"ALLURE_TESTPLAN_PATH", "AS_TESTPLAN_PATH"}; - /** - * {@link ObjectMapper} to read test plan file. - */ private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper() - .enable(JsonGenerator.Feature.IGNORE_UNKNOWN); + .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); /** * Supply test plan. diff --git a/allure-test-filter/src/main/java/io/qameta/allure/testfilter/TestPlanV1_0.java b/allure-test-filter/src/main/java/io/qameta/allure/testfilter/TestPlanV1_0.java index a74ccef9a..72d79e816 100644 --- a/allure-test-filter/src/main/java/io/qameta/allure/testfilter/TestPlanV1_0.java +++ b/allure-test-filter/src/main/java/io/qameta/allure/testfilter/TestPlanV1_0.java @@ -59,7 +59,7 @@ public TestPlanV1_0 setTests(final List tests) { /** * @param allureId value of @AllureId annotation, if not set pass null value * @param selector selector of test method - * @return + * @return true if test case with given allureId or selection is selected, false otherwise. */ public boolean isSelected(final String allureId, final String selector) { return getTests().stream().map(test -> new String[]{test.getId(), test.getSelector()}) diff --git a/build.gradle.kts b/build.gradle.kts index 251b7ea55..9ce5133e2 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -10,6 +10,8 @@ val gradleScriptDir by extra("${rootProject.projectDir}/gradle") val qualityConfigsDir by extra("$gradleScriptDir/quality-configs") val spotlessDtr by extra("$qualityConfigsDir/spotless") +val libs = subprojects.filterNot { it.name in "allure-bom" } + tasks.withType(Wrapper::class) { gradleVersion = "7.1.1" } @@ -31,6 +33,7 @@ java { targetCompatibility = JavaVersion.VERSION_1_8 } + tasks.withType(JavaCompile::class) { options.encoding = "UTF-8" } @@ -47,14 +50,79 @@ nexusPublishing { } configure(subprojects) { - val project = this group = "io.qameta.allure" version = version - apply(plugin = "java") apply(plugin = "signing") - apply(plugin = "java-library") apply(plugin = "maven-publish") + + publishing { + publications { + create("maven") { + suppressAllPomMetadataWarnings() + versionMapping { + allVariants { + fromResolutionResult() + } + } + pom { + name.set(project.name) + description.set("Module ${project.name} of Allure Framework.") + url.set("https://github.com/allure-framework/allure-java") + licenses { + license { + name.set("The Apache License, Version 2.0") + url.set("http://www.apache.org/licenses/LICENSE-2.0.txt") + } + } + developers { + developer { + id.set("baev") + name.set("Dmitry Baev") + email.set("dmitry.baev@qameta.io") + } + developer { + id.set("eroshenkoam") + name.set("Artem Eroshenko") + email.set("artem.eroshenko@qameta.io") + } + } + scm { + developerConnection.set("scm:git:git://github.com/allure-framework/allure-java") + connection.set("scm:git:git://github.com/allure-framework/allure-java") + url.set("https://github.com/allure-framework/allure-java") + } + issueManagement { + system.set("GitHub Issues") + url.set("https://github.com/allure-framework/allure-java/issues") + } + } + } + } + } + + signing { + sign(publishing.publications["maven"]) + } + + tasks.withType().configureEach { + onlyIf { !project.version.toString().endsWith("-SNAPSHOT") } + } + + tasks.withType { + enabled = false + } + + repositories { + mavenLocal() + mavenCentral() + } +} + +configure(libs) { + val project = this + apply(plugin = "java") + apply(plugin = "java-library") apply(plugin = "io.qameta.allure") apply(plugin = "ru.vyarus.quality") apply(plugin = "com.diffplug.spotless") @@ -219,68 +287,11 @@ configure(subprojects) { (options as StandardJavadocDocletOptions).addStringOption("Xdoclint:none", "-quiet") } - tasks.withType { - enabled = false - } - - publishing { - publications { - create("maven") { - from(components["java"]) - suppressAllPomMetadataWarnings() - versionMapping { - allVariants { - fromResolutionResult() - } - } - pom { - name.set(project.name) - description.set("Module ${project.name} of Allure Framework.") - url.set("https://github.com/allure-framework/allure-java") - licenses { - license { - name.set("The Apache License, Version 2.0") - url.set("http://www.apache.org/licenses/LICENSE-2.0.txt") - } - } - developers { - developer { - id.set("baev") - name.set("Dmitry Baev") - email.set("dmitry.baev@qameta.io") - } - developer { - id.set("eroshenkoam") - name.set("Artem Eroshenko") - email.set("artem.eroshenko@qameta.io") - } - } - scm { - developerConnection.set("scm:git:git://github.com/allure-framework/allure-java") - connection.set("scm:git:git://github.com/allure-framework/allure-java") - url.set("https://github.com/allure-framework/allure-java") - } - issueManagement { - system.set("GitHub Issues") - url.set("https://github.com/allure-framework/allure-java/issues") - } - } - } + publishing.publications.named("maven") { + pom { + from(components["java"]) } } - - signing { - sign(publishing.publications["maven"]) - } - - tasks.withType().configureEach { - onlyIf { !project.version.toString().endsWith("-SNAPSHOT") } - } - - repositories { - mavenLocal() - mavenCentral() - } } allure { diff --git a/settings.gradle.kts b/settings.gradle.kts index f6d13d198..34c483a40 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -2,6 +2,7 @@ rootProject.name = "allure-java" include("allure-assertj") include("allure-attachments") +include("allure-bom") include("allure-citrus") include("allure-cucumber-jvm") include("allure-cucumber2-jvm") @@ -25,6 +26,7 @@ include("allure-junit5-assert") include("allure-model") include("allure-okhttp") include("allure-okhttp3") +include("allure-reader") include("allure-rest-assured") include("allure-scalatest") include("allure-selenide") @@ -39,13 +41,14 @@ pluginManagement { gradlePluginPortal() } plugins { - id("com.gradle.enterprise") version "3.6.2" id("com.diffplug.spotless") version "5.13.0" - kotlin("jvm") version "1.5.0" - id("ru.vyarus.quality") version "4.6.0" - id("io.spring.dependency-management") version "1.0.11.RELEASE" + id("com.github.johnrengelman.shadow") version "7.0.0" + id("com.gradle.enterprise") version "3.6.2" id("io.github.gradle-nexus.publish-plugin") version "1.1.0" id("io.qameta.allure") version "2.8.1" + id("io.spring.dependency-management") version "1.0.11.RELEASE" + id("ru.vyarus.quality") version "4.6.0" + kotlin("jvm") version "1.5.0" } } From 909568a90e53c0e3cd73543d642c96233fdf7caa Mon Sep 17 00:00:00 2001 From: Dmitry Baev Date: Sun, 4 Jul 2021 23:12:41 +0300 Subject: [PATCH 6/9] fix checkstyle and tests --- .../io/qameta/allure/model/FixtureResult.java | 7 ++++--- .../io/qameta/allure/model/StepResult.java | 7 ++++--- .../io/qameta/allure/model/TestResult.java | 16 +++++----------- .../allure/model/TestResultContainer.java | 18 +++--------------- .../allure/reader/AllureEnumDeserializer.java | 1 + 5 files changed, 17 insertions(+), 32 deletions(-) diff --git a/allure-model/src/main/java/io/qameta/allure/model/FixtureResult.java b/allure-model/src/main/java/io/qameta/allure/model/FixtureResult.java index 604ebd4a7..7c2e12427 100644 --- a/allure-model/src/main/java/io/qameta/allure/model/FixtureResult.java +++ b/allure-model/src/main/java/io/qameta/allure/model/FixtureResult.java @@ -16,6 +16,7 @@ package io.qameta.allure.model; import java.io.Serializable; +import java.util.ArrayList; import java.util.List; import java.util.Objects; @@ -38,9 +39,9 @@ public class FixtureResult implements Serializable, ExecutableItem { private Stage stage; private String description; private String descriptionHtml; - private List steps; - private List attachments; - private List parameters; + private List steps = new ArrayList<>(); + private List attachments = new ArrayList<>(); + private List parameters = new ArrayList<>(); private Long start; private Long stop; diff --git a/allure-model/src/main/java/io/qameta/allure/model/StepResult.java b/allure-model/src/main/java/io/qameta/allure/model/StepResult.java index 863fce5ff..04855631a 100644 --- a/allure-model/src/main/java/io/qameta/allure/model/StepResult.java +++ b/allure-model/src/main/java/io/qameta/allure/model/StepResult.java @@ -16,6 +16,7 @@ package io.qameta.allure.model; import java.io.Serializable; +import java.util.ArrayList; import java.util.List; import java.util.Objects; @@ -41,9 +42,9 @@ public class StepResult implements Serializable, ExecutableItem { private Stage stage; private String description; private String descriptionHtml; - private List steps; - private List attachments; - private List parameters; + private List steps = new ArrayList<>(); + private List attachments = new ArrayList<>(); + private List parameters = new ArrayList<>(); private Long start; private Long stop; diff --git a/allure-model/src/main/java/io/qameta/allure/model/TestResult.java b/allure-model/src/main/java/io/qameta/allure/model/TestResult.java index 444438268..9b86512bf 100644 --- a/allure-model/src/main/java/io/qameta/allure/model/TestResult.java +++ b/allure-model/src/main/java/io/qameta/allure/model/TestResult.java @@ -43,17 +43,17 @@ public class TestResult implements Serializable, ExecutableItem, WithLinks { private String historyId; private String testCaseId; private String fullName; - private List