Skip to content

Commit

Permalink
EPMRPP-96177 || Unique errors. Empty clusters shouldn't be displayed …
Browse files Browse the repository at this point in the history
…on UI (#1046)
  • Loading branch information
APiankouski authored Oct 31, 2024
1 parent ce13df3 commit 15a418b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ public interface ClusterRepository extends ReportPortalRepository<Cluster, Long>
"SELECT new com.epam.reportportal.model.launch.cluster.ClusterInfoResource(c.id, c.indexId as index, c.launchId, c.message, count(cti.itemId) as matchedTests) "
+ "FROM Cluster c LEFT JOIN ClusterTestItem cti ON c.id = cti.clusterId "
+ "WHERE c.launchId = :launchId "
+ "GROUP BY c.id")
+ "GROUP BY c.id "
+ "HAVING count(cti.itemId) > 0")
Page<ClusterInfoResource> findAllByLaunchIdWithCount(@Param("launchId") Long launchId, Pageable pageable);

@Modifying
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ void insertClusters() {
return cluster;
}).collect(Collectors.toList());
clusterRepository.saveAll(clusters);
clusterRepository.saveClusterTestItems(clusters.get(0), Set.of(1L));
clusters.stream().map(Cluster::getId).forEach(savedIds::add);
}

Expand All @@ -92,7 +93,7 @@ void shouldFindAllByLaunchIdWithCount() {
final Pageable pageable = PageRequest.of(0, 3, Sort.by(Sort.Order.by(CRITERIA_ID)));
final Page<ClusterInfoResource> clusters = clusterRepository.findAllByLaunchIdWithCount(LAUNCH_ID, pageable);
assertFalse(clusters.isEmpty());
assertEquals(3, clusters.getContent().size());
assertEquals(1, clusters.getContent().size());
clusters.getContent().forEach(cluster -> assertEquals(LAUNCH_ID, cluster.getLaunchId()));
}

Expand Down Expand Up @@ -128,36 +129,24 @@ void shouldDeleteByLaunchId() {

@Test
void shouldDeleteClusterTestItemsByProjectId() {
final Cluster cluster = clusterRepository.findByIndexIdAndLaunchId(1L, 1L).get();
clusterRepository.saveClusterTestItems(cluster, Set.of(1L));

final int removed = clusterRepository.deleteClusterTestItemsByProjectId(1L);
assertEquals(1, removed);
}

@Test
void shouldDeleteClusterTestItemsByLaunchId() {
final Cluster cluster = clusterRepository.findByIndexIdAndLaunchId(1L, 1L).get();
clusterRepository.saveClusterTestItems(cluster, Set.of(1L));

final int removed = clusterRepository.deleteClusterTestItemsByLaunchId(1L);
assertEquals(1, removed);
}

@Test
void shouldDeleteClusterTestItemsByItemId() {
final Cluster cluster = clusterRepository.findByIndexIdAndLaunchId(1L, 1L).get();
clusterRepository.saveClusterTestItems(cluster, Set.of(1L));

final int removed = clusterRepository.deleteClusterTestItemsByItemId(1L);
assertEquals(1, removed);
}

@Test
void shouldDeleteClusterTestItemsByItemIdIn() {
final Cluster cluster = clusterRepository.findByIndexIdAndLaunchId(1L, 1L).get();
clusterRepository.saveClusterTestItems(cluster, Set.of(1L));

final int removed = clusterRepository.deleteClusterTestItemsByItemIds(List.of(1L));
assertEquals(1, removed);

Expand All @@ -168,7 +157,7 @@ void shouldDeleteClusterTestItemsByItemIdIn() {

@Test
void shouldSaveClusterTestItems() {
final Cluster cluster = clusterRepository.findAllByLaunchId(LAUNCH_ID).get(0);
final Cluster cluster = clusterRepository.findAllByLaunchId(LAUNCH_ID).get(1);
final int inserted = clusterRepository.saveClusterTestItems(cluster, Set.of(1L, 2L));
assertEquals(2, inserted);
}
Expand Down

0 comments on commit 15a418b

Please sign in to comment.