@Test void getStatus() { String operationId = "testId"; Operation operation = mock(Operation.class); when(operationService.getOperationForAccountIdAndOperationId(ACCOUNT_ID, operationId)).thenReturn(operation); SyncOperationStatus status = mock(SyncOperationStatus.class); when(operationToSyncOperationStatus.convert(operation)).thenReturn(status); assertEquals(status, ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.getSyncOperationStatus(operationId))); verify(operationService, times(1)).getOperationForAccountIdAndOperationId(ACCOUNT_ID, operationId); }
@Override @CheckPermissionByAccount(action = AuthorizationResourceAction.GET_OPERATION_STATUS) public SyncOperationStatus getSyncOperationStatus(@NotNull String operationId) { checkActorCrn(); String accountId = ThreadBasedUserCrnProvider.getAccountId(); LOGGER.debug("getSyncOperationStatus() requested for operation '{}' in account '{}'", operationId, accountId); return operationToSyncOperationStatus.convert( operationService.getOperationForAccountIdAndOperationId(accountId, operationId)); }
UserV1Controller implements UserV1Endpoint { @Override @CheckPermissionByAccount(action = AuthorizationResourceAction.GET_OPERATION_STATUS) public SyncOperationStatus getSyncOperationStatus(@NotNull String operationId) { checkActorCrn(); String accountId = ThreadBasedUserCrnProvider.getAccountId(); LOGGER.debug("getSyncOperationStatus() requested for operation '{}' in account '{}'", operationId, accountId); return operationToSyncOperationStatus.convert( operationService.getOperationForAccountIdAndOperationId(accountId, operationId)); } }
UserV1Controller implements UserV1Endpoint { @Override @CheckPermissionByAccount(action = AuthorizationResourceAction.GET_OPERATION_STATUS) public SyncOperationStatus getSyncOperationStatus(@NotNull String operationId) { checkActorCrn(); String accountId = ThreadBasedUserCrnProvider.getAccountId(); LOGGER.debug("getSyncOperationStatus() requested for operation '{}' in account '{}'", operationId, accountId); return operationToSyncOperationStatus.convert( operationService.getOperationForAccountIdAndOperationId(accountId, operationId)); }  }
UserV1Controller implements UserV1Endpoint { @Override @CheckPermissionByAccount(action = AuthorizationResourceAction.GET_OPERATION_STATUS) public SyncOperationStatus getSyncOperationStatus(@NotNull String operationId) { checkActorCrn(); String accountId = ThreadBasedUserCrnProvider.getAccountId(); LOGGER.debug("getSyncOperationStatus() requested for operation '{}' in account '{}'", operationId, accountId); return operationToSyncOperationStatus.convert( operationService.getOperationForAccountIdAndOperationId(accountId, operationId)); }  @Override @CustomPermissionCheck SyncOperationStatus synchronizeUser(SynchronizeUserRequest request); @Override @CustomPermissionCheck SyncOperationStatus synchronizeAllUsers(SynchronizeAllUsersRequest request); @Override @CustomPermissionCheck @CheckPermissionByAccount(action = AuthorizationResourceAction.ENVIRONMENT_READ) SyncOperationStatus setPassword(SetPasswordRequest request); @Override @CheckPermissionByAccount(action = AuthorizationResourceAction.GET_OPERATION_STATUS) SyncOperationStatus getSyncOperationStatus(@NotNull String operationId); @Override @CheckPermissionByResourceCrn(action = AuthorizationResourceAction.DESCRIBE_ENVIRONMENT) EnvironmentUserSyncState getUserSyncState(@ResourceCrn @TenantAwareParam @NotEmpty String environmentCrn); }
UserV1Controller implements UserV1Endpoint { @Override @CheckPermissionByAccount(action = AuthorizationResourceAction.GET_OPERATION_STATUS) public SyncOperationStatus getSyncOperationStatus(@NotNull String operationId) { checkActorCrn(); String accountId = ThreadBasedUserCrnProvider.getAccountId(); LOGGER.debug("getSyncOperationStatus() requested for operation '{}' in account '{}'", operationId, accountId); return operationToSyncOperationStatus.convert( operationService.getOperationForAccountIdAndOperationId(accountId, operationId)); }  @Override @CustomPermissionCheck SyncOperationStatus synchronizeUser(SynchronizeUserRequest request); @Override @CustomPermissionCheck SyncOperationStatus synchronizeAllUsers(SynchronizeAllUsersRequest request); @Override @CustomPermissionCheck @CheckPermissionByAccount(action = AuthorizationResourceAction.ENVIRONMENT_READ) SyncOperationStatus setPassword(SetPasswordRequest request); @Override @CheckPermissionByAccount(action = AuthorizationResourceAction.GET_OPERATION_STATUS) SyncOperationStatus getSyncOperationStatus(@NotNull String operationId); @Override @CheckPermissionByResourceCrn(action = AuthorizationResourceAction.DESCRIBE_ENVIRONMENT) EnvironmentUserSyncState getUserSyncState(@ResourceCrn @TenantAwareParam @NotEmpty String environmentCrn);  }