Skip to content

Commit

Permalink
#94: Fixed tags support
Browse files Browse the repository at this point in the history
 - replaced tags with attributes
 - updated related tests
  • Loading branch information
Invictum committed Apr 2, 2020
1 parent e2dfdf5 commit 959a23f
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 27 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>com.github.invictum</groupId>
<artifactId>serenity-reportportal-integration</artifactId>
<version>1.4.4-SNAPSHOT</version>
<version>1.5.0-SNAPSHOT</version>

<packaging>jar</packaging>

Expand Down Expand Up @@ -59,7 +59,7 @@
<dependency>
<groupId>com.epam.reportportal</groupId>
<artifactId>client-java</artifactId>
<version>5.0.0-BETA-9</version>
<version>5.0.0-BETA-10</version>
</dependency>
<dependency>
<groupId>com.epam.reportportal</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public void proceed(TestStep step) {
units.forEach(item -> {
Collection<SaveLogRQ> logs = item.apply(step);
logs.forEach(log -> ReportPortal.emitLog(id -> {
// log.setTestItemId(id);
log.setItemUuid(id);
return log;
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@ public String communicationDirectory() {

public int modulesQuantity() {
String value = System.getProperty(MODULES_COUNT_KEY);
return value == null ? 0 : Integer.valueOf(value);
return value == null ? 0 : Integer.parseInt(value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.epam.ta.reportportal.ws.model.ParameterResource;
import com.epam.ta.reportportal.ws.model.StartTestItemRQ;
import com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ;
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import net.thucydides.core.model.DataTable;
Expand Down Expand Up @@ -52,9 +53,9 @@ public StartEventBuilder withParameters(DataTable.RowValueAccessor data) {
}

public StartEventBuilder withTags(Set<TestTag> tags) {
Set<String> result = tags.stream().filter(t -> !t.getType().contentEquals("story"))
.map(tag -> tag.getType() + ":" + tag.getName()).collect(Collectors.toSet());
// startEvent.setTags(result);
Set<ItemAttributesRQ> result = tags.stream().filter(t -> !t.getType().contentEquals("story"))
.map(tag -> new ItemAttributesRQ(tag.getType(), tag.getName())).collect(Collectors.toSet());
startEvent.setAttributes(result);
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void finalizeActive() {
/**
* Node class that holds suite metadata
*/
private class SuiteMetadata {
private static class SuiteMetadata {
private Maybe<String> id;
private Runnable finisher;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.slf4j.LoggerFactory;

import java.util.Calendar;
import java.util.HashSet;

public class ReportLaunchProvider implements Provider<Launch> {

Expand Down Expand Up @@ -57,16 +58,15 @@ private StartLaunchRQ buildStartLaunchEvent(ListenerParameters parameters) {
event.setName(parameters.getLaunchName());
event.setStartTime(Calendar.getInstance().getTime());
event.setMode(parameters.getLaunchRunningMode());
// As I understood Tags functionality moved to somewhere in RP 5. Unfortunately, I can't find right way to use Tags
// event.setTags(parameters.getTags());
event.setAttributes(parameters.getAttributes());
event.setDescription(parameters.getDescription());
return event;
}

private MergeLaunchesRQ buildMergeLaunchesEvent(ListenerParameters parameters) {
MergeLaunchesRQ merge = new MergeLaunchesRQ();
merge.setName(parameters.getLaunchName());
// merge.setTags(parameters.getTags());
merge.setAttributes(new HashSet<>(parameters.getAttributes()));
merge.setExtendSuitesDescription(true);
merge.setMergeStrategyType("DEEP");
merge.setLaunches(fileStorage.loadAndClean());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
package com.github.invictum.reportportal.recorder;

import java.util.Collection;

import net.thucydides.core.model.TestOutcome;

import com.epam.reportportal.service.Launch;
import com.epam.reportportal.service.ReportPortal;
import com.epam.ta.reportportal.ws.model.FinishTestItemRQ;
import com.epam.ta.reportportal.ws.model.StartTestItemRQ;
import com.epam.ta.reportportal.ws.model.log.SaveLogRQ;
import com.github.invictum.reportportal.FinishEventBuilder;
import com.github.invictum.reportportal.ItemType;
import com.github.invictum.reportportal.LogUnitsHolder;
import com.github.invictum.reportportal.StartEventBuilder;
import com.github.invictum.reportportal.Status;
import com.github.invictum.reportportal.SuiteStorage;
import com.github.invictum.reportportal.*;
import com.github.invictum.reportportal.log.unit.Error;
import com.google.inject.Inject;
import io.reactivex.Maybe;
import net.thucydides.core.model.TestOutcome;

import java.util.Collection;

/**
* Common test recorder suitable for most cases
Expand Down Expand Up @@ -65,12 +59,11 @@ public void record(TestOutcome out) {
suiteStorage.suiteFinisher(out.getUserStory().getId(), () -> launch.finishTestItem(id, finishSuite));
}

private void recordNonStepFailure(TestOutcome out){
private void recordNonStepFailure(TestOutcome out) {
Collection<SaveLogRQ> logs = Error.errorInTest().apply(out);
logs.forEach(l -> ReportPortal.emitLog(id -> {
// l.setTestItemId(id);
l.setItemUuid(id);
return l;
logs.forEach(log -> ReportPortal.emitLog(id -> {
log.setItemUuid(id);
return log;
}));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.epam.ta.reportportal.ws.model.ParameterResource;
import com.epam.ta.reportportal.ws.model.StartTestItemRQ;
import com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ;
import net.thucydides.core.model.DataTable;
import net.thucydides.core.model.TestTag;
import org.junit.Assert;
Expand Down Expand Up @@ -92,6 +93,6 @@ public void withTagsTest() {
.withName("name")
.withTags(tags)
.build();
// Assert.assertEquals(Collections.singleton("type:name"), event.getTags());
Assert.assertEquals(Collections.singleton(new ItemAttributesRQ("type", "name")), event.getAttributes());
}
}

0 comments on commit 959a23f

Please sign in to comment.