@Test public void createWithExistingIssue() { CreateRequestCommand command = createCommand(); Optional<Request> request = Optional.of(RequestMother.freeCodeCampNoUserStories().build()); when(requestRepository.findByPlatformAndPlatformId(command.getPlatform(), command.getPlatformId())).thenReturn(request); IssueInformation issueInformation = IssueInformationMother.kazuki43zooApiStub().build(); when(githubLinkParser.parseIssue(command.getPlatformId())).thenReturn(issueInformation); when(requestRepository.save(any(Request.class))).then(returnsFirstArg()); requestService.createRequest(command); }
@Override @Transactional @CacheEvict(value = {"projects", "technologies"}, key = "'all'") public Long createRequest(CreateRequestCommand command) { Optional<Request> request = requestRepository.findByPlatformAndPlatformId(command.getPlatform(), command.getPlatformId()); Request r = request.orElseGet(() -> createNewRequest(command)); return r.getId(); }
RequestServiceImpl implements RequestService { @Override @Transactional @CacheEvict(value = {"projects", "technologies"}, key = "'all'") public Long createRequest(CreateRequestCommand command) { Optional<Request> request = requestRepository.findByPlatformAndPlatformId(command.getPlatform(), command.getPlatformId()); Request r = request.orElseGet(() -> createNewRequest(command)); return r.getId(); } }
RequestServiceImpl implements RequestService { @Override @Transactional @CacheEvict(value = {"projects", "technologies"}, key = "'all'") public Long createRequest(CreateRequestCommand command) { Optional<Request> request = requestRepository.findByPlatformAndPlatformId(command.getPlatform(), command.getPlatformId()); Request r = request.orElseGet(() -> createNewRequest(command)); return r.getId(); } RequestServiceImpl(final RequestRepository requestRepository,
                              final Mappers mappers,
                              final GithubPlatformIdParser githubLinkParser,
                              final ProfileService profileService,
                              final ClaimRepository claimRepository,
                              final GithubGateway githubGateway,
                              final GithubClaimResolver githubClaimResolver,
                              final ApplicationEventPublisher eventPublisher,
                              final Erc67Generator erc67Generator,
                              final Environment environment); }
RequestServiceImpl implements RequestService { @Override @Transactional @CacheEvict(value = {"projects", "technologies"}, key = "'all'") public Long createRequest(CreateRequestCommand command) { Optional<Request> request = requestRepository.findByPlatformAndPlatformId(command.getPlatform(), command.getPlatformId()); Request r = request.orElseGet(() -> createNewRequest(command)); return r.getId(); } RequestServiceImpl(final RequestRepository requestRepository,
                              final Mappers mappers,
                              final GithubPlatformIdParser githubLinkParser,
                              final ProfileService profileService,
                              final ClaimRepository claimRepository,
                              final GithubGateway githubGateway,
                              final GithubClaimResolver githubClaimResolver,
                              final ApplicationEventPublisher eventPublisher,
                              final Erc67Generator erc67Generator,
                              final Environment environment); @Override @Transactional(readOnly = true) List<RequestDto> findAll(); @Transactional(readOnly = true) List<RequestDto> findAllFor(final List<String> projects, final List<String> technologies, final Long lastUpdatedSinceDays); @Override @Transactional(readOnly = true) List<RequestDto> findAll(Iterable<Long> ids); @Override @Transactional(readOnly = true) @Cacheable(value = "technologies", key = "'all'") Set<String> findAllTechnologies(); @Override @Transactional(readOnly = true) @Cacheable(value = "projects", key = "'all'") Set<String> findAllProjects(); @Override @Transactional UserClaimableDto getUserClaimableResult(final Principal principal, final Long requestId); @Override @Transactional ClaimableResultDto getClaimableResult(final Long requestId); @Override @Transactional(readOnly = true) List<RequestDto> findRequestsForUser(Principal principal); @Override @Transactional(readOnly = true) RequestDto findRequest(Long id); @Override @Transactional(readOnly = true) List<CommentDto> getComments(Long requestId); @Override @Transactional(readOnly = true) RequestDto findRequest(Platform platform, String platformId); @Override @Transactional @CacheEvict(value = {"projects", "technologies"}, key = "'all'") Long createRequest(CreateRequestCommand command); @Override @Transactional @CacheEvict(value = {"projects", "technologies"}, key = "'all'") Request requestClaimed(RequestClaimedCommand command); @Override @Transactional(readOnly = true) SignedClaim signClaimRequest(Principal user, UserClaimRequest userClaimRequest); @Override @Transactional(readOnly = true) Boolean canClaim(Principal user, CanClaimRequest canClaimRequest); @Override @Transactional void addWatcherToRequest(Principal principal, Long requestId); @Override @Transactional void removeWatcherFromRequest(Principal principal, Long requestId); @Override String generateERC67(final CreateERC67FundRequest createERC67FundRequest); @Override void update(final UpdateRequestStatusCommand command); }
RequestServiceImpl implements RequestService { @Override @Transactional @CacheEvict(value = {"projects", "technologies"}, key = "'all'") public Long createRequest(CreateRequestCommand command) { Optional<Request> request = requestRepository.findByPlatformAndPlatformId(command.getPlatform(), command.getPlatformId()); Request r = request.orElseGet(() -> createNewRequest(command)); return r.getId(); } RequestServiceImpl(final RequestRepository requestRepository,
                              final Mappers mappers,
                              final GithubPlatformIdParser githubLinkParser,
                              final ProfileService profileService,
                              final ClaimRepository claimRepository,
                              final GithubGateway githubGateway,
                              final GithubClaimResolver githubClaimResolver,
                              final ApplicationEventPublisher eventPublisher,
                              final Erc67Generator erc67Generator,
                              final Environment environment); @Override @Transactional(readOnly = true) List<RequestDto> findAll(); @Transactional(readOnly = true) List<RequestDto> findAllFor(final List<String> projects, final List<String> technologies, final Long lastUpdatedSinceDays); @Override @Transactional(readOnly = true) List<RequestDto> findAll(Iterable<Long> ids); @Override @Transactional(readOnly = true) @Cacheable(value = "technologies", key = "'all'") Set<String> findAllTechnologies(); @Override @Transactional(readOnly = true) @Cacheable(value = "projects", key = "'all'") Set<String> findAllProjects(); @Override @Transactional UserClaimableDto getUserClaimableResult(final Principal principal, final Long requestId); @Override @Transactional ClaimableResultDto getClaimableResult(final Long requestId); @Override @Transactional(readOnly = true) List<RequestDto> findRequestsForUser(Principal principal); @Override @Transactional(readOnly = true) RequestDto findRequest(Long id); @Override @Transactional(readOnly = true) List<CommentDto> getComments(Long requestId); @Override @Transactional(readOnly = true) RequestDto findRequest(Platform platform, String platformId); @Override @Transactional @CacheEvict(value = {"projects", "technologies"}, key = "'all'") Long createRequest(CreateRequestCommand command); @Override @Transactional @CacheEvict(value = {"projects", "technologies"}, key = "'all'") Request requestClaimed(RequestClaimedCommand command); @Override @Transactional(readOnly = true) SignedClaim signClaimRequest(Principal user, UserClaimRequest userClaimRequest); @Override @Transactional(readOnly = true) Boolean canClaim(Principal user, CanClaimRequest canClaimRequest); @Override @Transactional void addWatcherToRequest(Principal principal, Long requestId); @Override @Transactional void removeWatcherFromRequest(Principal principal, Long requestId); @Override String generateERC67(final CreateERC67FundRequest createERC67FundRequest); @Override void update(final UpdateRequestStatusCommand command);  }