Skip to content

Commit

Permalink
Improve cross DB compatibility by using jpql
Browse files Browse the repository at this point in the history
Signed-off-by: Aindriu Lavelle <aindriu.lavelle@aiven.io>
  • Loading branch information
aindriu-aiven committed Apr 8, 2024
1 parent 01de206 commit ddb80f5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public boolean existsAclRequest(
}

public boolean existsAclSslInTeam(int teamId, int tenantId, String aclSsl) {
return aclRepo.existsAclSslInTeamInTenant(teamId, tenantId, aclSsl);
return aclRepo.existsByTeamIdAndTenantIdAndAclssl(teamId, tenantId, aclSsl);
}

public boolean existsSpecificAclRequest(
Expand Down
6 changes: 1 addition & 5 deletions core/src/main/java/io/aiven/klaw/repository/AclRepo.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,7 @@ boolean existsByTeamIdNotAndTenantIdAndConsumergroup(
boolean existsByEnvironmentAndTenantId(
@Param("envId") String envId, @Param("tenantId") Integer tenantId);

@Query(
value =
"select count(*) > 0 from kwacls where teamid = :teamId and tenantid = :tenantId and aclssl = :aclSsl",
nativeQuery = true)
boolean existsAclSslInTeamInTenant(Integer teamId, Integer tenantId, String aclSsl);
boolean existsByTeamIdAndTenantIdAndAclssl(Integer teamId, Integer tenantId, String aclSsl);

@Query(
value = "select count(*) from kwacls where env = :envId and tenantid = :tenantId",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,11 +359,12 @@ public static Stream<Arguments> doesAclExist() {
public void doesAclSslExistInTeam(
int teamId, int tenantId, String aclSsl, boolean expectedResult) {

when(aclRepo.existsAclSslInTeamInTenant(teamId, tenantId, aclSsl)).thenReturn(expectedResult);
when(aclRepo.existsByTeamIdAndTenantIdAndAclssl(teamId, tenantId, aclSsl))
.thenReturn(expectedResult);

assertThat(selectData.existsAclSslInTeam(teamId, tenantId, aclSsl)).isEqualTo(expectedResult);

verify(aclRepo, times(1)).existsAclSslInTeamInTenant(teamId, tenantId, aclSsl);
verify(aclRepo, times(1)).existsByTeamIdAndTenantIdAndAclssl(teamId, tenantId, aclSsl);
}

public static Stream<Arguments> doesAclSslExistInTeam() {
Expand Down

0 comments on commit ddb80f5

Please sign in to comment.