### Question:
UserV1Controller implements UserV1Endpoint { @Override @CustomPermissionCheck @CheckPermissionByAccount(action = AuthorizationResourceAction.ENVIRONMENT_READ) public SyncOperationStatus setPassword(SetPasswordRequest request) { String userCrn = checkActorCrn(); String accountId = ThreadBasedUserCrnProvider.getAccountId(); LOGGER.debug("setPassword() requested for user {} in account {}", userCrn, accountId); Operation setPasswordOperation = passwordService.setPasswordWithCustomPermissionCheck(accountId, userCrn, userCrn, request.getPassword(), nullToEmpty(request.getEnvironments()), AuthorizationResourceAction.DESCRIBE_ENVIRONMENT); return checkOperationRejected(operationToSyncOperationStatus.convert(setPasswordOperation)); }  @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);  }### Answer:
@Test void setPassword() { String password = "password"; SetPasswordRequest request = mock(SetPasswordRequest.class); when(request.getPassword()).thenReturn(password); Operation operation = mock(Operation.class); when(passwordService.setPasswordWithCustomPermissionCheck(any(), any(), any(), any(), any(), any())).thenReturn(operation); SyncOperationStatus status = mock(SyncOperationStatus.class); when(operationToSyncOperationStatus.convert(operation)).thenReturn(status); assertEquals(status, ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.setPassword(request))); verify(passwordService, times(1)).setPasswordWithCustomPermissionCheck(ACCOUNT_ID, USER_CRN, USER_CRN, password, new HashSet<>(), AuthorizationResourceAction.DESCRIBE_ENVIRONMENT); }
@Test void setPasswordRejected() { String password = "password"; SetPasswordRequest request = mock(SetPasswordRequest.class); when(request.getPassword()).thenReturn(password); Operation operation = mock(Operation.class); when(passwordService.setPasswordWithCustomPermissionCheck(ACCOUNT_ID, USER_CRN, USER_CRN, password, new HashSet<>(), AuthorizationResourceAction.DESCRIBE_ENVIRONMENT)).thenReturn(operation); SyncOperationStatus status = mock(SyncOperationStatus.class); when(status.getStatus()).thenReturn(SynchronizationStatus.REJECTED); when(operationToSyncOperationStatus.convert(operation)).thenReturn(status); assertThrows(SyncOperationAlreadyRunningException.class, () -> ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.setPassword(request))); }