method2testcases
stringlengths
118
6.63k
### Question: DMNParseServiceImpl implements DMNParseService { @Override public RangeValue parseRangeValue(final String source) { final FEEL_1_1Parser parser = makeParser(source); final BaseNode baseNode = makeVisitor().visit(parser.expression()); final RangeValue rangeValue = new RangeValue(); if (baseNode instanceof ...
### Question: SetChildrenCommand extends org.kie.workbench.common.stunner.core.graph.command.impl.SetChildrenCommand { @Override protected void execute(final GraphCommandExecutionContext context, final Node<?, Edge> parent, final Node<?, Edge> candidate) { super.execute(context, parent, candidate); if (parent.getConten...
### Question: DMNDeleteElementsGraphCommand extends DeleteElementsCommand { @Override protected DMNSafeDeleteNodeCommand createSafeDeleteNodeCommand(final Node<?, Edge> node, final SafeDeleteNodeCommand.Options options, final DeleteCallback callback) { return new DMNSafeDeleteNodeCommand(node, callback.onDeleteNode(nod...
### Question: DMNDeleteElementsCommand extends DeleteElementsCommand { @Override protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler context) { return new DMNDeleteElementsGraphCommand(() -> elements, new CanvasMultipleDeleteProcessor(), getGraphsProvider()); } DMN...
### Question: DMNDeleteNodeCommand extends DeleteNodeCommand { @Override protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler context) { return new DMNSafeDeleteNodeCommand(candidate, deleteProcessor, options, getGraphsProvider()); } DMNDeleteNodeCommand(final Node ...
### Question: DMNSafeDeleteNodeCommand extends SafeDeleteNodeCommand { @Override public boolean shouldKeepChildren(final Node<Definition<?>, Edge> candidate) { return DefinitionUtils.getElementDefinition(candidate) instanceof DecisionService; } DMNSafeDeleteNodeCommand(final Node<?, Edge> node, ...
### Question: NoOperationGraphCommand extends AbstractGraphCommand { @Override protected CommandResult<RuleViolation> check(final GraphCommandExecutionContext context) { return GraphCommandResultBuilder.SUCCESS; } @Override CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context); @Override Com...
### Question: NoOperationGraphCommand extends AbstractGraphCommand { @Override public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context) { return GraphCommandResultBuilder.SUCCESS; } @Override CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context); @Override Comm...
### Question: NoOperationGraphCommand extends AbstractGraphCommand { @Override public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext context) { return GraphCommandResultBuilder.SUCCESS; } @Override CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context); @Override Command...
### Question: DMNServiceClient { public <T> ServiceCallback<List<T>> callback(final Consumer<List<T>> consumer) { return new ServiceCallback<List<T>>() { @Override public void onSuccess(final List<T> item) { consumer.accept(item); } @Override public void onError(final ClientRuntimeError error) { getClientServicesProxy(...
### Question: DMNIncludeModelsClient extends DMNServiceClient { public void loadModels(final Path path, final Consumer<List<IncludedModel>> listConsumer) { clientServicesProxy.loadModels(path, callback(listConsumer)); } @Inject DMNIncludeModelsClient(final DMNClientServicesProxy clientServicesProxy); void loadModels(f...
### Question: DMNIncludeModelsClient extends DMNServiceClient { public void loadNodesFromImports(final List<DMNIncludedModel> includeModels, final Consumer<List<DMNIncludedNode>> consumer) { clientServicesProxy.loadNodesFromImports(includeModels, callback(consumer)); } @Inject DMNIncludeModelsClient(final DMNClientSer...
### Question: DMNIncludeModelsClient extends DMNServiceClient { public void loadItemDefinitionsByNamespace(final String modelName, final String namespace, final Consumer<List<ItemDefinition>> consumer) { clientServicesProxy.loadItemDefinitionsByNamespace(modelName, namespace, callback(consumer)); } @Inject DMNIncludeM...
### Question: ReadOnlyProviderImpl implements ReadOnlyProvider { @Override public boolean isReadOnlyDiagram() { return contextProvider.isReadOnly(); } @Inject ReadOnlyProviderImpl(final EditorContextProvider contextProvider); @Override boolean isReadOnlyDiagram(); }### Answer: @Test public void testIsReadOnlyDiagramW...
### Question: DMNDataObjectsClient extends DMNServiceClient { public void loadDataObjects(final Consumer<List<DataObject>> listConsumer) { clientServicesProxy.loadDataObjects( callback(listConsumer)); } @Inject DMNDataObjectsClient(final DMNClientServicesProxy clientServicesProxy); void loadDataObjects(final Consumer<...
### Question: BoxedExpressionHelper { public Optional<HasExpression> getOptionalHasExpression(final Node<View, Edge> node) { final Object definition = DefinitionUtils.getElementDefinition(node); final HasExpression expression; if (definition instanceof BusinessKnowledgeModel) { expression = ((BusinessKnowledgeModel) de...
### Question: BoxedExpressionHelper { public Expression getExpression(final Node<View, Edge> node) { return getHasExpression(node).getExpression(); } Optional<HasExpression> getOptionalHasExpression(final Node<View, Edge> node); Optional<Expression> getOptionalExpression(final Node<View, Edge> node); Expression getExp...
### Question: BoxedExpressionHelper { public HasExpression getHasExpression(final Node<View, Edge> node) { return getOptionalHasExpression(node).orElseThrow(UnsupportedOperationException::new); } Optional<HasExpression> getOptionalHasExpression(final Node<View, Edge> node); Optional<Expression> getOptionalExpression(f...
### Question: DocumentationLinksWidget extends Composite implements HasValue<DocumentationLinks>, HasEnabled { @EventHandler("add-button") @SuppressWarnings("unused") public void onClickTypeButton(final ClickEvent clickEvent) { cellEditor.show(nameAndUr...
### Question: DocumentationLinksWidget extends Composite implements HasValue<DocumentationLinks>, HasEnabled { public void setDMNModel(final DRGElement model) { setValue(model.getLinksHolder().getValue()); refresh(); } @Inject DocumentationLinksWidget(...
### Question: DocumentationLinksWidget extends Composite implements HasValue<DocumentationLinks>, HasEnabled { void refresh() { final List<DMNExternalLink> all = getValue().getLinks(); RemoveHelper.removeChildren(linksContainer); for (final DMNExternalL...
### Question: DocumentationLinksWidget extends Composite implements HasValue<DocumentationLinks>, HasEnabled { void refreshContainersVisibility() { if (getValue().getLinks().size() == 0) { HiddenHelper.show(noneContainer); HiddenHelper.hide(linksContain...
### Question: DocumentationLinksWidget extends Composite implements HasValue<DocumentationLinks>, HasEnabled { void onExternalLinkDeleted(final DMNExternalLink externalLink) { locker.fire(new LockRequiredEvent()); getValue().getLinks().remove(externalLi...
### Question: DocumentationLinksWidget extends Composite implements HasValue<DocumentationLinks>, HasEnabled { void onDMNExternalLinkCreated(final DMNExternalLink externalLink) { locker.fire(new LockRequiredEvent()); getValue().addLink(externalLink); re...
### Question: DocumentationLinksWidget extends Composite implements HasValue<DocumentationLinks>, HasEnabled { @PostConstruct public void init() { nameAndUrlPopover.setOnExternalLinkCreated(this::onDMNExternalLinkCreated); addLink.textContent = translat...
### Question: DocumentationLinksWidget extends Composite implements HasValue<DocumentationLinks>, HasEnabled { void setupAddButtonReadOnlyStatus() { if (readOnlyProvider.isReadOnlyDiagram()) { addButton.classList.add(READ_ONLY_CSS_CLASS); } else { addBu...
### Question: DocumentationLinkItem implements UberElemental<DMNExternalLink> { @Override public void init(final DMNExternalLink externalLink) { this.externalLink = externalLink; link.href = externalLink.getUrl(); link.textContent = externalLink.getDescription(); } @Inject DocumentationLinkItem(final HTMLDivElement it...
### Question: DocumentationLinkItem implements UberElemental<DMNExternalLink> { @SuppressWarnings("unused") @EventHandler("deleteLink") public void onDeleteLinkClick(final ClickEvent clickEvent) { if (!Objects.isNull(getOnDeleted())) { getOnDeleted().accept(externalLink); } } @Inject DocumentationLinkItem(final HTMLDi...
### Question: DMNDocumentationExternalLink { @JsOverlay public static DMNDocumentationExternalLink create(final String description, final String url) { final DMNDocumentationExternalLink link = new DMNDocumentationExternalLink(); link.description = description; link.url = url; return link; } private DMNDocumentationEx...
### Question: DMNDocumentationDRDsFactory { public List<DMNDocumentationDRD> create(final Diagram diagram) { final Optional<String> previousNodeUUID = getExpressionContainerGrid().getNodeUUID(); final List<DMNDocumentationDRD> drds = createDMNDocumentationDRDs(diagram); previousNodeUUID.ifPresent(uuid -> setExpressionC...
### Question: DMNDocumentationDRDsFactory { String getNodeImage(final Diagram diagram, final Node<View, Edge> node) { if (!hasExpression(node)) { return NONE; } setExpressionContainerGrid(diagram, node.getUUID()); final ExpressionContainerGrid grid = getExpressionContainerGrid(); final Viewport viewport = grid.getViewp...
### Question: DMNDocumentationDRDsFactory { void setExpressionContainerGrid(final Diagram diagram, final String uuid) { final Node<View, Edge> node = getNode(diagram, uuid); final Object definition = DefinitionUtils.getElementDefinition(node); final HasExpression hasExpression = expressionHelper.getHasExpression(node);...
### Question: DMNDocumentationDRDsFactory { void clearSelections(final ExpressionContainerGrid grid) { grid.getBaseExpressionGrid().ifPresent(expressionGrid -> { expressionGrid.getModel().clearSelections(); expressionGrid.draw(); }); } @Inject DMNDocumentationDRDsFactory(final SessionManager sessionManager, ...
### Question: DMNDocumentationServiceImpl implements DMNDocumentationService { @Override public DMNDocumentation processDocumentation(final Diagram diagram) { return dmnDocumentationFactory.create(diagram); } @Inject DMNDocumentationServiceImpl(final ClientMustacheTemplateRenderer mustacheTemplateRenderer, ...
### Question: DMNDocumentationServiceImpl implements DMNDocumentationService { @Override public HTMLDocumentationTemplate getDocumentationTemplate() { final DMNDocumentationTemplateSource source = GWT.create(DMNDocumentationTemplateSource.class); return new HTMLDocumentationTemplate(source.documentationTemplate().getTe...
### Question: DMNDocumentationServiceImpl implements DMNDocumentationService { @Override public DocumentationOutput buildDocumentation(final HTMLDocumentationTemplate template, final DMNDocumentation diagramDocumentation) { final String rendered = mustacheTemplateRenderer.render(template.getTemplate(), diagramDocumenta...
### Question: DMNDocumentationServiceImpl implements DMNDocumentationService { @Override public DocumentationOutput generate(final Diagram diagram) { return Optional.ofNullable(diagram) .map(this::processDocumentation) .map(dmnDocumentation -> buildDocumentation(getDocumentationTemplate(), dmnDocumentation)) .orElse(EM...
### Question: DMNDocumentationFactory { protected String getDiagramImage() { return getCanvasHandler() .map(canvasFileExport::exportToPng) .orElse(EMPTY); } @Inject DMNDocumentationFactory(final CanvasFileExport canvasFileExport, final TranslationService translationService, ...
### Question: DMNDocumentationFactory { protected boolean hasGraphNodes(final Diagram diagram) { return !graphUtils.getDRGElements(diagram).isEmpty(); } @Inject DMNDocumentationFactory(final CanvasFileExport canvasFileExport, final TranslationService translationService, ...
### Question: NameAndUrlPopoverViewImpl extends AbstractPopoverViewImpl implements NameAndUrlPopoverView { @PostConstruct public void init() { okButton.disabled = true; urlLabel.textContent = translationService.getTranslation(DMNDocumentationI18n_URL); attachmentName.textContent = translationService.getTranslation(DMND...
### Question: NameAndUrlPopoverViewImpl extends AbstractPopoverViewImpl implements NameAndUrlPopoverView { @EventHandler("okButton") @SuppressWarnings("unused") public void onClickOkButton(final ClickEvent clickEvent) { final Consumer<DMNExternalLink> consumer = getOnExternalLinkCreated(); if (!Objects.isNull(consumer)...
### Question: NameAndUrlPopoverViewImpl extends AbstractPopoverViewImpl implements NameAndUrlPopoverView { @EventHandler("cancelButton") @SuppressWarnings("unused") public void onClickCancelButton(final ClickEvent clickEvent) { hide(); } NameAndUrlPopoverViewImpl(); @Inject NameAndUrlPopoverViewImpl(final Div popoverE...
### Question: NameAndUrlPopoverViewImpl extends AbstractPopoverViewImpl implements NameAndUrlPopoverView { @Override public void show(final Optional<String> popoverTitle) { clear(); superShow(popoverTitle); } NameAndUrlPopoverViewImpl(); @Inject NameAndUrlPopoverViewImpl(final Div popoverElement, ...
### Question: NameAndUrlPopoverViewImpl extends AbstractPopoverViewImpl implements NameAndUrlPopoverView { void clear() { attachmentNameInput.value = ""; urlInput.value = ""; } NameAndUrlPopoverViewImpl(); @Inject NameAndUrlPopoverViewImpl(final Div popoverElement, final Div popove...
### Question: NameAndUriPopoverImpl extends AbstractPopoverImpl<NameAndUrlPopoverView, NameAndUrlPopoverView.Presenter> implements NameAndUrlPopoverView.Presenter { @PostConstruct public void init() { view.init(this); } NameAndUriPopoverImpl(); @Inject NameAndUriPopoverImpl(final NameAndUrlPopoverView view); @PostCons...
### Question: NameAndUriPopoverImpl extends AbstractPopoverImpl<NameAndUrlPopoverView, NameAndUrlPopoverView.Presenter> implements NameAndUrlPopoverView.Presenter { @Override public HTMLElement getElement() { return view.getElement(); } NameAndUriPopoverImpl(); @Inject NameAndUriPopoverImpl(final NameAndUrlPopoverView...
### Question: NameAndUriPopoverImpl extends AbstractPopoverImpl<NameAndUrlPopoverView, NameAndUrlPopoverView.Presenter> implements NameAndUrlPopoverView.Presenter { @Override public void show() { view.show(Optional.ofNullable(getPopoverTitle())); } NameAndUriPopoverImpl(); @Inject NameAndUriPopoverImpl(final NameAndUr...
### Question: NameAndUriPopoverImpl extends AbstractPopoverImpl<NameAndUrlPopoverView, NameAndUrlPopoverView.Presenter> implements NameAndUrlPopoverView.Presenter { @Override public void hide() { view.hide(); } NameAndUriPopoverImpl(); @Inject NameAndUriPopoverImpl(final NameAndUrlPopoverView view); @PostConstruct voi...
### Question: NameAndUriPopoverImpl extends AbstractPopoverImpl<NameAndUrlPopoverView, NameAndUrlPopoverView.Presenter> implements NameAndUrlPopoverView.Presenter { @Override public void setOnExternalLinkCreated(final Consumer<DMNExternalLink> onExternalLinkCreated) { view.setOnExternalLinkCreated(onExternalLinkCreated...
### Question: DMNDocumentationView extends DefaultDiagramDocumentationView { @Override public DocumentationView<Diagram> refresh() { refreshDocumentationHTML(); refreshDocumentationHTMLAfter200ms(); if (!buttonsVisibilitySupplier.isButtonsVisible()) { hide(printButton); hide(downloadHtmlFile); } return this; } @Inject ...
### Question: DMNDocumentationView extends DefaultDiagramDocumentationView { void refreshDocumentationHTML() { documentationContent.innerHTML = getDocumentationHTML(); } @Inject DMNDocumentationView(final HTMLDivElement documentationPanel, final HTMLDivElement documentationContent, ...
### Question: DMNDocumentationView extends DefaultDiagramDocumentationView { void refreshDocumentationHTMLAfter200ms() { setTimeout((w) -> refreshDocumentationHTML(), 200); } @Inject DMNDocumentationView(final HTMLDivElement documentationPanel, final HTMLDivElement documentationContent,...
### Question: DMNDocumentationView extends DefaultDiagramDocumentationView { @Override public boolean isEnabled() { return true; } @Inject DMNDocumentationView(final HTMLDivElement documentationPanel, final HTMLDivElement documentationContent, final HTMLB...
### Question: DMNDocumentationView extends DefaultDiagramDocumentationView { @EventHandler("print-button") public void onPrintButtonClick(final ClickEvent e) { printHelper.print(documentationContent); } @Inject DMNDocumentationView(final HTMLDivElement documentationPanel, final HTMLDivE...
### Question: DMNDocumentationView extends DefaultDiagramDocumentationView { @EventHandler("download-html-file") public void onDownloadHtmlFile(final ClickEvent e) { final String html = getCurrentDocumentationHTML(); downloadHelper.download(getCurrentDocumentationModelName(), html); } @Inject DMNDocumentationView(fina...
### Question: DMNContentServiceImpl extends KieService<String> implements DMNContentService { @Override protected String constructContent(final Path path, final Overview _overview) { return getSource(path); } @Inject DMNContentServiceImpl(final CommentedOptionFactory commentedOptionFactory, ...
### Question: RoomResourceTemplate implements RoomResource { @Override public List<Room> listRooms() { return Arrays.asList(restTemplate.getForEntity("https: } RoomResourceTemplate(final RestTemplate restTemplate); @Override List<Room> listRooms(); }### Answer: @Test void listRooms() { mockServer.expect(requestTo("htt...
### Question: GithubClaimResolver { public ClaimableResultDto claimableResult(final String owner, final String repo, final String number, final RequestStatus requestStatus) { final GithubIssue githubIssue = githubScraper.fetchGithubIssue(owner, repo, number); if (isIssueClosed(githubIssue) && githubIssue.getSolver() !=...
### Question: GithubClaimResolver { public Boolean canClaim(final Principal user, final RequestDto request) { final String owner = request.getIssueInformation().getOwner(); final String repo = request.getIssueInformation().getRepo(); final String number = request.getIssueInformation().getNumber(); final GithubIssue git...
### Question: FiatService { public double getUsdPrice(TokenValueDto... funds) { return Arrays.stream(funds) .filter(f -> f != null && StringUtils.isNotBlank(f.getTokenSymbol())) .map(this::getValue) .mapToDouble(f -> f) .sum(); } FiatService(CryptoCompareService cryptoCompareService, CoinMarketCapService coinMarketCapS...
### Question: CoinMarketCapClientImpl implements CoinMarketCapClient { @Override public CmcListingsResult getListings() { return restTemplate.getForObject(endpoint + "/v1/cryptocurrency/listings/latest?limit=5000", CmcListingsResult.class); } CoinMarketCapClientImpl(@Value("${coinmarketcap.apikey}") String apiKey); @Ov...
### Question: RequestFundedGitterHandler { @EventListener @Async("taskExecutor") @Transactional(readOnly = true, propagation = REQUIRES_NEW) public void handle(final RequestFundedNotificationDto notification) { final FundDto fund = fundService.findOne(notification.getFundId()); Context context = new Context(); context....
### Question: CryptoCompareClientImpl implements CryptoCompareClient { public PriceResultDto getPrice(String symbol) { return restTemplate.getForObject(endpoint + "/data/price?fsym={symbol}&tsyms=USD", PriceResultDto.class, symbol); } CryptoCompareClientImpl(@Value("${cryptocompare.apikey}") String apiKey); PriceResult...
### Question: RequestServiceImpl implements RequestService { @Override @Transactional(readOnly = true) public List<RequestDto> findAll() { return mappers.mapList(Request.class, RequestDto.class, requestRepository.findAll()); } RequestServiceImpl(final RequestRepository requestRepository, f...
### Question: RequestServiceImpl implements RequestService { @Transactional(readOnly = true) public List<RequestDto> findAllFor(final List<String> projects, final List<String> technologies, final Long lastUpdatedSinceDays) { final RequestSpecification specification = new RequestSpecification(projects, technologies, las...
### Question: RequestServiceImpl implements RequestService { @Override @Transactional(readOnly = true) public RequestDto findRequest(Long id) { Request request = findOne(id); return mappers.map(Request.class, RequestDto.class, request); } RequestServiceImpl(final RequestRepository requestRepository, ...
### Question: RequestServiceImpl implements RequestService { @Override @Transactional(readOnly = true) public SignedClaim signClaimRequest(Principal user, UserClaimRequest userClaimRequest) { return githubClaimResolver.getSignedClaim(user, userClaimRequest, findRequest(userClaimRequest.getPlatform(), userClaimRequest.g...
### Question: RequestServiceImpl implements RequestService { @Override @Transactional(readOnly = true) public List<CommentDto> getComments(Long requestId) { Request request = requestRepository.findOne(requestId).orElseThrow(() -> new EntityNotFoundException("Request not found")); return mappers.mapList(GithubIssueComme...
### Question: RequestServiceImpl implements RequestService { @Override public void update(final UpdateRequestStatusCommand command) { requestRepository.findOne(command.getRequestId()).ifPresent(request -> { request.setStatus(command.getNewStatus()); requestRepository.save(request); }); } RequestServiceImpl(final Reques...
### Question: Erc67Generator { public String toFunction(CreateERC67FundRequest erc67FundRequest) { TokenInfoDto tokenInfo = tokenInfoService.getTokenInfo(erc67FundRequest.getTokenAddress()); final StringBuilder builder = new StringBuilder("approveAndCall").append("("); builder.append("address ").append(fundRequestContr...
### Question: UpdateRequestLastModifiedDateOnFundedHandler { @EventListener public void handle(final RequestFundedEvent event) { final Request request = requestRepository.findOne(event.getRequestId()) .orElseThrow(() -> new RuntimeException("Unable to find request")); request.setLastModifiedDate(LocalDateTime.now()); r...
### Question: ChangeRequestStatusOnFundedHandler { @EventListener public void handle(final RequestFundedEvent event) { final Request request = requestRepository.findOne(event.getRequestId()) .orElseThrow(() -> new RuntimeException("Unable to find request")); if (RequestStatus.OPEN == request.getStatus()) { request.setS...
### Question: GithubPlatformIdParser { public IssueInformation parseIssue(String platformId) { IssueInformation issueInformation = IssueInformation.builder().build(); String[] splitted = platformId.split(Pattern.quote(PLATFORM_ID_GITHUB_DELIMTER)); issueInformation.setOwner(splitted[0]); issueInformation.setRepo(splitt...
### Question: GithubPlatformIdParser { public static String extractOwner(final String platformId) { return extract(platformId, OWNER_GROUP_NAME); } GithubPlatformIdParser(GithubGateway githubGateway); static String extractOwner(final String platformId); static String extractRepo(String platformId); static String extrac...
### Question: RequestClaimedUserNotificationHandler { @EventListener @Async("taskExecutor") @Transactional(readOnly = true, propagation = REQUIRES_NEW) public void handle(final RequestClaimedNotificationDto notification) { claimService.findOne(notification.getClaimId()) .ifPresent(claim -> { final RequestDto request = ...
### Question: GithubPlatformIdParser { public static String extractRepo(String platformId) { return extract(platformId, REPO_GROUP_NAME); } GithubPlatformIdParser(GithubGateway githubGateway); static String extractOwner(final String platformId); static String extractRepo(String platformId); static String extractIssueNu...
### Question: GithubPlatformIdParser { public static String extractIssueNumber(final String platformId) { return extract(platformId, ISSUE_NUMBER_GROUP_NAME); } GithubPlatformIdParser(GithubGateway githubGateway); static String extractOwner(final String platformId); static String extractRepo(String platformId); static ...
### Question: BlockchainEventServiceImpl implements BlockchainEventService { @Override public Optional<BlockchainEventDto> findOne(final Long id) { return mapper.mapToOptional(blockchainEventRepo.findOne(id).orElse(null)); } BlockchainEventServiceImpl(final BlockchainEventRepository blockchainEventRepo, final Blockchai...
### Question: Request extends AbstractEntity { public Set<String> getTechnologies() { return this.technologies != null && !this.technologies.isEmpty() ? this.technologies.stream() .map(RequestTechnology::getTechnology) .collect(Collectors.toSet()) : new HashSet<>(); } protected Request(); void setStatus(RequestStatus ...
### Question: Request extends AbstractEntity { @Override public void setLastModifiedDate(final LocalDateTime lastModifiedDate) { super.setLastModifiedDate(lastModifiedDate); } protected Request(); void setStatus(RequestStatus status); Long getId(); RequestStatus getStatus(); RequestType getType(); IssueInformation get...
### Question: PendingFundService { @Transactional public void save(final Principal principal, final PendingFundCommand command) { final IssueInformation issueInformation = githubLinkParser.parseIssue(command.getPlatformId()); final PendingFund pf = PendingFund.builder() .amount(toWei(command)) .description(command.getD...
### Question: MessagesController extends AbstractController { @RequestMapping("/messages") public ModelAndView showAllMessagesPage(final Model model) { model.addAttribute("referralMessages", messageService.getMessagesByType(MessageType.REFERRAL_SHARE)); return new ModelAndView("messages/index"); } MessagesController(fi...
### Question: FundsAndRefundsAggregator { public List<UserFundsDto> aggregate(final List<FundsByFunderDto> fundsByFunder) { return fundsByFunder.stream() .collect(Collectors.groupingBy(funds -> funds.getFunderAddress().toLowerCase() + funds.getFunderUserId(), Collectors.mapping(mapToUserFundDto(), Collectors.reducing(m...
### Question: CommentDtoMapperDecorator implements CommentDtoMapper { @Override public CommentDto map(GithubIssueCommentsResult in) { CommentDto comment = delegate.map(in); if (comment != null) { comment.setUserName(in.getUser().getLogin()); comment.setUserUrl(in.getUser().getUrl()); comment.setUserAvatar(in.getUser()....
### Question: FundServiceImpl implements FundService { @Transactional(readOnly = true) @Override public List<FundDto> findAll() { return mappers.mapList(Fund.class, FundDto.class, fundRepository.findAll()); } @Autowired FundServiceImpl(final FundRepository fundRepository, final RefundReposit...
### Question: UserFundsDto { public boolean hasRefunds() { return fndRefunds != null || otherRefunds != null; } boolean hasRefunds(); }### Answer: @Test void hasRefunds_noRefunds() { assertThat(UserFundsDto.builder().build().hasRefunds()).isFalse(); } @Test void hasRefunds_fndRefunds() { assertThat(UserFundsDto.build...
### Question: MessagesController extends AbstractController { @RequestMapping("/messages/{type}") public ModelAndView showMessagesOfTypePage(final Model model, @PathVariable String type) { model.addAttribute("type", type.toUpperCase()); model.addAttribute("messages", messageService.getMessagesByType(MessageType.valueOf...
### Question: CheckFundsGtZeroHandler { @EventListener public void handleRefund(final RefundProcessedEvent refundProcessedEvent) { final Long requestId = refundProcessedEvent.getRefund().getRequestId(); if (!hasTokenValueGtZero(fundService.getTotalFundsForRequest(requestId)) && hasRequestStatus(requestId, FUNDED)) { re...
### Question: CheckFundsGtZeroHandler { @EventListener public void handleFund(final RequestFundedEvent requestFundedEvent) { final Long requestId = requestFundedEvent.getRequestId(); if (hasTokenValueGtZero(fundService.getTotalFundsForRequest(requestId)) && hasRequestStatus(requestId, OPEN)) { requestService.update(new...
### Question: PublishRequestClaimedNotificationHandler { @TransactionalEventListener public void onClaimed(final RequestClaimedEvent claimedEvent) { eventPublisher.publishEvent(RequestClaimedNotificationDto.builder() .blockchainEventId(claimedEvent.getBlockchainEventId()) .date(claimedEvent.getTimestamp()) .requestId(c...
### Question: CreateGithubCommentOnFundHandler { @TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT) public void createGithubCommentOnRequestFunded(final RequestFundedEvent event) { if (addComment) { final IssueInformationDto issueInformation = requestService.findRequest(event.getRequestId()).getIssueInf...
### Question: MessagesController extends AbstractController { @RequestMapping("/messages/{type}/add") public ModelAndView showAddMessageToTypePage(final Model model, @PathVariable String type) { model.addAttribute("message", MessageDto.builder().type(MessageType.valueOf(type)).build()); return new ModelAndView("message...
### Question: PublishRequestFundedNotificationHandler { @TransactionalEventListener public void onFunded(final RequestFundedEvent fundedEvent) { eventPublisher.publishEvent(new RequestFundedNotificationDto(fundedEvent.getFundDto().getBlockchainEventId(), fundedEvent.getTimestamp(), fundedEvent.getRequestId(), fundedEve...
### Question: PendingFundCleaner { @Scheduled(fixedDelay = 300_000 ) public void cleanupPendingFunds() { pendingFundService.findAll() .stream() .filter(fund -> { try { return hasFailed(fund) || hasAged(fund); } catch (final Exception ex) { log.error("Unable to fetch status for transaction {} : ", fund.getTransactionHas...
### Question: RefundServiceImpl implements RefundService { @Override @Transactional public void requestRefund(final RequestRefundCommand requestRefundCommand) { refundRequestRepository.save(RefundRequest.builder() .requestId(requestRefundCommand.getRequestId()) .funderAddress(requestRefundCommand.getFunderAddress()) .r...
### Question: RefundServiceImpl implements RefundService { @Override @Transactional(readOnly = true) public List<RefundRequestDto> findAllRefundRequestsFor(final long requestId, final RefundRequestStatus... statuses) { return refundRequestDtoMapper.mapToList(refundRequestRepository.findAllByRequestIdAndStatusIn(request...
### Question: MessagesController extends AbstractController { @RequestMapping("/messages/{type}/{name}/edit") public ModelAndView showEditPage(final Model model, @PathVariable String type, @PathVariable String name) { model.addAttribute("message", messageService.getMessageByTypeAndName(MessageType.valueOf(type.toUpperC...
### Question: FundRequestContractsService { @Cacheable(value = "possible_tokens", keyGenerator = "getAllPossibleTokensKeyGenerator") public List<TokenInfoDto> getAllPossibleTokens(final String platform, final String platformId) { return checkNotEmpty(getAllPossibleTokens().stream() .filter(token -> tokenWhitelistPrecon...
### Question: GetAllPossibleTokensKeyGenerator implements KeyGenerator { @Override public Object generate(final Object target, final Method method, final Object... params) { final String platform = (String) params[0]; if (Platform.GITHUB.name().equalsIgnoreCase(platform)) { return generateGitHubKey(platform, (String) p...
### Question: TweetRequestFundedHandler { @EventListener @Async("taskExecutor") @Transactional(readOnly = true, propagation = REQUIRES_NEW) public void handle(final RequestFundedNotificationDto notification) { final FundDto fund = fundService.findOne(notification.getFundId()); Context context = new Context(); context.s...