Remove peek usage as advised by sonar - mainly for debugging (#2073)

By API Stream.peek is mainly for debugging and could be skiped in some cases

Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
Avgustin Marinov
2024-11-18 09:44:52 +02:00
committed by GitHub
parent c3bcc4371d
commit 516a3273b6
4 changed files with 21 additions and 7 deletions

View File

@@ -558,8 +558,12 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
assertThat(getResultingActionCount(assignmentResults)).isEqualTo(4);
targetIds.forEach(controllerId -> {
final List<Long> assignedDsIds = deploymentManagement.findActionsByTarget(controllerId, PAGE).stream()
.peek(a -> assertThat(a.getInitiatedBy()).as("Actions should be initiated by current user")
.isEqualTo(tenantAware.getCurrentUsername()))
.map(a -> {
// don't use peek since it is by documentation mainly for debugging and could be skipped in some cases
assertThat(a.getInitiatedBy()).as("Actions should be initiated by current user")
.isEqualTo(tenantAware.getCurrentUsername());
return a;
})
.map(action -> action.getDistributionSet().getId()).collect(Collectors.toList());
assertThat(assignedDsIds).containsExactlyInAnyOrderElementsOf(dsIds);
});
@@ -662,8 +666,12 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
targets.forEach(target -> {
final List<Long> assignedDsIds = deploymentManagement.findActionsByTarget(target.getControllerId(), PAGE)
.stream()
.peek(a -> assertThat(a.getInitiatedBy()).as("Initiated by current user")
.isEqualTo(tenantAware.getCurrentUsername()))
.map(a -> {
// don't use peek since it is by documentation mainly for debugging and could be skipped in some cases
assertThat(a.getInitiatedBy()).as("Initiated by current user")
.isEqualTo(tenantAware.getCurrentUsername());
return a;
})
.map(action -> action.getDistributionSet().getId()).collect(Collectors.toList());
assertThat(assignedDsIds).containsExactlyInAnyOrderElementsOf(dsIds);
});