diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cf5db9f..ea325da 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,10 +35,10 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up JDK 1.8 - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: distribution: 'temurin' java-version: '8' @@ -47,4 +47,6 @@ jobs: run: ./gradlew build - name: Codecov upload - run: bash <(curl -s https://codecov.io/bash) + uses: codecov/codecov-action@v4 + with: + token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index af72b15..5dc7415 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -37,7 +37,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Generate versions uses: HardNorth/github-version-generate@v1 @@ -47,7 +47,7 @@ jobs: version-file-extraction-pattern: ${{ env.VERSION_EXTRACT_PATTERN }} - name: Set up JDK 1.8 - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: distribution: 'temurin' java-version: '8' @@ -98,7 +98,7 @@ jobs: - name: Checkout develop branch if: ${{github.ref}} == 'master' - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: ref: 'develop' fetch-depth: 0 diff --git a/CHANGELOG.md b/CHANGELOG.md index f5595b4..67a3038 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ # Changelog ## [Unreleased] +### Changed +- Client version updated on [5.2.4](https://github.com/reportportal/client-java/releases/tag/5.2.4), by @HardNorth +### Removed +- `commons-model` dependency to rely on `clinet-java` exclusions in security fixes, by @HardNorth ## [5.2.0] ### Changed diff --git a/build.gradle b/build.gradle index bc27169..8de4ad9 100644 --- a/build.gradle +++ b/build.gradle @@ -37,8 +37,7 @@ repositories { } dependencies { - api 'com.epam.reportportal:client-java:5.2.1' - api 'com.epam.reportportal:commons-model:5.0.0' + api 'com.epam.reportportal:client-java:5.2.4' api 'com.google.code.findbugs:jsr305:3.0.2' api "io.cucumber:cucumber-java:${project.cucumber_version}" diff --git a/src/main/java/com/epam/reportportal/cucumber/AbstractReporter.java b/src/main/java/com/epam/reportportal/cucumber/AbstractReporter.java index 11021ea..fb50a43 100644 --- a/src/main/java/com/epam/reportportal/cucumber/AbstractReporter.java +++ b/src/main/java/com/epam/reportportal/cucumber/AbstractReporter.java @@ -161,7 +161,7 @@ protected TestCaseIdEntry getTestCaseId(@Nonnull TestStep testStep, @Nullable St List arguments = ((PickleStepTestStep) testStep).getDefinitionArgument(); if (definitionMatch != null) { try { - Method method = retrieveMethod((StepDefinitionMatch) definitionMatch); + Method method = retrieveMethod(definitionMatch); return TestCaseIdUtils.getTestCaseId(method.getAnnotation(TestCaseId.class), method, codeRef, @@ -332,7 +332,7 @@ protected void afterScenario(TestCaseFinished event) { currentScenarioContextMap.remove(Pair.of(context.getLine(), featureUri)); Date endTime = finishTestItem(context.getId(), event.result.getStatus()); featureEndTime.put(featureUri, endTime); - currentScenarioContext.set(null); + currentScenarioContext.remove(); removeFromTree(currentFeatureContextMap.get(context.getFeatureUri()), context); } @@ -342,7 +342,7 @@ protected void afterScenario(TestCaseFinished event) { protected void startLaunch() { launch = new MemoizingSupplier<>(new Supplier() { - /* should no be lazy */ + /* should not be lazy */ private final Date startTime = Calendar.getInstance().getTime(); @Override @@ -912,7 +912,7 @@ protected Set getAttributes(@Nonnull TestStep testStep) { Object definitionMatch = getDefinitionMatch(testStep); if (definitionMatch != null) { try { - Method method = retrieveMethod((StepDefinitionMatch) definitionMatch); + Method method = retrieveMethod(definitionMatch); Attributes attributesAnnotation = method.getAnnotation(Attributes.class); if (attributesAnnotation != null) { return AttributeParser.retrieveAttributes(attributesAnnotation); diff --git a/src/main/java/com/epam/reportportal/cucumber/Utils.java b/src/main/java/com/epam/reportportal/cucumber/Utils.java index 59eec01..d45817b 100644 --- a/src/main/java/com/epam/reportportal/cucumber/Utils.java +++ b/src/main/java/com/epam/reportportal/cucumber/Utils.java @@ -20,9 +20,7 @@ import com.epam.reportportal.utils.reflect.Accessible; import cucumber.api.Result; import cucumber.api.TestStep; -import cucumber.runtime.StepDefinitionMatch; -import java.lang.reflect.Field; import java.lang.reflect.Method; import java.util.*; import java.util.stream.Collectors; @@ -82,13 +80,13 @@ public static String buildName(String prefix, String infix, String argument) { return (prefix == null ? EMPTY : prefix) + infix + argument; } - public static Method retrieveMethod(StepDefinitionMatch stepDefinitionMatch) throws IllegalAccessException, NoSuchFieldException { - Field stepDefinitionField = stepDefinitionMatch.getClass().getDeclaredField(STEP_DEFINITION_FIELD_NAME); - stepDefinitionField.setAccessible(true); - Object javaStepDefinition = stepDefinitionField.get(stepDefinitionMatch); - Field methodField = javaStepDefinition.getClass().getDeclaredField(METHOD_FIELD_NAME); - methodField.setAccessible(true); - return (Method) methodField.get(javaStepDefinition); + public static Method retrieveMethod(Object stepDefinitionMatch) throws IllegalAccessException, NoSuchFieldException { + Object javaStepDefinition = Accessible.on(stepDefinitionMatch).field(STEP_DEFINITION_FIELD_NAME).getValue(); + Method method = null; + if (javaStepDefinition != null) { + method = (Method) Accessible.on(javaStepDefinition).field(METHOD_FIELD_NAME).getValue(); + } + return method; } public static final java.util.function.Function, List> ARGUMENTS_TRANSFORM = arguments -> ofNullable( diff --git a/src/test/java/com/epam/reportportal/cucumber/EmbeddingTest.java b/src/test/java/com/epam/reportportal/cucumber/EmbeddingTest.java index f0176bf..988c00d 100644 --- a/src/test/java/com/epam/reportportal/cucumber/EmbeddingTest.java +++ b/src/test/java/com/epam/reportportal/cucumber/EmbeddingTest.java @@ -54,42 +54,42 @@ public class EmbeddingTest { @CucumberOptions(features = "src/test/resources/features/embedding/ImageEmbeddingFeature.feature", glue = { "com.epam.reportportal.cucumber.integration.embed.image" }, plugin = { "pretty", "com.epam.reportportal.cucumber.integration.TestStepReporter" }) - public static class ImageStepReporter extends AbstractTestNGCucumberTests { + public static class ImageStepReporterTest extends AbstractTestNGCucumberTests { } @CucumberOptions(features = "src/test/resources/features/embedding/TextEmbeddingFeature.feature", glue = { "com.epam.reportportal.cucumber.integration.embed.text" }, plugin = { "pretty", "com.epam.reportportal.cucumber.integration.TestStepReporter" }) - public static class TextStepReporter extends AbstractTestNGCucumberTests { + public static class TextStepReporterTest extends AbstractTestNGCucumberTests { } @CucumberOptions(features = "src/test/resources/features/embedding/PdfEmbeddingFeature.feature", glue = { "com.epam.reportportal.cucumber.integration.embed.pdf" }, plugin = { "pretty", "com.epam.reportportal.cucumber.integration.TestStepReporter" }) - public static class PdfStepReporter extends AbstractTestNGCucumberTests { + public static class PdfStepReporterTest extends AbstractTestNGCucumberTests { } @CucumberOptions(features = "src/test/resources/features/embedding/ArchiveEmbeddingFeature.feature", glue = { "com.epam.reportportal.cucumber.integration.embed.zip" }, plugin = { "pretty", "com.epam.reportportal.cucumber.integration.TestStepReporter" }) - public static class ZipStepReporter extends AbstractTestNGCucumberTests { + public static class ZipStepReporterTest extends AbstractTestNGCucumberTests { } @CucumberOptions(features = "src/test/resources/features/embedding/EmbedImageWithoutName.feature", glue = { "com.epam.reportportal.cucumber.integration.embed.image" }, plugin = { "pretty", "com.epam.reportportal.cucumber.integration.TestStepReporter" }) - public static class ImageNoNameStepReporter extends AbstractTestNGCucumberTests { + public static class ImageNoNameStepReporterTest extends AbstractTestNGCucumberTests { } @CucumberOptions(features = "src/test/resources/features/embedding/EmbedImageWithEmptyName.feature", glue = { "com.epam.reportportal.cucumber.integration.embed.image" }, plugin = { "pretty", "com.epam.reportportal.cucumber.integration.TestStepReporter" }) - public static class ImageEmptyNameStepReporter extends AbstractTestNGCucumberTests { + public static class ImageEmptyNameStepReporterTest extends AbstractTestNGCucumberTests { } @@ -132,7 +132,7 @@ public void setup() { @Test public void verify_image_embedding() { - TestUtils.runTests(ImageStepReporter.class); + TestUtils.runTests(ImageStepReporterTest.class); ArgumentCaptor> logCaptor = ArgumentCaptor.forClass(List.class); verify(client, atLeastOnce()).log(logCaptor.capture()); @@ -147,7 +147,7 @@ public void verify_image_embedding() { @Test public void verify_text_embedding() { - TestUtils.runTests(TextStepReporter.class); + TestUtils.runTests(TextStepReporterTest.class); ArgumentCaptor> logCaptor = ArgumentCaptor.forClass(List.class); verify(client, atLeastOnce()).log(logCaptor.capture()); @@ -161,7 +161,7 @@ public void verify_text_embedding() { @Test public void verify_pfd_embedding() { - TestUtils.runTests(PdfStepReporter.class); + TestUtils.runTests(PdfStepReporterTest.class); ArgumentCaptor> logCaptor = ArgumentCaptor.forClass(List.class); verify(client, atLeastOnce()).log(logCaptor.capture()); @@ -170,12 +170,12 @@ public void verify_pfd_embedding() { List types = getTypes(logCaptor, logs); assertThat(types, hasSize(3)); - assertThat(types, containsInAnyOrder("application/pdf", "image/png", "application/octet-stream")); + assertThat(types, containsInAnyOrder("application/pdf", "image/png", "application/pdf")); } @Test public void verify_archive_embedding() { - TestUtils.runTests(ZipStepReporter.class); + TestUtils.runTests(ZipStepReporterTest.class); ArgumentCaptor> logCaptor = ArgumentCaptor.forClass(List.class); verify(client, atLeastOnce()).log(logCaptor.capture()); @@ -183,12 +183,12 @@ public void verify_archive_embedding() { List types = getTypes(logCaptor, logs); assertThat(types, hasSize(3)); - assertThat(types, containsInAnyOrder("application/zip", "image/png", "application/octet-stream")); + assertThat(types, containsInAnyOrder("application/zip", "image/png", "application/zip")); } @Test public void verify_image_no_name_embedding() { - TestUtils.runTests(ImageNoNameStepReporter.class); + TestUtils.runTests(ImageNoNameStepReporterTest.class); ArgumentCaptor> logCaptor = ArgumentCaptor.forClass(List.class); verify(client, atLeastOnce()).log(logCaptor.capture()); @@ -203,7 +203,7 @@ public void verify_image_no_name_embedding() { @Test public void verify_image_empty_name_embedding() { - TestUtils.runTests(ImageEmptyNameStepReporter.class); + TestUtils.runTests(ImageEmptyNameStepReporterTest.class); ArgumentCaptor> logCaptor = ArgumentCaptor.forClass(List.class); verify(client, atLeastOnce()).log(logCaptor.capture());