Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EPMRPP-93488 || Similar testItem attribute keys cannot be added in the results #2060

Merged
merged 1 commit into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public OperationCompletionRS finishTestItem(ReportPortalUser user,
final TestItem itemForUpdate =
new TestItemBuilder(testItem).addDescription(finishExecutionRQ.getDescription())
.addTestCaseId(finishExecutionRQ.getTestCaseId())
.overwriteAttributesValues(finishExecutionRQ.getAttributes())
.addAttributes(finishExecutionRQ.getAttributes())
.addTestItemResults(testItemResults).get();

testItemRepository.save(itemForUpdate);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,25 +136,6 @@ public TestItemBuilder addAttributes(Set<ItemAttributesRQ> attributes) {
return this;
}

public TestItemBuilder overwriteAttributesValues(Set<? extends ItemAttributeResource> attributes) {
if (attributes != null) {
attributes.forEach(val -> {
ItemAttribute itemAttribute = FROM_RESOURCE.apply(val);
itemAttribute.setTestItem(testItem);
Optional<ItemAttribute> existingAttr = testItem.getAttributes().stream()
.filter(attr -> Objects.nonNull(attr.getKey()) && attr.getKey()
.equals(itemAttribute.getKey()))
.findFirst();
if (existingAttr.isPresent()) {
existingAttr.get().setValue(itemAttribute.getValue());
} else {
testItem.getAttributes().add(itemAttribute);
}
});
}
return this;
}

public TestItemBuilder overwriteAttributes(Set<? extends ItemAttributeResource> attributes) {
if (attributes != null) {
final Set<ItemAttribute> overwrittenAttributes = testItem.getAttributes()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,28 +127,6 @@ void addResultsTest() {
new ItemAttribute("k", "v", false));
}

@Test
void overwriteAttributesValuesTest() {
TestItem item = new TestItem();
final Instant now = Instant.now().truncatedTo(ChronoUnit.MILLIS);
item.setStartTime(now);
final TestItemResults itemResults = new TestItemResults();
itemResults.setEndTime(now.plusSeconds(120));
item.setItemResults(itemResults);
final ItemAttribute systemAttribute = new ItemAttribute("key", "val", true);
item.setAttributes(Sets.newHashSet(new ItemAttribute("someKey", "val", false), systemAttribute));

final TestItem resultItem = new TestItemBuilder(item).addTestItemResults(itemResults)
.addStatus(StatusEnum.PASSED)
.overwriteAttributesValues(Sets.newHashSet(new ItemAttributeResource("someKey", "newVal")))
.get();

assertEquals(120, resultItem.getItemResults().getDuration(), 0.1);
assertEquals(StatusEnum.PASSED, resultItem.getItemResults().getStatus());
assertThat(resultItem.getAttributes()).containsExactlyInAnyOrder(systemAttribute,
new ItemAttribute("someKey", "newVal", false));
}

@Test
void providedTestCaseIdTest() {
StartTestItemRQ request = new StartTestItemRQ();
Expand Down
Loading