### Question:
EnvironmentSyncService { public EnvironmentStatus getStatusByFreeipa(Environment environment) { Optional<DescribeFreeIpaResponse> freeIpaResponseOpt = freeIpaService.describe(environment.getResourceCrn()); if (freeIpaResponseOpt.isPresent()) { DescribeFreeIpaResponse freeIpaResponse = freeIpaResponseOpt.get(); switch (freeIpaResponse.getStatus()) { case STOPPED: return ENV_STOPPED; case DELETED_ON_PROVIDER_SIDE: return FREEIPA_DELETED_ON_PROVIDER_SIDE; case STOP_FAILED: return STOP_FREEIPA_FAILED; case START_FAILED: return START_FREEIPA_FAILED; case START_IN_PROGRESS: return START_FREEIPA_STARTED; case STOP_IN_PROGRESS: return STOP_FREEIPA_STARTED; default: break; } } else if (environment.isCreateFreeIpa()) { return FREEIPA_DELETED_ON_PROVIDER_SIDE; } return EnvironmentStatus.AVAILABLE; } EnvironmentSyncService(FreeIpaService freeIpaService); EnvironmentStatus getStatusByFreeipa(Environment environment);  }### Answer:
@Test void testGetStatusByFreeipaWhenFreeipaAttachedButNotFound() { Environment environment = new Environment(); environment.setResourceCrn("crn"); environment.setCreateFreeIpa(true); when(freeIpaService.describe(environment.getResourceCrn())).thenReturn(Optional.empty()); EnvironmentStatus actual = underTest.getStatusByFreeipa(environment); Assertions.assertEquals(EnvironmentStatus.FREEIPA_DELETED_ON_PROVIDER_SIDE, actual); }
@Test void testGetStatusByFreeipaWhenFreeipaNotAttached() { Environment environment = new Environment(); environment.setResourceCrn("crn"); environment.setCreateFreeIpa(false); when(freeIpaService.describe(environment.getResourceCrn())).thenReturn(Optional.empty()); EnvironmentStatus actual = underTest.getStatusByFreeipa(environment); Assertions.assertEquals(EnvironmentStatus.AVAILABLE, actual); }