### Question:
FreeIpaPollerService { public void stopAttachedFreeipaInstances(Long envId, String envCrn) { executeFreeIpaOperationAndStartPolling(envCrn, freeIpaService::stopFreeIpa, freeipaPollerProvider.stopPoller(envId, envCrn), Status::isStoppable); } 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 testStopAttachedFreeipaInstancesWhenFreeipaAvailable() { DescribeFreeIpaResponse freeipaResponse = new DescribeFreeIpaResponse(); freeipaResponse.setStatus(Status.AVAILABLE); when(freeIpaService.describe(ENV_CRN)).thenReturn(Optional.of(freeipaResponse)); when(freeipaPollerProvider.stopPoller(ENV_ID, ENV_CRN)).thenReturn(AttemptResults::justFinish); underTest.stopAttachedFreeipaInstances(ENV_ID, ENV_CRN); verify(freeIpaService, times(1)).stopFreeIpa(ENV_CRN); }
@Test void testStopAttachedFreeipaInstancesWhenFreeipaStopped() { DescribeFreeIpaResponse freeipaResponse = new DescribeFreeIpaResponse(); freeipaResponse.setStatus(Status.STOPPED); when(freeIpaService.describe(ENV_CRN)).thenReturn(Optional.of(freeipaResponse)); when(freeipaPollerProvider.stopPoller(ENV_ID, ENV_CRN)).thenReturn(AttemptResults::justFinish); underTest.stopAttachedFreeipaInstances(ENV_ID, ENV_CRN); verify(freeIpaService, times(0)).stopFreeIpa(ENV_CRN); }