Skip to content

Commit

Permalink
Use where existsConnectorRequestonly existence check is required
Browse files Browse the repository at this point in the history
  • Loading branch information
snuyanzin committed Nov 24, 2023
1 parent f0aff57 commit 3050fa0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -200,14 +200,12 @@ public ApiResponse createConnectorRequest(KafkaConnectorRequestModel connectorRe
}

if (manageDatabase
.getHandleDbRequests()
.getConnectorRequests(
connectorRequestModel.getConnectorName(),
connectorRequestModel.getEnvironment(),
RequestStatus.CREATED.value,
tenantId)
.size()
> 0) {
.getHandleDbRequests()
.existsConnectorRequest(
connectorRequestModel.getConnectorName(),
connectorRequestModel.getEnvironment(),
RequestStatus.CREATED.value,
tenantId)) {
return ApiResponse.notOk(KAFKA_CONNECT_ERR_110);
}

Expand Down Expand Up @@ -855,14 +853,12 @@ public ApiResponse createConnectorDeleteRequest(String connectorName, String env
.findFirst();

if (manageDatabase
.getHandleDbRequests()
.getConnectorRequests(
kafkaConnectorRequest.getConnectorName(),
kafkaConnectorRequest.getEnvironment(),
RequestStatus.CREATED.value,
tenantId)
.size()
> 0) {
.getHandleDbRequests()
.existsConnectorRequest(
kafkaConnectorRequest.getConnectorName(),
kafkaConnectorRequest.getEnvironment(),
RequestStatus.CREATED.value,
tenantId)) {
return ApiResponse.notOk(KAFKA_CONNECT_ERR_115);
}

Expand Down Expand Up @@ -988,10 +984,8 @@ public ApiResponse createClaimConnectorRequest(String connectorName, String envI
int tenantId = commonUtilsService.getTenantId(getUserName());

if (manageDatabase
.getHandleDbRequests()
.getConnectorRequests(connectorName, envId, RequestStatus.CREATED.value, tenantId)
.size()
> 0) {
.getHandleDbRequests()
.existsConnectorRequest(connectorName, envId, RequestStatus.CREATED.value, tenantId)) {
return ApiResponse.notOk(KAFKA_CONNECT_ERR_117);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,9 @@ public void createClaimConnectorRequestAlreadyExists() throws KlawException {
stubUserInfo();
when(commonUtilsService.isNotAuthorizedUser(any(), any())).thenReturn(false);
when(commonUtilsService.getTenantId(any())).thenReturn(TENANT_ID);
when(handleDbRequests.getConnectorRequests(
when(handleDbRequests.existsConnectorRequest(
"ConnectorOne", "1", RequestStatus.CREATED.value, TENANT_ID))
.thenReturn(List.of(new KafkaConnectorRequest()));
.thenReturn(true);
ApiResponse apiResponse =
kafkaConnectControllerService.createClaimConnectorRequest("ConnectorOne", "1");

Expand Down

0 comments on commit 3050fa0

Please sign in to comment.