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..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", + "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 bbf772bb5c..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", + "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 12303f80f6..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", + "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 0e03092f72..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", + "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); 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..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 @@ -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,10 @@ 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 +625,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({