Skip to content

Commit

Permalink
Merge pull request #82 from reportportal/develop
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
HardNorth authored Feb 23, 2022
2 parents 51e531d + 11785f9 commit 7e3eeaf
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 31 deletions.
5 changes: 0 additions & 5 deletions .github/workflows/promote.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@ jobs:

steps:

- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8

- name: Get variables
run: |
echo "ARTIFACT=`echo ${{ github.repository }} | cut -d/ -f2- | awk '{print tolower($0)}'`" >> $GITHUB_ENV
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Changelog

## [Unreleased]
### Fixed
- Invalid Data Tables format for some Report Portal versions
### Changed
- Client version updated on [5.1.4](https://github.com/reportportal/client-java/releases/tag/5.1.4)
- Slf4j version updated on 1.7.32 to support newer versions of Logback with security fixes

## [5.1.0]
### Added
Expand Down
10 changes: 5 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,23 @@ repositories {
}

dependencies {
api 'com.epam.reportportal:client-java:5.1.0'
api 'com.epam.reportportal:client-java:5.1.4'
api 'com.epam.reportportal:commons-model:5.0.0'
api 'com.google.code.findbugs:jsr305:3.0.2'
api 'info.cukes:gherkin:2.12.2'

implementation 'org.slf4j:slf4j-api:1.7.25'
implementation 'org.slf4j:slf4j-api:1.7.32'
implementation 'org.apache.commons:commons-text:1.9'

testImplementation 'com.github.reportportal:agent-java-test-utils:ddcf50ee20'
testImplementation 'com.github.reportportal:agent-java-test-utils:236a68c'
testImplementation 'org.aspectj:aspectjweaver:1.9.2'
testImplementation "io.cucumber:cucumber-java:${project.cucumber_version}"
testImplementation "io.cucumber:cucumber-testng:${project.cucumber_version}"
testImplementation 'org.hamcrest:hamcrest-core:2.2'
testImplementation 'org.mockito:mockito-core:3.3.3'
testImplementation 'org.mockito:mockito-junit-jupiter:3.3.3'
testImplementation 'ch.qos.logback:logback-classic:1.2.3'
testImplementation 'com.epam.reportportal:logger-java-logback:5.0.3'
testImplementation 'ch.qos.logback:logback-classic:1.2.10'
testImplementation 'com.epam.reportportal:logger-java-logback:5.1.1'

testImplementation ("org.junit.platform:junit-platform-runner:${project.junit_runner_version}") {
exclude module: 'junit'
Expand Down
22 changes: 17 additions & 5 deletions src/main/java/com/epam/reportportal/cucumber/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@
public class Utils {
private static final String STEP_DEFINITION_FIELD_NAME = "stepDefinition";
private static final String METHOD_FIELD_NAME = "method";
private static final String ONE_SPACE = " ";
public static final String ONE_SPACE = "\u00A0";
private static final String NEW_LINE = "\r\n";
private static final String TABLE_INDENT = "    ";
private static final String TABLE_SEPARATOR = "|";
public static final String TABLE_INDENT = "\u00A0\u00A0\u00A0\u00A0";
public static final String TABLE_COLUMN_SEPARATOR = "|";
public static final String TABLE_ROW_SEPARATOR = "-";

//@formatter:off
public static final Map<String, ItemStatus> STATUS_MAPPING = ImmutableMap.<String, ItemStatus>builder()
Expand Down Expand Up @@ -103,8 +104,9 @@ public static String formatDataTable(@Nonnull final List<List<String>> table) {
.map(col -> col.stream().mapToInt(String::length).max().orElse(0))
.collect(Collectors.toList());

boolean header = true;
for (List<String> row : table) {
result.append(TABLE_INDENT).append(TABLE_SEPARATOR);
result.append(TABLE_INDENT).append(TABLE_COLUMN_SEPARATOR);
for (int i = 0; i < row.size(); i++) {
String cell = row.get(i);
int maxSize = colSizes.get(i) - cell.length() + 2;
Expand All @@ -113,7 +115,17 @@ public static String formatDataTable(@Nonnull final List<List<String>> table) {
IntStream.range(0, lSpace).forEach(j -> result.append(ONE_SPACE));
result.append(cell);
IntStream.range(0, rSpace).forEach(j -> result.append(ONE_SPACE));
result.append(TABLE_SEPARATOR);
result.append(TABLE_COLUMN_SEPARATOR);
}
if (header) {
header = false;
result.append(NEW_LINE);
result.append(TABLE_INDENT).append(TABLE_COLUMN_SEPARATOR);
for (int i = 0; i < row.size(); i++) {
int maxSize = colSizes.get(i) + 2;
IntStream.range(0, maxSize).forEach(j -> result.append(TABLE_ROW_SEPARATOR));
result.append(TABLE_COLUMN_SEPARATOR);
}
}
result.append(NEW_LINE);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import com.epam.ta.reportportal.ws.model.log.SaveLogRQ;
import cucumber.api.CucumberOptions;
import cucumber.api.testng.AbstractTestNGCucumberTests;
import io.reactivex.Maybe;
import org.apache.commons.lang3.tuple.Pair;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -98,7 +99,7 @@ public void setup() {
TestScenarioReporter.RP.set(reportPortal);
TestStepReporter.addReportPortal(reportPortal);
TestStepReporter.RP.set(reportPortal);
when(client.log(any(SaveLogRQ.class))).thenReturn(CommonUtils.createMaybe(new EntryCreatedAsyncRS()));
when(client.log(any(SaveLogRQ.class))).thenReturn(Maybe.just(new EntryCreatedAsyncRS()));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class ParameterScenarioReporterTest {
@CucumberOptions(features = "src/test/resources/features/OneSimpleAndOneScenarioOutline.feature", glue = {
"com.epam.reportportal.cucumber.integration.feature" }, plugin = { "pretty",
"com.epam.reportportal.cucumber.integration.TestScenarioReporter" })
public static class OneSimpleAndOneScenarioOutlineScenarioReporter extends AbstractTestNGCucumberTests {
public static class OneSimpleAndOneScenarioOutlineScenarioReporterTest extends AbstractTestNGCucumberTests {

}

Expand Down Expand Up @@ -97,7 +97,7 @@ public void initLaunch() {

@Test
public void verify_agent_creates_correct_step_names() {
TestUtils.runTests(OneSimpleAndOneScenarioOutlineScenarioReporter.class);
TestUtils.runTests(OneSimpleAndOneScenarioOutlineScenarioReporterTest.class);

verify(client, times(1)).startTestItem(any());
verify(client, times(1)).startTestItem(same(suiteId), any());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void iHaveANamedStrInlineParameter(@ParameterKey("my name") String str) {

@Given("a step with a data table:")
public void testStep(DataTable dataTable) throws InterruptedException {
LOGGER.info("DataTable parameter:&#13;&#10;{}", dataTable.toString());
LOGGER.info("DataTable parameter:\r\n{}", dataTable.toString());
Thread.sleep(CommonUtils.MINIMAL_TEST_PAUSE);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import java.util.function.Predicate;
import java.util.stream.Collectors;

import static com.epam.reportportal.util.test.CommonUtils.createMaybe;
import static com.epam.reportportal.util.test.CommonUtils.generateUniqueId;
import static java.util.Optional.ofNullable;
import static org.mockito.ArgumentMatchers.*;
Expand Down Expand Up @@ -58,14 +57,14 @@ public static void mockLaunch(ReportPortalClient client, String launchUuid, Stri
@SuppressWarnings("unchecked")
public static <T extends Collection<String>> void mockLaunch(ReportPortalClient client, String launchUuid, String suiteUuid,
Collection<Pair<String, T>> testSteps) {
when(client.startLaunch(any())).thenReturn(createMaybe(new StartLaunchRS(launchUuid, 1L)));
when(client.startLaunch(any())).thenReturn(Maybe.just(new StartLaunchRS(launchUuid, 1L)));

Maybe<ItemCreatedRS> suiteMaybe = createMaybe(new ItemCreatedRS(suiteUuid, suiteUuid));
Maybe<ItemCreatedRS> suiteMaybe = Maybe.just(new ItemCreatedRS(suiteUuid, suiteUuid));
when(client.startTestItem(any())).thenReturn(suiteMaybe);

List<Maybe<ItemCreatedRS>> testResponses = testSteps.stream()
.map(Pair::getKey)
.map(uuid -> createMaybe(new ItemCreatedRS(uuid, uuid)))
.map(uuid -> Maybe.just(new ItemCreatedRS(uuid, uuid)))
.collect(Collectors.toList());

Maybe<ItemCreatedRS> first = testResponses.get(0);
Expand All @@ -76,26 +75,26 @@ public static <T extends Collection<String>> void mockLaunch(ReportPortalClient
String testClassUuid = test.getKey();
List<Maybe<ItemCreatedRS>> stepResponses = test.getValue()
.stream()
.map(uuid -> createMaybe(new ItemCreatedRS(uuid, uuid)))
.map(uuid -> Maybe.just(new ItemCreatedRS(uuid, uuid)))
.collect(Collectors.toList());

Maybe<ItemCreatedRS> myFirst = stepResponses.get(0);
Maybe<ItemCreatedRS>[] myOther = stepResponses.subList(1, stepResponses.size()).toArray(new Maybe[0]);
when(client.startTestItem(same(testClassUuid), any())).thenReturn(myFirst, myOther);
new HashSet<>(test.getValue()).forEach(testMethodUuid -> when(client.finishTestItem(same(testMethodUuid), any())).thenReturn(
createMaybe(new OperationCompletionRS())));
when(client.finishTestItem(same(testClassUuid), any())).thenReturn(createMaybe(new OperationCompletionRS()));
Maybe.just(new OperationCompletionRS())));
when(client.finishTestItem(same(testClassUuid), any())).thenReturn(Maybe.just(new OperationCompletionRS()));
});

Maybe<OperationCompletionRS> suiteFinishMaybe = createMaybe(new OperationCompletionRS());
Maybe<OperationCompletionRS> suiteFinishMaybe = Maybe.just(new OperationCompletionRS());
when(client.finishTestItem(eq(suiteUuid), any())).thenReturn(suiteFinishMaybe);

when(client.finishLaunch(eq(launchUuid), any())).thenReturn(createMaybe(new OperationCompletionRS()));
when(client.finishLaunch(eq(launchUuid), any())).thenReturn(Maybe.just(new OperationCompletionRS()));
}

@SuppressWarnings("unchecked")
public static void mockLogging(ReportPortalClient client) {
when(client.log(any(List.class))).thenReturn(createMaybe(new BatchSaveOperatingRS()));
when(client.log(any(List.class))).thenReturn(Maybe.just(new BatchSaveOperatingRS()));
}

public static void mockNestedSteps(ReportPortalClient client, Pair<String, String> parentNestedPair) {
Expand All @@ -108,7 +107,7 @@ public static void mockNestedSteps(final ReportPortalClient client, final List<P
.collect(Collectors.groupingBy(Pair::getKey, Collectors.mapping(Pair::getValue, Collectors.toList())));
responseOrders.forEach((k, v) -> {
List<Maybe<ItemCreatedRS>> responses = v.stream()
.map(uuid -> createMaybe(new ItemCreatedRS(uuid, uuid)))
.map(uuid -> Maybe.just(new ItemCreatedRS(uuid, uuid)))
.collect(Collectors.toList());

Maybe<ItemCreatedRS> first = responses.get(0);
Expand All @@ -118,7 +117,7 @@ public static void mockNestedSteps(final ReportPortalClient client, final List<P
parentNestedPairs.forEach(p -> when(client.finishTestItem(
same(p.getValue()),
any()
)).thenAnswer((Answer<Maybe<OperationCompletionRS>>) invocation -> createMaybe(new OperationCompletionRS())));
)).thenAnswer((Answer<Maybe<OperationCompletionRS>>) invocation -> Maybe.just(new OperationCompletionRS())));
}

public static ListenerParameters standardParameters() {
Expand Down

0 comments on commit 7e3eeaf

Please sign in to comment.