### Question:
EnvironmentViewService { public Long getIdByName(String environmentName, String accountId) { return Optional.ofNullable(environmentViewRepository .getIdByNameAndAccountIdAndArchivedIsFalse(environmentName, accountId)) .orElseThrow(notFound("Environment with name", environmentName)); } EnvironmentViewService(EnvironmentViewRepository environmentViewRepository, ConversionService conversionService); Set<EnvironmentView> findByNamesInAccount(Set<String> names, @NotNull String accountid); Set<EnvironmentView> findByResourceCrnsInAccount(Set<String> resourceCrns, @NotNull String accountid); Set<SimpleEnvironmentResponse> listByAccountId(String accountId); Set<EnvironmentView> findAllByAccountId(String accountId); Set<EnvironmentView> findAllByCredentialId(Long credentialId); Long getIdByName(String environmentName, String accountId); Long getIdByCrn(String crn, String accountId);  }### Answer:
@Test void getIdByName() { long value = 1L; when(environmentViewRepository .getIdByNameAndAccountIdAndArchivedIsFalse(eq(ENVIRONMENT_NAME), eq(ACCOUNT_ID))).thenReturn(value); assertEquals(value, environmentViewServiceUnderTest.getIdByName(ENVIRONMENT_NAME, ACCOUNT_ID)); }
@Test void getIdByNameNotFound() { when(environmentViewRepository .getIdByNameAndAccountIdAndArchivedIsFalse(eq(ENVIRONMENT_NAME), eq(ACCOUNT_ID))).thenReturn(null); assertThrows(NotFoundException.class, () -> environmentViewServiceUnderTest.getIdByName(ENVIRONMENT_NAME, ACCOUNT_ID)); }