### Question:
FreeIpaPollerService { public void waitForSynchronizeUsers(Long envId, String envCrn) { executeFreeIpaSyncOperationAndStartPolling(envCrn, freeIpaService::synchronizeAllUsersInEnvironment, opId -> freeipaPollerProvider.syncUsersPoller(envId, envCrn, opId), Status::isAvailable); } FreeIpaPollerService(FreeIpaService freeIpaService, FreeIpaPollerProvider freeipaPollerProvider); void startAttachedFreeipaInstances(Long envId, String envCrn); void stopAttachedFreeipaInstances(Long envId, String envCrn); void waitForSynchronizeUsers(Long envId, String envCrn);  }### Answer:
@Test void testSyncUsersWhenFreeIpaAvailable() { DescribeFreeIpaResponse freeipaResponse = new DescribeFreeIpaResponse(); freeipaResponse.setStatus(Status.AVAILABLE); when(freeIpaService.describe(ENV_CRN)).thenReturn(Optional.of(freeipaResponse)); when(freeIpaService.synchronizeAllUsersInEnvironment(ENV_CRN)).thenReturn(createStatus(SynchronizationStatus.REQUESTED, "")); when(freeipaPollerProvider.syncUsersPoller(ENV_ID, ENV_CRN, OPERATION)).thenReturn(AttemptResults::justFinish); underTest.waitForSynchronizeUsers(ENV_ID, ENV_CRN); verify(freeIpaService, times(1)).synchronizeAllUsersInEnvironment(ENV_CRN); }
@Test void testSyncUsersWhenFreeIpaStopped() { DescribeFreeIpaResponse freeipaResponse = new DescribeFreeIpaResponse(); freeipaResponse.setStatus(Status.STOPPED); when(freeIpaService.describe(ENV_CRN)).thenReturn(Optional.of(freeipaResponse)); underTest.waitForSynchronizeUsers(ENV_ID, ENV_CRN); verify(freeIpaService, never()).synchronizeAllUsersInEnvironment(ENV_CRN); }