Skip to content

Commit

Permalink
Update query with created state (#1233)
Browse files Browse the repository at this point in the history
* Update query with created state

Signed-off-by: muralibasani <muralidahr.basani@aiven.io>

* spotless

Signed-off-by: muralibasani <muralidahr.basani@aiven.io>

* Update query for only requestors

Signed-off-by: muralibasani <muralidahr.basani@aiven.io>

---------

Signed-off-by: muralibasani <muralidahr.basani@aiven.io>
Co-authored-by: muralibasani <muralidahr.basani@aiven.io>
  • Loading branch information
muralibasani and muralibasani authored May 17, 2023
1 parent b91eb0d commit d2bc3bc
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ List<Object[]> 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<Object[]> findAllRecordsCountForUserId(
@Param("userId") String userId, @Param("tenantId") Integer tenantId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ List<Object[]> 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<Object[]> findAllRecordsCountForUserId(
@Param("userId") String userId, @Param("tenantId") Integer tenantId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ List<Object[]> 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<Object[]> findAllRecordsCountForUserId(
@Param("userId") String userId, @Param("tenantId") Integer tenantId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ List<Object[]> 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<Object[]> findAllRecordsCountForUserId(
@Param("userId") String userId, @Param("tenantId") Integer tenantId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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({
Expand Down

0 comments on commit d2bc3bc

Please sign in to comment.