diff --git a/allure-assertj/src/main/java/io/qameta/allure/assertj/AllureAspectJ.java b/allure-assertj/src/main/java/io/qameta/allure/assertj/AllureAspectJ.java
index 00af9c095..7ba05d2f8 100644
--- a/allure-assertj/src/main/java/io/qameta/allure/assertj/AllureAspectJ.java
+++ b/allure-assertj/src/main/java/io/qameta/allure/assertj/AllureAspectJ.java
@@ -17,7 +17,6 @@
import io.qameta.allure.Allure;
import io.qameta.allure.AllureLifecycle;
-import org.assertj.core.api.AbstractAssert;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.After;
@@ -26,6 +25,7 @@
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
+import org.assertj.core.api.AbstractAssert;
import java.util.function.Supplier;
@@ -51,22 +51,26 @@ protected AllureLifecycle initialValue() {
private static final ThreadLocal RECORDING_MUTED = ThreadLocal.withInitial(() -> false);
- @Pointcut("("
- + "call(public static * org.assertj.core.api.Assertions*.assertThat*(..))"
- + " || call(public static * org.assertj.core.api.BDDAssertions*.then*(..))"
- + " || call(public * org.assertj.core.api.*SoftAssertionsProvider+.assertThat*(..))"
- + " || call(public * org.assertj.core.api.*SoftAssertionsProvider+.then*(..))"
- + ")")
+ @Pointcut(
+ "("
+ + "call(public static * org.assertj.core.api.Assertions*.assertThat*(..))"
+ + " || call(public static * org.assertj.core.api.BDDAssertions*.then*(..))"
+ + " || call(public * org.assertj.core.api.*SoftAssertionsProvider+.assertThat*(..))"
+ + " || call(public * org.assertj.core.api.*SoftAssertionsProvider+.then*(..))"
+ + ")"
+ )
public void assertFactoryCall() {
//pointcut body, should be empty
}
- @Pointcut("("
- + "call(public * org.assertj.core.api.AbstractAssert+.*(..))"
- + " || call(public * org.assertj.core.api.Assert+.*(..))"
- + " || call(public * org.assertj.core.api.Descriptable+.*(..))"
- + ")"
- + " && target(assertion)")
+ @Pointcut(
+ "("
+ + "call(public * org.assertj.core.api.AbstractAssert+.*(..))"
+ + " || call(public * org.assertj.core.api.Assert+.*(..))"
+ + " || call(public * org.assertj.core.api.Descriptable+.*(..))"
+ + ")"
+ + " && target(assertion)"
+ )
public void assertOperationCall(final AbstractAssert, ?> assertion) {
//pointcut body, should be empty
}
@@ -76,7 +80,10 @@ public void userCodeCall() {
//pointcut body, should be empty
}
- @AfterReturning(pointcut = "assertFactoryCall() && userCodeCall()", returning = "result")
+ @AfterReturning(
+ pointcut = "assertFactoryCall() && userCodeCall()",
+ returning = "result"
+ )
public void logAssertCreation(final JoinPoint joinPoint, final Object result) {
if (isRecordingMuted() || !(result instanceof AbstractAssert)) {
return;
@@ -88,7 +95,8 @@ public void logAssertCreation(final JoinPoint joinPoint, final Object result) {
@Around("assertOperationCall(assertion) && userCodeCall()")
public Object logAssertOperation(final ProceedingJoinPoint joinPoint,
- final AbstractAssert, ?> assertion) throws Throwable {
+ final AbstractAssert, ?> assertion)
+ throws Throwable {
final String methodName = getMethodName(joinPoint);
if (isRecordingMuted() || getRecorder().isIgnored(methodName)) {
return joinPoint.proceed();
@@ -110,8 +118,10 @@ public Object logAssertOperation(final ProceedingJoinPoint joinPoint,
}
}
- @After("execution(public void org.assertj.core.api.DefaultAssertionErrorCollector.collectAssertionError("
- + "java.lang.AssertionError)) && args(error)")
+ @After(
+ "execution(public void org.assertj.core.api.DefaultAssertionErrorCollector.collectAssertionError("
+ + "java.lang.AssertionError)) && args(error)"
+ )
public void softAssertionFailed(final AssertionError error) {
getRecorder().softAssertionFailed(error);
}
diff --git a/allure-assertj/src/main/java/io/qameta/allure/assertj/AssertJMethodSupport.java b/allure-assertj/src/main/java/io/qameta/allure/assertj/AssertJMethodSupport.java
index 685e51bf0..455b28039 100644
--- a/allure-assertj/src/main/java/io/qameta/allure/assertj/AssertJMethodSupport.java
+++ b/allure-assertj/src/main/java/io/qameta/allure/assertj/AssertJMethodSupport.java
@@ -37,35 +37,37 @@ final class AssertJMethodSupport {
"toString"
);
- private static final Set NAVIGATION_METHODS = new HashSet<>(Arrays.asList(
- "asBase64Decoded",
- "asBoolean",
- "asByte",
- "asDouble",
- "asFloat",
- "asInstanceOf",
- "asInt",
- "asList",
- "asLong",
- "asShort",
- "asString",
- "bytes",
- "decodedAsBase64",
- "element",
- "elements",
- "extracting",
- "extractingResultOf",
- "first",
- "flatExtracting",
- "flatMap",
- "last",
- "map",
- "rootCause",
- "singleElement",
- "size",
- "usingRecursiveAssertion",
- "usingRecursiveComparison"
- ));
+ private static final Set NAVIGATION_METHODS = new HashSet<>(
+ Arrays.asList(
+ "asBase64Decoded",
+ "asBoolean",
+ "asByte",
+ "asDouble",
+ "asFloat",
+ "asInstanceOf",
+ "asInt",
+ "asList",
+ "asLong",
+ "asShort",
+ "asString",
+ "bytes",
+ "decodedAsBase64",
+ "element",
+ "elements",
+ "extracting",
+ "extractingResultOf",
+ "first",
+ "flatExtracting",
+ "flatMap",
+ "last",
+ "map",
+ "rootCause",
+ "singleElement",
+ "size",
+ "usingRecursiveAssertion",
+ "usingRecursiveComparison"
+ )
+ );
private AssertJMethodSupport() {
throw new IllegalStateException("do not instantiate");
diff --git a/allure-assertj/src/main/java/io/qameta/allure/assertj/AssertJOperation.java b/allure-assertj/src/main/java/io/qameta/allure/assertj/AssertJOperation.java
index d79b025fc..f06b8be49 100644
--- a/allure-assertj/src/main/java/io/qameta/allure/assertj/AssertJOperation.java
+++ b/allure-assertj/src/main/java/io/qameta/allure/assertj/AssertJOperation.java
@@ -15,8 +15,8 @@
*/
package io.qameta.allure.assertj;
-import io.qameta.allure.model.Stage;
import io.qameta.allure.model.Parameter;
+import io.qameta.allure.model.Stage;
import io.qameta.allure.model.Status;
import io.qameta.allure.model.StatusDetails;
import io.qameta.allure.model.StepResult;
diff --git a/allure-assertj/src/main/java/io/qameta/allure/assertj/AssertJRecorder.java b/allure-assertj/src/main/java/io/qameta/allure/assertj/AssertJRecorder.java
index 423d5a48d..50bc77531 100644
--- a/allure-assertj/src/main/java/io/qameta/allure/assertj/AssertJRecorder.java
+++ b/allure-assertj/src/main/java/io/qameta/allure/assertj/AssertJRecorder.java
@@ -221,12 +221,10 @@ private boolean isNavigationResult(final AssertJOperation activeOperation) {
return activeOperation != null && activeOperation.isNavigation();
}
- @SuppressWarnings("PMD.CompareObjectsWithEquals")
private boolean isInternalCallOnSameChain(final AssertJOperation activeOperation, final AssertJChain chain) {
return activeOperation != null && activeOperation.getChain() == chain;
}
- @SuppressWarnings("PMD.CompareObjectsWithEquals")
private void pop(final AssertJOperation operation) {
if (operation.isNested()) {
operation.leaveNested();
diff --git a/allure-assertj/src/main/java/io/qameta/allure/assertj/AssertJValueRenderer.java b/allure-assertj/src/main/java/io/qameta/allure/assertj/AssertJValueRenderer.java
index d7bee7c89..3e33ae78c 100644
--- a/allure-assertj/src/main/java/io/qameta/allure/assertj/AssertJValueRenderer.java
+++ b/allure-assertj/src/main/java/io/qameta/allure/assertj/AssertJValueRenderer.java
@@ -70,10 +70,12 @@ List renderParameters(final String methodName, final Object[] args) {
if (renderedOperation.contains(value)) {
continue;
}
- parameters.add(new Parameter()
- .setName(parameterName(methodName, index))
- .setValue(value)
- .setMode(Parameter.Mode.DEFAULT));
+ parameters.add(
+ new Parameter()
+ .setName(parameterName(methodName, index))
+ .setValue(value)
+ .setMode(Parameter.Mode.DEFAULT)
+ );
}
return parameters;
}
diff --git a/allure-assertj/src/test/java/io/qameta/allure/assertj/AllureAspectJTest.java b/allure-assertj/src/test/java/io/qameta/allure/assertj/AllureAspectJTest.java
index 1567e7e11..71e14e7ca 100644
--- a/allure-assertj/src/test/java/io/qameta/allure/assertj/AllureAspectJTest.java
+++ b/allure-assertj/src/test/java/io/qameta/allure/assertj/AllureAspectJTest.java
@@ -150,10 +150,12 @@ void shouldRenderSmallArraysAsValues() {
@Test
void shouldRenderTuplesAsValues() {
final AllureResults results = runWithinTestContext(() -> {
- assertThat(Arrays.asList(
- tuple("first", Status.PASSED),
- tuple("second", Status.FAILED)
- ))
+ assertThat(
+ Arrays.asList(
+ tuple("first", Status.PASSED),
+ tuple("second", Status.FAILED)
+ )
+ )
.containsExactly(
tuple("first", Status.PASSED),
tuple("second", Status.FAILED)
@@ -465,9 +467,11 @@ void shouldMarkTheFailedSoftAssertionOperationBeforeAssertAll() {
void shouldAttachNestedAssertionsUnderCallbackOperations() {
final AllureResults results = runWithinTestContext(() -> {
assertThat("alpha")
- .satisfies(value -> assertThat(value)
- .startsWith("al")
- .endsWith("ha"));
+ .satisfies(
+ value -> assertThat(value)
+ .startsWith("al")
+ .endsWith("ha")
+ );
}, AllureAspectJ::setLifecycle);
final TestResult result = assertOnlyOneResult(results);
diff --git a/allure-attachments/src/main/java/io/qameta/allure/attachment/AttachmentRenderer.java b/allure-attachments/src/main/java/io/qameta/allure/attachment/AttachmentRenderer.java
index 15423fc86..44029cc85 100644
--- a/allure-attachments/src/main/java/io/qameta/allure/attachment/AttachmentRenderer.java
+++ b/allure-attachments/src/main/java/io/qameta/allure/attachment/AttachmentRenderer.java
@@ -19,7 +19,6 @@
* @param the type of attachment data
* @author charlie (Dmitry Baev).
*/
-@SuppressWarnings("PMD.AvoidUncheckedExceptionsInSignatures")
@FunctionalInterface
public interface AttachmentRenderer {
diff --git a/allure-attachments/src/test/java/io/qameta/allure/attachment/FreemarkerAttachmentRendererTest.java b/allure-attachments/src/test/java/io/qameta/allure/attachment/FreemarkerAttachmentRendererTest.java
index 4f0c235e8..3c37c53ab 100644
--- a/allure-attachments/src/test/java/io/qameta/allure/attachment/FreemarkerAttachmentRendererTest.java
+++ b/allure-attachments/src/test/java/io/qameta/allure/attachment/FreemarkerAttachmentRendererTest.java
@@ -35,7 +35,6 @@ class FreemarkerAttachmentRendererTest {
private static final String FILE_EXTENSION = "fileExtension";
private static final String HTML = ".html";
-
@AllureFeatures.Attachments
@Test
void shouldRenderRequestAttachment() {
diff --git a/allure-awaitility/src/main/java/io/qameta/allure/awaitility/AllureAwaitilityListener.java b/allure-awaitility/src/main/java/io/qameta/allure/awaitility/AllureAwaitilityListener.java
index 451e3fd9b..a19e5e31e 100644
--- a/allure-awaitility/src/main/java/io/qameta/allure/awaitility/AllureAwaitilityListener.java
+++ b/allure-awaitility/src/main/java/io/qameta/allure/awaitility/AllureAwaitilityListener.java
@@ -77,8 +77,7 @@ public class AllureAwaitilityListener implements ConditionEvaluationListener LIFECYCLE
- = new InheritableThreadLocal() {
+ private static final InheritableThreadLocal LIFECYCLE = new InheritableThreadLocal() {
@Override
protected AllureLifecycle initialValue() {
return Allure.getLifecycle();
@@ -225,7 +224,8 @@ public void exceptionIgnored(final IgnoredException ignoredException) {
getLifecycle().updateStep(awaitilityCondition -> {
final String currentExceptionIgnoredStepUUID = UUID.randomUUID().toString();
final String message = String.format(
- onExceptionStepTextPattern, ignoredException.getThrowable().getMessage());
+ onExceptionStepTextPattern, ignoredException.getThrowable().getMessage()
+ );
final StringWriter stringWriter = new StringWriter();
ignoredException.getThrowable().printStackTrace(new PrintWriter(stringWriter));
final String stackTrace = stringWriter.toString();
@@ -239,7 +239,8 @@ public void exceptionIgnored(final IgnoredException ignoredException) {
);
getLifecycle().addAttachment(
ignoredException.getThrowable().getMessage(), "text/plain", ".txt",
- stackTrace.getBytes(StandardCharsets.UTF_8));
+ stackTrace.getBytes(StandardCharsets.UTF_8)
+ );
getLifecycle().stopStep(currentExceptionIgnoredStepUUID);
});
}
diff --git a/allure-awaitility/src/test/java/io/qameta/allure/awaitility/ConditionListenersPositiveTest.java b/allure-awaitility/src/test/java/io/qameta/allure/awaitility/ConditionListenersPositiveTest.java
index 592078479..9eb6d7d6f 100644
--- a/allure-awaitility/src/test/java/io/qameta/allure/awaitility/ConditionListenersPositiveTest.java
+++ b/allure-awaitility/src/test/java/io/qameta/allure/awaitility/ConditionListenersPositiveTest.java
@@ -58,27 +58,27 @@ static void setup() {
@TestFactory
Stream globalSettingsAwaitWoAliasCheckTopLevelPassedStep() {
final List testResult = runWithinTestContext(() -> {
- final AtomicInteger atomicInteger = new AtomicInteger(0);
- await().with()
- .conditionEvaluationListener(new AllureAwaitilityListener())
- .atMost(Duration.of(1000, ChronoUnit.MILLIS))
- .pollInterval(Duration.of(50, ChronoUnit.MILLIS))
- .until(atomicInteger::getAndIncrement, is(3));
- },
+ final AtomicInteger atomicInteger = new AtomicInteger(0);
+ await().with()
+ .conditionEvaluationListener(new AllureAwaitilityListener())
+ .atMost(Duration.of(1000, ChronoUnit.MILLIS))
+ .pollInterval(Duration.of(50, ChronoUnit.MILLIS))
+ .until(atomicInteger::getAndIncrement, is(3));
+ },
AllureAwaitilityListener::setLifecycle
).getTestResults();
return Stream.of(
- DynamicTest.dynamicTest("Exactly 1 top level step for 1 awaitility condition", () ->
- assertThat(testResult.get(0).getSteps())
+ DynamicTest.dynamicTest(
+ "Exactly 1 top level step for 1 awaitility condition", () -> assertThat(testResult.get(0).getSteps())
.hasSize(1)
),
- DynamicTest.dynamicTest("Top level step has passed status", () ->
- assertThat(testResult.get(0).getSteps())
+ DynamicTest.dynamicTest(
+ "Top level step has passed status", () -> assertThat(testResult.get(0).getSteps())
.allMatch(step -> Status.PASSED.equals(step.getStatus()))
),
- DynamicTest.dynamicTest("Top level step has default name because await() wo alias", () ->
- assertThat(testResult.get(0).getSteps())
+ DynamicTest.dynamicTest(
+ "Top level step has default name because await() wo alias", () -> assertThat(testResult.get(0).getSteps())
.extracting(StepResult::getName)
.containsExactly("Awaitility: Starting evaluation")
)
@@ -96,13 +96,13 @@ Stream globalSettingsAwaitWoAliasCheckTopLevelPassedStep() {
@Test
void globalSettingsAwaitWithAliasCheckTopLevelPassedStep() {
final List testResult = runWithinTestContext(() -> {
- final AtomicInteger atomicInteger = new AtomicInteger(0);
- await("Counter should be at least 3").with()
- .conditionEvaluationListener(new AllureAwaitilityListener())
- .atMost(Duration.of(1000, ChronoUnit.MILLIS))
- .pollInterval(Duration.of(50, ChronoUnit.MILLIS))
- .until(atomicInteger::getAndIncrement, is(3));
- },
+ final AtomicInteger atomicInteger = new AtomicInteger(0);
+ await("Counter should be at least 3").with()
+ .conditionEvaluationListener(new AllureAwaitilityListener())
+ .atMost(Duration.of(1000, ChronoUnit.MILLIS))
+ .pollInterval(Duration.of(50, ChronoUnit.MILLIS))
+ .until(atomicInteger::getAndIncrement, is(3));
+ },
AllureAwaitilityListener::setLifecycle
).getTestResults();
assertEquals(
@@ -125,51 +125,51 @@ void globalSettingsAwaitWithAliasCheckTopLevelPassedStep() {
@TestFactory
Stream globalSettingsCheckAwaitWoAliasSecondLevelPassedSteps() {
final List testResult = runWithinTestContext(() -> {
- final AtomicInteger atomicInteger = new AtomicInteger(0);
- await().with()
- .conditionEvaluationListener(new AllureAwaitilityListener())
- .atMost(Duration.of(1000, ChronoUnit.MILLIS))
- .pollInterval(Duration.of(50, ChronoUnit.MILLIS))
- .until(atomicInteger::getAndIncrement, is(3));
- },
+ final AtomicInteger atomicInteger = new AtomicInteger(0);
+ await().with()
+ .conditionEvaluationListener(new AllureAwaitilityListener())
+ .atMost(Duration.of(1000, ChronoUnit.MILLIS))
+ .pollInterval(Duration.of(50, ChronoUnit.MILLIS))
+ .until(atomicInteger::getAndIncrement, is(3));
+ },
AllureAwaitilityListener::setLifecycle
).getTestResults();
return Stream.of(
- dynamicTest("Exactly 4 second level steps for 4 polling iterations", () ->
- assertThat(testResult.get(0).getSteps().get(0).getSteps())
+ dynamicTest(
+ "Exactly 4 second level steps for 4 polling iterations", () -> assertThat(testResult.get(0).getSteps().get(0).getSteps())
.hasSize(4)
),
- dynamicTest("All second level steps has passed statuses", () ->
- assertThat(testResult.get(0).getSteps().get(0).getSteps())
+ dynamicTest(
+ "All second level steps has passed statuses", () -> assertThat(testResult.get(0).getSteps().get(0).getSteps())
.allMatch(x -> x.getStatus().equals(Status.PASSED))
),
- dynamicTest("Second level step 1 name", () ->
- assertThat(testResult.get(0).getSteps().get(0).getSteps().get(0).getName())
+ dynamicTest(
+ "Second level step 1 name", () -> assertThat(testResult.get(0).getSteps().get(0).getSteps().get(0).getName())
.contains("io.qameta.allure.awaitility.ConditionListenersPositiveTest")
.contains("expected <3> but was <0>")
.contains("elapsed time")
.contains("remaining time")
.contains("last poll interval was")
),
- dynamicTest("Second level step 2 name", () ->
- assertThat(testResult.get(0).getSteps().get(0).getSteps().get(1).getName())
+ dynamicTest(
+ "Second level step 2 name", () -> assertThat(testResult.get(0).getSteps().get(0).getSteps().get(1).getName())
.contains("io.qameta.allure.awaitility.ConditionListenersPositiveTest")
.contains("expected <3> but was <1>")
.contains("elapsed time")
.contains("remaining time")
.contains("last poll interval was")
),
- dynamicTest("Second level step 3 name", () ->
- assertThat(testResult.get(0).getSteps().get(0).getSteps().get(2).getName())
+ dynamicTest(
+ "Second level step 3 name", () -> assertThat(testResult.get(0).getSteps().get(0).getSteps().get(2).getName())
.contains("io.qameta.allure.awaitility.ConditionListenersPositiveTest")
.contains("expected <3> but was <2>")
.contains("elapsed time")
.contains("remaining time")
.contains("last poll interval was")
),
- dynamicTest("Second level step 4 name", () ->
- assertThat(testResult.get(0).getSteps().get(0).getSteps().get(3).getName())
+ dynamicTest(
+ "Second level step 4 name", () -> assertThat(testResult.get(0).getSteps().get(0).getSteps().get(3).getName())
.contains("io.qameta.allure.awaitility.ConditionListenersPositiveTest")
.contains("reached its end value of <3> after")
.contains("remaining time")
diff --git a/allure-awaitility/src/test/java/io/qameta/allure/awaitility/GlobalSettingsNegativeTest.java b/allure-awaitility/src/test/java/io/qameta/allure/awaitility/GlobalSettingsNegativeTest.java
index b01c36cd6..c00fcf774 100644
--- a/allure-awaitility/src/test/java/io/qameta/allure/awaitility/GlobalSettingsNegativeTest.java
+++ b/allure-awaitility/src/test/java/io/qameta/allure/awaitility/GlobalSettingsNegativeTest.java
@@ -63,12 +63,12 @@ void setup() {
@Test
void globalSettingsAwaitWoAliasCheckTopLevelBrokenStep() {
final List testResult = runWithinTestContext(() -> {
- final AtomicInteger atomicInteger = new AtomicInteger(0);
- await().with()
- .atMost(Duration.of(1000, ChronoUnit.MILLIS))
- .pollInterval(Duration.of(500, ChronoUnit.MILLIS))
- .until(atomicInteger::getAndIncrement, is(3));
- },
+ final AtomicInteger atomicInteger = new AtomicInteger(0);
+ await().with()
+ .atMost(Duration.of(1000, ChronoUnit.MILLIS))
+ .pollInterval(Duration.of(500, ChronoUnit.MILLIS))
+ .until(atomicInteger::getAndIncrement, is(3));
+ },
AllureAwaitilityListener::setLifecycle
).getTestResults();
assertEquals(
@@ -90,37 +90,42 @@ void globalSettingsAwaitWoAliasCheckTopLevelBrokenStep() {
@TestFactory
Stream globalSettingsCheckAwaitWoAliasSecondLevelTimeoutStep() {
final List testResult = runWithinTestContext(() -> {
- final AtomicInteger atomicInteger = new AtomicInteger(0);
- await().with()
- .atMost(Duration.of(1000, ChronoUnit.MILLIS))
- .pollInterval(Duration.of(500, ChronoUnit.MILLIS))
- .until(atomicInteger::getAndIncrement, is(3));
- },
+ final AtomicInteger atomicInteger = new AtomicInteger(0);
+ await().with()
+ .atMost(Duration.of(1000, ChronoUnit.MILLIS))
+ .pollInterval(Duration.of(500, ChronoUnit.MILLIS))
+ .until(atomicInteger::getAndIncrement, is(3));
+ },
AllureAwaitilityListener::setLifecycle
).getTestResults();
return Stream.of(
- dynamicTest("Second level steps count", () ->
- assertThat(testResult.get(0).getSteps().get(0).getSteps())
+ dynamicTest(
+ "Second level steps count", () -> assertThat(testResult.get(0).getSteps().get(0).getSteps())
.as("Exactly 2 second level steps for 2 polling iterations")
- .hasSize(2)),
- dynamicTest("Second level step 1 name", () ->
- assertThat(testResult.get(0).getSteps().get(0).getSteps().get(0).getName())
+ .hasSize(2)
+ ),
+ dynamicTest(
+ "Second level step 1 name", () -> assertThat(testResult.get(0).getSteps().get(0).getSteps().get(0).getName())
.contains("io.qameta.allure.awaitility.GlobalSettingsNegativeTest")
.contains("expected <3> but was <0>")
.contains("elapsed time")
.contains("remaining time")
- .contains("last poll interval was")),
- dynamicTest("Second level step 1 status", () ->
- assertThat(testResult.get(0).getSteps().get(0).getSteps().get(0).getStatus())
- .isEqualTo(Status.PASSED)),
- dynamicTest("Second level step 2 name", () ->
- assertThat(testResult.get(0).getSteps().get(0).getSteps().get(1).getName())
+ .contains("last poll interval was")
+ ),
+ dynamicTest(
+ "Second level step 1 status", () -> assertThat(testResult.get(0).getSteps().get(0).getSteps().get(0).getStatus())
+ .isEqualTo(Status.PASSED)
+ ),
+ dynamicTest(
+ "Second level step 2 name", () -> assertThat(testResult.get(0).getSteps().get(0).getSteps().get(1).getName())
.contains("Condition timeout.")
- .contains("io.qameta.allure.awaitility.GlobalSettingsNegativeTest")),
- dynamicTest("Second level step 2 status", () ->
- assertThat(testResult.get(0).getSteps().get(0).getSteps().get(1).getStatus())
- .isEqualTo(Status.BROKEN))
+ .contains("io.qameta.allure.awaitility.GlobalSettingsNegativeTest")
+ ),
+ dynamicTest(
+ "Second level step 2 status", () -> assertThat(testResult.get(0).getSteps().get(0).getSteps().get(1).getStatus())
+ .isEqualTo(Status.BROKEN)
+ )
);
}
diff --git a/allure-awaitility/src/test/java/io/qameta/allure/awaitility/GlobalSettingsPositiveTest.java b/allure-awaitility/src/test/java/io/qameta/allure/awaitility/GlobalSettingsPositiveTest.java
index df782adac..dfb3ff3b7 100644
--- a/allure-awaitility/src/test/java/io/qameta/allure/awaitility/GlobalSettingsPositiveTest.java
+++ b/allure-awaitility/src/test/java/io/qameta/allure/awaitility/GlobalSettingsPositiveTest.java
@@ -65,29 +65,29 @@ void setup() {
@Test
Stream globalSettingsAwaitWoAliasCheckTopLevelPassedStep() {
final List testResult = runWithinTestContext(() -> {
- final AtomicInteger atomicInteger = new AtomicInteger(0);
- await().with()
- .atMost(Duration.of(1000, ChronoUnit.MILLIS))
- .pollInterval(Duration.of(50, ChronoUnit.MILLIS))
- .until(atomicInteger::getAndIncrement, is(3));
- },
+ final AtomicInteger atomicInteger = new AtomicInteger(0);
+ await().with()
+ .atMost(Duration.of(1000, ChronoUnit.MILLIS))
+ .pollInterval(Duration.of(50, ChronoUnit.MILLIS))
+ .until(atomicInteger::getAndIncrement, is(3));
+ },
AllureAwaitilityListener::setLifecycle
).getTestResults();
return Stream.of(
- dynamicTest("Steps count", () ->
- assertThat(testResult.get(0).getSteps())
+ dynamicTest(
+ "Steps count", () -> assertThat(testResult.get(0).getSteps())
.as("Exactly 1 top level step for 1 awaitility condition")
.hasSize(1)
),
- dynamicTest("Top level step status", () ->
- assertEquals(
+ dynamicTest(
+ "Top level step status", () -> assertEquals(
Status.PASSED, testResult.get(0).getSteps().get(0).getStatus(),
"Top level step has passed status"
)
),
- dynamicTest("Top level step name", () ->
- assertEquals(
+ dynamicTest(
+ "Top level step name", () -> assertEquals(
"Awaitility: Starting evaluation",
testResult.get(0).getSteps().get(0).getName(),
"Top level step has default name because await() wo alias"
@@ -107,12 +107,12 @@ Stream globalSettingsAwaitWoAliasCheckTopLevelPassedStep() {
@Test
void globalSettingsAwaitWithAliasCheckTopLevelPassedStep() {
final List testResult = runWithinTestContext(() -> {
- final AtomicInteger atomicInteger = new AtomicInteger(0);
- await("Counter should be at least 3").with()
- .atMost(Duration.of(1000, ChronoUnit.MILLIS))
- .pollInterval(Duration.of(50, ChronoUnit.MILLIS))
- .until(atomicInteger::getAndIncrement, is(3));
- },
+ final AtomicInteger atomicInteger = new AtomicInteger(0);
+ await("Counter should be at least 3").with()
+ .atMost(Duration.of(1000, ChronoUnit.MILLIS))
+ .pollInterval(Duration.of(50, ChronoUnit.MILLIS))
+ .until(atomicInteger::getAndIncrement, is(3));
+ },
AllureAwaitilityListener::setLifecycle
).getTestResults();
assertEquals(
@@ -135,24 +135,24 @@ void globalSettingsAwaitWithAliasCheckTopLevelPassedStep() {
@Test
Stream globalSettingsCheckAwaitWoAliasSecondLevelPassedSteps() {
final List testResult = runWithinTestContext(() -> {
- final AtomicInteger atomicInteger = new AtomicInteger(0);
- await().with()
- .atMost(Duration.of(1000, ChronoUnit.MILLIS))
- .pollInterval(Duration.of(50, ChronoUnit.MILLIS))
- .until(atomicInteger::getAndIncrement, is(3));
- },
+ final AtomicInteger atomicInteger = new AtomicInteger(0);
+ await().with()
+ .atMost(Duration.of(1000, ChronoUnit.MILLIS))
+ .pollInterval(Duration.of(50, ChronoUnit.MILLIS))
+ .until(atomicInteger::getAndIncrement, is(3));
+ },
AllureAwaitilityListener::setLifecycle
).getTestResults();
return Stream.of(
- dynamicTest("Second level steps count", () ->
- assertEquals(
+ dynamicTest(
+ "Second level steps count", () -> assertEquals(
4, testResult.get(0).getSteps().get(0).getSteps().size(),
"Exactly 4 second level steps for 4 polling iterations"
)
),
- dynamicTest("Second level steps all passed", () ->
- assertThat(testResult.get(0).getSteps().get(0).getSteps())
+ dynamicTest(
+ "Second level steps all passed", () -> assertThat(testResult.get(0).getSteps().get(0).getSteps())
.extracting(StepResult::getStatus)
.containsExactlyInAnyOrder(
Status.PASSED,
@@ -161,32 +161,32 @@ Stream globalSettingsCheckAwaitWoAliasSecondLevelPassedSteps() {
Status.PASSED
)
),
- dynamicTest("Second level step 1 name", () ->
- assertThat(testResult.get(0).getSteps().get(0).getSteps().get(0).getName())
+ dynamicTest(
+ "Second level step 1 name", () -> assertThat(testResult.get(0).getSteps().get(0).getSteps().get(0).getName())
.contains("io.qameta.allure.awaitility.GlobalSettingsPositiveTest")
.contains("expected <3> but was <0>")
.contains("elapsed time")
.contains("remaining time")
.contains("last poll interval was")
),
- dynamicTest("Second level step 2 name", () ->
- assertThat(testResult.get(0).getSteps().get(0).getSteps().get(1).getName())
+ dynamicTest(
+ "Second level step 2 name", () -> assertThat(testResult.get(0).getSteps().get(0).getSteps().get(1).getName())
.contains("io.qameta.allure.awaitility.GlobalSettingsPositiveTest")
.contains("expected <3> but was <1>")
.contains("elapsed time")
.contains("remaining time")
.contains("last poll interval was")
),
- dynamicTest("Second level step 3 name", () ->
- assertThat(testResult.get(0).getSteps().get(0).getSteps().get(2).getName())
+ dynamicTest(
+ "Second level step 3 name", () -> assertThat(testResult.get(0).getSteps().get(0).getSteps().get(2).getName())
.contains("io.qameta.allure.awaitility.GlobalSettingsPositiveTest")
.contains("expected <3> but was <2>")
.contains("elapsed time")
.contains("remaining time")
.contains("last poll interval was")
),
- dynamicTest("Second level step 4 name", () ->
- assertThat(testResult.get(0).getSteps().get(0).getSteps().get(3).getName())
+ dynamicTest(
+ "Second level step 4 name", () -> assertThat(testResult.get(0).getSteps().get(0).getSteps().get(3).getName())
.contains("io.qameta.allure.awaitility.GlobalSettingsPositiveTest")
.contains("java.util.concurrent.atomic.AtomicInteger:")
.contains("reached its end value of <3> after")
diff --git a/allure-awaitility/src/test/java/io/qameta/allure/awaitility/MultipleConditionsTest.java b/allure-awaitility/src/test/java/io/qameta/allure/awaitility/MultipleConditionsTest.java
index 8acb2782f..6b2fff5f9 100644
--- a/allure-awaitility/src/test/java/io/qameta/allure/awaitility/MultipleConditionsTest.java
+++ b/allure-awaitility/src/test/java/io/qameta/allure/awaitility/MultipleConditionsTest.java
@@ -43,24 +43,24 @@ void setup() {
@TestFactory
Stream bothAwaitilityStepsShouldAppearTest() {
final List testResult = runWithinTestContext(() -> {
- await().with()
- .alias("First waiting")
- .until(() -> true);
- await().with()
- .alias("Second waiting")
- .until(() -> true);
- },
+ await().with()
+ .alias("First waiting")
+ .until(() -> true);
+ await().with()
+ .alias("Second waiting")
+ .until(() -> true);
+ },
AllureAwaitilityListener::setLifecycle
).getTestResults();
return Stream.of(
- DynamicTest.dynamicTest("Exactly 2 top level step for 2 awaitility condition", () ->
- assertThat(testResult.get(0).getSteps())
+ DynamicTest.dynamicTest(
+ "Exactly 2 top level step for 2 awaitility condition", () -> assertThat(testResult.get(0).getSteps())
.describedAs("Allure TestResult contains exactly 2 top level step for 2 awaitility condition")
.hasSize(2)
),
- DynamicTest.dynamicTest("All top level step for all awaitility condition has PASSED", () ->
- assertThat(testResult.get(0).getSteps())
+ DynamicTest.dynamicTest(
+ "All top level step for all awaitility condition has PASSED", () -> assertThat(testResult.get(0).getSteps())
.describedAs("Allure TestResult contains all top level step for all awaitility with PASSED condition")
.allMatch(step -> Status.PASSED.equals(step.getStatus()))
)
diff --git a/allure-citrus/src/main/java/io/qameta/allure/citrus/AllureCitrus.java b/allure-citrus/src/main/java/io/qameta/allure/citrus/AllureCitrus.java
index 8aeac02d8..b50ec45df 100644
--- a/allure-citrus/src/main/java/io/qameta/allure/citrus/AllureCitrus.java
+++ b/allure-citrus/src/main/java/io/qameta/allure/citrus/AllureCitrus.java
@@ -167,23 +167,26 @@ private void startTestCase(final TestCase testCase) {
final TestResult result = new TestResult()
.setUuid(uuid)
.setName(testCase.getName())
- .setTitlePath(testClass
- .map(ResultsUtils::createTitlePathFromJavaClass)
- .orElseGet(() -> createTitlePath(testCase.getName())))
+ .setTitlePath(
+ testClass
+ .map(ResultsUtils::createTitlePathFromJavaClass)
+ .orElseGet(() -> createTitlePath(testCase.getName()))
+ )
.setStage(Stage.RUNNING);
result.getLabels().addAll(getProvidedLabels());
-
testClass.map(this::getLabels).ifPresent(result.getLabels()::addAll);
testClass.map(this::getLinks).ifPresent(result.getLinks()::addAll);
- result.getLabels().addAll(Arrays.asList(
- createHostLabel(),
- createThreadLabel(),
- createFrameworkLabel("citrus"),
- createLanguageLabel("java")
- ));
+ result.getLabels().addAll(
+ Arrays.asList(
+ createHostLabel(),
+ createThreadLabel(),
+ createFrameworkLabel("citrus"),
+ createLanguageLabel("java")
+ )
+ );
testClass.ifPresent(aClass -> {
final String suiteName = aClass.getCanonicalName();
@@ -221,7 +224,6 @@ private void stopTestCase(final TestCase testCase,
getLifecycle().writeTestCase(uuid);
}
-
private String createUuid(final TestCase testCase) {
final String uuid = UUID.randomUUID().toString();
try {
@@ -269,7 +271,8 @@ private List getLinks(final AnnotatedElement annotatedElement) {
return Stream.of(
getAnnotations(annotatedElement, io.qameta.allure.Link.class).map(ResultsUtils::createLink),
getAnnotations(annotatedElement, io.qameta.allure.Issue.class).map(ResultsUtils::createLink),
- getAnnotations(annotatedElement, io.qameta.allure.TmsLink.class).map(ResultsUtils::createLink))
+ getAnnotations(annotatedElement, io.qameta.allure.TmsLink.class).map(ResultsUtils::createLink)
+ )
.reduce(Stream::concat).orElseGet(Stream::empty).collect(Collectors.toList());
}
diff --git a/allure-cucumber4-jvm/src/main/java/io/qameta/allure/cucumber4jvm/AllureCucumber4Jvm.java b/allure-cucumber4-jvm/src/main/java/io/qameta/allure/cucumber4jvm/AllureCucumber4Jvm.java
index 8f57e5005..7cfdc67e5 100644
--- a/allure-cucumber4-jvm/src/main/java/io/qameta/allure/cucumber4jvm/AllureCucumber4Jvm.java
+++ b/allure-cucumber4-jvm/src/main/java/io/qameta/allure/cucumber4jvm/AllureCucumber4Jvm.java
@@ -80,11 +80,14 @@
/**
* Allure plugin for Cucumber JVM 4.0.
*/
-@SuppressWarnings({
- "ClassDataAbstractionCoupling",
- "ClassFanOutComplexity",
- "MultipleStringLiterals",
-})
+@SuppressWarnings(
+ {
+ "ClassDataAbstractionCoupling",
+ "ClassFanOutComplexity",
+ "MultipleStringLiterals",
+ "PMD.GodClass",
+ }
+)
public class AllureCucumber4Jvm implements ConcurrentEventListener {
private static final String COLON = ":";
@@ -146,11 +149,11 @@ private void handleTestCaseStarted(final TestCaseStarted event) {
final String name = testCase.getName();
-
// the same way full name is generated for
// org.junit.platform.engine.support.descriptor.ClasspathResourceSource
// to support io.qameta.allure.junitplatform.AllurePostDiscoveryFilter
- final String fullName = String.format("%s:%d",
+ final String fullName = String.format(
+ "%s:%d",
getTestCaseUri(testCase),
testCase.getLine()
);
@@ -171,11 +174,10 @@ private void handleTestCaseStarted(final TestCaseStarted event) {
.setLabels(labelBuilder.getScenarioLabels())
.setLinks(labelBuilder.getScenarioLinks());
- final ScenarioDefinition scenarioDefinition =
- testSources.getScenarioDefinition(
- testCase.getUri(),
- testCase.getLine()
- );
+ final ScenarioDefinition scenarioDefinition = testSources.getScenarioDefinition(
+ testCase.getUri(),
+ testCase.getLine()
+ );
if (scenarioDefinition instanceof ScenarioOutline) {
result.setParameters(
@@ -215,9 +217,10 @@ private void handleTestCaseFinished(final TestCaseFinished event) {
.setMuted(tagParser.isMuted())
.setKnown(tagParser.isKnown());
- lifecycle.updateTestCase(uuid, testResult -> testResult
- .setStatus(status)
- .setStatusDetails(statusDetails)
+ lifecycle.updateTestCase(
+ uuid, testResult -> testResult
+ .setStatus(status)
+ .setStatusDetails(statusDetails)
);
lifecycle.stopTestCase(uuid);
@@ -303,13 +306,13 @@ private void handleStartFixtureHook(final TestCase testCase,
return;
}
-
final String containerUuid = hookStepContainerUuid
.computeIfAbsent(hook, unused -> UUID.randomUUID().toString());
- lifecycle.startTestContainer(new TestResultContainer()
- .setUuid(containerUuid)
- .setChildren(Collections.singletonList(uuid))
+ lifecycle.startTestContainer(
+ new TestResultContainer()
+ .setUuid(containerUuid)
+ .setChildren(Collections.singletonList(uuid))
);
final FixtureResult hookResult = new FixtureResult()
@@ -408,15 +411,14 @@ private Status translateTestCaseStatus(final Result testCaseResult) {
}
private List getExamplesAsParameters(
- final ScenarioOutline scenario,
- final TestCase localCurrentTestCase) {
- final Optional maybeExample =
- scenario.getExamples().stream()
- .filter(example -> example.getTableBody().stream()
- .anyMatch(row -> row.getLocation().getLine()
- == localCurrentTestCase.getLine())
- )
- .findFirst();
+ final ScenarioOutline scenario,
+ final TestCase localCurrentTestCase) {
+ final Optional maybeExample = scenario.getExamples().stream()
+ .filter(
+ example -> example.getTableBody().stream()
+ .anyMatch(row -> row.getLocation().getLine() == localCurrentTestCase.getLine())
+ )
+ .findFirst();
if (!maybeExample.isPresent()) {
return Collections.emptyList();
@@ -455,8 +457,10 @@ private void createDataTableAttachment(final PickleTable pickleTable) {
}
final String attachmentSource = lifecycle
.prepareAttachment("Data table", "text/tab-separated-values", "csv");
- lifecycle.writeAttachment(attachmentSource,
- new ByteArrayInputStream(dataTableCsv.toString().getBytes(StandardCharsets.UTF_8)));
+ lifecycle.writeAttachment(
+ attachmentSource,
+ new ByteArrayInputStream(dataTableCsv.toString().getBytes(StandardCharsets.UTF_8))
+ );
}
private void handleStopHookStep(final Result eventResult,
@@ -477,9 +481,10 @@ private void handleStopHookStep(final Result eventResult,
final StatusDetails statusDetails = getStatusDetails(eventResult.getError())
.orElseGet(StatusDetails::new);
- lifecycle.updateFixture(uuid, result -> result
- .setStatus(status)
- .setStatusDetails(statusDetails)
+ lifecycle.updateFixture(
+ uuid, result -> result
+ .setStatus(status)
+ .setStatusDetails(statusDetails)
);
lifecycle.stopFixture(uuid);
@@ -500,8 +505,7 @@ private void handleStopStep(final TestCase testCase,
final Status stepStatus = translateTestCaseStatus(eventResult);
- final StatusDetails statusDetails
- = eventResult.getStatus() == Result.Type.UNDEFINED
+ final StatusDetails statusDetails = eventResult.getStatus() == Result.Type.UNDEFINED
? new StatusDetails().setMessage("Undefined Step. Please add step definition")
: getStatusDetails(eventResult.getError())
.orElse(new StatusDetails());
diff --git a/allure-cucumber4-jvm/src/main/java/io/qameta/allure/cucumber4jvm/LabelBuilder.java b/allure-cucumber4-jvm/src/main/java/io/qameta/allure/cucumber4jvm/LabelBuilder.java
index 0424e6e15..1f54ea8f9 100644
--- a/allure-cucumber4-jvm/src/main/java/io/qameta/allure/cucumber4jvm/LabelBuilder.java
+++ b/allure-cucumber4-jvm/src/main/java/io/qameta/allure/cucumber4jvm/LabelBuilder.java
@@ -49,7 +49,7 @@
/**
* Scenario labels and links builder.
*/
-@SuppressWarnings({"CyclomaticComplexity", "MultipleStringLiterals"})
+@SuppressWarnings({"CyclomaticComplexity", "MultipleStringLiterals", "PMD.CognitiveComplexity"})
final class LabelBuilder {
private static final Logger LOGGER = LoggerFactory.getLogger(LabelBuilder.class);
private static final String COMPOSITE_TAG_DELIMITER = "=";
@@ -116,17 +116,19 @@ final class LabelBuilder {
final String uri = scenario.getUri();
scenarioLabels.addAll(ResultsUtils.getProvidedLabels());
- scenarioLabels.addAll(Arrays.asList(
- createHostLabel(),
- createThreadLabel(),
- createFeatureLabel(featureName),
- createStoryLabel(scenario.getName()),
- createSuiteLabel(featureName),
- createTestClassLabel(scenario.getName()),
- createFrameworkLabel("cucumber4jvm"),
- createLanguageLabel("java"),
- createLabel("gherkin_uri", uri)
- ));
+ scenarioLabels.addAll(
+ Arrays.asList(
+ createHostLabel(),
+ createThreadLabel(),
+ createFeatureLabel(featureName),
+ createStoryLabel(scenario.getName()),
+ createSuiteLabel(featureName),
+ createTestClassLabel(scenario.getName()),
+ createFrameworkLabel("cucumber4jvm"),
+ createLanguageLabel("java"),
+ createLabel("gherkin_uri", uri)
+ )
+ );
featurePackage(uri, featureName)
.map(ResultsUtils::createPackageLabel)
@@ -159,8 +161,10 @@ private void tryHandleNamedLink(final String tagString) {
final String name = tagString.split(COMPOSITE_TAG_DELIMITER)[1];
scenarioLinks.add(ResultsUtils.createLink(null, name, null, type));
} else {
- LOGGER.warn("Composite named tag {} does not match regex {}. Skipping", tagString,
- namedLinkPatternString);
+ LOGGER.warn(
+ "Composite named tag {} does not match regex {}. Skipping", tagString,
+ namedLinkPatternString
+ );
}
}
@@ -178,10 +182,12 @@ private Optional featurePackage(final String uriString, final String fea
final String schemeSpecificPart = uri.normalize().getSchemeSpecificPart();
final Stream folders = Stream.of(schemeSpecificPart.replaceAll("\\.", "_").split("/"));
final Stream name = Stream.of(featureName);
- return Optional.of(Stream.concat(folders, name)
- .filter(Objects::nonNull)
- .filter(s -> !s.isEmpty())
- .collect(Collectors.joining(".")));
+ return Optional.of(
+ Stream.concat(folders, name)
+ .filter(Objects::nonNull)
+ .filter(s -> !s.isEmpty())
+ .collect(Collectors.joining("."))
+ );
}
private static Optional safeUri(final String uri) {
diff --git a/allure-cucumber4-jvm/src/main/java/io/qameta/allure/cucumber4jvm/TagParser.java b/allure-cucumber4-jvm/src/main/java/io/qameta/allure/cucumber4jvm/TagParser.java
index 4839d4eac..cc4b120dc 100644
--- a/allure-cucumber4-jvm/src/main/java/io/qameta/allure/cucumber4jvm/TagParser.java
+++ b/allure-cucumber4-jvm/src/main/java/io/qameta/allure/cucumber4jvm/TagParser.java
@@ -52,9 +52,9 @@ public boolean isKnown() {
private boolean getStatusDetailByTag(final String tagName) {
return scenario.getTags().stream()
- .anyMatch(tag -> tag.getName().equalsIgnoreCase(tagName))
- || feature.getTags().stream()
- .anyMatch(tag -> tag.getName().equalsIgnoreCase(tagName));
+ .anyMatch(tag -> tag.getName().equalsIgnoreCase(tagName))
+ || feature.getTags().stream()
+ .anyMatch(tag -> tag.getName().equalsIgnoreCase(tagName));
}
public boolean isResultTag(final PickleTag tag) {
diff --git a/allure-cucumber4-jvm/src/test/java/io/qameta/allure/cucumber4jvm/AllureCucumber4JvmTest.java b/allure-cucumber4-jvm/src/test/java/io/qameta/allure/cucumber4jvm/AllureCucumber4JvmTest.java
index a957cd88c..640148a10 100644
--- a/allure-cucumber4-jvm/src/test/java/io/qameta/allure/cucumber4jvm/AllureCucumber4JvmTest.java
+++ b/allure-cucumber4-jvm/src/test/java/io/qameta/allure/cucumber4jvm/AllureCucumber4JvmTest.java
@@ -182,7 +182,7 @@ void shouldSetDescription() {
final AllureResults results = runFeature("features/description.feature");
final String expected = "This is description for current feature.\n"
- + "It should appear on each scenario in report";
+ + "It should appear on each scenario in report";
final List testResults = results.getTestResults();
assertThat(testResults)
@@ -199,7 +199,7 @@ void shouldSetScenarioDescription() {
final AllureResults results = runFeature("features/scenario_description.feature");
final String expected = "This is description for current feature.\n"
- + "It should appear on each scenario in report";
+ + "It should appear on each scenario in report";
final List testResults = results.getTestResults();
assertThat(testResults)
@@ -237,11 +237,12 @@ void shouldAddDataTableAttachment() {
final String attachmentContent = new String(bytes, StandardCharsets.UTF_8);
assertThat(attachmentContent)
- .isEqualTo("""
- name\tlogin\temail
- Viktor\tclicman\tclicman@ya.ru
- Viktor2\tclicman2\tclicman2@ya.ru
+ .isEqualTo(
"""
+ name\tlogin\temail
+ Viktor\tclicman\tclicman@ya.ru
+ Viktor2\tclicman2\tclicman2@ya.ru
+ """
);
}
@@ -380,8 +381,14 @@ void shouldAddTags() {
@AllureFeatures.Links
@ExtendWith(SystemPropertyExtension.class)
- @SystemProperty(name = "allure.link.issue.pattern", value = "https://example.org/issue/{}")
- @SystemProperty(name = "allure.link.tms.pattern", value = "https://example.org/tms/{}")
+ @SystemProperty(
+ name = "allure.link.issue.pattern",
+ value = "https://example.org/issue/{}"
+ )
+ @SystemProperty(
+ name = "allure.link.tms.pattern",
+ value = "https://example.org/tms/{}"
+ )
@Test
void shouldAddLinks() {
final AllureResults results = runFeature("features/tags.feature");
@@ -510,8 +517,10 @@ void shouldSupportDryRunForSimpleFeatures() {
@AllureFeatures.Base
@Test
void shouldSupportDryRunForHooks() {
- final AllureResults results = runFeature("features/hooks.feature", "--dry-run", "-t",
- "@WithHooks or @BeforeHookWithException or @AfterHookWithException");
+ final AllureResults results = runFeature(
+ "features/hooks.feature", "--dry-run", "-t",
+ "@WithHooks or @BeforeHookWithException or @AfterHookWithException"
+ );
final TestResult tr1 = results.getTestResultByName("Simple scenario with Before and After hooks");
@@ -651,8 +660,10 @@ void shouldProcessScenariosInParallelMode() {
@AllureFeatures.Stages
@Test
void shouldDisplayHooksAsStages() {
- final AllureResults results = runFeature("features/hooks.feature", "-t",
- "@WithHooks or @BeforeHookWithException or @AfterHookWithException");
+ final AllureResults results = runFeature(
+ "features/hooks.feature", "-t",
+ "@WithHooks or @BeforeHookWithException or @AfterHookWithException"
+ );
final TestResult tr1 = results.getTestResultByName("Simple scenario with Before and After hooks");
final TestResult tr2 = results.getTestResultByName("Simple scenario with Before hook with Exception");
@@ -690,7 +701,6 @@ void shouldDisplayHooksAsStages() {
tuple("Then result is 15", Status.SKIPPED)
);
-
assertThat(results.getTestResultContainersForTestResult(tr2))
.flatExtracting(TestResultContainer::getBefores)
.extracting(FixtureResult::getName, FixtureResult::getStatus)
@@ -736,8 +746,14 @@ void shouldHandleAmbigiousStepsExceptions() {
);
}
- @ResourceLock(value = SYSTEM_PROPERTIES, mode = READ_WRITE)
- @SystemProperty(name = "allure.label.x-provided", value = "cucumberjvm5-test-provided")
+ @ResourceLock(
+ value = SYSTEM_PROPERTIES,
+ mode = READ_WRITE
+ )
+ @SystemProperty(
+ name = "allure.label.x-provided",
+ value = "cucumberjvm5-test-provided"
+ )
@Test
void shouldSupportProvidedLabels() {
final AllureResults results = runFeature("features/simple.feature");
@@ -782,7 +798,10 @@ void shouldSupportRuntimeApiInStepsWhenHooksAreUsed() {
);
}
- @SystemProperty(name = "cucumber.junit-platform.naming-strategy", value = "long")
+ @SystemProperty(
+ name = "cucumber.junit-platform.naming-strategy",
+ value = "long"
+ )
@Step
private AllureResults runFeature(final String featureResource,
final String... moreOptions) {
@@ -790,17 +809,18 @@ private AllureResults runFeature(final String featureResource,
final AllureCucumber4Jvm cucumber4Jvm = new AllureCucumber4Jvm(lifecycle);
final ClassLoader classLoader = currentThread().getContextClassLoader();
final ResourceLoader resourceLoader = new MultiLoader(classLoader);
- final List opts = new ArrayList<>(Arrays.asList(
- "--glue", "io.qameta.allure.cucumber4jvm.samples",
- "--plugin", "null_summary"
- ));
+ final List opts = new ArrayList<>(
+ Arrays.asList(
+ "--glue", "io.qameta.allure.cucumber4jvm.samples",
+ "--plugin", "null_summary"
+ )
+ );
opts.addAll(Arrays.asList(moreOptions));
final FeatureWithLines featureWithLines = FeatureWithLines.parse("src/test/resources/" + featureResource);
final RuntimeOptions options = new CommandlineOptionsParser()
.parse(opts.toArray(new String[]{})).addFeature(featureWithLines).build();
- final FeaturePathFeatureSupplier supplier
- = new FeaturePathFeatureSupplier(new FeatureLoader(resourceLoader), options);
+ final FeaturePathFeatureSupplier supplier = new FeaturePathFeatureSupplier(new FeatureLoader(resourceLoader), options);
final Runtime runtime = Runtime.builder()
.withClassLoader(classLoader)
@@ -813,5 +833,4 @@ private AllureResults runFeature(final String featureResource,
});
}
-
}
diff --git a/allure-cucumber4-jvm/src/test/java/io/qameta/allure/cucumber4jvm/samples/AmbigiousSteps.java b/allure-cucumber4-jvm/src/test/java/io/qameta/allure/cucumber4jvm/samples/AmbigiousSteps.java
index 429e6290c..07de408cf 100644
--- a/allure-cucumber4-jvm/src/test/java/io/qameta/allure/cucumber4jvm/samples/AmbigiousSteps.java
+++ b/allure-cucumber4-jvm/src/test/java/io/qameta/allure/cucumber4jvm/samples/AmbigiousSteps.java
@@ -34,7 +34,7 @@ public void ambigious_2() {
}
@Then("^something bad should happen")
- public void somethingBadStep(){
+ public void somethingBadStep() {
//nothing here
}
}
diff --git a/allure-cucumber4-jvm/src/test/java/io/qameta/allure/cucumber4jvm/samples/AttachmentSteps.java b/allure-cucumber4-jvm/src/test/java/io/qameta/allure/cucumber4jvm/samples/AttachmentSteps.java
index d83071100..75b44942f 100644
--- a/allure-cucumber4-jvm/src/test/java/io/qameta/allure/cucumber4jvm/samples/AttachmentSteps.java
+++ b/allure-cucumber4-jvm/src/test/java/io/qameta/allure/cucumber4jvm/samples/AttachmentSteps.java
@@ -19,25 +19,21 @@
import io.cucumber.java.Before;
import io.cucumber.java.en.Given;
-public class AttachmentSteps
-{
+public class AttachmentSteps {
private Scenario scenario;
@Before("@attachments")
- public void setup(Scenario scenario)
- {
+ public void setup(Scenario scenario) {
this.scenario = scenario;
}
@Given("step with scenario write")
- public void stepWithScenarioWrite()
- {
+ public void stepWithScenarioWrite() {
scenario.write("text attachment");
}
@Given("step with scenario embed")
- public void stepWithScenarioEmbed()
- {
+ public void stepWithScenarioEmbed() {
scenario.embed("image attachment".getBytes(), "image/png");
}
}
diff --git a/allure-cucumber4-jvm/src/test/java/io/qameta/allure/cucumber4jvm/samples/DatatableFeatureSteps.java b/allure-cucumber4-jvm/src/test/java/io/qameta/allure/cucumber4jvm/samples/DatatableFeatureSteps.java
index 158b5ece1..235af0322 100644
--- a/allure-cucumber4-jvm/src/test/java/io/qameta/allure/cucumber4jvm/samples/DatatableFeatureSteps.java
+++ b/allure-cucumber4-jvm/src/test/java/io/qameta/allure/cucumber4jvm/samples/DatatableFeatureSteps.java
@@ -15,8 +15,8 @@
*/
package io.qameta.allure.cucumber4jvm.samples;
-import io.cucumber.java.en.Given;
import io.cucumber.datatable.DataTable;
+import io.cucumber.java.en.Given;
/**
* @author charlie (Dmitry Baev).
diff --git a/allure-cucumber4-jvm/src/test/java/io/qameta/allure/cucumber4jvm/samples/HookSteps.java b/allure-cucumber4-jvm/src/test/java/io/qameta/allure/cucumber4jvm/samples/HookSteps.java
index 2aa7f01ff..9c4666faf 100644
--- a/allure-cucumber4-jvm/src/test/java/io/qameta/allure/cucumber4jvm/samples/HookSteps.java
+++ b/allure-cucumber4-jvm/src/test/java/io/qameta/allure/cucumber4jvm/samples/HookSteps.java
@@ -25,22 +25,22 @@
public class HookSteps {
@Before("@WithHooks")
- public void beforeHook(){
+ public void beforeHook() {
// nothing
}
@After("@WithHooks")
- public void afterHook(){
+ public void afterHook() {
// nothing
}
@Before("@BeforeHookWithException")
- public void beforeHookWithException(){
+ public void beforeHookWithException() {
Assertions.fail("Exception in Hook step");
}
@After("@AfterHookWithException")
- public void afterHookWithException(){
+ public void afterHookWithException() {
Assertions.fail("Exception in Hook step");
}
diff --git a/allure-cucumber4-jvm/src/test/java/io/qameta/allure/cucumber4jvm/samples/RuntimeApiSteps.java b/allure-cucumber4-jvm/src/test/java/io/qameta/allure/cucumber4jvm/samples/RuntimeApiSteps.java
index 4c768742d..16ac13201 100644
--- a/allure-cucumber4-jvm/src/test/java/io/qameta/allure/cucumber4jvm/samples/RuntimeApiSteps.java
+++ b/allure-cucumber4-jvm/src/test/java/io/qameta/allure/cucumber4jvm/samples/RuntimeApiSteps.java
@@ -27,12 +27,12 @@
public class RuntimeApiSteps {
@Before("@beforeScenario")
- public void beforeScenario(){
+ public void beforeScenario() {
// nothing
}
@Before("@beforeFeature")
- public void beforeFeature(){
+ public void beforeFeature() {
// nothing
}
diff --git a/allure-cucumber5-jvm/src/main/java/io/qameta/allure/cucumber5jvm/AllureCucumber5Jvm.java b/allure-cucumber5-jvm/src/main/java/io/qameta/allure/cucumber5jvm/AllureCucumber5Jvm.java
index a0dec5f37..682cc3787 100644
--- a/allure-cucumber5-jvm/src/main/java/io/qameta/allure/cucumber5jvm/AllureCucumber5Jvm.java
+++ b/allure-cucumber5-jvm/src/main/java/io/qameta/allure/cucumber5jvm/AllureCucumber5Jvm.java
@@ -76,11 +76,14 @@
/**
* Allure plugin for Cucumber JVM 5.0.
*/
-@SuppressWarnings({
- "ClassDataAbstractionCoupling",
- "ClassFanOutComplexity",
- "MultipleStringLiterals",
-})
+@SuppressWarnings(
+ {
+ "ClassDataAbstractionCoupling",
+ "ClassFanOutComplexity",
+ "MultipleStringLiterals",
+ "PMD.GodClass",
+ }
+)
public class AllureCucumber5Jvm implements ConcurrentEventListener {
private static final String COLON = ":";
@@ -141,11 +144,11 @@ private void handleTestCaseStarted(final TestCaseStarted event) {
final String name = testCase.getName();
-
// the same way full name is generated for
// org.junit.platform.engine.support.descriptor.ClasspathResourceSource
// to support io.qameta.allure.junitplatform.AllurePostDiscoveryFilter
- final String fullName = String.format("%s:%d",
+ final String fullName = String.format(
+ "%s:%d",
getTestCaseUri(testCase),
testCase.getLine()
);
@@ -165,11 +168,10 @@ private void handleTestCaseStarted(final TestCaseStarted event) {
.setLabels(labelBuilder.getScenarioLabels())
.setLinks(labelBuilder.getScenarioLinks());
- final ScenarioDefinition scenarioDefinition =
- testSources.getScenarioDefinition(
- testCase.getUri(),
- testCase.getLine()
- );
+ final ScenarioDefinition scenarioDefinition = testSources.getScenarioDefinition(
+ testCase.getUri(),
+ testCase.getLine()
+ );
if (scenarioDefinition instanceof ScenarioOutline) {
result.setParameters(
@@ -205,9 +207,10 @@ private void handleTestCaseFinished(final TestCaseFinished event) {
.setMuted(tagParser.isMuted())
.setKnown(tagParser.isKnown());
- lifecycle.updateTestCase(uuid, testResult -> testResult
- .setStatus(status)
- .setStatusDetails(statusDetails)
+ lifecycle.updateTestCase(
+ uuid, testResult -> testResult
+ .setStatus(status)
+ .setStatusDetails(statusDetails)
);
lifecycle.stopTestCase(uuid);
@@ -275,9 +278,10 @@ private void handleStartFixtureHook(final TestCase testCase,
final String containerUuid = hookStepContainerUuid
.computeIfAbsent(hook, unused -> UUID.randomUUID().toString());
- lifecycle.startTestContainer(new TestResultContainer()
- .setUuid(containerUuid)
- .setChildren(Collections.singletonList(uuid))
+ lifecycle.startTestContainer(
+ new TestResultContainer()
+ .setUuid(containerUuid)
+ .setChildren(Collections.singletonList(uuid))
);
final FixtureResult hookResult = new FixtureResult()
@@ -360,15 +364,14 @@ private Status translateTestCaseStatus(final Result testCaseResult) {
}
private List getExamplesAsParameters(
- final ScenarioOutline scenario,
- final TestCase localCurrentTestCase) {
- final Optional maybeExample =
- scenario.getExamples().stream()
- .filter(example -> example.getTableBody().stream()
- .anyMatch(row -> row.getLocation().getLine()
- == localCurrentTestCase.getLine())
- )
- .findFirst();
+ final ScenarioOutline scenario,
+ final TestCase localCurrentTestCase) {
+ final Optional maybeExample = scenario.getExamples().stream()
+ .filter(
+ example -> example.getTableBody().stream()
+ .anyMatch(row -> row.getLocation().getLine() == localCurrentTestCase.getLine())
+ )
+ .findFirst();
if (!maybeExample.isPresent()) {
return Collections.emptyList();
@@ -406,8 +409,10 @@ private void createDataTableAttachment(final DataTableArgument dataTableArgument
}
final String attachmentSource = lifecycle
.prepareAttachment("Data table", "text/tab-separated-values", "csv");
- lifecycle.writeAttachment(attachmentSource,
- new ByteArrayInputStream(dataTableCsv.toString().getBytes(StandardCharsets.UTF_8)));
+ lifecycle.writeAttachment(
+ attachmentSource,
+ new ByteArrayInputStream(dataTableCsv.toString().getBytes(StandardCharsets.UTF_8))
+ );
}
private void handleStopHookStep(final Result eventResult,
@@ -428,9 +433,10 @@ private void handleStopHookStep(final Result eventResult,
final StatusDetails statusDetails = getStatusDetails(eventResult.getError())
.orElseGet(StatusDetails::new);
- lifecycle.updateFixture(uuid, result -> result
- .setStatus(status)
- .setStatusDetails(statusDetails)
+ lifecycle.updateFixture(
+ uuid, result -> result
+ .setStatus(status)
+ .setStatusDetails(statusDetails)
);
lifecycle.stopFixture(uuid);
@@ -451,8 +457,7 @@ private void handleStopStep(final TestCase testCase,
final Status stepStatus = translateTestCaseStatus(eventResult);
- final StatusDetails statusDetails
- = eventResult.getStatus() == io.cucumber.plugin.event.Status.UNDEFINED
+ final StatusDetails statusDetails = eventResult.getStatus() == io.cucumber.plugin.event.Status.UNDEFINED
? new StatusDetails().setMessage("Undefined Step. Please add step definition")
: getStatusDetails(eventResult.getError())
.orElse(new StatusDetails());
diff --git a/allure-cucumber5-jvm/src/main/java/io/qameta/allure/cucumber5jvm/LabelBuilder.java b/allure-cucumber5-jvm/src/main/java/io/qameta/allure/cucumber5jvm/LabelBuilder.java
index 733211486..31d7d53f8 100644
--- a/allure-cucumber5-jvm/src/main/java/io/qameta/allure/cucumber5jvm/LabelBuilder.java
+++ b/allure-cucumber5-jvm/src/main/java/io/qameta/allure/cucumber5jvm/LabelBuilder.java
@@ -15,8 +15,8 @@
*/
package io.qameta.allure.cucumber5jvm;
-import io.cucumber.plugin.event.TestCase;
import gherkin.ast.Feature;
+import io.cucumber.plugin.event.TestCase;
import io.qameta.allure.model.Label;
import io.qameta.allure.model.Link;
import io.qameta.allure.util.ResultsUtils;
@@ -48,7 +48,7 @@
/**
* Scenario labels and links builder.
*/
-@SuppressWarnings({"CyclomaticComplexity", "MultipleStringLiterals"})
+@SuppressWarnings({"CyclomaticComplexity", "MultipleStringLiterals", "PMD.CognitiveComplexity"})
class LabelBuilder {
private static final Logger LOGGER = LoggerFactory.getLogger(LabelBuilder.class);
private static final String COMPOSITE_TAG_DELIMITER = "=";
@@ -113,17 +113,19 @@ class LabelBuilder {
final URI uri = scenario.getUri();
scenarioLabels.addAll(ResultsUtils.getProvidedLabels());
- scenarioLabels.addAll(Arrays.asList(
- createHostLabel(),
- createThreadLabel(),
- createFeatureLabel(featureName),
- createStoryLabel(scenario.getName()),
- createSuiteLabel(featureName),
- createTestClassLabel(scenario.getName()),
- createFrameworkLabel("cucumber5jvm"),
- createLanguageLabel("java"),
- createLabel("gherkin_uri", uri.toString())
- ));
+ scenarioLabels.addAll(
+ Arrays.asList(
+ createHostLabel(),
+ createThreadLabel(),
+ createFeatureLabel(featureName),
+ createStoryLabel(scenario.getName()),
+ createSuiteLabel(featureName),
+ createTestClassLabel(scenario.getName()),
+ createFrameworkLabel("cucumber5jvm"),
+ createLanguageLabel("java"),
+ createLabel("gherkin_uri", uri.toString())
+ )
+ );
featurePackage(uri.toString(), featureName)
.map(ResultsUtils::createPackageLabel)
@@ -156,8 +158,10 @@ private void tryHandleNamedLink(final String tagString) {
final String name = tagString.split(COMPOSITE_TAG_DELIMITER)[1];
scenarioLinks.add(ResultsUtils.createLink(null, name, null, type));
} else {
- LOGGER.warn("Composite named tag {} does not match regex {}. Skipping", tagString,
- namedLinkPatternString);
+ LOGGER.warn(
+ "Composite named tag {} does not match regex {}. Skipping", tagString,
+ namedLinkPatternString
+ );
}
}
@@ -175,10 +179,12 @@ private Optional featurePackage(final String uriString, final String fea
final String schemeSpecificPart = uri.normalize().getSchemeSpecificPart();
final Stream folders = Stream.of(schemeSpecificPart.replaceAll("\\.", "_").split("/"));
final Stream name = Stream.of(featureName);
- return Optional.of(Stream.concat(folders, name)
- .filter(Objects::nonNull)
- .filter(s -> !s.isEmpty())
- .collect(Collectors.joining(".")));
+ return Optional.of(
+ Stream.concat(folders, name)
+ .filter(Objects::nonNull)
+ .filter(s -> !s.isEmpty())
+ .collect(Collectors.joining("."))
+ );
}
private static Optional safeUri(final String uri) {
diff --git a/allure-cucumber5-jvm/src/main/java/io/qameta/allure/cucumber5jvm/TagParser.java b/allure-cucumber5-jvm/src/main/java/io/qameta/allure/cucumber5jvm/TagParser.java
index 5e980a981..e2e31d22f 100644
--- a/allure-cucumber5-jvm/src/main/java/io/qameta/allure/cucumber5jvm/TagParser.java
+++ b/allure-cucumber5-jvm/src/main/java/io/qameta/allure/cucumber5jvm/TagParser.java
@@ -51,9 +51,9 @@ public boolean isKnown() {
private boolean getStatusDetailByTag(final String tagName) {
return scenario.getTags().stream()
- .anyMatch(tag -> tag.equalsIgnoreCase(tagName))
- || feature.getTags().stream()
- .anyMatch(tag -> tag.getName().equalsIgnoreCase(tagName));
+ .anyMatch(tag -> tag.equalsIgnoreCase(tagName))
+ || feature.getTags().stream()
+ .anyMatch(tag -> tag.getName().equalsIgnoreCase(tagName));
}
public boolean isResultTag(final String tag) {
diff --git a/allure-cucumber5-jvm/src/main/java/io/qameta/allure/cucumber5jvm/testsourcemodel/TestSourcesModel.java b/allure-cucumber5-jvm/src/main/java/io/qameta/allure/cucumber5jvm/testsourcemodel/TestSourcesModel.java
index 356783cbf..7249c97a5 100644
--- a/allure-cucumber5-jvm/src/main/java/io/qameta/allure/cucumber5jvm/testsourcemodel/TestSourcesModel.java
+++ b/allure-cucumber5-jvm/src/main/java/io/qameta/allure/cucumber5jvm/testsourcemodel/TestSourcesModel.java
@@ -28,6 +28,7 @@
import gherkin.ast.Step;
import gherkin.ast.TableRow;
import io.cucumber.plugin.event.TestSourceRead;
+
import java.net.URI;
import java.util.HashMap;
import java.util.Map;
@@ -38,7 +39,8 @@ public final class TestSourcesModel {
private final Map> pathToNodeMap = new HashMap<>();
public static ScenarioDefinition getScenarioDefinition(final AstNode astNode) {
- return astNode.node instanceof ScenarioDefinition ? (ScenarioDefinition) astNode.node
+ return astNode.node instanceof ScenarioDefinition
+ ? (ScenarioDefinition) astNode.node
: (ScenarioDefinition) astNode.parent.parent.node;
}
@@ -73,8 +75,10 @@ private void parseGherkinSource(final URI path) {
final Parser parser = new Parser<>(new AstBuilder());
final TokenMatcher matcher = new TokenMatcher();
try {
- final GherkinDocument gherkinDocument = parser.parse(pathToReadEventMap.get(path).getSource(),
- matcher);
+ final GherkinDocument gherkinDocument = parser.parse(
+ pathToReadEventMap.get(path).getSource(),
+ matcher
+ );
pathToAstMap.put(path, gherkinDocument);
final Map nodeMap = new HashMap<>();
final AstNode currentParent = new AstNode(gherkinDocument.getFeature(), null);
@@ -83,8 +87,10 @@ private void parseGherkinSource(final URI path) {
}
pathToNodeMap.put(path, nodeMap);
} catch (ParserException e) {
- throw new IllegalStateException("You are using a plugin that only supports till Gherkin 5.\n"
- + "Please check if the Gherkin provided follows the standard of Gherkin 5\n", e
+ throw new IllegalStateException(
+ "You are using a plugin that only supports till Gherkin 5.\n"
+ + "Please check if the Gherkin provided follows the standard of Gherkin 5\n",
+ e
);
}
}
diff --git a/allure-cucumber5-jvm/src/test/java/io/qameta/allure/cucumber5jvm/AllureCucumber5JvmTest.java b/allure-cucumber5-jvm/src/test/java/io/qameta/allure/cucumber5jvm/AllureCucumber5JvmTest.java
index ff4a2e24e..11f282717 100644
--- a/allure-cucumber5-jvm/src/test/java/io/qameta/allure/cucumber5jvm/AllureCucumber5JvmTest.java
+++ b/allure-cucumber5-jvm/src/test/java/io/qameta/allure/cucumber5jvm/AllureCucumber5JvmTest.java
@@ -185,7 +185,7 @@ void shouldSetDescription() {
final AllureResults results = runFeature("features/description.feature");
final String expected = "This is description for current feature.\n"
- + "It should appear on each scenario in report";
+ + "It should appear on each scenario in report";
final List testResults = results.getTestResults();
assertThat(testResults)
@@ -202,7 +202,7 @@ void shouldSetScenarioDescription() {
final AllureResults results = runFeature("features/scenario_description.feature");
final String expected = "This is description for current feature.\n"
- + "It should appear on each scenario in report";
+ + "It should appear on each scenario in report";
final List testResults = results.getTestResults();
assertThat(testResults)
@@ -240,11 +240,12 @@ void shouldAddDataTableAttachment() {
final String attachmentContent = new String(bytes, StandardCharsets.UTF_8);
assertThat(attachmentContent)
- .isEqualTo("""
- name\tlogin\temail
- Viktor\tclicman\tclicman@ya.ru
- Viktor2\tclicman2\tclicman2@ya.ru
+ .isEqualTo(
"""
+ name\tlogin\temail
+ Viktor\tclicman\tclicman@ya.ru
+ Viktor2\tclicman2\tclicman2@ya.ru
+ """
);
}
@@ -383,8 +384,14 @@ void shouldAddTags() {
@AllureFeatures.Links
@ExtendWith(SystemPropertyExtension.class)
- @SystemProperty(name = "allure.link.issue.pattern", value = "https://example.org/issue/{}")
- @SystemProperty(name = "allure.link.tms.pattern", value = "https://example.org/tms/{}")
+ @SystemProperty(
+ name = "allure.link.issue.pattern",
+ value = "https://example.org/issue/{}"
+ )
+ @SystemProperty(
+ name = "allure.link.tms.pattern",
+ value = "https://example.org/tms/{}"
+ )
@Test
void shouldAddLinks() {
final AllureResults results = runFeature("features/tags.feature");
@@ -513,8 +520,10 @@ void shouldSupportDryRunForSimpleFeatures() {
@AllureFeatures.Base
@Test
void shouldSupportDryRunForHooks() {
- final AllureResults results = runFeature("features/hooks.feature", "--dry-run", "-t",
- "@WithHooks or @BeforeHookWithException or @AfterHookWithException");
+ final AllureResults results = runFeature(
+ "features/hooks.feature", "--dry-run", "-t",
+ "@WithHooks or @BeforeHookWithException or @AfterHookWithException"
+ );
final TestResult tr1 = results.getTestResultByName("Simple scenario with Before and After hooks");
@@ -654,8 +663,10 @@ void shouldProcessScenariosInParallelMode() {
@AllureFeatures.Stages
@Test
void shouldDisplayHooksAsStages() {
- final AllureResults results = runFeature("features/hooks.feature", "-t",
- "@WithHooks or @BeforeHookWithException or @AfterHookWithException");
+ final AllureResults results = runFeature(
+ "features/hooks.feature", "-t",
+ "@WithHooks or @BeforeHookWithException or @AfterHookWithException"
+ );
final TestResult tr1 = results.getTestResultByName("Simple scenario with Before and After hooks");
final TestResult tr2 = results.getTestResultByName("Simple scenario with Before hook with Exception");
@@ -693,7 +704,6 @@ void shouldDisplayHooksAsStages() {
tuple("Then result is 15", Status.SKIPPED)
);
-
assertThat(results.getTestResultContainersForTestResult(tr2))
.flatExtracting(TestResultContainer::getBefores)
.extracting(FixtureResult::getName, FixtureResult::getStatus)
@@ -739,8 +749,14 @@ void shouldHandleAmbigiousStepsExceptions() {
);
}
- @ResourceLock(value = SYSTEM_PROPERTIES, mode = READ_WRITE)
- @SystemProperty(name = "allure.label.x-provided", value = "cucumberjvm5-test-provided")
+ @ResourceLock(
+ value = SYSTEM_PROPERTIES,
+ mode = READ_WRITE
+ )
+ @SystemProperty(
+ name = "allure.label.x-provided",
+ value = "cucumberjvm5-test-provided"
+ )
@Test
void shouldSupportProvidedLabels() {
final AllureResults results = runFeature("features/simple.feature");
@@ -785,17 +801,22 @@ void shouldSupportRuntimeApiInStepsWhenHooksAreUsed() {
);
}
- @SystemProperty(name = "cucumber.junit-platform.naming-strategy", value = "long")
+ @SystemProperty(
+ name = "cucumber.junit-platform.naming-strategy",
+ value = "long"
+ )
@Step
private AllureResults runFeature(final String featureResource,
final String... moreOptions) {
return RunUtils.runTests(lifecycle -> {
final AllureCucumber5Jvm cucumber5jvm = new AllureCucumber5Jvm(lifecycle);
final Supplier classLoader = ClassLoaders::getDefaultClassLoader;
- final List opts = new ArrayList<>(Arrays.asList(
- "--glue", "io.qameta.allure.cucumber5jvm.samples",
- "--plugin", "null_summary"
- ));
+ final List opts = new ArrayList<>(
+ Arrays.asList(
+ "--glue", "io.qameta.allure.cucumber5jvm.samples",
+ "--plugin", "null_summary"
+ )
+ );
opts.addAll(Arrays.asList(moreOptions));
final FeatureWithLines featureWithLines = FeatureWithLines.parse("src/test/resources/" + featureResource);
final RuntimeOptions options = new CommandlineOptionsParser()
@@ -803,8 +824,7 @@ private AllureResults runFeature(final String featureResource,
final EventBus bus = new TimeServiceEventBus(Clock.systemUTC(), UUID::randomUUID);
final FeatureParser parser = new FeatureParser(bus::generateId);
- final FeaturePathFeatureSupplier supplier
- = new FeaturePathFeatureSupplier(classLoader, options, parser);
+ final FeaturePathFeatureSupplier supplier = new FeaturePathFeatureSupplier(classLoader, options, parser);
final Runtime runtime = Runtime.builder()
.withClassLoader(classLoader)
@@ -817,5 +837,4 @@ private AllureResults runFeature(final String featureResource,
});
}
-
}
diff --git a/allure-cucumber5-jvm/src/test/java/io/qameta/allure/cucumber5jvm/samples/AmbigiousSteps.java b/allure-cucumber5-jvm/src/test/java/io/qameta/allure/cucumber5jvm/samples/AmbigiousSteps.java
index 3e605bb67..fe41e55b3 100644
--- a/allure-cucumber5-jvm/src/test/java/io/qameta/allure/cucumber5jvm/samples/AmbigiousSteps.java
+++ b/allure-cucumber5-jvm/src/test/java/io/qameta/allure/cucumber5jvm/samples/AmbigiousSteps.java
@@ -34,7 +34,7 @@ public void ambigious_2() {
}
@Then("^something bad should happen")
- public void somethingBadStep(){
+ public void somethingBadStep() {
//nothing here
}
}
diff --git a/allure-cucumber5-jvm/src/test/java/io/qameta/allure/cucumber5jvm/samples/AttachmentSteps.java b/allure-cucumber5-jvm/src/test/java/io/qameta/allure/cucumber5jvm/samples/AttachmentSteps.java
index a4489b086..1310cb9d4 100644
--- a/allure-cucumber5-jvm/src/test/java/io/qameta/allure/cucumber5jvm/samples/AttachmentSteps.java
+++ b/allure-cucumber5-jvm/src/test/java/io/qameta/allure/cucumber5jvm/samples/AttachmentSteps.java
@@ -15,29 +15,25 @@
*/
package io.qameta.allure.cucumber5jvm.samples;
-import io.cucumber.java.Scenario;
import io.cucumber.java.Before;
+import io.cucumber.java.Scenario;
import io.cucumber.java.en.Given;
-public class AttachmentSteps
-{
+public class AttachmentSteps {
private Scenario scenario;
@Before("@attachments")
- public void setup(Scenario scenario)
- {
+ public void setup(Scenario scenario) {
this.scenario = scenario;
}
@Given("step with scenario write")
- public void stepWithScenarioWrite()
- {
+ public void stepWithScenarioWrite() {
scenario.write("text attachment");
}
@Given("step with scenario embed")
- public void stepWithScenarioEmbed()
- {
- scenario.embed("image attachment".getBytes(), "image/png","ImageAttachment");
+ public void stepWithScenarioEmbed() {
+ scenario.embed("image attachment".getBytes(), "image/png", "ImageAttachment");
}
}
diff --git a/allure-cucumber5-jvm/src/test/java/io/qameta/allure/cucumber5jvm/samples/HookSteps.java b/allure-cucumber5-jvm/src/test/java/io/qameta/allure/cucumber5jvm/samples/HookSteps.java
index 775d90860..8c7162e77 100644
--- a/allure-cucumber5-jvm/src/test/java/io/qameta/allure/cucumber5jvm/samples/HookSteps.java
+++ b/allure-cucumber5-jvm/src/test/java/io/qameta/allure/cucumber5jvm/samples/HookSteps.java
@@ -25,22 +25,22 @@
public class HookSteps {
@Before("@WithHooks")
- public void beforeHook(){
+ public void beforeHook() {
// nothing
}
@After("@WithHooks")
- public void afterHook(){
+ public void afterHook() {
// nothing
}
@Before("@BeforeHookWithException")
- public void beforeHookWithException(){
+ public void beforeHookWithException() {
Assertions.fail("Exception in Hook step");
}
@After("@AfterHookWithException")
- public void afterHookWithException(){
+ public void afterHookWithException() {
Assertions.fail("Exception in Hook step");
}
diff --git a/allure-cucumber5-jvm/src/test/java/io/qameta/allure/cucumber5jvm/samples/RuntimeApiSteps.java b/allure-cucumber5-jvm/src/test/java/io/qameta/allure/cucumber5jvm/samples/RuntimeApiSteps.java
index 581b2afe5..f507b64ad 100644
--- a/allure-cucumber5-jvm/src/test/java/io/qameta/allure/cucumber5jvm/samples/RuntimeApiSteps.java
+++ b/allure-cucumber5-jvm/src/test/java/io/qameta/allure/cucumber5jvm/samples/RuntimeApiSteps.java
@@ -27,12 +27,12 @@
public class RuntimeApiSteps {
@Before("@beforeScenario")
- public void beforeScenario(){
+ public void beforeScenario() {
// nothing
}
@Before("@beforeFeature")
- public void beforeFeature(){
+ public void beforeFeature() {
// nothing
}
diff --git a/allure-cucumber6-jvm/src/main/java/io/qameta/allure/cucumber6jvm/AllureCucumber6Jvm.java b/allure-cucumber6-jvm/src/main/java/io/qameta/allure/cucumber6jvm/AllureCucumber6Jvm.java
index 67f11b0a8..c7384b9ba 100644
--- a/allure-cucumber6-jvm/src/main/java/io/qameta/allure/cucumber6jvm/AllureCucumber6Jvm.java
+++ b/allure-cucumber6-jvm/src/main/java/io/qameta/allure/cucumber6jvm/AllureCucumber6Jvm.java
@@ -74,13 +74,16 @@
/**
* Allure plugin for Cucumber JVM 6.0.
*/
-@SuppressWarnings({
- "ClassDataAbstractionCoupling",
- "ClassFanOutComplexity",
-})
+@SuppressWarnings(
+ {
+ "ClassDataAbstractionCoupling",
+ "ClassFanOutComplexity",
+ }
+)
public class AllureCucumber6Jvm implements ConcurrentEventListener {
private static final String COLON = ":";
+ private static final String NEW_LINE = "\n";
private final AllureLifecycle lifecycle;
@@ -136,11 +139,11 @@ private void handleTestCaseStarted(final TestCaseStarted event) {
final String name = testCase.getName();
-
// the same way full name is generated for
// org.junit.platform.engine.support.descriptor.ClasspathResourceSource
// to support io.qameta.allure.junitplatform.AllurePostDiscoveryFilter
- final String fullName = String.format("%s:%d",
+ final String fullName = String.format(
+ "%s:%d",
getTestCaseUri(testCase),
testCase.getLocation().getLine()
);
@@ -160,11 +163,10 @@ private void handleTestCaseStarted(final TestCaseStarted event) {
.setLabels(labelBuilder.getScenarioLabels())
.setLinks(labelBuilder.getScenarioLinks());
- final Scenario scenarioDefinition =
- testSources.getScenarioDefinition(
- testCase.getUri(),
- testCase.getLocation().getLine()
- );
+ final Scenario scenarioDefinition = testSources.getScenarioDefinition(
+ testCase.getUri(),
+ testCase.getLocation().getLine()
+ );
if (scenarioDefinition.getExamplesList() != null) {
result.setParameters(
@@ -175,7 +177,7 @@ private void handleTestCaseStarted(final TestCaseStarted event) {
final String description = Stream.of(feature.getDescription(), scenarioDefinition.getDescription())
.filter(Objects::nonNull)
.filter(s -> !s.isEmpty())
- .collect(Collectors.joining("\n"));
+ .collect(Collectors.joining(NEW_LINE));
if (!description.isEmpty()) {
result.setDescription(description);
@@ -200,9 +202,10 @@ private void handleTestCaseFinished(final TestCaseFinished event) {
.setMuted(tagParser.isMuted())
.setKnown(tagParser.isKnown());
- lifecycle.updateTestCase(uuid, testResult -> testResult
- .setStatus(status)
- .setStatusDetails(statusDetails)
+ lifecycle.updateTestCase(
+ uuid, testResult -> testResult
+ .setStatus(status)
+ .setStatusDetails(statusDetails)
);
lifecycle.stopTestCase(uuid);
@@ -262,9 +265,10 @@ private void handleStartFixtureHook(final TestCase testCase,
final String containerUuid = hookStepContainerUuid
.computeIfAbsent(hookId, unused -> UUID.randomUUID().toString());
- lifecycle.startTestContainer(new TestResultContainer()
- .setUuid(containerUuid)
- .setChildren(Collections.singletonList(uuid))
+ lifecycle.startTestContainer(
+ new TestResultContainer()
+ .setUuid(containerUuid)
+ .setChildren(Collections.singletonList(uuid))
);
final FixtureResult hookResult = new FixtureResult()
@@ -345,15 +349,14 @@ private Status translateTestCaseStatus(final Result testCaseResult) {
}
private List getExamplesAsParameters(
- final Scenario scenario,
- final TestCase localCurrentTestCase) {
- final Optional maybeExample =
- scenario.getExamplesList().stream()
- .filter(example -> example.getTableBodyList().stream()
- .anyMatch(row -> row.getLocation().getLine()
- == localCurrentTestCase.getLocation().getLine())
- )
- .findFirst();
+ final Scenario scenario,
+ final TestCase localCurrentTestCase) {
+ final Optional maybeExample = scenario.getExamplesList().stream()
+ .filter(
+ example -> example.getTableBodyList().stream()
+ .anyMatch(row -> row.getLocation().getLine() == localCurrentTestCase.getLocation().getLine())
+ )
+ .findFirst();
if (!maybeExample.isPresent()) {
return Collections.emptyList();
@@ -385,14 +388,16 @@ private void createDataTableAttachment(final DataTableArgument dataTableArgument
final StringBuilder dataTableCsv = new StringBuilder();
for (List columns : rowsInTable) {
if (!columns.isEmpty()) {
- final String rowValue = columns.stream().collect(Collectors.joining("\t", "", "\n"));
+ final String rowValue = columns.stream().collect(Collectors.joining("\t", "", NEW_LINE));
dataTableCsv.append(rowValue);
}
}
final String attachmentSource = lifecycle
.prepareAttachment("Data table", "text/tab-separated-values", "csv");
- lifecycle.writeAttachment(attachmentSource,
- new ByteArrayInputStream(dataTableCsv.toString().getBytes(StandardCharsets.UTF_8)));
+ lifecycle.writeAttachment(
+ attachmentSource,
+ new ByteArrayInputStream(dataTableCsv.toString().getBytes(StandardCharsets.UTF_8))
+ );
}
private void handleStopHookStep(final Result eventResult,
@@ -409,9 +414,10 @@ private void handleStopHookStep(final Result eventResult,
final StatusDetails statusDetails = getStatusDetails(eventResult.getError())
.orElseGet(StatusDetails::new);
- lifecycle.updateFixture(uuid, result -> result
- .setStatus(status)
- .setStatusDetails(statusDetails)
+ lifecycle.updateFixture(
+ uuid, result -> result
+ .setStatus(status)
+ .setStatusDetails(statusDetails)
);
lifecycle.stopFixture(uuid);
@@ -426,8 +432,7 @@ private void handleStopStep(final TestCase testCase,
final Status stepStatus = translateTestCaseStatus(eventResult);
- final StatusDetails statusDetails
- = eventResult.getStatus() == io.cucumber.plugin.event.Status.UNDEFINED
+ final StatusDetails statusDetails = eventResult.getStatus() == io.cucumber.plugin.event.Status.UNDEFINED
? new StatusDetails().setMessage("Undefined Step. Please add step definition")
: getStatusDetails(eventResult.getError())
.orElse(new StatusDetails());
diff --git a/allure-cucumber6-jvm/src/main/java/io/qameta/allure/cucumber6jvm/LabelBuilder.java b/allure-cucumber6-jvm/src/main/java/io/qameta/allure/cucumber6jvm/LabelBuilder.java
index 9684b9d51..794b78aff 100644
--- a/allure-cucumber6-jvm/src/main/java/io/qameta/allure/cucumber6jvm/LabelBuilder.java
+++ b/allure-cucumber6-jvm/src/main/java/io/qameta/allure/cucumber6jvm/LabelBuilder.java
@@ -48,7 +48,7 @@
/**
* Scenario labels and links builder.
*/
-@SuppressWarnings({"CyclomaticComplexity", "MultipleStringLiterals"})
+@SuppressWarnings({"CyclomaticComplexity", "MultipleStringLiterals", "PMD.CognitiveComplexity"})
class LabelBuilder {
private static final Logger LOGGER = LoggerFactory.getLogger(LabelBuilder.class);
private static final String COMPOSITE_TAG_DELIMITER = "=";
@@ -113,17 +113,19 @@ class LabelBuilder {
final URI uri = scenario.getUri();
scenarioLabels.addAll(ResultsUtils.getProvidedLabels());
- scenarioLabels.addAll(Arrays.asList(
- createHostLabel(),
- createThreadLabel(),
- createFeatureLabel(featureName),
- createStoryLabel(scenario.getName()),
- createSuiteLabel(featureName),
- createTestClassLabel(scenario.getName()),
- createFrameworkLabel("cucumber6jvm"),
- createLanguageLabel("java"),
- createLabel("gherkin_uri", uri.toString())
- ));
+ scenarioLabels.addAll(
+ Arrays.asList(
+ createHostLabel(),
+ createThreadLabel(),
+ createFeatureLabel(featureName),
+ createStoryLabel(scenario.getName()),
+ createSuiteLabel(featureName),
+ createTestClassLabel(scenario.getName()),
+ createFrameworkLabel("cucumber6jvm"),
+ createLanguageLabel("java"),
+ createLabel("gherkin_uri", uri.toString())
+ )
+ );
featurePackage(uri.toString(), featureName)
.map(ResultsUtils::createPackageLabel)
@@ -156,8 +158,10 @@ private void tryHandleNamedLink(final String tagString) {
final String name = tagString.split(COMPOSITE_TAG_DELIMITER)[1];
scenarioLinks.add(ResultsUtils.createLink(null, name, null, type));
} else {
- LOGGER.warn("Composite named tag {} does not match regex {}. Skipping", tagString,
- namedLinkPatternString);
+ LOGGER.warn(
+ "Composite named tag {} does not match regex {}. Skipping", tagString,
+ namedLinkPatternString
+ );
}
}
@@ -175,10 +179,12 @@ private Optional featurePackage(final String uriString, final String fea
final String schemeSpecificPart = uri.normalize().getSchemeSpecificPart();
final Stream folders = Stream.of(schemeSpecificPart.replaceAll("\\.", "_").split("/"));
final Stream name = Stream.of(featureName);
- return Optional.of(Stream.concat(folders, name)
- .filter(Objects::nonNull)
- .filter(s -> !s.isEmpty())
- .collect(Collectors.joining(".")));
+ return Optional.of(
+ Stream.concat(folders, name)
+ .filter(Objects::nonNull)
+ .filter(s -> !s.isEmpty())
+ .collect(Collectors.joining("."))
+ );
}
private static Optional safeUri(final String uri) {
diff --git a/allure-cucumber6-jvm/src/main/java/io/qameta/allure/cucumber6jvm/TagParser.java b/allure-cucumber6-jvm/src/main/java/io/qameta/allure/cucumber6jvm/TagParser.java
index 3d31fdef5..66644299e 100644
--- a/allure-cucumber6-jvm/src/main/java/io/qameta/allure/cucumber6jvm/TagParser.java
+++ b/allure-cucumber6-jvm/src/main/java/io/qameta/allure/cucumber6jvm/TagParser.java
@@ -51,9 +51,9 @@ public boolean isKnown() {
private boolean getStatusDetailByTag(final String tagName) {
return scenario.getTags().stream()
- .anyMatch(tag -> tag.equalsIgnoreCase(tagName))
- || feature.getTagsList().stream()
- .anyMatch(tag -> tag.getName().equalsIgnoreCase(tagName));
+ .anyMatch(tag -> tag.equalsIgnoreCase(tagName))
+ || feature.getTagsList().stream()
+ .anyMatch(tag -> tag.getName().equalsIgnoreCase(tagName));
}
public boolean isResultTag(final String tag) {
diff --git a/allure-cucumber6-jvm/src/main/java/io/qameta/allure/cucumber6jvm/testsourcemodel/TestSourcesModel.java b/allure-cucumber6-jvm/src/main/java/io/qameta/allure/cucumber6jvm/testsourcemodel/TestSourcesModel.java
index 2a338e95f..2fa406eac 100644
--- a/allure-cucumber6-jvm/src/main/java/io/qameta/allure/cucumber6jvm/testsourcemodel/TestSourcesModel.java
+++ b/allure-cucumber6-jvm/src/main/java/io/qameta/allure/cucumber6jvm/testsourcemodel/TestSourcesModel.java
@@ -73,14 +73,16 @@ private void parseGherkinSource(final URI path) {
final String source = pathToReadEventMap.get(path).getSource();
final List sources = singletonList(
- makeSourceEnvelope(source, path.toString()));
+ makeSourceEnvelope(source, path.toString())
+ );
final List envelopes = Gherkin.fromSources(
sources,
true,
true,
true,
- () -> String.valueOf(UUID.randomUUID())).collect(toList());
+ () -> String.valueOf(UUID.randomUUID())
+ ).collect(toList());
final GherkinDocument gherkinDocument = envelopes.stream()
.filter(Messages.Envelope::hasGherkinDocument)
@@ -99,7 +101,7 @@ private void parseGherkinSource(final URI path) {
}
private void processFeatureDefinition(
- final Map nodeMap, final FeatureChild child, final AstNode currentParent) {
+ final Map nodeMap, final FeatureChild child, final AstNode currentParent) {
if (child.hasBackground()) {
processBackgroundDefinition(nodeMap, child.getBackground(), currentParent);
} else if (child.hasScenario()) {
@@ -114,8 +116,7 @@ private void processFeatureDefinition(
}
private void processBackgroundDefinition(
- final Map nodeMap, final Background background, final AstNode currentParent
- ) {
+ final Map nodeMap, final Background background, final AstNode currentParent) {
final AstNode childNode = createAstNode(background, currentParent);
nodeMap.put(background.getLocation().getLine(), childNode);
for (Step step : background.getStepsList()) {
@@ -124,7 +125,7 @@ private void processBackgroundDefinition(
}
private void processScenarioDefinition(
- final Map nodeMap, final Scenario child, final AstNode currentParent) {
+ final Map nodeMap, final Scenario child, final AstNode currentParent) {
final AstNode childNode = createAstNode(child, currentParent);
nodeMap.put(child.getLocation().getLine(), childNode);
for (Step step : child.getStepsList()) {
@@ -136,7 +137,7 @@ private void processScenarioDefinition(
}
private void processRuleDefinition(
- final Map nodeMap, final RuleChild child, final AstNode currentParent) {
+ final Map nodeMap, final RuleChild child, final AstNode currentParent) {
if (child.hasBackground()) {
processBackgroundDefinition(nodeMap, child.getBackground(), currentParent);
} else if (child.hasScenario()) {
@@ -145,8 +146,7 @@ private void processRuleDefinition(
}
private void processScenarioOutlineExamples(
- final Map nodeMap, final Scenario scenarioOutline, final AstNode parent
- ) {
+ final Map nodeMap, final Scenario scenarioOutline, final AstNode parent) {
for (Examples examples : scenarioOutline.getExamplesList()) {
final AstNode examplesNode = createAstNode(examples, parent);
final TableRow headerRow = examples.getTableHeader();
diff --git a/allure-cucumber6-jvm/src/test/java/io/qameta/allure/cucumber6jvm/AllureCucumber6JvmTest.java b/allure-cucumber6-jvm/src/test/java/io/qameta/allure/cucumber6jvm/AllureCucumber6JvmTest.java
index 50c32afab..6788dc6c5 100644
--- a/allure-cucumber6-jvm/src/test/java/io/qameta/allure/cucumber6jvm/AllureCucumber6JvmTest.java
+++ b/allure-cucumber6-jvm/src/test/java/io/qameta/allure/cucumber6jvm/AllureCucumber6JvmTest.java
@@ -185,7 +185,7 @@ void shouldSetDescription() {
final AllureResults results = runFeature("features/description.feature");
final String expected = "This is description for current feature.\n"
- + "It should appear on each scenario in report";
+ + "It should appear on each scenario in report";
final List testResults = results.getTestResults();
assertThat(testResults)
@@ -202,7 +202,7 @@ void shouldSetScenarioDescription() {
final AllureResults results = runFeature("features/scenario_description.feature");
final String expected = "This is description for current feature.\n"
- + "It should appear on each scenario in report";
+ + "It should appear on each scenario in report";
final List testResults = results.getTestResults();
assertThat(testResults)
@@ -240,11 +240,12 @@ void shouldAddDataTableAttachment() {
final String attachmentContent = new String(bytes, StandardCharsets.UTF_8);
assertThat(attachmentContent)
- .isEqualTo("""
- name\tlogin\temail
- Viktor\tclicman\tclicman@ya.ru
- Viktor2\tclicman2\tclicman2@ya.ru
+ .isEqualTo(
"""
+ name\tlogin\temail
+ Viktor\tclicman\tclicman@ya.ru
+ Viktor2\tclicman2\tclicman2@ya.ru
+ """
);
}
@@ -383,8 +384,14 @@ void shouldAddTags() {
@AllureFeatures.Links
@ExtendWith(SystemPropertyExtension.class)
- @SystemProperty(name = "allure.link.issue.pattern", value = "https://example.org/issue/{}")
- @SystemProperty(name = "allure.link.tms.pattern", value = "https://example.org/tms/{}")
+ @SystemProperty(
+ name = "allure.link.issue.pattern",
+ value = "https://example.org/issue/{}"
+ )
+ @SystemProperty(
+ name = "allure.link.tms.pattern",
+ value = "https://example.org/tms/{}"
+ )
@Test
void shouldAddLinks() {
final AllureResults results = runFeature("features/tags.feature");
@@ -513,8 +520,10 @@ void shouldSupportDryRunForSimpleFeatures() {
@AllureFeatures.Base
@Test
void shouldSupportDryRunForHooks() {
- final AllureResults results = runFeature("features/hooks.feature", "--dry-run", "-t",
- "@WithHooks or @BeforeHookWithException or @AfterHookWithException");
+ final AllureResults results = runFeature(
+ "features/hooks.feature", "--dry-run", "-t",
+ "@WithHooks or @BeforeHookWithException or @AfterHookWithException"
+ );
final TestResult tr1 = results.getTestResultByName("Simple scenario with Before and After hooks");
@@ -654,8 +663,10 @@ void shouldProcessScenariosInParallelMode() {
@AllureFeatures.Stages
@Test
void shouldDisplayHooksAsStages() {
- final AllureResults results = runFeature("features/hooks.feature", "-t",
- "@WithHooks or @BeforeHookWithException or @AfterHookWithException");
+ final AllureResults results = runFeature(
+ "features/hooks.feature", "-t",
+ "@WithHooks or @BeforeHookWithException or @AfterHookWithException"
+ );
final TestResult tr1 = results.getTestResultByName("Simple scenario with Before and After hooks");
final TestResult tr2 = results.getTestResultByName("Simple scenario with Before hook with Exception");
@@ -693,7 +704,6 @@ void shouldDisplayHooksAsStages() {
tuple("Then result is 15", Status.SKIPPED)
);
-
assertThat(results.getTestResultContainersForTestResult(tr2))
.flatExtracting(TestResultContainer::getBefores)
.extracting(FixtureResult::getName, FixtureResult::getStatus)
@@ -739,8 +749,14 @@ void shouldHandleAmbigiousStepsExceptions() {
);
}
- @ResourceLock(value = SYSTEM_PROPERTIES, mode = READ_WRITE)
- @SystemProperty(name = "allure.label.x-provided", value = "cucumberjvm6-test-provided")
+ @ResourceLock(
+ value = SYSTEM_PROPERTIES,
+ mode = READ_WRITE
+ )
+ @SystemProperty(
+ name = "allure.label.x-provided",
+ value = "cucumberjvm6-test-provided"
+ )
@Test
void shouldSupportProvidedLabels() {
final AllureResults results = runFeature("features/simple.feature");
@@ -785,17 +801,22 @@ void shouldSupportRuntimeApiInStepsWhenHooksAreUsed() {
);
}
- @SystemProperty(name = "cucumber.junit-platform.naming-strategy", value = "long")
+ @SystemProperty(
+ name = "cucumber.junit-platform.naming-strategy",
+ value = "long"
+ )
@Step
private AllureResults runFeature(final String featureResource,
final String... moreOptions) {
return RunUtils.runTests(lifecycle -> {
final AllureCucumber6Jvm cucumber6jvm = new AllureCucumber6Jvm(lifecycle);
final Supplier classLoader = ClassLoaders::getDefaultClassLoader;
- final List opts = new ArrayList<>(Arrays.asList(
- "--glue", "io.qameta.allure.cucumber6jvm.samples",
- "--plugin", "null_summary"
- ));
+ final List opts = new ArrayList<>(
+ Arrays.asList(
+ "--glue", "io.qameta.allure.cucumber6jvm.samples",
+ "--plugin", "null_summary"
+ )
+ );
opts.addAll(Arrays.asList(moreOptions));
final FeatureWithLines featureWithLines = FeatureWithLines.parse("src/test/resources/" + featureResource);
final RuntimeOptions options = new CommandlineOptionsParser(System.out)
@@ -803,8 +824,7 @@ private AllureResults runFeature(final String featureResource,
final EventBus bus = new TimeServiceEventBus(Clock.systemUTC(), UUID::randomUUID);
final FeatureParser parser = new FeatureParser(bus::generateId);
- final FeaturePathFeatureSupplier supplier
- = new FeaturePathFeatureSupplier(classLoader, options, parser);
+ final FeaturePathFeatureSupplier supplier = new FeaturePathFeatureSupplier(classLoader, options, parser);
final Runtime runtime = Runtime.builder()
.withClassLoader(classLoader)
diff --git a/allure-cucumber6-jvm/src/test/java/io/qameta/allure/cucumber6jvm/samples/AmbigiousSteps.java b/allure-cucumber6-jvm/src/test/java/io/qameta/allure/cucumber6jvm/samples/AmbigiousSteps.java
index 5a2e5a126..22a70c07f 100644
--- a/allure-cucumber6-jvm/src/test/java/io/qameta/allure/cucumber6jvm/samples/AmbigiousSteps.java
+++ b/allure-cucumber6-jvm/src/test/java/io/qameta/allure/cucumber6jvm/samples/AmbigiousSteps.java
@@ -34,7 +34,7 @@ public void ambigious_2() {
}
@Then("^something bad should happen")
- public void somethingBadStep(){
+ public void somethingBadStep() {
//nothing here
}
}
diff --git a/allure-cucumber6-jvm/src/test/java/io/qameta/allure/cucumber6jvm/samples/AttachmentSteps.java b/allure-cucumber6-jvm/src/test/java/io/qameta/allure/cucumber6jvm/samples/AttachmentSteps.java
index 6a9393a89..2b72de701 100644
--- a/allure-cucumber6-jvm/src/test/java/io/qameta/allure/cucumber6jvm/samples/AttachmentSteps.java
+++ b/allure-cucumber6-jvm/src/test/java/io/qameta/allure/cucumber6jvm/samples/AttachmentSteps.java
@@ -15,8 +15,8 @@
*/
package io.qameta.allure.cucumber6jvm.samples;
-import io.cucumber.java.Scenario;
import io.cucumber.java.Before;
+import io.cucumber.java.Scenario;
import io.cucumber.java.en.Given;
public class AttachmentSteps {
diff --git a/allure-cucumber6-jvm/src/test/java/io/qameta/allure/cucumber6jvm/samples/HookSteps.java b/allure-cucumber6-jvm/src/test/java/io/qameta/allure/cucumber6jvm/samples/HookSteps.java
index d7fe2a8e0..5ca9cc61a 100644
--- a/allure-cucumber6-jvm/src/test/java/io/qameta/allure/cucumber6jvm/samples/HookSteps.java
+++ b/allure-cucumber6-jvm/src/test/java/io/qameta/allure/cucumber6jvm/samples/HookSteps.java
@@ -25,22 +25,22 @@
public class HookSteps {
@Before("@WithHooks")
- public void beforeHook(){
+ public void beforeHook() {
// nothing
}
@After("@WithHooks")
- public void afterHook(){
+ public void afterHook() {
// nothing
}
@Before("@BeforeHookWithException")
- public void beforeHookWithException(){
+ public void beforeHookWithException() {
Assertions.fail("Exception in Hook step");
}
@After("@AfterHookWithException")
- public void afterHookWithException(){
+ public void afterHookWithException() {
Assertions.fail("Exception in Hook step");
}
diff --git a/allure-cucumber6-jvm/src/test/java/io/qameta/allure/cucumber6jvm/samples/RuntimeApiSteps.java b/allure-cucumber6-jvm/src/test/java/io/qameta/allure/cucumber6jvm/samples/RuntimeApiSteps.java
index 7438ea192..4fd9281df 100644
--- a/allure-cucumber6-jvm/src/test/java/io/qameta/allure/cucumber6jvm/samples/RuntimeApiSteps.java
+++ b/allure-cucumber6-jvm/src/test/java/io/qameta/allure/cucumber6jvm/samples/RuntimeApiSteps.java
@@ -27,12 +27,12 @@
public class RuntimeApiSteps {
@Before("@beforeScenario")
- public void beforeScenario(){
+ public void beforeScenario() {
// nothing
}
@Before("@beforeFeature")
- public void beforeFeature(){
+ public void beforeFeature() {
// nothing
}
diff --git a/allure-cucumber7-jvm/src/main/java/io/qameta/allure/cucumber7jvm/AllureCucumber7Jvm.java b/allure-cucumber7-jvm/src/main/java/io/qameta/allure/cucumber7jvm/AllureCucumber7Jvm.java
index adac06dfd..ac4ca986e 100644
--- a/allure-cucumber7-jvm/src/main/java/io/qameta/allure/cucumber7jvm/AllureCucumber7Jvm.java
+++ b/allure-cucumber7-jvm/src/main/java/io/qameta/allure/cucumber7jvm/AllureCucumber7Jvm.java
@@ -75,13 +75,16 @@
/**
* Allure plugin for Cucumber JVM 7.0.
*/
-@SuppressWarnings({
- "ClassDataAbstractionCoupling",
- "ClassFanOutComplexity",
-})
+@SuppressWarnings(
+ {
+ "ClassDataAbstractionCoupling",
+ "ClassFanOutComplexity",
+ }
+)
public class AllureCucumber7Jvm implements ConcurrentEventListener {
private static final String COLON = ":";
+ private static final String NEW_LINE = "\n";
private final AllureLifecycle lifecycle;
@@ -137,11 +140,11 @@ private void handleTestCaseStarted(final TestCaseStarted event) {
final String name = testCase.getName();
-
// the same way full name is generated for
// org.junit.platform.engine.support.descriptor.ClasspathResourceSource
// to support io.qameta.allure.junitplatform.AllurePostDiscoveryFilter
- final String fullName = String.format("%s:%d",
+ final String fullName = String.format(
+ "%s:%d",
getTestCaseUri(testCase),
testCase.getLocation().getLine()
);
@@ -161,11 +164,10 @@ private void handleTestCaseStarted(final TestCaseStarted event) {
.setLabels(labelBuilder.getScenarioLabels())
.setLinks(labelBuilder.getScenarioLinks());
- final Scenario scenarioDefinition =
- testSources.getScenarioDefinition(
- testCase.getUri(),
- testCase.getLocation().getLine()
- );
+ final Scenario scenarioDefinition = testSources.getScenarioDefinition(
+ testCase.getUri(),
+ testCase.getLocation().getLine()
+ );
if (scenarioDefinition.getExamples() != null) {
result.setParameters(
@@ -176,7 +178,7 @@ private void handleTestCaseStarted(final TestCaseStarted event) {
final String description = Stream.of(feature.getDescription(), scenarioDefinition.getDescription())
.filter(Objects::nonNull)
.filter(s -> !s.isEmpty())
- .collect(Collectors.joining("\n"));
+ .collect(Collectors.joining(NEW_LINE));
if (!description.isEmpty()) {
result.setDescription(description);
@@ -201,9 +203,10 @@ private void handleTestCaseFinished(final TestCaseFinished event) {
.setMuted(tagParser.isMuted())
.setKnown(tagParser.isKnown());
- lifecycle.updateTestCase(uuid, testResult -> testResult
- .setStatus(status)
- .setStatusDetails(statusDetails)
+ lifecycle.updateTestCase(
+ uuid, testResult -> testResult
+ .setStatus(status)
+ .setStatusDetails(statusDetails)
);
lifecycle.stopTestCase(uuid);
@@ -263,9 +266,10 @@ private void handleStartFixtureHook(final TestCase testCase,
final String containerUuid = hookStepContainerUuid
.computeIfAbsent(hookId, unused -> UUID.randomUUID().toString());
- lifecycle.startTestContainer(new TestResultContainer()
- .setUuid(containerUuid)
- .setChildren(Collections.singletonList(uuid))
+ lifecycle.startTestContainer(
+ new TestResultContainer()
+ .setUuid(containerUuid)
+ .setChildren(Collections.singletonList(uuid))
);
final FixtureResult hookResult = new FixtureResult()
@@ -346,16 +350,15 @@ private Status translateTestCaseStatus(final Result testCaseResult) {
}
private List getExamplesAsParameters(
- final Scenario scenario,
- final TestCase localCurrentTestCase) {
+ final Scenario scenario,
+ final TestCase localCurrentTestCase) {
- final Optional maybeExample =
- scenario.getExamples().stream()
- .filter(example -> example.getTableBody().stream()
- .anyMatch(row -> row.getLocation().getLine()
- == localCurrentTestCase.getLocation().getLine())
- )
- .findFirst();
+ final Optional maybeExample = scenario.getExamples().stream()
+ .filter(
+ example -> example.getTableBody().stream()
+ .anyMatch(row -> row.getLocation().getLine() == localCurrentTestCase.getLocation().getLine())
+ )
+ .findFirst();
if (!maybeExample.isPresent()) {
return Collections.emptyList();
@@ -376,9 +379,10 @@ private List getExamplesAsParameters(
final List headerNames = examples.getTableHeader()
.map(TableRow::getCells)
- .map(rows -> rows.stream()
- .map(TableCell::getValue)
- .collect(Collectors.toList())
+ .map(
+ rows -> rows.stream()
+ .map(TableCell::getValue)
+ .collect(Collectors.toList())
)
.orElse(null);
@@ -398,14 +402,16 @@ private void createDataTableAttachment(final DataTableArgument dataTableArgument
final StringBuilder dataTableCsv = new StringBuilder();
for (List columns : rowsInTable) {
if (!columns.isEmpty()) {
- final String rowValue = columns.stream().collect(Collectors.joining("\t", "", "\n"));
+ final String rowValue = columns.stream().collect(Collectors.joining("\t", "", NEW_LINE));
dataTableCsv.append(rowValue);
}
}
final String attachmentSource = lifecycle
.prepareAttachment("Data table", "text/tab-separated-values", "csv");
- lifecycle.writeAttachment(attachmentSource,
- new ByteArrayInputStream(dataTableCsv.toString().getBytes(StandardCharsets.UTF_8)));
+ lifecycle.writeAttachment(
+ attachmentSource,
+ new ByteArrayInputStream(dataTableCsv.toString().getBytes(StandardCharsets.UTF_8))
+ );
}
private void handleStopHookStep(final Result eventResult,
@@ -422,9 +428,10 @@ private void handleStopHookStep(final Result eventResult,
final StatusDetails statusDetails = getStatusDetails(eventResult.getError())
.orElseGet(StatusDetails::new);
- lifecycle.updateFixture(uuid, result -> result
- .setStatus(status)
- .setStatusDetails(statusDetails)
+ lifecycle.updateFixture(
+ uuid, result -> result
+ .setStatus(status)
+ .setStatusDetails(statusDetails)
);
lifecycle.stopFixture(uuid);
@@ -439,8 +446,7 @@ private void handleStopStep(final TestCase testCase,
final Status stepStatus = translateTestCaseStatus(eventResult);
- final StatusDetails statusDetails
- = eventResult.getStatus() == io.cucumber.plugin.event.Status.UNDEFINED
+ final StatusDetails statusDetails = eventResult.getStatus() == io.cucumber.plugin.event.Status.UNDEFINED
? new StatusDetails().setMessage("Undefined Step. Please add step definition")
: getStatusDetails(eventResult.getError())
.orElse(new StatusDetails());
diff --git a/allure-cucumber7-jvm/src/main/java/io/qameta/allure/cucumber7jvm/LabelBuilder.java b/allure-cucumber7-jvm/src/main/java/io/qameta/allure/cucumber7jvm/LabelBuilder.java
index e4d96d5ff..62123bdfc 100644
--- a/allure-cucumber7-jvm/src/main/java/io/qameta/allure/cucumber7jvm/LabelBuilder.java
+++ b/allure-cucumber7-jvm/src/main/java/io/qameta/allure/cucumber7jvm/LabelBuilder.java
@@ -48,7 +48,7 @@
/**
* Scenario labels and links builder.
*/
-@SuppressWarnings({"CyclomaticComplexity", "MultipleStringLiterals"})
+@SuppressWarnings({"CyclomaticComplexity", "MultipleStringLiterals", "PMD.CognitiveComplexity"})
class LabelBuilder {
private static final Logger LOGGER = LoggerFactory.getLogger(LabelBuilder.class);
private static final String COMPOSITE_TAG_DELIMITER = "=";
@@ -117,17 +117,19 @@ class LabelBuilder {
final URI uri = scenario.getUri();
scenarioLabels.addAll(ResultsUtils.getProvidedLabels());
- scenarioLabels.addAll(Arrays.asList(
- createHostLabel(),
- createThreadLabel(),
- createFeatureLabel(featureName),
- createStoryLabel(scenario.getName()),
- createSuiteLabel(featureName),
- createTestClassLabel(scenario.getName()),
- createFrameworkLabel("cucumber4jvm"),
- createLanguageLabel("java"),
- createLabel("gherkin_uri", uri.toString())
- ));
+ scenarioLabels.addAll(
+ Arrays.asList(
+ createHostLabel(),
+ createThreadLabel(),
+ createFeatureLabel(featureName),
+ createStoryLabel(scenario.getName()),
+ createSuiteLabel(featureName),
+ createTestClassLabel(scenario.getName()),
+ createFrameworkLabel("cucumber4jvm"),
+ createLanguageLabel("java"),
+ createLabel("gherkin_uri", uri.toString())
+ )
+ );
featurePackage(uri.toString(), featureName)
.map(ResultsUtils::createPackageLabel)
@@ -160,8 +162,10 @@ private void tryHandleNamedLink(final String tagString) {
final String name = tagString.split(COMPOSITE_TAG_DELIMITER)[1];
scenarioLinks.add(ResultsUtils.createLink(null, name, null, type));
} else {
- LOGGER.warn("Composite named tag {} does not match regex {}. Skipping", tagString,
- namedLinkPatternString);
+ LOGGER.warn(
+ "Composite named tag {} does not match regex {}. Skipping", tagString,
+ namedLinkPatternString
+ );
}
}
@@ -179,10 +183,12 @@ private Optional featurePackage(final String uriString, final String fea
final String schemeSpecificPart = uri.normalize().getSchemeSpecificPart();
final Stream folders = Stream.of(schemeSpecificPart.replaceAll("\\.", "_").split("/"));
final Stream name = Stream.of(featureName);
- return Optional.of(Stream.concat(folders, name)
- .filter(Objects::nonNull)
- .filter(s -> !s.isEmpty())
- .collect(Collectors.joining(".")));
+ return Optional.of(
+ Stream.concat(folders, name)
+ .filter(Objects::nonNull)
+ .filter(s -> !s.isEmpty())
+ .collect(Collectors.joining("."))
+ );
}
private static Optional safeUri(final String uri) {
diff --git a/allure-cucumber7-jvm/src/main/java/io/qameta/allure/cucumber7jvm/TagParser.java b/allure-cucumber7-jvm/src/main/java/io/qameta/allure/cucumber7jvm/TagParser.java
index ea7e10eff..faca7e91e 100644
--- a/allure-cucumber7-jvm/src/main/java/io/qameta/allure/cucumber7jvm/TagParser.java
+++ b/allure-cucumber7-jvm/src/main/java/io/qameta/allure/cucumber7jvm/TagParser.java
@@ -51,9 +51,9 @@ public boolean isKnown() {
private boolean getStatusDetailByTag(final String tagName) {
return scenario.getTags().stream()
- .anyMatch(tag -> tag.equalsIgnoreCase(tagName))
- || feature.getTags().stream()
- .anyMatch(tag -> tag.getName().equalsIgnoreCase(tagName));
+ .anyMatch(tag -> tag.equalsIgnoreCase(tagName))
+ || feature.getTags().stream()
+ .anyMatch(tag -> tag.getName().equalsIgnoreCase(tagName));
}
public boolean isResultTag(final String tag) {
diff --git a/allure-cucumber7-jvm/src/main/java/io/qameta/allure/cucumber7jvm/testsourcemodel/TestSourcesModel.java b/allure-cucumber7-jvm/src/main/java/io/qameta/allure/cucumber7jvm/testsourcemodel/TestSourcesModel.java
index 479ada73a..91e4e185f 100644
--- a/allure-cucumber7-jvm/src/main/java/io/qameta/allure/cucumber7jvm/testsourcemodel/TestSourcesModel.java
+++ b/allure-cucumber7-jvm/src/main/java/io/qameta/allure/cucumber7jvm/testsourcemodel/TestSourcesModel.java
@@ -73,7 +73,8 @@ private void parseGherkinSource(final URI path) {
.build();
final Stream envelopes = parser.parse(
- Envelope.of(new Source(path.toString(), source, SourceMediaType.TEXT_X_CUCUMBER_GHERKIN_PLAIN)));
+ Envelope.of(new Source(path.toString(), source, SourceMediaType.TEXT_X_CUCUMBER_GHERKIN_PLAIN))
+ );
// TODO: What about empty gherkin docs?
final GherkinDocument gherkinDocument = envelopes
@@ -97,7 +98,7 @@ private void parseGherkinSource(final URI path) {
}
private void processFeatureDefinition(
- final Map nodeMap, final FeatureChild child, final AstNode currentParent) {
+ final Map nodeMap, final FeatureChild child, final AstNode currentParent) {
child.getBackground().ifPresent(background -> processBackgroundDefinition(nodeMap, background, currentParent));
child.getScenario().ifPresent(scenario -> processScenarioDefinition(nodeMap, scenario, currentParent));
child.getRule().ifPresent(rule -> {
@@ -108,8 +109,7 @@ private void processFeatureDefinition(
}
private void processBackgroundDefinition(
- final Map nodeMap, final Background background, final AstNode currentParent
- ) {
+ final Map nodeMap, final Background background, final AstNode currentParent) {
final AstNode childNode = createAstNode(background, currentParent);
nodeMap.put(background.getLocation().getLine(), childNode);
for (Step step : background.getSteps()) {
@@ -118,7 +118,7 @@ private void processBackgroundDefinition(
}
private void processScenarioDefinition(
- final Map nodeMap, final Scenario child, final AstNode currentParent) {
+ final Map nodeMap, final Scenario child, final AstNode currentParent) {
final AstNode childNode = createAstNode(child, currentParent);
nodeMap.put(child.getLocation().getLine(), childNode);
for (Step step : child.getSteps()) {
@@ -130,14 +130,13 @@ private void processScenarioDefinition(
}
private void processRuleDefinition(
- final Map nodeMap, final RuleChild child, final AstNode currentParent) {
+ final Map nodeMap, final RuleChild child, final AstNode currentParent) {
child.getBackground().ifPresent(background -> processBackgroundDefinition(nodeMap, background, currentParent));
child.getScenario().ifPresent(scenario -> processScenarioDefinition(nodeMap, scenario, currentParent));
}
private void processScenarioOutlineExamples(
- final Map nodeMap, final Scenario scenarioOutline, final AstNode parent
- ) {
+ final Map nodeMap, final Scenario scenarioOutline, final AstNode parent) {
for (Examples examples : scenarioOutline.getExamples()) {
final AstNode examplesNode = createAstNode(examples, parent);
// TODO: Can tables without headers even exist?
diff --git a/allure-cucumber7-jvm/src/test/java/io/qameta/allure/cucumber7jvm/AllureCucumber7JvmTest.java b/allure-cucumber7-jvm/src/test/java/io/qameta/allure/cucumber7jvm/AllureCucumber7JvmTest.java
index ed1acc536..ea50e510d 100644
--- a/allure-cucumber7-jvm/src/test/java/io/qameta/allure/cucumber7jvm/AllureCucumber7JvmTest.java
+++ b/allure-cucumber7-jvm/src/test/java/io/qameta/allure/cucumber7jvm/AllureCucumber7JvmTest.java
@@ -185,7 +185,7 @@ void shouldSetDescription() {
final AllureResults results = runFeature("features/description.feature");
final String expected = "This is description for current feature.\n"
- + "It should appear on each scenario in report";
+ + "It should appear on each scenario in report";
final List testResults = results.getTestResults();
assertThat(testResults)
@@ -202,7 +202,7 @@ void shouldSetScenarioDescription() {
final AllureResults results = runFeature("features/scenario_description.feature");
final String expected = "This is description for current feature.\n"
- + "It should appear on each scenario in report";
+ + "It should appear on each scenario in report";
final List testResults = results.getTestResults();
assertThat(testResults)
@@ -240,11 +240,12 @@ void shouldAddDataTableAttachment() {
final String attachmentContent = new String(bytes, StandardCharsets.UTF_8);
assertThat(attachmentContent)
- .isEqualTo("""
- name\tlogin\temail
- Viktor\tclicman\tclicman@ya.ru
- Viktor2\tclicman2\tclicman2@ya.ru
+ .isEqualTo(
"""
+ name\tlogin\temail
+ Viktor\tclicman\tclicman@ya.ru
+ Viktor2\tclicman2\tclicman2@ya.ru
+ """
);
}
@@ -383,8 +384,14 @@ void shouldAddTags() {
@AllureFeatures.Links
@ExtendWith(SystemPropertyExtension.class)
- @SystemProperty(name = "allure.link.issue.pattern", value = "https://example.org/issue/{}")
- @SystemProperty(name = "allure.link.tms.pattern", value = "https://example.org/tms/{}")
+ @SystemProperty(
+ name = "allure.link.issue.pattern",
+ value = "https://example.org/issue/{}"
+ )
+ @SystemProperty(
+ name = "allure.link.tms.pattern",
+ value = "https://example.org/tms/{}"
+ )
@Test
void shouldAddLinks() {
final AllureResults results = runFeature("features/tags.feature");
@@ -513,8 +520,10 @@ void shouldSupportDryRunForSimpleFeatures() {
@AllureFeatures.Base
@Test
void shouldSupportDryRunForHooks() {
- final AllureResults results = runFeature("features/hooks.feature", "--dry-run", "-t",
- "@WithHooks or @BeforeHookWithException or @AfterHookWithException");
+ final AllureResults results = runFeature(
+ "features/hooks.feature", "--dry-run", "-t",
+ "@WithHooks or @BeforeHookWithException or @AfterHookWithException"
+ );
final TestResult tr1 = results.getTestResultByName("Simple scenario with Before and After hooks");
@@ -654,8 +663,10 @@ void shouldProcessScenariosInParallelMode() {
@AllureFeatures.Stages
@Test
void shouldDisplayHooksAsStages() {
- final AllureResults results = runFeature("features/hooks.feature", "-t",
- "@WithHooks or @BeforeHookWithException or @AfterHookWithException");
+ final AllureResults results = runFeature(
+ "features/hooks.feature", "-t",
+ "@WithHooks or @BeforeHookWithException or @AfterHookWithException"
+ );
final TestResult tr1 = results.getTestResultByName("Simple scenario with Before and After hooks");
final TestResult tr2 = results.getTestResultByName("Simple scenario with Before hook with Exception");
@@ -693,7 +704,6 @@ void shouldDisplayHooksAsStages() {
tuple("Then result is 15", Status.SKIPPED)
);
-
assertThat(results.getTestResultContainersForTestResult(tr2))
.flatExtracting(TestResultContainer::getBefores)
.extracting(FixtureResult::getName, FixtureResult::getStatus)
@@ -739,8 +749,14 @@ void shouldHandleAmbigiousStepsExceptions() {
);
}
- @ResourceLock(value = SYSTEM_PROPERTIES, mode = READ_WRITE)
- @SystemProperty(name = "allure.label.x-provided", value = "cucumberjvm7-test-provided")
+ @ResourceLock(
+ value = SYSTEM_PROPERTIES,
+ mode = READ_WRITE
+ )
+ @SystemProperty(
+ name = "allure.label.x-provided",
+ value = "cucumberjvm7-test-provided"
+ )
@Test
void shouldSupportProvidedLabels() {
final AllureResults results = runFeature("features/simple.feature");
@@ -785,7 +801,10 @@ void shouldSupportRuntimeApiInStepsWhenHooksAreUsed() {
);
}
- @SystemProperty(name = "cucumber.junit-platform.naming-strategy", value = "long")
+ @SystemProperty(
+ name = "cucumber.junit-platform.naming-strategy",
+ value = "long"
+ )
@Step
private AllureResults runFeature(final String featureResource,
final String... moreOptions) {
@@ -793,10 +812,12 @@ private AllureResults runFeature(final String featureResource,
return RunUtils.runTests(lifecycle -> {
final AllureCucumber7Jvm cucumber7jvm = new AllureCucumber7Jvm(lifecycle);
final Supplier classLoader = ClassLoaders::getDefaultClassLoader;
- final List opts = new ArrayList<>(Arrays.asList(
- "--glue", "io.qameta.allure.cucumber7jvm.samples",
- "--no-summary"
- ));
+ final List opts = new ArrayList<>(
+ Arrays.asList(
+ "--glue", "io.qameta.allure.cucumber7jvm.samples",
+ "--no-summary"
+ )
+ );
opts.addAll(Arrays.asList(moreOptions));
final FeatureWithLines featureWithLines = FeatureWithLines.parse("src/test/resources/" + featureResource);
final RuntimeOptions options = new CommandlineOptionsParser(System.out)
@@ -804,8 +825,7 @@ private AllureResults runFeature(final String featureResource,
final EventBus bus = new TimeServiceEventBus(Clock.systemUTC(), UUID::randomUUID);
final FeatureParser parser = new FeatureParser(bus::generateId);
- final FeaturePathFeatureSupplier supplier
- = new FeaturePathFeatureSupplier(classLoader, options, parser);
+ final FeaturePathFeatureSupplier supplier = new FeaturePathFeatureSupplier(classLoader, options, parser);
final Runtime runtime = Runtime.builder()
.withClassLoader(classLoader)
diff --git a/allure-cucumber7-jvm/src/test/java/io/qameta/allure/cucumber7jvm/samples/AmbigiousSteps.java b/allure-cucumber7-jvm/src/test/java/io/qameta/allure/cucumber7jvm/samples/AmbigiousSteps.java
index 0406db2f3..b5fec46cd 100644
--- a/allure-cucumber7-jvm/src/test/java/io/qameta/allure/cucumber7jvm/samples/AmbigiousSteps.java
+++ b/allure-cucumber7-jvm/src/test/java/io/qameta/allure/cucumber7jvm/samples/AmbigiousSteps.java
@@ -34,7 +34,7 @@ public void ambigious_2() {
}
@Then("^something bad should happen")
- public void somethingBadStep(){
+ public void somethingBadStep() {
//nothing here
}
}
diff --git a/allure-cucumber7-jvm/src/test/java/io/qameta/allure/cucumber7jvm/samples/AttachmentSteps.java b/allure-cucumber7-jvm/src/test/java/io/qameta/allure/cucumber7jvm/samples/AttachmentSteps.java
index 455aaffe7..bd1fb2a48 100644
--- a/allure-cucumber7-jvm/src/test/java/io/qameta/allure/cucumber7jvm/samples/AttachmentSteps.java
+++ b/allure-cucumber7-jvm/src/test/java/io/qameta/allure/cucumber7jvm/samples/AttachmentSteps.java
@@ -15,8 +15,8 @@
*/
package io.qameta.allure.cucumber7jvm.samples;
-import io.cucumber.java.Scenario;
import io.cucumber.java.Before;
+import io.cucumber.java.Scenario;
import io.cucumber.java.en.Given;
public class AttachmentSteps {
diff --git a/allure-cucumber7-jvm/src/test/java/io/qameta/allure/cucumber7jvm/samples/HookSteps.java b/allure-cucumber7-jvm/src/test/java/io/qameta/allure/cucumber7jvm/samples/HookSteps.java
index b85751afa..46ca418ac 100644
--- a/allure-cucumber7-jvm/src/test/java/io/qameta/allure/cucumber7jvm/samples/HookSteps.java
+++ b/allure-cucumber7-jvm/src/test/java/io/qameta/allure/cucumber7jvm/samples/HookSteps.java
@@ -25,22 +25,22 @@
public class HookSteps {
@Before("@WithHooks")
- public void beforeHook(){
+ public void beforeHook() {
// nothing
}
@After("@WithHooks")
- public void afterHook(){
+ public void afterHook() {
// nothing
}
@Before("@BeforeHookWithException")
- public void beforeHookWithException(){
+ public void beforeHookWithException() {
Assertions.fail("Exception in Hook step");
}
@After("@AfterHookWithException")
- public void afterHookWithException(){
+ public void afterHookWithException() {
Assertions.fail("Exception in Hook step");
}
diff --git a/allure-cucumber7-jvm/src/test/java/io/qameta/allure/cucumber7jvm/samples/RuntimeApiSteps.java b/allure-cucumber7-jvm/src/test/java/io/qameta/allure/cucumber7jvm/samples/RuntimeApiSteps.java
index e76d71acc..50eabea7e 100644
--- a/allure-cucumber7-jvm/src/test/java/io/qameta/allure/cucumber7jvm/samples/RuntimeApiSteps.java
+++ b/allure-cucumber7-jvm/src/test/java/io/qameta/allure/cucumber7jvm/samples/RuntimeApiSteps.java
@@ -16,9 +16,9 @@
package io.qameta.allure.cucumber7jvm.samples;
import io.cucumber.java.Before;
+import io.cucumber.java.en.And;
import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;
-import io.cucumber.java.en.And;
import io.qameta.allure.Allure;
/**
@@ -27,12 +27,12 @@
public class RuntimeApiSteps {
@Before("@beforeScenario")
- public void beforeScenario(){
+ public void beforeScenario() {
// nothing
}
@Before("@beforeFeature")
- public void beforeFeature(){
+ public void beforeFeature() {
// nothing
}
diff --git a/allure-descriptions-javadoc/src/main/java/io/qameta/allure/description/JavaDocDescriptionRenderer.java b/allure-descriptions-javadoc/src/main/java/io/qameta/allure/description/JavaDocDescriptionRenderer.java
index 6546dbb48..1985af5f6 100644
--- a/allure-descriptions-javadoc/src/main/java/io/qameta/allure/description/JavaDocDescriptionRenderer.java
+++ b/allure-descriptions-javadoc/src/main/java/io/qameta/allure/description/JavaDocDescriptionRenderer.java
@@ -47,6 +47,7 @@
* description path suitable for open source projects where comments may evolve over time and where
* security is more important than pixel-perfect parity with the standard doclet.
*/
+@SuppressWarnings({"PMD.GodClass", "PMD.TooManyMethods"})
final class JavaDocDescriptionRenderer {
private static final String PARAGRAPH_BREAK = "\n\n";
@@ -58,6 +59,7 @@ final class JavaDocDescriptionRenderer {
private static final String CODE_TAG = "code";
private static final String HTML_TAG_END = ">";
private static final String CLOSING_TAG_PREFIX = "";
+ private static final String NEW_LINE = "\n";
/**
* Converts raw JavaDoc comment text into the description format stored by the annotation
@@ -84,7 +86,7 @@ String render(final String rawDocComment) {
}
private String extractDescriptionBody(final String rawDocComment) {
- final String[] lines = normalize(rawDocComment).split("\n", -1);
+ final String[] lines = normalize(rawDocComment).split(NEW_LINE, -1);
final StringBuilder body = new StringBuilder();
int inlineTagDepth = 0;
@@ -107,7 +109,7 @@ private boolean startsBlockTag(final String line) {
return trimmed.length() > 1 && trimmed.charAt(0) == '@' && Character.isJavaIdentifierStart(trimmed.charAt(1));
}
- @SuppressWarnings("checkstyle:CyclomaticComplexity")
+ @SuppressWarnings({"checkstyle:CyclomaticComplexity", "PMD.CognitiveComplexity"})
private void renderFragment(final String fragment, final StringBuilder rendered) {
int index = 0;
while (index < fragment.length()) {
@@ -182,10 +184,13 @@ private int renderInlineTag(final String fragment, final int start, final String
return end + 1;
}
- @SuppressWarnings({
- "checkstyle:CyclomaticComplexity",
- "checkstyle:NPathComplexity",
- "checkstyle:ReturnCount"})
+ @SuppressWarnings(
+ {
+ "checkstyle:CyclomaticComplexity",
+ "checkstyle:NPathComplexity",
+ "PMD.CognitiveComplexity",
+ "checkstyle:ReturnCount"}
+ )
private int renderHtmlTag(final String fragment, final int start, final StringBuilder rendered) {
if (start + 1 >= fragment.length() || Character.isWhitespace(fragment.charAt(start + 1))) {
return start;
@@ -317,7 +322,7 @@ private void appendLineBreak(final StringBuilder rendered) {
}
private String cleanup(final String rendered) {
- final String[] lines = normalize(rendered).split("\n", -1);
+ final String[] lines = normalize(rendered).split(NEW_LINE, -1);
final StringBuilder cleaned = new StringBuilder();
boolean blankLinePending = false;
@@ -331,7 +336,7 @@ private String cleanup(final String rendered) {
}
if (cleaned.length() > 0) {
- cleaned.append(blankLinePending ? PARAGRAPH_BREAK : "\n");
+ cleaned.append(blankLinePending ? PARAGRAPH_BREAK : NEW_LINE);
}
cleaned.append(trimmed);
blankLinePending = false;
@@ -341,7 +346,7 @@ private String cleanup(final String rendered) {
}
private String trimBlankLines(final String value) {
- final String[] lines = normalize(value).split("\n", -1);
+ final String[] lines = normalize(value).split(NEW_LINE, -1);
int start = 0;
int end = lines.length;
@@ -452,7 +457,7 @@ private String trimTrailingWhitespace(final String line) {
}
private String normalize(final String value) {
- return value.replace("\r\n", "\n").replace('\r', '\n');
+ return value.replace("\r\n", NEW_LINE).replace('\r', '\n');
}
private boolean isBlank(final String value) {
@@ -479,10 +484,12 @@ private int renderEntityReference(final String fragment, final int start, final
return end + 1;
}
- @SuppressWarnings({
- "checkstyle:CyclomaticComplexity",
- "checkstyle:NPathComplexity",
- "checkstyle:ReturnCount"})
+ @SuppressWarnings(
+ {
+ "checkstyle:CyclomaticComplexity",
+ "checkstyle:NPathComplexity",
+ "checkstyle:ReturnCount"}
+ )
private String decodeEntity(final String entity) {
if (entity.isEmpty()) {
return null;
diff --git a/allure-descriptions-javadoc/src/main/java/io/qameta/allure/description/JavaDocDescriptionsProcessor.java b/allure-descriptions-javadoc/src/main/java/io/qameta/allure/description/JavaDocDescriptionsProcessor.java
index acc1d5559..289c5f43a 100644
--- a/allure-descriptions-javadoc/src/main/java/io/qameta/allure/description/JavaDocDescriptionsProcessor.java
+++ b/allure-descriptions-javadoc/src/main/java/io/qameta/allure/description/JavaDocDescriptionsProcessor.java
@@ -31,6 +31,7 @@
import javax.tools.Diagnostic;
import javax.tools.FileObject;
import javax.tools.StandardLocation;
+
import java.io.IOException;
import java.io.Writer;
import java.math.BigInteger;
@@ -96,14 +97,18 @@ public boolean process(final Set extends TypeElement> annotations, final Round
method.getEnclosingElement().toString(), name, typeParams
);
try {
- final FileObject file = filer.createResource(StandardLocation.CLASS_OUTPUT, "",
- ALLURE_DESCRIPTIONS_FOLDER + hash);
+ final FileObject file = filer.createResource(
+ StandardLocation.CLASS_OUTPUT, "",
+ ALLURE_DESCRIPTIONS_FOLDER + hash
+ );
try (Writer writer = file.openWriter()) {
writer.write(docs);
}
} catch (IOException e) {
- messager.printMessage(Diagnostic.Kind.WARNING,
- "Unable to create resource from docs comment of method " + name + typeParams);
+ messager.printMessage(
+ Diagnostic.Kind.WARNING,
+ "Unable to create resource from docs comment of method " + name + typeParams
+ );
}
});
diff --git a/allure-descriptions-javadoc/src/test/java/io/qameta/allure/description/JavaDocDescriptionRendererTest.java b/allure-descriptions-javadoc/src/test/java/io/qameta/allure/description/JavaDocDescriptionRendererTest.java
index 180d2b03a..b82f4c476 100644
--- a/allure-descriptions-javadoc/src/test/java/io/qameta/allure/description/JavaDocDescriptionRendererTest.java
+++ b/allure-descriptions-javadoc/src/test/java/io/qameta/allure/description/JavaDocDescriptionRendererTest.java
@@ -29,10 +29,10 @@ class JavaDocDescriptionRendererTest {
void shouldRenderPlainTextAndTrimBlankLines() {
final String rendered = renderer.render(
"\r\n"
- + " First line \r\n"
- + "\r\n"
- + " Second line\t\r\n"
- + "\r\n"
+ + " First line \r\n"
+ + "\r\n"
+ + " Second line\t\r\n"
+ + "\r\n"
);
assertThat(rendered)
@@ -43,7 +43,7 @@ void shouldRenderPlainTextAndTrimBlankLines() {
void shouldReturnEmptyStringWhenBodyContainsOnlyBlockTags() {
final String rendered = renderer.render(
"@param value description\n"
- + "@throws Exception description"
+ + "@throws Exception description"
);
assertThat(rendered)
@@ -54,9 +54,9 @@ void shouldReturnEmptyStringWhenBodyContainsOnlyBlockTags() {
void shouldIgnoreBlockTagsAndEverythingAfterThem() {
final String rendered = renderer.render(
"Summary paragraph.\n"
- + "\n"
- + "@param value Description of the value.\n"
- + "Continuation that should also be ignored."
+ + "\n"
+ + "@param value Description of the value.\n"
+ + "Continuation that should also be ignored."
);
assertThat(rendered)
@@ -95,7 +95,7 @@ void shouldIgnoreStandardBlockTagsAfterMainDescription() {
void shouldNotTreatAtSignsInsideTextAsBlockTags() {
final String rendered = renderer.render(
"Email support@example.com\n"
- + "Use @smoke in prose."
+ + "Use @smoke in prose."
);
assertThat(rendered)
@@ -106,7 +106,7 @@ void shouldNotTreatAtSignsInsideTextAsBlockTags() {
void shouldDecodeEscapedAtEntityBeforeBlockTags() {
final String rendered = renderer.render(
"@version stays in prose.\n"
- + "@version 2.4.0"
+ + "@version 2.4.0"
);
assertThat(rendered)
@@ -135,9 +135,9 @@ void shouldDecodeSupportedNamedAndNumericEntities() {
void shouldRenderSupportedInlineTags() {
final String rendered = renderer.render(
"Use {@code a < b}, {@literal }, "
- + "{@link java.lang.String}, "
- + "{@linkplain java.lang.String#valueOf(Object)}, "
- + "{@link java.util.List list docs}."
+ + "{@link java.lang.String}, "
+ + "{@linkplain java.lang.String#valueOf(Object)}, "
+ + "{@link java.util.List list docs}."
);
assertThat(rendered)
@@ -158,9 +158,9 @@ void shouldSupportBalancedBracesInsideInlineTags() {
void shouldNotTreatAtLinesInsideBalancedInlineTagsAsBlockTags() {
final String rendered = renderer.render(
"Summary {@literal first line\n"
- + "@notATag\n"
- + "last line}\n"
- + "@param ignored"
+ + "@notATag\n"
+ + "last line}\n"
+ + "@param ignored"
);
assertThat(rendered)
@@ -181,14 +181,14 @@ void shouldRenderNestedInlineTagsInsideLinkLabels() {
void shouldSafelyDegradeUnsupportedStandardInlineTags() {
final String rendered = renderer.render(
"Fallbacks: {@docRoot}, {@inheritDoc}, {@index release}, "
- + "{@summary quick summary}, {@systemProperty user.home}, "
- + "{@value java.lang.Integer#MAX_VALUE}."
+ + "{@summary quick summary}, {@systemProperty user.home}, "
+ + "{@value java.lang.Integer#MAX_VALUE}."
);
assertThat(rendered)
.isEqualTo(
"Fallbacks: docRoot, inheritDoc, index release, summary quick summary, "
- + "systemProperty user.home, value java.lang.Integer#MAX_VALUE."
+ + "systemProperty user.home, value java.lang.Integer#MAX_VALUE."
);
}
@@ -196,9 +196,9 @@ void shouldSafelyDegradeUnsupportedStandardInlineTags() {
void shouldSafelyDegradeSnippetTags() {
final String rendered = renderer.render(
"Snippet {@snippet :\n"
- + "int answer = 42;\n"
- + "@highlight substring=\"answer\"\n"
- + "}."
+ + "int answer = 42;\n"
+ + "@highlight substring=\"answer\"\n"
+ + "}."
);
assertThat(rendered)
@@ -301,28 +301,28 @@ void shouldDropUnknownHtmlTagsButKeepTheirTextContentEscaped() {
void shouldRenderComplexModernJavadocExampleSafely() {
final String rendered = renderer.render(
"Fetches release metadata for the current build.\n"
- + "\n"
- + "Use {@link java.net.URI URIs} for endpoint configuration.
\n"
- + "\n"
- + "- Supports café, Привет, 東京, and λ.
\n"
- + "- See the Javadoc specification "
- + "and {@linkplain java.lang.String#formatted(Object...) formatted examples}.
\n"
- + "
\n"
- + "Example: client.fetch(\"v2\")\n"
- + "@beta remains prose.\n"
- + "@author Jane Doe\n"
- + "@version 2.3.0\n"
- + "@since 2.0"
+ + "\n"
+ + "Use {@link java.net.URI URIs} for endpoint configuration.
\n"
+ + "\n"
+ + "- Supports café, Привет, 東京, and λ.
\n"
+ + "- See the Javadoc specification "
+ + "and {@linkplain java.lang.String#formatted(Object...) formatted examples}.
\n"
+ + "
\n"
+ + "Example: client.fetch(\"v2\")\n"
+ + "@beta remains prose.\n"
+ + "@author Jane Doe\n"
+ + "@version 2.3.0\n"
+ + "@since 2.0"
);
assertThat(rendered)
.isEqualTo(
"Fetches release metadata for the current build.\n\n"
- + "Use URIs for endpoint configuration.\n\n"
- + "- Supports café, Привет, 東京, and λ.\n"
- + "- See the Javadoc specification and formatted examples.\n\n"
- + "Example: `client.fetch(\"v2\")`\n"
- + "@beta remains prose."
+ + "Use URIs for endpoint configuration.\n\n"
+ + "- Supports café, Привет, 東京, and λ.\n"
+ + "- See the Javadoc specification and formatted examples.\n\n"
+ + "Example: `client.fetch(\"v2\")`\n"
+ + "@beta remains prose."
);
}
}
diff --git a/allure-descriptions-javadoc/src/test/java/io/qameta/allure/description/ProcessDescriptionsTest.java b/allure-descriptions-javadoc/src/test/java/io/qameta/allure/description/ProcessDescriptionsTest.java
index 29f80277e..49ab0437a 100644
--- a/allure-descriptions-javadoc/src/test/java/io/qameta/allure/description/ProcessDescriptionsTest.java
+++ b/allure-descriptions-javadoc/src/test/java/io/qameta/allure/description/ProcessDescriptionsTest.java
@@ -237,10 +237,10 @@ void shouldIgnoreBlockTagsAndRenderSafeMarkdown() {
.contentsAsUtf8String()
.isEqualTo(
"This is my test description with `sample` and <safe>.\n\n"
- + "Use String for values.\n\n"
- + "- first item\n"
- + "- second item\n\n"
- + "alert(\"xss\")"
+ + "Use String for values.\n\n"
+ + "- first item\n"
+ + "- second item\n\n"
+ + "alert(\"xss\")"
);
}
@@ -290,12 +290,12 @@ void shouldCaptureComplexModernJavadocDescriptionSafely() {
.contentsAsUtf8String()
.isEqualTo(
"Fetches release metadata for the current build.\n\n"
- + "Use URIs for endpoint configuration.\n\n"
- + "- Supports café, Привет, 東京, and λ.\n"
- + "- See the Javadoc specification\n"
- + "and formatted examples.\n\n"
- + "Example: `client.fetch(\"v2\")`\n"
- + "@beta remains prose."
+ + "Use URIs for endpoint configuration.\n\n"
+ + "- Supports café, Привет, 東京, and λ.\n"
+ + "- See the Javadoc specification\n"
+ + "and formatted examples.\n\n"
+ + "Example: `client.fetch(\"v2\")`\n"
+ + "@beta remains prose."
);
}
}
diff --git a/allure-grpc/src/main/java/io/qameta/allure/grpc/AllureGrpc.java b/allure-grpc/src/main/java/io/qameta/allure/grpc/AllureGrpc.java
index ce71871a8..73c0fa527 100644
--- a/allure-grpc/src/main/java/io/qameta/allure/grpc/AllureGrpc.java
+++ b/allure-grpc/src/main/java/io/qameta/allure/grpc/AllureGrpc.java
@@ -34,6 +34,9 @@
import io.qameta.allure.model.Attachment;
import io.qameta.allure.model.Status;
import io.qameta.allure.model.StepResult;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import java.io.ByteArrayInputStream;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
@@ -42,19 +45,20 @@
import java.util.Locale;
import java.util.Map;
import java.util.UUID;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* Allure interceptor logger for gRPC.
*
* @author dtuchs (Dmitry Tuchs).
*/
-@SuppressWarnings({
- "checkstyle:ClassFanOutComplexity",
- "checkstyle:AnonInnerLength",
- "checkstyle:JavaNCSS"
-})
+@SuppressWarnings(
+ {
+ "checkstyle:ClassFanOutComplexity",
+ "checkstyle:AnonInnerLength",
+ "checkstyle:JavaNCSS",
+ "PMD.GodClass"
+ }
+)
public class AllureGrpc implements ClientInterceptor {
private static final Logger LOGGER = LoggerFactory.getLogger(AllureGrpc.class);
@@ -69,17 +73,18 @@ public class AllureGrpc implements ClientInterceptor {
private final String responseTemplatePath;
public AllureGrpc() {
- this(Allure.getLifecycle(), true, false,
- "grpc-request.ftl", "grpc-response.ftl");
+ this(
+ Allure.getLifecycle(), true, false,
+ "grpc-request.ftl", "grpc-response.ftl"
+ );
}
public AllureGrpc(
- final AllureLifecycle lifecycle,
- final boolean markStepFailedOnNonZeroCode,
- final boolean interceptResponseMetadata,
- final String requestTemplatePath,
- final String responseTemplatePath
- ) {
+ final AllureLifecycle lifecycle,
+ final boolean markStepFailedOnNonZeroCode,
+ final boolean interceptResponseMetadata,
+ final String requestTemplatePath,
+ final String responseTemplatePath) {
this.lifecycle = lifecycle;
this.markStepFailedOnNonZeroCode = markStepFailedOnNonZeroCode;
this.interceptResponseMetadata = interceptResponseMetadata;
@@ -89,10 +94,9 @@ public AllureGrpc(
@Override
public ClientCall interceptCall(
- final MethodDescriptor methodDescriptor,
- final CallOptions callOptions,
- final Channel nextChannel
- ) {
+ final MethodDescriptor methodDescriptor,
+ final CallOptions callOptions,
+ final Channel nextChannel) {
final AllureLifecycle current = lifecycle;
final String parent = current.getCurrentTestCaseOrStep().orElse(null);
final String stepUuid = UUID.randomUUID().toString();
@@ -109,12 +113,12 @@ public ClientCall interceptCall(
}
final StepContext stepContext = new StepContext<>(
- stepUuid, methodDescriptor, current, clientMessages,
- serverMessages, initialHeaders, trailers
+ stepUuid, methodDescriptor, current, clientMessages,
+ serverMessages, initialHeaders, trailers
);
return new ForwardingClientCall.SimpleForwardingClientCall(
- nextChannel.newCall(methodDescriptor, callOptions)
+ nextChannel.newCall(methodDescriptor, callOptions)
) {
@Override
public void start(final Listener responseListener, final Metadata requestHeaders) {
@@ -154,59 +158,59 @@ public void sendMessage(final T message) {
}
private void addRawJsonAttachment(
- final String stepUuid,
- final String attachmentName,
- final String jsonBody,
- final AllureLifecycle lifecycle
- ) {
+ final String stepUuid,
+ final String attachmentName,
+ final String jsonBody,
+ final AllureLifecycle lifecycle) {
if (jsonBody == null || jsonBody.isEmpty()) {
return;
}
final String source = UUID.randomUUID() + ".json";
- lifecycle.updateStep(stepUuid, step -> step.getAttachments().add(
- new Attachment()
- .setName(attachmentName)
- .setSource(source)
- .setType("application/json")
- ));
+ lifecycle.updateStep(
+ stepUuid, step -> step.getAttachments().add(
+ new Attachment()
+ .setName(attachmentName)
+ .setSource(source)
+ .setType("application/json")
+ )
+ );
lifecycle.writeAttachment(
- source,
- new ByteArrayInputStream(jsonBody.getBytes(StandardCharsets.UTF_8))
+ source,
+ new ByteArrayInputStream(jsonBody.getBytes(StandardCharsets.UTF_8))
);
}
private void handleClose(
- final io.grpc.Status status,
- final Metadata responseTrailers,
- final StepContext, ?> stepContext
- ) {
+ final io.grpc.Status status,
+ final Metadata responseTrailers,
+ final StepContext, ?> stepContext) {
try {
if (interceptResponseMetadata && responseTrailers != null) {
copyAsciiResponseMetadata(responseTrailers, stepContext.getTrailers());
}
attachRequestIfPresent(
- stepContext.getStepUuid(),
- stepContext.getMethodDescriptor(),
- stepContext.getClientMessages(),
- stepContext.getLifecycle()
+ stepContext.getStepUuid(),
+ stepContext.getMethodDescriptor(),
+ stepContext.getClientMessages(),
+ stepContext.getLifecycle()
);
attachResponse(
- stepContext.getStepUuid(),
- stepContext.getServerMessages(),
- status,
- stepContext.getInitialHeaders(),
- stepContext.getTrailers(),
- stepContext.getLifecycle()
+ stepContext.getStepUuid(),
+ stepContext.getServerMessages(),
+ status,
+ stepContext.getInitialHeaders(),
+ stepContext.getTrailers(),
+ stepContext.getLifecycle()
);
stepContext.getLifecycle().updateStep(
- stepContext.getStepUuid(),
- step -> step.setStatus(convertStatus(status))
+ stepContext.getStepUuid(),
+ step -> step.setStatus(convertStatus(status))
);
} catch (Throwable throwable) {
LOGGER.error("Failed to finalize Allure step for gRPC call", throwable);
stepContext.getLifecycle().updateStep(
- stepContext.getStepUuid(),
- step -> step.setStatus(Status.BROKEN)
+ stepContext.getStepUuid(),
+ step -> step.setStatus(Status.BROKEN)
);
} finally {
stopStepSafely(stepContext.getLifecycle(), stepContext.getStepUuid());
@@ -244,45 +248,43 @@ private void handleServerMessage(final R message, final List destina
}
private void attachRequestIfPresent(
- final String stepUuid,
- final MethodDescriptor methodDescriptor,
- final List clientMessages,
- final AllureLifecycle lifecycle
- ) {
+ final String stepUuid,
+ final MethodDescriptor methodDescriptor,
+ final List clientMessages,
+ final AllureLifecycle lifecycle) {
final String body = toJsonBody(clientMessages);
if (body == null) {
return;
}
final String name = clientMessages.size() > 1
- ? "gRPC request (collection of elements from Client stream)"
- : "gRPC request";
+ ? "gRPC request (collection of elements from Client stream)"
+ : "gRPC request";
final GrpcRequestAttachment requestAttachment = GrpcRequestAttachment.Builder
- .create(name, methodDescriptor.getFullMethodName())
- .setBody(body)
- .build();
+ .create(name, methodDescriptor.getFullMethodName())
+ .setBody(body)
+ .build();
addRenderedAttachmentToStep(
- stepUuid,
- requestAttachment.getName(),
- requestAttachment,
- requestTemplatePath,
- lifecycle
+ stepUuid,
+ requestAttachment.getName(),
+ requestAttachment,
+ requestTemplatePath,
+ lifecycle
);
addRawJsonAttachment(stepUuid, name + JSON_SUFFIX, body, lifecycle);
}
private void attachResponse(
- final String stepUuid,
- final List serverMessages,
- final io.grpc.Status status,
- final Map initialHeaders,
- final Map trailers,
- final AllureLifecycle lifecycle
- ) {
+ final String stepUuid,
+ final List serverMessages,
+ final io.grpc.Status status,
+ final Map initialHeaders,
+ final Map trailers,
+ final AllureLifecycle lifecycle) {
final String body = toJsonBody(serverMessages);
final String name = serverMessages.size() > 1
- ? "gRPC response (collection of elements from Server stream)"
- : "gRPC response";
+ ? "gRPC response (collection of elements from Server stream)"
+ : "gRPC response";
final Map metadata = new LinkedHashMap<>();
if (interceptResponseMetadata) {
@@ -291,8 +293,8 @@ private void attachResponse(
}
final GrpcResponseAttachment.Builder builder = GrpcResponseAttachment.Builder
- .create(name)
- .setStatus(status.toString());
+ .create(name)
+ .setStatus(status.toString());
if (body != null) {
builder.setBody(body);
@@ -303,11 +305,11 @@ private void attachResponse(
final GrpcResponseAttachment responseAttachment = builder.build();
addRenderedAttachmentToStep(
- stepUuid,
- responseAttachment.getName(),
- responseAttachment,
- responseTemplatePath,
- lifecycle
+ stepUuid,
+ responseAttachment.getName(),
+ responseAttachment,
+ responseTemplatePath,
+ lifecycle
);
if (body != null) {
addRawJsonAttachment(stepUuid, name + JSON_SUFFIX, body, lifecycle);
@@ -330,14 +332,13 @@ private Status convertStatus(final io.grpc.Status grpcStatus) {
}
private static String buildStepName(
- final Channel channel,
- final MethodDescriptor, ?> methodDescriptor
- ) {
+ final Channel channel,
+ final MethodDescriptor, ?> methodDescriptor) {
final String authority = channel != null ? channel.authority() : null;
final String safeAuthority = authority != null ? authority : UNKNOWN;
final String type = toSnakeCase(methodDescriptor.getType());
return "Send " + type + " gRPC request to "
- + safeAuthority + "/" + methodDescriptor.getFullMethodName();
+ + safeAuthority + "/" + methodDescriptor.getFullMethodName();
}
private static String toSnakeCase(final MethodDescriptor.MethodType methodType) {
@@ -348,21 +349,19 @@ private static String toSnakeCase(final MethodDescriptor.MethodType methodType)
}
private void addRenderedAttachmentToStep(
- final String stepUuid,
- final String attachmentName,
- final AttachmentData data,
- final String templatePath,
- final AllureLifecycle lifecycle
- ) {
- final AttachmentRenderer renderer =
- new FreemarkerAttachmentRenderer(templatePath);
+ final String stepUuid,
+ final String attachmentName,
+ final AttachmentData data,
+ final String templatePath,
+ final AllureLifecycle lifecycle) {
+ final AttachmentRenderer renderer = new FreemarkerAttachmentRenderer(templatePath);
final io.qameta.allure.attachment.AttachmentContent content;
try {
content = renderer.render(data);
} catch (Throwable throwable) {
LOGGER.warn(
- "Could not render attachment '{}' using template '{}'",
- attachmentName, templatePath, throwable
+ "Could not render attachment '{}' using template '{}'",
+ attachmentName, templatePath, throwable
);
return;
}
@@ -376,21 +375,21 @@ private void addRenderedAttachmentToStep(
}
final String source = UUID.randomUUID() + fileExtension;
lifecycle.updateStep(
- stepUuid,
- step -> step.getAttachments().add(
- new Attachment()
- .setName(attachmentName)
- .setSource(source)
- .setType(
- content.getContentType() != null
- ? content.getContentType()
- : "text/html"
- )
- )
+ stepUuid,
+ step -> step.getAttachments().add(
+ new Attachment()
+ .setName(attachmentName)
+ .setSource(source)
+ .setType(
+ content.getContentType() != null
+ ? content.getContentType()
+ : "text/html"
+ )
+ )
);
lifecycle.writeAttachment(
- source,
- new ByteArrayInputStream(content.getContent().getBytes(StandardCharsets.UTF_8))
+ source,
+ new ByteArrayInputStream(content.getContent().getBytes(StandardCharsets.UTF_8))
);
}
@@ -406,9 +405,8 @@ private static String toJsonBody(final List items) {
}
private static void copyAsciiResponseMetadata(
- final Metadata source,
- final Map target
- ) {
+ final Metadata source,
+ final Map target) {
for (String key : source.keys()) {
if (key == null) {
continue;
@@ -416,8 +414,7 @@ private static void copyAsciiResponseMetadata(
if (key.endsWith(Metadata.BINARY_HEADER_SUFFIX)) {
continue;
}
- final Metadata.Key keyAscii =
- Metadata.Key.of(key, Metadata.ASCII_STRING_MARSHALLER);
+ final Metadata.Key keyAscii = Metadata.Key.of(key, Metadata.ASCII_STRING_MARSHALLER);
final String value = source.get(keyAscii);
if (value != null) {
target.put(key, value);
@@ -435,14 +432,13 @@ private static final class StepContext {
private final Map trailers;
StepContext(
- final String stepUuid,
- final MethodDescriptor methodDescriptor,
- final AllureLifecycle lifecycle,
- final List clientMessages,
- final List serverMessages,
- final Map initialHeaders,
- final Map trailers
- ) {
+ final String stepUuid,
+ final MethodDescriptor methodDescriptor,
+ final AllureLifecycle lifecycle,
+ final List clientMessages,
+ final List serverMessages,
+ final Map initialHeaders,
+ final Map trailers) {
this.stepUuid = stepUuid;
this.methodDescriptor = methodDescriptor;
this.lifecycle = lifecycle;
diff --git a/allure-grpc/src/test/java/io/qameta/allure/grpc/AllureGrpcTest.java b/allure-grpc/src/test/java/io/qameta/allure/grpc/AllureGrpcTest.java
index a98e09e70..ec5d55ca1 100644
--- a/allure-grpc/src/test/java/io/qameta/allure/grpc/AllureGrpcTest.java
+++ b/allure-grpc/src/test/java/io/qameta/allure/grpc/AllureGrpcTest.java
@@ -61,37 +61,47 @@ class AllureGrpcTest {
@BeforeEach
void configureMockServer() {
managedChannel = ManagedChannelBuilder
- .forAddress("localhost", GrpcMock.getGlobalPort())
- .usePlaintext()
- .directExecutor()
- .build();
-
- GrpcMock.stubFor(unaryMethod(TestServiceGrpc.getCalculateMethod())
- .willReturn(Response.newBuilder().setMessage(RESPONSE_MESSAGE).build()));
-
- GrpcMock.stubFor(serverStreamingMethod(TestServiceGrpc.getCalculateServerStreamMethod())
- .willReturn(asList(
- Response.newBuilder().setMessage(RESPONSE_MESSAGE).build(),
- Response.newBuilder().setMessage(RESPONSE_MESSAGE).build()
- )));
-
- GrpcMock.stubFor(clientStreamingMethod(TestServiceGrpc.getCalculateClientStreamMethod())
- .willReturn(Response.newBuilder().setMessage(RESPONSE_MESSAGE).build()));
-
- GrpcMock.stubFor(bidiStreamingMethod(TestServiceGrpc.getCalculateBidiStreamMethod())
- .willProxyTo(responseObserver -> new StreamObserver() {
- @Override
- public void onNext(Request request) {
- responseObserver.onNext(Response.newBuilder().setMessage(RESPONSE_MESSAGE).build());
- }
- @Override
- public void onError(Throwable throwable) {
- }
- @Override
- public void onCompleted() {
- responseObserver.onCompleted();
- }
- }));
+ .forAddress("localhost", GrpcMock.getGlobalPort())
+ .usePlaintext()
+ .directExecutor()
+ .build();
+
+ GrpcMock.stubFor(
+ unaryMethod(TestServiceGrpc.getCalculateMethod())
+ .willReturn(Response.newBuilder().setMessage(RESPONSE_MESSAGE).build())
+ );
+
+ GrpcMock.stubFor(
+ serverStreamingMethod(TestServiceGrpc.getCalculateServerStreamMethod())
+ .willReturn(
+ asList(
+ Response.newBuilder().setMessage(RESPONSE_MESSAGE).build(),
+ Response.newBuilder().setMessage(RESPONSE_MESSAGE).build()
+ )
+ )
+ );
+
+ GrpcMock.stubFor(
+ clientStreamingMethod(TestServiceGrpc.getCalculateClientStreamMethod())
+ .willReturn(Response.newBuilder().setMessage(RESPONSE_MESSAGE).build())
+ );
+
+ GrpcMock.stubFor(
+ bidiStreamingMethod(TestServiceGrpc.getCalculateBidiStreamMethod())
+ .willProxyTo(responseObserver -> new StreamObserver() {
+ @Override
+ public void onNext(Request request) {
+ responseObserver.onNext(Response.newBuilder().setMessage(RESPONSE_MESSAGE).build());
+ }
+ @Override
+ public void onError(Throwable throwable) {
+ }
+ @Override
+ public void onCompleted() {
+ responseObserver.onCompleted();
+ }
+ })
+ );
}
@AfterEach
@@ -102,8 +112,8 @@ void shutdownChannel() {
@Test
void shouldCreateRequestAttachment() {
Request request = Request.newBuilder()
- .setTopic("1")
- .build();
+ .setTopic("1")
+ .build();
Status errorStatus = Status.NOT_FOUND;
GrpcMock.stubFor(unaryMethod(TestServiceGrpc.getCalculateMethod()).willReturn(errorStatus));
@@ -111,40 +121,40 @@ void shouldCreateRequestAttachment() {
AllureResults allureResults = executeUnaryExpectingException(request);
assertThat(allureResults.getTestResults().get(0).getSteps().get(0).getStatus())
- .isEqualTo(io.qameta.allure.model.Status.FAILED);
+ .isEqualTo(io.qameta.allure.model.Status.FAILED);
assertThat(allureResults.getTestResults().get(0).getSteps())
- .flatExtracting(StepResult::getAttachments)
- .extracting(Attachment::getName)
- .contains("gRPC request", "gRPC response");
+ .flatExtracting(StepResult::getAttachments)
+ .extracting(Attachment::getName)
+ .contains("gRPC request", "gRPC response");
}
@Test
void shouldCreateResponseAttachment() {
Request request = Request.newBuilder()
- .setTopic("1")
- .build();
+ .setTopic("1")
+ .build();
AllureResults allureResults = executeUnary(request);
assertThat(allureResults.getTestResults().get(0).getSteps())
- .flatExtracting(StepResult::getAttachments)
- .extracting(Attachment::getName)
- .contains("gRPC response");
+ .flatExtracting(StepResult::getAttachments)
+ .extracting(Attachment::getName)
+ .contains("gRPC response");
}
@Test
void shouldCreateResponseAttachmentForServerStreamingResponse() {
Request request = Request.newBuilder()
- .setTopic("1")
- .build();
+ .setTopic("1")
+ .build();
AllureResults allureResults = executeServerStreaming(request);
assertThat(allureResults.getTestResults().get(0).getSteps())
- .flatExtracting(StepResult::getAttachments)
- .extracting(Attachment::getName)
- .contains("gRPC response (collection of elements from Server stream)");
+ .flatExtracting(StepResult::getAttachments)
+ .extracting(Attachment::getName)
+ .contains("gRPC response (collection of elements from Server stream)");
}
@Test
@@ -153,18 +163,18 @@ void shouldCreateResponseAttachmentOnStatusException() {
GrpcMock.stubFor(unaryMethod(TestServiceGrpc.getCalculateMethod()).willReturn(notFoundStatus));
Request request = Request.newBuilder()
- .setTopic("2")
- .build();
+ .setTopic("2")
+ .build();
AllureResults allureResults = executeUnaryExpectingException(request);
assertThat(allureResults.getTestResults().get(0).getSteps().get(0).getStatus())
- .isEqualTo(io.qameta.allure.model.Status.FAILED);
+ .isEqualTo(io.qameta.allure.model.Status.FAILED);
assertThat(allureResults.getTestResults().get(0).getSteps())
- .flatExtracting(StepResult::getAttachments)
- .extracting(Attachment::getName)
- .contains("gRPC response");
+ .flatExtracting(StepResult::getAttachments)
+ .extracting(Attachment::getName)
+ .contains("gRPC response");
}
@Test
@@ -173,8 +183,7 @@ void shouldCreateAttachmentsForClientStreamingWithAsynchronousStub() {
Request secondClientRequest = Request.newBuilder().setTopic("B").build();
runWithinTestContext(() -> {
- TestServiceGrpc.TestServiceStub asynchronousStub =
- TestServiceGrpc.newStub(managedChannel).withInterceptors(new AllureGrpc());
+ TestServiceGrpc.TestServiceStub asynchronousStub = TestServiceGrpc.newStub(managedChannel).withInterceptors(new AllureGrpc());
final List receivedResponses = new ArrayList();
@@ -209,16 +218,22 @@ void shouldCreateAttachmentsForBidirectionalStreamingWithAsynchronousStub() {
Request secondBidirectionalRequest = Request.newBuilder().setTopic("D").build();
runWithinTestContext(() -> {
- TestServiceGrpc.TestServiceStub asynchronousStub =
- TestServiceGrpc.newStub(managedChannel).withInterceptors(new AllureGrpc());
+ TestServiceGrpc.TestServiceStub asynchronousStub = TestServiceGrpc.newStub(managedChannel).withInterceptors(new AllureGrpc());
List receivedResponses = new ArrayList<>();
Allure.step("async-root-bidi-stream", () -> {
StreamObserver responseObserver = new StreamObserver() {
- @Override public void onNext(Response value) { receivedResponses.add(value); }
- @Override public void onError(Throwable throwable) { }
- @Override public void onCompleted() { }
+ @Override
+ public void onNext(Response value) {
+ receivedResponses.add(value);
+ }
+ @Override
+ public void onError(Throwable throwable) {
+ }
+ @Override
+ public void onCompleted() {
+ }
};
StreamObserver requestObserver = asynchronousStub.calculateBidiStream(responseObserver);
@@ -235,14 +250,15 @@ void shouldCreateAttachmentsForBidirectionalStreamingWithAsynchronousStub() {
@Test
void unaryRequestBodyIsCapturedAsJsonObject() throws Exception {
- GrpcMock.stubFor(unaryMethod(TestServiceGrpc.getCalculateMethod())
- .willReturn(Response.newBuilder().setMessage("ok").build()));
+ GrpcMock.stubFor(
+ unaryMethod(TestServiceGrpc.getCalculateMethod())
+ .willReturn(Response.newBuilder().setMessage("ok").build())
+ );
Request request = Request.newBuilder().setTopic("topic-1").build();
AllureResults allureResults = runWithinTestContext(() -> {
- TestServiceGrpc.TestServiceBlockingStub stub =
- TestServiceGrpc.newBlockingStub(managedChannel).withInterceptors(new AllureGrpc());
+ TestServiceGrpc.TestServiceBlockingStub stub = TestServiceGrpc.newBlockingStub(managedChannel).withInterceptors(new AllureGrpc());
Response response = stub.calculate(request);
assertThat(response.getMessage()).isEqualTo("ok");
});
@@ -256,14 +272,15 @@ void unaryRequestBodyIsCapturedAsJsonObject() throws Exception {
@Test
void unaryResponseBodyIsCapturedAsJsonObject() throws Exception {
- GrpcMock.stubFor(unaryMethod(TestServiceGrpc.getCalculateMethod())
- .willReturn(Response.newBuilder().setMessage("hello-world").build()));
+ GrpcMock.stubFor(
+ unaryMethod(TestServiceGrpc.getCalculateMethod())
+ .willReturn(Response.newBuilder().setMessage("hello-world").build())
+ );
Request request = Request.newBuilder().setTopic("x").build();
AllureResults allureResults = runWithinTestContext(() -> {
- TestServiceGrpc.TestServiceBlockingStub stub =
- TestServiceGrpc.newBlockingStub(managedChannel).withInterceptors(new AllureGrpc());
+ TestServiceGrpc.TestServiceBlockingStub stub = TestServiceGrpc.newBlockingStub(managedChannel).withInterceptors(new AllureGrpc());
Response response = stub.calculate(request);
assertThat(response.getMessage()).isEqualTo("hello-world");
});
@@ -277,17 +294,20 @@ void unaryResponseBodyIsCapturedAsJsonObject() throws Exception {
@Test
void serverStreamingResponseBodyIsJsonArrayInOrder() throws Exception {
- GrpcMock.stubFor(serverStreamingMethod(TestServiceGrpc.getCalculateServerStreamMethod())
- .willReturn(asList(
- Response.newBuilder().setMessage("first").build(),
- Response.newBuilder().setMessage("second").build()
- )));
+ GrpcMock.stubFor(
+ serverStreamingMethod(TestServiceGrpc.getCalculateServerStreamMethod())
+ .willReturn(
+ asList(
+ Response.newBuilder().setMessage("first").build(),
+ Response.newBuilder().setMessage("second").build()
+ )
+ )
+ );
Request request = Request.newBuilder().setTopic("stream-topic").build();
AllureResults allureResults = runWithinTestContext(() -> {
- TestServiceGrpc.TestServiceBlockingStub stub =
- TestServiceGrpc.newBlockingStub(managedChannel).withInterceptors(new AllureGrpc());
+ TestServiceGrpc.TestServiceBlockingStub stub = TestServiceGrpc.newBlockingStub(managedChannel).withInterceptors(new AllureGrpc());
Iterator responseIterator = stub.calculateServerStream(request);
assertThat(responseIterator.hasNext()).isTrue();
assertThat(responseIterator.next().getMessage()).isEqualTo("first");
@@ -297,7 +317,7 @@ void serverStreamingResponseBodyIsJsonArrayInOrder() throws Exception {
});
String jsonPayload = readJsonAttachmentByName(
- allureResults, "gRPC response (collection of elements from Server stream) (json)"
+ allureResults, "gRPC response (collection of elements from Server stream) (json)"
);
JsonNode actualJsonArray = JSON.readTree(jsonPayload);
@@ -310,10 +330,10 @@ private static String readJsonAttachmentByName(AllureResults allureResults, Stri
TestResult test = allureResults.getTestResults().get(0);
Attachment matchedAttachment = flattenSteps(test.getSteps()).stream()
- .flatMap(step -> step.getAttachments().stream())
- .filter(attachment -> jsonAttachmentName.equals(attachment.getName()))
- .findFirst()
- .orElseThrow(() -> new IllegalStateException("Attachment not found: " + jsonAttachmentName));
+ .flatMap(step -> step.getAttachments().stream())
+ .filter(attachment -> jsonAttachmentName.equals(attachment.getName()))
+ .findFirst()
+ .orElseThrow(() -> new IllegalStateException("Attachment not found: " + jsonAttachmentName));
String attachmentSourceKey = matchedAttachment.getSource();
Map attachmentsContent = allureResults.getAttachments();
@@ -327,8 +347,7 @@ private static String readJsonAttachmentByName(AllureResults allureResults, Stri
protected final AllureResults executeUnary(Request request) {
return runWithinTestContext(() -> {
try {
- TestServiceGrpc.TestServiceBlockingStub stub =
- TestServiceGrpc.newBlockingStub(managedChannel).withInterceptors(new AllureGrpc());
+ TestServiceGrpc.TestServiceBlockingStub stub = TestServiceGrpc.newBlockingStub(managedChannel).withInterceptors(new AllureGrpc());
Response response = stub.calculate(request);
assertThat(response.getMessage()).isEqualTo(RESPONSE_MESSAGE);
} catch (Exception exception) {
@@ -340,8 +359,7 @@ protected final AllureResults executeUnary(Request request) {
protected final AllureResults executeServerStreaming(Request request) {
return runWithinTestContext(() -> {
try {
- TestServiceGrpc.TestServiceBlockingStub stub =
- TestServiceGrpc.newBlockingStub(managedChannel).withInterceptors(new AllureGrpc());
+ TestServiceGrpc.TestServiceBlockingStub stub = TestServiceGrpc.newBlockingStub(managedChannel).withInterceptors(new AllureGrpc());
Iterator responseIterator = stub.calculateServerStream(request);
int responseCount = 0;
while (responseIterator.hasNext()) {
@@ -356,14 +374,13 @@ protected final AllureResults executeServerStreaming(Request request) {
}
protected final AllureResults executeUnaryExpectingException(Request request) {
- return runWithinTestContext(() ->
- assertThatExceptionOfType(StatusRuntimeException.class)
- .isThrownBy(() -> {
- TestServiceGrpc.TestServiceBlockingStub stub =
- TestServiceGrpc.newBlockingStub(managedChannel).withInterceptors(new AllureGrpc());
- Response response = stub.calculate(request);
- assertThat(response.getMessage()).isEqualTo("ok");
- })
+ return runWithinTestContext(
+ () -> assertThatExceptionOfType(StatusRuntimeException.class)
+ .isThrownBy(() -> {
+ TestServiceGrpc.TestServiceBlockingStub stub = TestServiceGrpc.newBlockingStub(managedChannel).withInterceptors(new AllureGrpc());
+ Response response = stub.calculate(request);
+ assertThat(response.getMessage()).isEqualTo("ok");
+ })
);
}
diff --git a/allure-hamcrest/src/main/java/io/qameta/allure/hamcrest/AllureHamcrestAssert.java b/allure-hamcrest/src/main/java/io/qameta/allure/hamcrest/AllureHamcrestAssert.java
index 60153b143..4a1782edc 100644
--- a/allure-hamcrest/src/main/java/io/qameta/allure/hamcrest/AllureHamcrestAssert.java
+++ b/allure-hamcrest/src/main/java/io/qameta/allure/hamcrest/AllureHamcrestAssert.java
@@ -15,17 +15,17 @@
*/
package io.qameta.allure.hamcrest;
-import org.aspectj.lang.JoinPoint;
-import org.aspectj.lang.annotation.Aspect;
-import org.aspectj.lang.annotation.Pointcut;
-import org.aspectj.lang.annotation.Before;
-import org.aspectj.lang.annotation.AfterThrowing;
-import org.aspectj.lang.annotation.AfterReturning;
import io.qameta.allure.Allure;
import io.qameta.allure.AllureLifecycle;
import io.qameta.allure.model.Status;
import io.qameta.allure.model.StepResult;
import io.qameta.allure.util.ObjectUtils;
+import org.aspectj.lang.JoinPoint;
+import org.aspectj.lang.annotation.AfterReturning;
+import org.aspectj.lang.annotation.AfterThrowing;
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.Before;
+import org.aspectj.lang.annotation.Pointcut;
import org.hamcrest.Matcher;
import org.hamcrest.StringDescription;
@@ -106,7 +106,10 @@ public void catchAndStartStep(final JoinPoint joinPoint) {
}
}
- @AfterThrowing(pointcut = "initAssertThat()", throwing = "e")
+ @AfterThrowing(
+ pointcut = "initAssertThat()",
+ throwing = "e"
+ )
public void stepFailed(final Throwable e) {
getLifecycle().updateStep(s -> s.setStatus(getStatus(e).orElse(Status.BROKEN)));
getLifecycle().stopStep();
diff --git a/allure-hamcrest/src/test/java/io/qameta/allure/hamcrest/AllureHamcrestCollectionsMatchersTest.java b/allure-hamcrest/src/test/java/io/qameta/allure/hamcrest/AllureHamcrestCollectionsMatchersTest.java
index 21f2e5ee1..acdd8900c 100644
--- a/allure-hamcrest/src/test/java/io/qameta/allure/hamcrest/AllureHamcrestCollectionsMatchersTest.java
+++ b/allure-hamcrest/src/test/java/io/qameta/allure/hamcrest/AllureHamcrestCollectionsMatchersTest.java
@@ -54,7 +54,7 @@ public class AllureHamcrestCollectionsMatchersTest {
@Test
void hamcrestAssertNameForArrayMatchers() {
final TestResult testResult = runWithinTestContext(
- () -> assertThat(new Integer[]{1,2,3}, is(array(equalTo(1), equalTo(2), equalTo(3)))),
+ () -> assertThat(new Integer[]{1, 2, 3}, is(array(equalTo(1), equalTo(2), equalTo(3)))),
AllureHamcrestAssert::setLifecycle
).getTestResults().get(0);
diff --git a/allure-hamcrest/src/test/java/io/qameta/allure/hamcrest/AllureHamcrestTextMatchersTest.java b/allure-hamcrest/src/test/java/io/qameta/allure/hamcrest/AllureHamcrestTextMatchersTest.java
index 6c3932a0d..515f6ecbb 100644
--- a/allure-hamcrest/src/test/java/io/qameta/allure/hamcrest/AllureHamcrestTextMatchersTest.java
+++ b/allure-hamcrest/src/test/java/io/qameta/allure/hamcrest/AllureHamcrestTextMatchersTest.java
@@ -20,7 +20,6 @@
import org.assertj.core.api.Assertions;
import org.hamcrest.Matcher;
import org.junit.jupiter.api.TestInstance;
-
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
diff --git a/allure-httpclient/src/main/java/io/qameta/allure/httpclient/AllureHttpClientRequest.java b/allure-httpclient/src/main/java/io/qameta/allure/httpclient/AllureHttpClientRequest.java
index e988f9226..833f45bca 100644
--- a/allure-httpclient/src/main/java/io/qameta/allure/httpclient/AllureHttpClientRequest.java
+++ b/allure-httpclient/src/main/java/io/qameta/allure/httpclient/AllureHttpClientRequest.java
@@ -43,8 +43,9 @@ public class AllureHttpClientRequest implements HttpRequestInterceptor {
private final AttachmentProcessor processor;
public AllureHttpClientRequest() {
- this(new FreemarkerAttachmentRenderer("http-request.ftl"),
- new DefaultAttachmentProcessor()
+ this(
+ new FreemarkerAttachmentRenderer("http-request.ftl"),
+ new DefaultAttachmentProcessor()
);
}
@@ -55,20 +56,25 @@ public AllureHttpClientRequest(final AttachmentRenderer renderer
}
private static String getAttachmentName(final HttpRequest request) {
- return String.format("Request_%s_%s", request.getRequestLine().getMethod(),
- request.getRequestLine().getUri());
+ return String.format(
+ "Request_%s_%s", request.getRequestLine().getMethod(),
+ request.getRequestLine().getUri()
+ );
}
@Override
public void process(final HttpRequest request,
- final HttpContext context) throws IOException {
+ final HttpContext context)
+ throws IOException {
- final HttpRequestAttachment.Builder builder = create(getAttachmentName(request),
- request.getRequestLine().getUri())
+ final HttpRequestAttachment.Builder builder = create(
+ getAttachmentName(request),
+ request.getRequestLine().getUri()
+ )
.setMethod(request.getRequestLine().getMethod());
Stream.of(request.getAllHeaders())
- .forEach(header -> builder.setHeader(header.getName(), header.getValue()));
+ .forEach(header -> builder.setHeader(header.getName(), header.getValue()));
if (request instanceof HttpEntityEnclosingRequest) {
final HttpEntity entity = ((HttpEntityEnclosingRequest) request).getEntity();
diff --git a/allure-httpclient/src/main/java/io/qameta/allure/httpclient/AllureHttpClientResponse.java b/allure-httpclient/src/main/java/io/qameta/allure/httpclient/AllureHttpClientResponse.java
index d34476b6c..5e8daec13 100644
--- a/allure-httpclient/src/main/java/io/qameta/allure/httpclient/AllureHttpClientResponse.java
+++ b/allure-httpclient/src/main/java/io/qameta/allure/httpclient/AllureHttpClientResponse.java
@@ -41,7 +41,8 @@ public class AllureHttpClientResponse implements HttpResponseInterceptor {
private final AttachmentProcessor processor;
public AllureHttpClientResponse() {
- this(new FreemarkerAttachmentRenderer("http-response.ftl"),
+ this(
+ new FreemarkerAttachmentRenderer("http-response.ftl"),
new DefaultAttachmentProcessor()
);
}
@@ -54,7 +55,8 @@ public AllureHttpClientResponse(final AttachmentRenderer rendere
@Override
public void process(final HttpResponse response,
- final HttpContext context) throws IOException {
+ final HttpContext context)
+ throws IOException {
final HttpResponseAttachment.Builder builder = create("Response")
.setResponseCode(response.getStatusLine().getStatusCode());
diff --git a/allure-httpclient/src/test/java/io/qameta/allure/httpclient/AllureHttpClientTest.java b/allure-httpclient/src/test/java/io/qameta/allure/httpclient/AllureHttpClientTest.java
index 4126ca325..8ed24f1f4 100644
--- a/allure-httpclient/src/test/java/io/qameta/allure/httpclient/AllureHttpClientTest.java
+++ b/allure-httpclient/src/test/java/io/qameta/allure/httpclient/AllureHttpClientTest.java
@@ -62,16 +62,26 @@ void setUp() {
server.start();
configureFor(server.port());
- stubFor(get(urlEqualTo("/hello"))
- .willReturn(aResponse()
- .withBody(BODY_STRING)));
-
- stubFor(get(urlEqualTo("/empty"))
- .willReturn(aResponse()
- .withStatus(304)));
-
- stubFor(delete(urlEqualTo("/hello"))
- .willReturn(noContent()));
+ stubFor(
+ get(urlEqualTo("/hello"))
+ .willReturn(
+ aResponse()
+ .withBody(BODY_STRING)
+ )
+ );
+
+ stubFor(
+ get(urlEqualTo("/empty"))
+ .willReturn(
+ aResponse()
+ .withStatus(304)
+ )
+ );
+
+ stubFor(
+ delete(urlEqualTo("/hello"))
+ .willReturn(noContent())
+ );
}
@AfterEach
@@ -169,7 +179,7 @@ void shouldCreateRequestAttachmentWithEmptyBodyWhenNoContentIsReturned() throws
final AttachmentProcessor processor = mock(AttachmentProcessor.class);
final HttpClientBuilder builder = HttpClientBuilder.create()
- .addInterceptorLast(new AllureHttpClientRequest(renderer, processor));
+ .addInterceptorLast(new AllureHttpClientRequest(renderer, processor));
try (CloseableHttpClient httpClient = builder.build()) {
final HttpDelete httpDelete = new HttpDelete(String.format("http://localhost:%d/hello", server.port()));
@@ -195,16 +205,16 @@ void shouldNotConsumeBody() throws Exception {
final AttachmentProcessor processor = mock(AttachmentProcessor.class);
final HttpClientBuilder builder = HttpClientBuilder.create()
- .addInterceptorLast(new AllureHttpClientResponse(renderer, processor));
+ .addInterceptorLast(new AllureHttpClientResponse(renderer, processor));
try (CloseableHttpClient httpClient = builder.build()) {
- final HttpGet httpGet = new HttpGet(String.format("http://localhost:%d/hello", server.port()));
- try (CloseableHttpResponse response = httpClient.execute(httpGet)) {
- response.getStatusLine().getStatusCode();
- BufferedHttpEntity ent = new BufferedHttpEntity(response.getEntity());
- assertThat(EntityUtils.toString(ent))
- .isEqualTo(BODY_STRING);
- }
+ final HttpGet httpGet = new HttpGet(String.format("http://localhost:%d/hello", server.port()));
+ try (CloseableHttpResponse response = httpClient.execute(httpGet)) {
+ response.getStatusLine().getStatusCode();
+ BufferedHttpEntity ent = new BufferedHttpEntity(response.getEntity());
+ assertThat(EntityUtils.toString(ent))
+ .isEqualTo(BODY_STRING);
+ }
}
}
}
diff --git a/allure-httpclient5/src/main/java/io/qameta/allure/httpclient5/AllureHttpClient5Response.java b/allure-httpclient5/src/main/java/io/qameta/allure/httpclient5/AllureHttpClient5Response.java
index 5c9683b47..90cdd03ac 100644
--- a/allure-httpclient5/src/main/java/io/qameta/allure/httpclient5/AllureHttpClient5Response.java
+++ b/allure-httpclient5/src/main/java/io/qameta/allure/httpclient5/AllureHttpClient5Response.java
@@ -37,9 +37,11 @@
/**
* @author a-simeshin (Simeshin Artem)
*/
-@SuppressWarnings({
- "checkstyle:ParameterAssignment",
- "PMD.AvoidReassigningParameters"})
+@SuppressWarnings(
+ {
+ "checkstyle:ParameterAssignment",
+ "PMD.AvoidReassigningParameters"}
+)
public class AllureHttpClient5Response implements HttpResponseInterceptor {
private final AttachmentRenderer renderer;
private final AttachmentProcessor processor;
@@ -71,7 +73,8 @@ public AllureHttpClient5Response(final AttachmentRenderer render
@Override
public void process(final HttpResponse response,
EntityDetails entity,
- final HttpContext context) throws IOException {
+ final HttpContext context)
+ throws IOException {
final HttpResponseAttachment.Builder builder = create("Response");
builder.setResponseCode(response.getCode());
@@ -82,8 +85,7 @@ public void process(final HttpResponse response,
// Looks like a bug or completely new logic. It's not enough to replace chaining EntityDetails entity.
// To read the response body twice, It needs to put in the context also
entity = new BufferedHttpEntity(originalHttpEntity);
- final BasicClassicHttpResponse responseEntity =
- (BasicClassicHttpResponse) context.getAttribute("http.response");
+ final BasicClassicHttpResponse responseEntity = (BasicClassicHttpResponse) context.getAttribute("http.response");
responseEntity.setEntity((HttpEntity) entity);
final String responseBody = AllureHttpEntityUtils.getBody((HttpEntity) entity);
diff --git a/allure-httpclient5/src/test/java/io/qameta/allure/httpclient5/AllureHttpClient5DeleteTest.java b/allure-httpclient5/src/test/java/io/qameta/allure/httpclient5/AllureHttpClient5DeleteTest.java
index 0b9688566..89ad99f75 100644
--- a/allure-httpclient5/src/test/java/io/qameta/allure/httpclient5/AllureHttpClient5DeleteTest.java
+++ b/allure-httpclient5/src/test/java/io/qameta/allure/httpclient5/AllureHttpClient5DeleteTest.java
@@ -58,9 +58,11 @@ void setUp() {
server.start();
configureFor(server.port());
- stubFor(delete(HELLO_RESOURCE_PATH).willReturn(
- aResponse()
- .withStatus(204))
+ stubFor(
+ delete(HELLO_RESOURCE_PATH).willReturn(
+ aResponse()
+ .withStatus(204)
+ )
);
}
diff --git a/allure-httpclient5/src/test/java/io/qameta/allure/httpclient5/AllureHttpClient5GetTest.java b/allure-httpclient5/src/test/java/io/qameta/allure/httpclient5/AllureHttpClient5GetTest.java
index d750d5cc2..468f25803 100644
--- a/allure-httpclient5/src/test/java/io/qameta/allure/httpclient5/AllureHttpClient5GetTest.java
+++ b/allure-httpclient5/src/test/java/io/qameta/allure/httpclient5/AllureHttpClient5GetTest.java
@@ -53,7 +53,6 @@ class AllureHttpClient5GetTest {
private static final String HELLO_GET_RETURN_BODY = "http://localhost:%d/hello";
private static final String HELLO_GET_201_NO_BODY = "http://localhost:%d/empty";
-
private WireMockServer server;
@BeforeEach
@@ -62,14 +61,18 @@ void setUp() {
server.start();
configureFor(server.port());
- stubFor(get(HELLO_RESOURCE_PATH).willReturn(
- aResponse()
- .withHeader("Content-Type", "application/json")
- .withBody(BODY_STRING)
- ));
- stubFor(get("/empty").willReturn(
- aResponse()
- .withStatus(200))
+ stubFor(
+ get(HELLO_RESOURCE_PATH).willReturn(
+ aResponse()
+ .withHeader("Content-Type", "application/json")
+ .withBody(BODY_STRING)
+ )
+ );
+ stubFor(
+ get("/empty").willReturn(
+ aResponse()
+ .withStatus(200)
+ )
);
}
diff --git a/allure-httpclient5/src/test/java/io/qameta/allure/httpclient5/AllureHttpClient5PostTest.java b/allure-httpclient5/src/test/java/io/qameta/allure/httpclient5/AllureHttpClient5PostTest.java
index 3346e1835..e2a375df8 100644
--- a/allure-httpclient5/src/test/java/io/qameta/allure/httpclient5/AllureHttpClient5PostTest.java
+++ b/allure-httpclient5/src/test/java/io/qameta/allure/httpclient5/AllureHttpClient5PostTest.java
@@ -56,7 +56,6 @@ class AllureHttpClient5PostTest {
private static final String HELLO_POST_RETURN_BODY = "http://localhost:%d/hello";
private static final String HELLO_POST_201_NO_BODY = "http://localhost:%d/empty";
-
private WireMockServer server;
@BeforeEach
@@ -65,14 +64,18 @@ void setUp() {
server.start();
configureFor(server.port());
- stubFor(post(HELLO_RESOURCE_PATH).willReturn(
- aResponse()
- .withHeader("Content-Type", "application/json")
- .withBody(BODY_STRING)
- ));
- stubFor(post("/empty").willReturn(
- aResponse()
- .withStatus(201))
+ stubFor(
+ post(HELLO_RESOURCE_PATH).willReturn(
+ aResponse()
+ .withHeader("Content-Type", "application/json")
+ .withBody(BODY_STRING)
+ )
+ );
+ stubFor(
+ post("/empty").willReturn(
+ aResponse()
+ .withStatus(201)
+ )
);
}
diff --git a/allure-java-commons-test/src/main/java/io/qameta/allure/test/AllureResults.java b/allure-java-commons-test/src/main/java/io/qameta/allure/test/AllureResults.java
index bc9225725..d41aacf98 100644
--- a/allure-java-commons-test/src/main/java/io/qameta/allure/test/AllureResults.java
+++ b/allure-java-commons-test/src/main/java/io/qameta/allure/test/AllureResults.java
@@ -39,9 +39,11 @@ default TestResult getTestResultByName(final String name) {
return getTestResults().stream()
.filter(tr -> Objects.equals(name, tr.getName()))
.findFirst()
- .orElseThrow(() -> new NoSuchElementException(
- "test result with name " + name + " is not found"
- ));
+ .orElseThrow(
+ () -> new NoSuchElementException(
+ "test result with name " + name + " is not found"
+ )
+ );
}
default List getTestResultContainersForTestResult(final TestResult testResult) {
diff --git a/allure-java-commons-test/src/main/java/io/qameta/allure/test/AllureTestCommonsUtils.java b/allure-java-commons-test/src/main/java/io/qameta/allure/test/AllureTestCommonsUtils.java
index 75fa00300..1065f8119 100644
--- a/allure-java-commons-test/src/main/java/io/qameta/allure/test/AllureTestCommonsUtils.java
+++ b/allure-java-commons-test/src/main/java/io/qameta/allure/test/AllureTestCommonsUtils.java
@@ -51,10 +51,11 @@ public final class AllureTestCommonsUtils {
.configure(USE_WRAPPER_NAME_AS_PROPERTY_NAME, true)
.serializationInclusion(NON_DEFAULT)
.build()
- .registerModule(new SimpleModule()
- .addSerializer(Status.class, new StatusSerializer())
- .addSerializer(Stage.class, new StageSerializer())
- .addSerializer(Parameter.Mode.class, new ParameterModeSerializer())
+ .registerModule(
+ new SimpleModule()
+ .addSerializer(Status.class, new StatusSerializer())
+ .addSerializer(Stage.class, new StageSerializer())
+ .addSerializer(Parameter.Mode.class, new ParameterModeSerializer())
)
.writerWithDefaultPrettyPrinter();
@@ -92,13 +93,14 @@ public static void attach(final AllureResults allureResults) {
}
});
- allureResults.getAttachments().forEach((fileName, body) -> Allure
- .addAttachment(
- fileName,
- type(fileName),
- new ByteArrayInputStream(body),
- extension(fileName)
- )
+ allureResults.getAttachments().forEach(
+ (fileName, body) -> Allure
+ .addAttachment(
+ fileName,
+ type(fileName),
+ new ByteArrayInputStream(body),
+ extension(fileName)
+ )
);
}
@@ -131,7 +133,8 @@ protected ParameterModeSerializer() {
@Override
public void serialize(final Parameter.Mode value,
final JsonGenerator gen,
- final SerializerProvider provider) throws IOException {
+ final SerializerProvider provider)
+ throws IOException {
gen.writeString(value.name().toLowerCase(Locale.ENGLISH));
}
}
@@ -147,7 +150,8 @@ protected StageSerializer() {
@Override
public void serialize(final Stage value,
final JsonGenerator gen,
- final SerializerProvider provider) throws IOException {
+ final SerializerProvider provider)
+ throws IOException {
gen.writeString(value.name().toLowerCase(Locale.ENGLISH));
}
}
@@ -163,7 +167,8 @@ protected StatusSerializer() {
@Override
public void serialize(final Status value,
final JsonGenerator gen,
- final SerializerProvider provider) throws IOException {
+ final SerializerProvider provider)
+ throws IOException {
gen.writeString(value.name().toLowerCase(Locale.ENGLISH));
}
}
diff --git a/allure-java-commons-test/src/main/java/io/qameta/allure/test/RunUtils.java b/allure-java-commons-test/src/main/java/io/qameta/allure/test/RunUtils.java
index d28a685e9..6faf95660 100644
--- a/allure-java-commons-test/src/main/java/io/qameta/allure/test/RunUtils.java
+++ b/allure-java-commons-test/src/main/java/io/qameta/allure/test/RunUtils.java
@@ -41,7 +41,7 @@ private RunUtils() {
}
public static AllureResults runTests(
- final Allure.ThrowableContextRunnableVoid runnable) {
+ final Allure.ThrowableContextRunnableVoid runnable) {
return runTests(
runnable,
Allure::setLifecycle,
@@ -51,8 +51,8 @@ public static AllureResults runTests(
}
public static AllureResults runTests(
- final Function lifecycleFactory,
- final Allure.ThrowableContextRunnableVoid runnable) {
+ final Function lifecycleFactory,
+ final Allure.ThrowableContextRunnableVoid runnable) {
return runTests(
lifecycleFactory,
runnable,
@@ -64,16 +64,16 @@ public static AllureResults runTests(
@SafeVarargs
public static AllureResults runTests(
- final Allure.ThrowableContextRunnableVoid runnable,
- final Consumer... configurers) {
+ final Allure.ThrowableContextRunnableVoid runnable,
+ final Consumer... configurers) {
return runTests(AllureLifecycle::new, runnable, configurers);
}
@SafeVarargs
public static AllureResults runTests(
- final Function lifecycleFactory,
- final Allure.ThrowableContextRunnableVoid runnable,
- final Consumer... configurers) {
+ final Function lifecycleFactory,
+ final Allure.ThrowableContextRunnableVoid runnable,
+ final Consumer... configurers) {
final AllureResultsWriterStub writer = new AllureResultsWriterStub();
final AllureLifecycle lifecycle = lifecycleFactory.apply(writer);
@@ -94,28 +94,28 @@ public static AllureResults runTests(
}
public static AllureResults runWithinTestContext(
- final Runnable runnable) {
+ final Runnable runnable) {
return runTests(lifecycle -> withTestContext(runnable, lifecycle));
}
public static AllureResults runWithinTestContext(
- final Function lifecycleFactory,
- final Runnable runnable) {
+ final Function lifecycleFactory,
+ final Runnable runnable) {
return runTests(lifecycleFactory, lifecycle -> withTestContext(runnable, lifecycle));
}
@SafeVarargs
public static AllureResults runWithinTestContext(
- final Runnable runnable,
- final Consumer... configurers) {
+ final Runnable runnable,
+ final Consumer... configurers) {
return runTests(lifecycle -> withTestContext(runnable, lifecycle), configurers);
}
@SafeVarargs
public static AllureResults runWithinTestContext(
- final Function lifecycleFactory,
- final Runnable runnable,
- final Consumer... configurers) {
+ final Function lifecycleFactory,
+ final Runnable runnable,
+ final Consumer... configurers) {
return runTests(lifecycleFactory, lifecycle -> withTestContext(runnable, lifecycle), configurers);
}
diff --git a/allure-java-commons-test/src/test/java/io/qameta/allure/test/RunUtilsTest.java b/allure-java-commons-test/src/test/java/io/qameta/allure/test/RunUtilsTest.java
index 12bd9c5d5..265ae9f9f 100644
--- a/allure-java-commons-test/src/test/java/io/qameta/allure/test/RunUtilsTest.java
+++ b/allure-java-commons-test/src/test/java/io/qameta/allure/test/RunUtilsTest.java
@@ -27,10 +27,9 @@ class RunUtilsTest {
@Test
void shouldCaptureFailureStatusWithinSyntheticTestContext() {
- final AllureResults results = Allure.step("Execute a synthetic test context that raises an assertion error", () ->
- RunUtils.runWithinTestContext(() -> {
- throw new AssertionError("boom");
- })
+ final AllureResults results = Allure.step("Execute a synthetic test context that raises an assertion error", () -> RunUtils.runWithinTestContext(() -> {
+ throw new AssertionError("boom");
+ })
);
Allure.step("Verify the captured synthetic test result is marked as failed", () -> {
@@ -42,19 +41,20 @@ void shouldCaptureFailureStatusWithinSyntheticTestContext() {
@Test
void shouldAttachNestedRunArtifactsToOuterLifecycle() {
- final AllureResults results = Allure.step("Execute a nested synthetic run and capture its emitted attachments", () ->
- RunUtils.runWithinTestContext(() ->
- RunUtils.runWithinTestContext(() -> {
- })
+ final AllureResults results = Allure
+ .step("Execute a nested synthetic run and capture its emitted attachments", () -> RunUtils.runWithinTestContext(() -> RunUtils.runWithinTestContext(() -> {
+ })
)
- );
+ );
Allure.addAttachment("nested-attachment-keys", String.join("\n", results.getAttachments().keySet()));
Allure.step("Verify the outer lifecycle receives serialized artifacts from the nested run", () -> {
assertFalse(results.getAttachments().isEmpty());
- assertTrue(results.getAttachments().values().stream()
- .map(bytes -> new String(bytes, java.nio.charset.StandardCharsets.UTF_8))
- .anyMatch(body -> body.contains("\"uuid\"")));
+ assertTrue(
+ results.getAttachments().values().stream()
+ .map(bytes -> new String(bytes, java.nio.charset.StandardCharsets.UTF_8))
+ .anyMatch(body -> body.contains("\"uuid\""))
+ );
});
}
}
diff --git a/allure-java-commons-test/src/test/java/io/qameta/allure/test/TestUtilitiesTest.java b/allure-java-commons-test/src/test/java/io/qameta/allure/test/TestUtilitiesTest.java
index d7fb298d1..2ecb62921 100644
--- a/allure-java-commons-test/src/test/java/io/qameta/allure/test/TestUtilitiesTest.java
+++ b/allure-java-commons-test/src/test/java/io/qameta/allure/test/TestUtilitiesTest.java
@@ -15,8 +15,8 @@
*/
package io.qameta.allure.test;
-import io.qameta.allure.Allure;
import io.github.benas.randombeans.api.EnhancedRandom;
+import io.qameta.allure.Allure;
import org.junit.jupiter.api.Test;
import java.util.concurrent.atomic.AtomicReference;
@@ -32,8 +32,8 @@ class TestUtilitiesTest {
void shouldGenerateStableThreadLocalRandomPerThread() throws Exception {
final EnhancedRandom mainThread = ThreadLocalEnhancedRandom.current();
final AtomicReference workerThread = new AtomicReference<>();
- final Thread thread = new Thread(() ->
- workerThread.set(ThreadLocalEnhancedRandom.current())
+ final Thread thread = new Thread(
+ () -> workerThread.set(ThreadLocalEnhancedRandom.current())
);
Allure.step("Resolve thread-local random generators on two threads and compare their identities", () -> {
@@ -42,7 +42,7 @@ void shouldGenerateStableThreadLocalRandomPerThread() throws Exception {
Allure.addAttachment(
"thread-local-random-identities",
"main=" + System.identityHashCode(mainThread)
- + "\nworker=" + System.identityHashCode(workerThread.get())
+ + "\nworker=" + System.identityHashCode(workerThread.get())
);
assertSame(mainThread, ThreadLocalEnhancedRandom.current());
assertNotSame(mainThread, workerThread.get());
diff --git a/allure-java-commons/src/main/java/io/qameta/allure/Allure.java b/allure-java-commons/src/main/java/io/qameta/allure/Allure.java
index 25092818e..6b9d32a82 100644
--- a/allure-java-commons/src/main/java/io/qameta/allure/Allure.java
+++ b/allure-java-commons/src/main/java/io/qameta/allure/Allure.java
@@ -45,6 +45,7 @@
/**
* The class contains some useful methods to work with {@link AllureLifecycle}.
*/
+@SuppressWarnings("PMD.TooManyMethods")
public final class Allure {
private static final String TXT_EXTENSION = ".txt";
@@ -181,9 +182,11 @@ public static T step(final ThrowableContextRunnable runnable
getLifecycle().updateStep(uuid, step -> step.setStatus(Status.PASSED));
return result;
} catch (Throwable throwable) {
- getLifecycle().updateStep(s -> s
- .setStatus(getStatus(throwable).orElse(Status.BROKEN))
- .setStatusDetails(getStatusDetails(throwable).orElse(null)));
+ getLifecycle().updateStep(
+ s -> s
+ .setStatus(getStatus(throwable).orElse(Status.BROKEN))
+ .setStatusDetails(getStatusDetails(throwable).orElse(null))
+ );
throw ExceptionUtils.sneakyThrow(throwable);
} finally {
getLifecycle().stopStep(uuid);
@@ -458,24 +461,23 @@ public static void addAttachment(final String name, final String type,
}
public static CompletableFuture addByteAttachmentAsync(
- final String name, final String type, final Supplier body) {
+ final String name, final String type, final Supplier body) {
return addByteAttachmentAsync(name, type, "", body);
}
public static CompletableFuture addByteAttachmentAsync(
- final String name, final String type, final String fileExtension, final Supplier body) {
+ final String name, final String type, final String fileExtension, final Supplier body) {
final String source = getLifecycle().prepareAttachment(name, type, fileExtension);
- return supplyAsync(body).whenComplete((result, ex) ->
- getLifecycle().writeAttachment(source, new ByteArrayInputStream(result)));
+ return supplyAsync(body).whenComplete((result, ex) -> getLifecycle().writeAttachment(source, new ByteArrayInputStream(result)));
}
public static CompletableFuture addStreamAttachmentAsync(
- final String name, final String type, final Supplier body) {
+ final String name, final String type, final Supplier body) {
return addStreamAttachmentAsync(name, type, "", body);
}
public static CompletableFuture addStreamAttachmentAsync(
- final String name, final String type, final String fileExtension, final Supplier body) {
+ final String name, final String type, final String fileExtension, final Supplier body) {
final String source = lifecycle.prepareAttachment(name, type, fileExtension);
return supplyAsync(body).whenComplete((result, ex) -> lifecycle.writeAttachment(source, result));
}
diff --git a/allure-java-commons/src/main/java/io/qameta/allure/AllureLifecycle.java b/allure-java-commons/src/main/java/io/qameta/allure/AllureLifecycle.java
index dc3f9d3b6..46e7d4479 100644
--- a/allure-java-commons/src/main/java/io/qameta/allure/AllureLifecycle.java
+++ b/allure-java-commons/src/main/java/io/qameta/allure/AllureLifecycle.java
@@ -49,7 +49,7 @@
/**
* The class contains Allure context and methods to change it.
*/
-@SuppressWarnings("PMD.AvoidSynchronizedStatement")
+@SuppressWarnings({"PMD.AvoidSynchronizedStatement", "PMD.TooManyMethods"})
public class AllureLifecycle {
private static final Logger LOGGER = LoggerFactory.getLogger(AllureLifecycle.class);
@@ -641,9 +641,11 @@ private static FileSystemResultsWriter getDefaultWriter() {
final Properties properties = PropertiesUtils.loadAllureProperties();
final String path = properties.getProperty("allure.results.directory", "allure-results");
final boolean cleanBeforeRun = Boolean.parseBoolean(
- properties.getProperty("allure.results.clean.before.run", "false"));
+ properties.getProperty("allure.results.clean.before.run", "false")
+ );
final boolean cleanOnlyOnce = Boolean.parseBoolean(
- properties.getProperty("allure.results.clean.only.once", "true"));
+ properties.getProperty("allure.results.clean.only.once", "true")
+ );
return new FileSystemResultsWriter(Paths.get(path), cleanBeforeRun, cleanOnlyOnce);
}
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 f4b0e3313..14216c0a7 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
@@ -29,8 +29,8 @@
import java.util.Comparator;
import java.util.Objects;
import java.util.UUID;
-import java.util.stream.Stream;
import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.stream.Stream;
/**
* @author charlie (Dmitry Baev).
@@ -54,8 +54,8 @@ public FileSystemResultsWriter(final Path outputDirectory) {
}
public FileSystemResultsWriter(final Path outputDirectory,
- final boolean cleanBeforeRun,
- final boolean cleanOnlyOnce) {
+ final boolean cleanBeforeRun,
+ final boolean cleanOnlyOnce) {
this.outputDirectory = outputDirectory;
this.cleanBeforeRun = cleanBeforeRun;
this.cleanOnlyOnce = cleanOnlyOnce;
diff --git a/allure-java-commons/src/main/java/io/qameta/allure/aspects/AttachmentsAspects.java b/allure-java-commons/src/main/java/io/qameta/allure/aspects/AttachmentsAspects.java
index 106a8069b..6db4164a7 100644
--- a/allure-java-commons/src/main/java/io/qameta/allure/aspects/AttachmentsAspects.java
+++ b/allure-java-commons/src/main/java/io/qameta/allure/aspects/AttachmentsAspects.java
@@ -39,8 +39,7 @@
@Aspect
public class AttachmentsAspects {
- private static final InheritableThreadLocal LIFECYCLE =
- new InheritableThreadLocal() {
+ private static final InheritableThreadLocal LIFECYCLE = new InheritableThreadLocal() {
@Override
protected AllureLifecycle initialValue() {
return Allure.getLifecycle();
@@ -70,13 +69,18 @@ public void anyMethod() {
* @param joinPoint the join point to process.
* @param result the returned value.
*/
- @AfterReturning(pointcut = "anyMethod() && withAttachmentAnnotation()", returning = "result")
+ @AfterReturning(
+ pointcut = "anyMethod() && withAttachmentAnnotation()",
+ returning = "result"
+ )
public void attachment(final JoinPoint joinPoint, final Object result) {
final MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
final Attachment attachment = methodSignature.getMethod()
.getAnnotation(Attachment.class);
- final byte[] bytes = (result instanceof byte[]) ? (byte[]) result : Objects.toString(result)
- .getBytes(StandardCharsets.UTF_8);
+ final byte[] bytes = (result instanceof byte[])
+ ? (byte[]) result
+ : Objects.toString(result)
+ .getBytes(StandardCharsets.UTF_8);
final String name = attachment.value().isEmpty()
? methodSignature.getName()
diff --git a/allure-java-commons/src/main/java/io/qameta/allure/aspects/StepsAspects.java b/allure-java-commons/src/main/java/io/qameta/allure/aspects/StepsAspects.java
index 8f59189d3..77e29082a 100644
--- a/allure-java-commons/src/main/java/io/qameta/allure/aspects/StepsAspects.java
+++ b/allure-java-commons/src/main/java/io/qameta/allure/aspects/StepsAspects.java
@@ -45,8 +45,7 @@
@Aspect
public class StepsAspects {
- private static final InheritableThreadLocal LIFECYCLE
- = new InheritableThreadLocal() {
+ private static final InheritableThreadLocal LIFECYCLE = new InheritableThreadLocal() {
@Override
protected AllureLifecycle initialValue() {
return Allure.getLifecycle();
@@ -79,11 +78,16 @@ public void stepStart(final JoinPoint joinPoint) {
getLifecycle().startStep(uuid, result);
}
- @AfterThrowing(pointcut = "anyMethod() && withStepAnnotation()", throwing = "e")
+ @AfterThrowing(
+ pointcut = "anyMethod() && withStepAnnotation()",
+ throwing = "e"
+ )
public void stepFailed(final Throwable e) {
- getLifecycle().updateStep(s -> s
- .setStatus(getStatus(e).orElse(Status.BROKEN))
- .setStatusDetails(getStatusDetails(e).orElse(null)));
+ getLifecycle().updateStep(
+ s -> s
+ .setStatus(getStatus(e).orElse(Status.BROKEN))
+ .setStatusDetails(getStatusDetails(e).orElse(null))
+ );
getLifecycle().stopStep();
}
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 21d2250ff..93d46e354 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
@@ -52,10 +52,11 @@ public static ObjectMapper createMapper() {
.serializationInclusion(NON_NULL)
.configure(INDENT_OUTPUT, Boolean.getBoolean(INDENT_OUTPUT_PROPERTY_NAME))
.build()
- .registerModule(new SimpleModule()
- .addSerializer(Status.class, new StatusSerializer())
- .addSerializer(Stage.class, new StageSerializer())
- .addSerializer(Parameter.Mode.class, new ParameterModeSerializer())
+ .registerModule(
+ new SimpleModule()
+ .addSerializer(Status.class, new StatusSerializer())
+ .addSerializer(Stage.class, new StageSerializer())
+ .addSerializer(Parameter.Mode.class, new ParameterModeSerializer())
);
}
@@ -70,7 +71,8 @@ protected ParameterModeSerializer() {
@Override
public void serialize(final Parameter.Mode value,
final JsonGenerator gen,
- final SerializerProvider provider) throws IOException {
+ final SerializerProvider provider)
+ throws IOException {
gen.writeString(value.name().toLowerCase(Locale.ENGLISH));
}
}
@@ -86,7 +88,8 @@ protected StageSerializer() {
@Override
public void serialize(final Stage value,
final JsonGenerator gen,
- final SerializerProvider provider) throws IOException {
+ final SerializerProvider provider)
+ throws IOException {
gen.writeString(value.name().toLowerCase(Locale.ENGLISH));
}
}
@@ -102,7 +105,8 @@ protected StatusSerializer() {
@Override
public void serialize(final Status value,
final JsonGenerator gen,
- final SerializerProvider provider) throws IOException {
+ final SerializerProvider provider)
+ throws IOException {
gen.writeString(value.name().toLowerCase(Locale.ENGLISH));
}
}
diff --git a/allure-java-commons/src/main/java/io/qameta/allure/listener/LifecycleNotifier.java b/allure-java-commons/src/main/java/io/qameta/allure/listener/LifecycleNotifier.java
index 29174eceb..7684b66d8 100644
--- a/allure-java-commons/src/main/java/io/qameta/allure/listener/LifecycleNotifier.java
+++ b/allure-java-commons/src/main/java/io/qameta/allure/listener/LifecycleNotifier.java
@@ -28,8 +28,13 @@
/**
* @since 2.0
*/
-public class LifecycleNotifier implements ContainerLifecycleListener,
- TestLifecycleListener, FixtureLifecycleListener, StepLifecycleListener {
+@SuppressWarnings("PMD.TooManyMethods")
+public class LifecycleNotifier
+ implements
+ ContainerLifecycleListener,
+ TestLifecycleListener,
+ FixtureLifecycleListener,
+ StepLifecycleListener {
private static final Logger LOGGER = LoggerFactory.getLogger(LifecycleNotifier.class);
@@ -51,7 +56,6 @@ public LifecycleNotifier(final List containerListene
this.stepListeners = stepListeners;
}
-
@Override
public void beforeTestSchedule(final TestResult result) {
runSafely(testListeners, TestLifecycleListener::beforeTestSchedule, result);
diff --git a/allure-java-commons/src/main/java/io/qameta/allure/util/AnnotationUtils.java b/allure-java-commons/src/main/java/io/qameta/allure/util/AnnotationUtils.java
index b032b35cf..1e6ad1246 100644
--- a/allure-java-commons/src/main/java/io/qameta/allure/util/AnnotationUtils.java
+++ b/allure-java-commons/src/main/java/io/qameta/allure/util/AnnotationUtils.java
@@ -141,9 +141,9 @@ public static Set