Skip to content

Commit

Permalink
Update unit tests to check if showClaimAcl is being correctly set.
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 10, 2024
1 parent 02707ef commit 2294ea7
Showing 1 changed file with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -735,11 +735,17 @@ public void getTopicOverviewWithNoAcls_OpenClaimRequest() {
when(handleDbRequests.existsClaimTopicRequest(
eq(TESTTOPIC), eq(RequestStatus.CREATED.value), eq(101)))
.thenReturn(true);
when(handleDbRequests.existsSpecificAclRequest(
eq(TESTTOPIC), eq(RequestStatus.CREATED.value), anyString(), eq(101), anyInt()))
.thenReturn(true);
when(kwClustersHashMap.get(anyInt())).thenReturn(kwClusters);

when(handleDbRequests.getSyncAcls(anyString(), eq(TESTTOPIC), eq(101)))
.thenReturn(getAclsSOT(TESTTOPIC));

topicOverview = topicOverviewService.getTopicOverview(TESTTOPIC, "1", AclGroupBy.NONE);

assertThat(topicOverview.getTopicInfoList().get(0).isHasACL()).isFalse(); // topic hasAcl
assertThat(topicOverview.getTopicInfoList().get(0).isHasACL()).isTrue(); // topic hasAcl

assertThat(topicOverview.getTopicInfoList().get(0).isHasOpenClaimRequest()).isTrue();

Expand All @@ -751,6 +757,9 @@ public void getTopicOverviewWithNoAcls_OpenClaimRequest() {
assertThat(topicOverview.getTopicInfoList().get(0).isHasOpenRequestOnAnyEnv())
.isTrue(); // topic hasAcl
assertThat(topicOverview.getTopicInfoList().get(0).isHasSchema()).isFalse(); // topic hasAcl
assertThat(topicOverview.getAclInfoList().get(0).isShowClaimAcl())
.isFalse(); // topic has open claim request so this can't be claimed twice. Don't offer UI
// choice to claim it.
}

@Test
Expand All @@ -767,7 +776,8 @@ public void getTopicOverviewFromDifferentTeam_OnlyReturnClaimBooleanAndOpenRequs
createListOfEnvs(KafkaClustersType.SCHEMA_REGISTRY, 5);
when(commonUtilsService.getTopicsForTopicName(anyString(), anyInt()))
.thenReturn(utilMethods.getTopicInMultipleEnvs("testtopic", TEAMID, 3));

when(manageDatabase.getClusters(any(KafkaClustersType.class), anyInt()))
.thenReturn(kwClustersHashMap);
when(kwClustersHashMap.get(anyInt())).thenReturn(kwClusters);

when(commonUtilsService.getTopicsForTopicName(anyString(), anyInt()))
Expand All @@ -780,14 +790,16 @@ public void getTopicOverviewFromDifferentTeam_OnlyReturnClaimBooleanAndOpenRequs
eq(TESTTOPIC), eq(RequestStatus.CREATED.value), eq(101)))
.thenReturn(true);
when(kwClustersHashMap.get(anyInt())).thenReturn(kwClusters);
when(handleDbRequests.getSyncAcls(anyString(), eq(TESTTOPIC), eq(101)))
.thenReturn(getAclsSOT(TESTTOPIC));

TopicOverview topicOverview =
topicOverviewService.getTopicOverview(TESTTOPIC, "1", AclGroupBy.NONE);

verify(handleDbRequests, times(0)).existsTopicRequest(any(), any(), any(), anyInt());
verify(handleDbRequests, times(0)).existsAclRequest(any(), any(), any(), anyInt());
verify(handleDbRequests, times(0)).existsSchemaRequest(any(), any(), any(), anyInt());
assertThat(topicOverview.getTopicInfoList().get(0).isHasACL()).isFalse(); // topic claim
assertThat(topicOverview.getTopicInfoList().get(0).isHasACL()).isTrue();

assertThat(topicOverview.getTopicInfoList().get(0).isHasOpenClaimRequest()).isTrue();
assertThat(topicOverview.getTopicInfoList().get(0).isHasOpenACLRequest()).isFalse();
Expand All @@ -796,6 +808,7 @@ public void getTopicOverviewFromDifferentTeam_OnlyReturnClaimBooleanAndOpenRequs
assertThat(topicOverview.getTopicInfoList().get(0).isHasOpenRequestOnAnyEnv())
.isTrue(); // topic hasAcl
assertThat(topicOverview.getTopicInfoList().get(0).isHasSchema()).isFalse();
assertThat(topicOverview.getAclInfoList().get(0).isShowClaimAcl()).isTrue();
}

private static Map<Integer, KwClusters> getKwClusterMap() {
Expand Down

0 comments on commit 2294ea7

Please sign in to comment.