@Test void getIdByNameNotFound() { when(environmentViewRepository .getIdByNameAndAccountIdAndArchivedIsFalse(eq(ENVIRONMENT_NAME), eq(ACCOUNT_ID))).thenReturn(null); assertThrows(NotFoundException.class, () -> environmentViewServiceUnderTest.getIdByName(ENVIRONMENT_NAME, ACCOUNT_ID)); }
public Long getIdByName(String environmentName, String accountId) { return Optional.ofNullable(environmentViewRepository .getIdByNameAndAccountIdAndArchivedIsFalse(environmentName, accountId)) .orElseThrow(notFound("Environment with name", environmentName)); }
EnvironmentViewService { public Long getIdByName(String environmentName, String accountId) { return Optional.ofNullable(environmentViewRepository .getIdByNameAndAccountIdAndArchivedIsFalse(environmentName, accountId)) .orElseThrow(notFound("Environment with name", environmentName)); } }
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); }
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); }
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);  }