Skip to content

Commit 49ea943

Browse files
authored
EPMRPP-99229 || Add query to check if filter with name exists on project (#1069) (#1070)
1 parent fb9b56a commit 49ea943

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/main/java/com/epam/ta/reportportal/dao/UserFilterRepository.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package com.epam.ta.reportportal.dao;
1818

1919
import com.epam.ta.reportportal.entity.filter.UserFilter;
20-
2120
import java.util.Collection;
2221
import java.util.List;
2322
import java.util.Optional;
@@ -64,4 +63,14 @@ public interface UserFilterRepository extends ReportPortalRepository<UserFilter,
6463
*/
6564
boolean existsByNameAndOwnerAndProjectId(String name, String owner, Long projectId);
6665

66+
/**
67+
* Checks the existence of the {@link UserFilter} with specified name on a project
68+
*
69+
* @param name {@link UserFilter#name}
70+
* @param projectId Id of the {@link com.epam.ta.reportportal.entity.project.Project} on which
71+
* filter existence will be checked
72+
* @return if exists 'true' else 'false'
73+
*/
74+
boolean existsByNameAndProjectId(String name, Long projectId);
75+
6776
}

src/test/java/com/epam/ta/reportportal/dao/UserFilterRepositoryTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,14 @@ void existsByNameAndOwnerAndProjectIdTest() {
106106
userFilterRepository.existsByNameAndOwnerAndProjectId("Admin Filter", "superadmin", 2L));
107107
}
108108

109+
@Test
110+
void existsByNameAndProjectIdTest() {
111+
assertTrue(
112+
userFilterRepository.existsByNameAndProjectId("Admin Filter", 1L));
113+
assertFalse(userFilterRepository.existsByNameAndProjectId("DEMO_FILTER", 1L));
114+
}
115+
116+
109117
@Test
110118
void findAllByProjectId() {
111119
final Long projectId = 1L;

0 commit comments

Comments
 (0)