From 01a7ec88feb51f792929576d9e2b1b1f9a2cb9c1 Mon Sep 17 00:00:00 2001 From: muralibasani Date: Mon, 15 May 2023 15:51:16 +0200 Subject: [PATCH 1/3] Update query with created state Signed-off-by: muralibasani --- .../klaw/repository/AclRequestsRepo.java | 2 +- .../KwKafkaConnectorRequestsRepo.java | 2 +- .../klaw/repository/SchemaRequestRepo.java | 2 +- .../klaw/repository/TopicRequestsRepo.java | 2 +- .../db/rdbms/AclRequestsIntegrationTest.java | 22 +++++++++++++++++++ 5 files changed, 26 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/io/aiven/klaw/repository/AclRequestsRepo.java b/core/src/main/java/io/aiven/klaw/repository/AclRequestsRepo.java index 58685a20a7..c694b82e60 100644 --- a/core/src/main/java/io/aiven/klaw/repository/AclRequestsRepo.java +++ b/core/src/main/java/io/aiven/klaw/repository/AclRequestsRepo.java @@ -29,7 +29,7 @@ List findAllRecordsCountForTeamId( @Query( value = - "select count(*) from kwaclrequests where (requestor = :userId or approver = :userId) and tenantid = :tenantId", + "select count(*) from kwaclrequests where (requestor = :userId or approver = :userId) and tenantid = :tenantId and topicstatus='created'", nativeQuery = true) List findAllRecordsCountForUserId( @Param("userId") String userId, @Param("tenantId") Integer tenantId); diff --git a/core/src/main/java/io/aiven/klaw/repository/KwKafkaConnectorRequestsRepo.java b/core/src/main/java/io/aiven/klaw/repository/KwKafkaConnectorRequestsRepo.java index bbf772bb5c..ef4fdda56d 100644 --- a/core/src/main/java/io/aiven/klaw/repository/KwKafkaConnectorRequestsRepo.java +++ b/core/src/main/java/io/aiven/klaw/repository/KwKafkaConnectorRequestsRepo.java @@ -40,7 +40,7 @@ List findAllRecordsCountForTeamId( @Query( value = - "select count(*) from kwkafkaconnectorrequests where (requestor = :userId or approver = :userId) and tenantid = :tenantId", + "select count(*) from kwkafkaconnectorrequests where (requestor = :userId or approver = :userId) and tenantid = :tenantId and connectorstatus='created'", nativeQuery = true) List findAllRecordsCountForUserId( @Param("userId") String userId, @Param("tenantId") Integer tenantId); diff --git a/core/src/main/java/io/aiven/klaw/repository/SchemaRequestRepo.java b/core/src/main/java/io/aiven/klaw/repository/SchemaRequestRepo.java index 12303f80f6..76453b8046 100644 --- a/core/src/main/java/io/aiven/klaw/repository/SchemaRequestRepo.java +++ b/core/src/main/java/io/aiven/klaw/repository/SchemaRequestRepo.java @@ -33,7 +33,7 @@ List findAllRecordsCountForTeamId( @Query( value = - "select count(*) from kwschemarequests where (requestor = :userId or approver = :userId) and tenantid = :tenantId", + "select count(*) from kwschemarequests where (requestor = :userId or approver = :userId) and tenantid = :tenantId and topicstatus='created'", nativeQuery = true) List findAllRecordsCountForUserId( @Param("userId") String userId, @Param("tenantId") Integer tenantId); diff --git a/core/src/main/java/io/aiven/klaw/repository/TopicRequestsRepo.java b/core/src/main/java/io/aiven/klaw/repository/TopicRequestsRepo.java index 0e03092f72..19f7c5e956 100644 --- a/core/src/main/java/io/aiven/klaw/repository/TopicRequestsRepo.java +++ b/core/src/main/java/io/aiven/klaw/repository/TopicRequestsRepo.java @@ -33,7 +33,7 @@ List findAllRecordsCountForTeamId( @Query( value = - "select count(*) from kwtopicrequests where (requestor = :userId or approver = :userId) and tenantid = :tenantId", + "select count(*) from kwtopicrequests where (requestor = :userId or approver = :userId) and tenantid = :tenantId and topicstatus='created'", nativeQuery = true) List findAllRecordsCountForUserId( @Param("userId") String userId, @Param("tenantId") Integer tenantId); diff --git a/core/src/test/java/io/aiven/klaw/helpers/db/rdbms/AclRequestsIntegrationTest.java b/core/src/test/java/io/aiven/klaw/helpers/db/rdbms/AclRequestsIntegrationTest.java index 41f9daeddb..2a5ea42050 100644 --- a/core/src/test/java/io/aiven/klaw/helpers/db/rdbms/AclRequestsIntegrationTest.java +++ b/core/src/test/java/io/aiven/klaw/helpers/db/rdbms/AclRequestsIntegrationTest.java @@ -11,6 +11,9 @@ import io.aiven.klaw.model.enums.RequestOperationType; import io.aiven.klaw.model.enums.RequestStatus; import io.aiven.klaw.repository.AclRequestsRepo; +import io.aiven.klaw.repository.KwKafkaConnectorRequestsRepo; +import io.aiven.klaw.repository.SchemaRequestRepo; +import io.aiven.klaw.repository.TopicRequestsRepo; import io.aiven.klaw.repository.UserInfoRepo; import java.util.List; import java.util.Map; @@ -34,6 +37,13 @@ public class AclRequestsIntegrationTest { @Autowired private AclRequestsRepo repo; + + @Autowired private SchemaRequestRepo schemaRequestRepo; + + @Autowired private KwKafkaConnectorRequestsRepo kafkaConnectorRequestsRepo; + + @Autowired private TopicRequestsRepo topicRequestsRepo; + @Autowired private UserInfoRepo userInfoRepo; @Autowired TestEntityManager entityManager; @@ -123,6 +133,9 @@ public void setUp() { selectDataJdbc = new SelectDataJdbc(); utilMethods = new UtilMethods(); ReflectionTestUtils.setField(selectDataJdbc, "aclRequestsRepo", repo); + ReflectionTestUtils.setField(selectDataJdbc, "schemaRequestRepo", schemaRequestRepo); + ReflectionTestUtils.setField(selectDataJdbc, "kafkaConnectorRequestsRepo", kafkaConnectorRequestsRepo); + ReflectionTestUtils.setField(selectDataJdbc, "topicRequestsRepo", topicRequestsRepo); ReflectionTestUtils.setField(selectDataJdbc, "userInfoRepo", userInfoRepo); loadData(); } @@ -611,6 +624,15 @@ public void getAclRequestsCountsForMyApprovalsJohnCreatedNone() { assertThat(operationTypeCount.get(RequestOperationType.DELETE.value)).isEqualTo(0L); } + @Test + @Order(24) + public void getRequestsCountForCreatedStatus(){ + int count = selectDataJdbc.findAllComponentsCountForUser("Jackie", 101); + assertThat(count).isEqualTo(21); + count = selectDataJdbc.findAllComponentsCountForUser("Jackie", 103); + assertThat(count).isEqualTo(10); + } + @Order(24) @ParameterizedTest @CsvSource({ From 224ced0ef5b07536581efc919e88dffed25cd52c Mon Sep 17 00:00:00 2001 From: muralibasani Date: Mon, 15 May 2023 15:58:51 +0200 Subject: [PATCH 2/3] spotless Signed-off-by: muralibasani --- .../klaw/helpers/db/rdbms/AclRequestsIntegrationTest.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/src/test/java/io/aiven/klaw/helpers/db/rdbms/AclRequestsIntegrationTest.java b/core/src/test/java/io/aiven/klaw/helpers/db/rdbms/AclRequestsIntegrationTest.java index 2a5ea42050..3682e26b80 100644 --- a/core/src/test/java/io/aiven/klaw/helpers/db/rdbms/AclRequestsIntegrationTest.java +++ b/core/src/test/java/io/aiven/klaw/helpers/db/rdbms/AclRequestsIntegrationTest.java @@ -134,7 +134,8 @@ public void setUp() { utilMethods = new UtilMethods(); ReflectionTestUtils.setField(selectDataJdbc, "aclRequestsRepo", repo); ReflectionTestUtils.setField(selectDataJdbc, "schemaRequestRepo", schemaRequestRepo); - ReflectionTestUtils.setField(selectDataJdbc, "kafkaConnectorRequestsRepo", kafkaConnectorRequestsRepo); + ReflectionTestUtils.setField( + selectDataJdbc, "kafkaConnectorRequestsRepo", kafkaConnectorRequestsRepo); ReflectionTestUtils.setField(selectDataJdbc, "topicRequestsRepo", topicRequestsRepo); ReflectionTestUtils.setField(selectDataJdbc, "userInfoRepo", userInfoRepo); loadData(); @@ -626,7 +627,7 @@ public void getAclRequestsCountsForMyApprovalsJohnCreatedNone() { @Test @Order(24) - public void getRequestsCountForCreatedStatus(){ + public void getRequestsCountForCreatedStatus() { int count = selectDataJdbc.findAllComponentsCountForUser("Jackie", 101); assertThat(count).isEqualTo(21); count = selectDataJdbc.findAllComponentsCountForUser("Jackie", 103); From c3f32300503eb02b4c2b1d79bc24dcee13a83264 Mon Sep 17 00:00:00 2001 From: muralibasani Date: Wed, 17 May 2023 09:54:03 +0200 Subject: [PATCH 3/3] Update query for only requestors Signed-off-by: muralibasani --- .../src/main/java/io/aiven/klaw/repository/AclRequestsRepo.java | 2 +- .../io/aiven/klaw/repository/KwKafkaConnectorRequestsRepo.java | 2 +- .../main/java/io/aiven/klaw/repository/SchemaRequestRepo.java | 2 +- .../main/java/io/aiven/klaw/repository/TopicRequestsRepo.java | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/io/aiven/klaw/repository/AclRequestsRepo.java b/core/src/main/java/io/aiven/klaw/repository/AclRequestsRepo.java index c694b82e60..37c03c695f 100644 --- a/core/src/main/java/io/aiven/klaw/repository/AclRequestsRepo.java +++ b/core/src/main/java/io/aiven/klaw/repository/AclRequestsRepo.java @@ -29,7 +29,7 @@ List findAllRecordsCountForTeamId( @Query( value = - "select count(*) from kwaclrequests where (requestor = :userId or approver = :userId) and tenantid = :tenantId and topicstatus='created'", + "select count(*) from kwaclrequests where (requestor = :userId) and tenantid = :tenantId and topicstatus='created'", nativeQuery = true) List findAllRecordsCountForUserId( @Param("userId") String userId, @Param("tenantId") Integer tenantId); diff --git a/core/src/main/java/io/aiven/klaw/repository/KwKafkaConnectorRequestsRepo.java b/core/src/main/java/io/aiven/klaw/repository/KwKafkaConnectorRequestsRepo.java index ef4fdda56d..3eb38b0b60 100644 --- a/core/src/main/java/io/aiven/klaw/repository/KwKafkaConnectorRequestsRepo.java +++ b/core/src/main/java/io/aiven/klaw/repository/KwKafkaConnectorRequestsRepo.java @@ -40,7 +40,7 @@ List findAllRecordsCountForTeamId( @Query( value = - "select count(*) from kwkafkaconnectorrequests where (requestor = :userId or approver = :userId) and tenantid = :tenantId and connectorstatus='created'", + "select count(*) from kwkafkaconnectorrequests where (requestor = :userId) and tenantid = :tenantId and connectorstatus='created'", nativeQuery = true) List findAllRecordsCountForUserId( @Param("userId") String userId, @Param("tenantId") Integer tenantId); diff --git a/core/src/main/java/io/aiven/klaw/repository/SchemaRequestRepo.java b/core/src/main/java/io/aiven/klaw/repository/SchemaRequestRepo.java index 76453b8046..7ff74ef1ed 100644 --- a/core/src/main/java/io/aiven/klaw/repository/SchemaRequestRepo.java +++ b/core/src/main/java/io/aiven/klaw/repository/SchemaRequestRepo.java @@ -33,7 +33,7 @@ List findAllRecordsCountForTeamId( @Query( value = - "select count(*) from kwschemarequests where (requestor = :userId or approver = :userId) and tenantid = :tenantId and topicstatus='created'", + "select count(*) from kwschemarequests where (requestor = :userId) and tenantid = :tenantId and topicstatus='created'", nativeQuery = true) List findAllRecordsCountForUserId( @Param("userId") String userId, @Param("tenantId") Integer tenantId); diff --git a/core/src/main/java/io/aiven/klaw/repository/TopicRequestsRepo.java b/core/src/main/java/io/aiven/klaw/repository/TopicRequestsRepo.java index 19f7c5e956..8e13731f47 100644 --- a/core/src/main/java/io/aiven/klaw/repository/TopicRequestsRepo.java +++ b/core/src/main/java/io/aiven/klaw/repository/TopicRequestsRepo.java @@ -33,7 +33,7 @@ List findAllRecordsCountForTeamId( @Query( value = - "select count(*) from kwtopicrequests where (requestor = :userId or approver = :userId) and tenantid = :tenantId and topicstatus='created'", + "select count(*) from kwtopicrequests where (requestor = :userId) and tenantid = :tenantId and topicstatus='created'", nativeQuery = true) List findAllRecordsCountForUserId( @Param("userId") String userId, @Param("tenantId") Integer tenantId);