Skip to content

Commit

Permalink
EPMRPP-89421 || Display number of tests related to each Unique Error …
Browse files Browse the repository at this point in the history
…cluster (#2020)
  • Loading branch information
APiankouski committed Jul 16, 2024
1 parent e5850a7 commit 207dbaa
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 20 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ dependencies {
implementation 'com.epam.reportportal:commons'
implementation 'com.epam.reportportal:plugin-api:5.11.1'
} else {
implementation 'com.github.reportportal:commons-dao:c37b0b0'
implementation 'com.github.reportportal:commons:916f0f8abd'
implementation 'com.github.reportportal:commons-dao:62a9d24'
implementation 'com.github.reportportal:commons:9620556'
implementation 'com.github.reportportal:plugin-api:d1c0f0e'
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,19 @@

package com.epam.ta.reportportal.core.launch.cluster;

import static com.epam.ta.reportportal.commons.querygen.constant.GeneralCriteriaConstant.CRITERIA_ID;
import static com.epam.ta.reportportal.ws.converter.converters.ClusterConverter.TO_CLUSTER_INFO;

import com.epam.reportportal.extension.event.GetClusterResourcesEvent;
import com.epam.reportportal.model.launch.cluster.ClusterInfoResource;
import com.epam.reportportal.rules.exception.ErrorType;
import com.epam.reportportal.rules.exception.ReportPortalException;
import com.epam.ta.reportportal.dao.ClusterRepository;
import com.epam.ta.reportportal.entity.cluster.Cluster;
import com.epam.ta.reportportal.entity.launch.Launch;
import com.epam.reportportal.rules.exception.ReportPortalException;
import com.epam.ta.reportportal.ws.converter.PagedResourcesAssembler;
import com.epam.reportportal.rules.exception.ErrorType;
import com.epam.reportportal.model.launch.cluster.ClusterInfoResource;
import java.util.function.Function;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;

/**
Expand Down Expand Up @@ -60,21 +56,17 @@ public Cluster getById(Long id) {
@Override
public Iterable<ClusterInfoResource> getResources(Launch launch, Pageable pageable) {

final Pageable pageableWithSort = applySort(pageable);
final Page<Cluster> clusters =
clusterRepository.findAllByLaunchId(launch.getId(), pageableWithSort);
Page<ClusterInfoResource> clusters =
clusterRepository.findAllByLaunchIdWithCount(launch.getId(), pageable);

return getClusterResources(clusters, launch.getId());
}

private Pageable applySort(Pageable pageable) {
final Sort idSort = Sort.by(Sort.Order.asc(CRITERIA_ID));
return PageRequest.of(pageable.getPageNumber(), pageable.getPageSize(), idSort);
}

private Iterable<ClusterInfoResource> getClusterResources(Page<Cluster> clusters, Long launchId) {
private Iterable<ClusterInfoResource> getClusterResources(Page<ClusterInfoResource> clusters,
Long launchId) {
final com.epam.ta.reportportal.model.Page<ClusterInfoResource> clustersPage =
PagedResourcesAssembler.pageConverter(TO_CLUSTER_INFO).apply(clusters);
PagedResourcesAssembler.pageConverter(
(Function<ClusterInfoResource, ClusterInfoResource>) c -> c).apply(clusters);
eventPublisher.publishEvent(new GetClusterResourcesEvent(clustersPage.getContent(), launchId));
return clustersPage;
}
Expand Down

0 comments on commit 207dbaa

Please sign in to comment.