@Test void getIdByCrnNotFound() { when(environmentViewRepository .getIdByResourceCrnAndAccountIdAndArchivedIsFalse(eq(CRN), eq(ACCOUNT_ID))).thenReturn(null); assertThrows(NotFoundException.class, () -> environmentViewServiceUnderTest.getIdByCrn(CRN, ACCOUNT_ID)); }
public Long getIdByCrn(String crn, String accountId) { return Optional.ofNullable(environmentViewRepository .getIdByResourceCrnAndAccountIdAndArchivedIsFalse(crn, accountId)) .orElseThrow(notFound("Environment with CRN", crn)); }
EnvironmentViewService { public Long getIdByCrn(String crn, String accountId) { return Optional.ofNullable(environmentViewRepository .getIdByResourceCrnAndAccountIdAndArchivedIsFalse(crn, accountId)) .orElseThrow(notFound("Environment with CRN", crn)); } }
EnvironmentViewService { public Long getIdByCrn(String crn, String accountId) { return Optional.ofNullable(environmentViewRepository .getIdByResourceCrnAndAccountIdAndArchivedIsFalse(crn, accountId)) .orElseThrow(notFound("Environment with CRN", crn)); } EnvironmentViewService(EnvironmentViewRepository environmentViewRepository, ConversionService conversionService); }
EnvironmentViewService { public Long getIdByCrn(String crn, String accountId) { return Optional.ofNullable(environmentViewRepository .getIdByResourceCrnAndAccountIdAndArchivedIsFalse(crn, accountId)) .orElseThrow(notFound("Environment with CRN", crn)); } 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 getIdByCrn(String crn, String accountId) { return Optional.ofNullable(environmentViewRepository .getIdByResourceCrnAndAccountIdAndArchivedIsFalse(crn, accountId)) .orElseThrow(notFound("Environment with CRN", crn)); } 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);  }