@Test void handle() { final long blockchainEventId = 2435L; final long requestId = 54657L; final long claimId = 7657L; final String solver = "afsg"; final String userEmail = "gsfd@afsgb.com"; final UserRepresentation userRepresentation = new UserRepresentation(); userRepresentation.setEmail(userEmail); final RequestClaimedNotificationDto notification = RequestClaimedNotificationDto.builder() .blockchainEventId(blockchainEventId) .requestId(requestId) .claimId(claimId) .date(LocalDateTime.now()) .build(); final RequestDto requestDto = RequestDtoMother.fundRequestArea51(); requestDto.setId(requestId); final String body = "szgsg"; final Context context = new Context(); context.setVariable("platformBasepath", platformBasepath); context.setVariable("request", requestDto); when(claimService.findOne(claimId)).thenReturn(Optional.of(ClaimDtoMother.aClaimDto().solver(solver).requestId(requestId).build())); when(requestService.findRequest(requestId)).thenReturn(requestDto); when(identityAPIClient.findByIdentityProviderAndFederatedUsername(requestDto.getIssueInformation().getPlatform().name().toLowerCase(), solver)).thenReturn(userRepresentation); when(githubTemplateEngine.process(eq("notification-templates/claimed-claimer-notification"), refEq(context, "locale"))).thenReturn(body); handler.handle(notification); verify(intercomApiClient).postMessage(AdminMessageBuilder.newInstanceWith() .messageType("email") .template("plain") .admin(AdminBuilder.newInstanceWith().id(adminId).build()) .subject("Your reward has been transferred to your account") .body(body) .user(UserBuilder.newInstanceWith().email(userEmail).build()) .build()); }
@EventListener @Async("taskExecutor") @Transactional(readOnly = true, propagation = REQUIRES_NEW) public void handle(final RequestClaimedNotificationDto notification) { claimService.findOne(notification.getClaimId()) .ifPresent(claim -> { final RequestDto request = requestService.findRequest(notification.getRequestId()); final UserRepresentation user = identityAPIClient.findByIdentityProviderAndFederatedUsername(request.getIssueInformation().getPlatform().name().toLowerCase(), claim.getSolver()); final Context context = new Context(); context.setVariable("platformBasepath", platformBasepath); context.setVariable("request", request); final String messageBody = githubTemplateEngine.process("notification-templates/claimed-claimer-notification", context); intercomApiClient.postMessage(AdminMessageBuilder.newInstanceWith() .messageType("email") .template("plain") .admin(AdminBuilder.newInstanceWith().id(adminId).build()) .subject("Your reward has been transferred to your account") .body(messageBody) .user(UserBuilder.newInstanceWith().email(user.getEmail()).build()) .build()); }); }
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 = requestService.findRequest(notification.getRequestId()); final UserRepresentation user = identityAPIClient.findByIdentityProviderAndFederatedUsername(request.getIssueInformation().getPlatform().name().toLowerCase(), claim.getSolver()); final Context context = new Context(); context.setVariable("platformBasepath", platformBasepath); context.setVariable("request", request); final String messageBody = githubTemplateEngine.process("notification-templates/claimed-claimer-notification", context); intercomApiClient.postMessage(AdminMessageBuilder.newInstanceWith() .messageType("email") .template("plain") .admin(AdminBuilder.newInstanceWith().id(adminId).build()) .subject("Your reward has been transferred to your account") .body(messageBody) .user(UserBuilder.newInstanceWith().email(user.getEmail()).build()) .build()); }); } }
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 = requestService.findRequest(notification.getRequestId()); final UserRepresentation user = identityAPIClient.findByIdentityProviderAndFederatedUsername(request.getIssueInformation().getPlatform().name().toLowerCase(), claim.getSolver()); final Context context = new Context(); context.setVariable("platformBasepath", platformBasepath); context.setVariable("request", request); final String messageBody = githubTemplateEngine.process("notification-templates/claimed-claimer-notification", context); intercomApiClient.postMessage(AdminMessageBuilder.newInstanceWith() .messageType("email") .template("plain") .admin(AdminBuilder.newInstanceWith().id(adminId).build()) .subject("Your reward has been transferred to your account") .body(messageBody) .user(UserBuilder.newInstanceWith().email(user.getEmail()).build()) .build()); }); } RequestClaimedUserNotificationHandler(@Value("${io.fundrequest.intercom.message.admin-id}") final String adminId,
                                                 @Value("${io.fundrequest.platform.base-path:https://fundrequest.io}") final String platformBasepath,
                                                 final ClaimService claimService,
                                                 final RequestService requestService,
                                                 final IdentityAPIClient identityAPIClient,
                                                 final ITemplateEngine githubTemplateEngine,
                                                 final IntercomApiClient intercomApiClient); }
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 = requestService.findRequest(notification.getRequestId()); final UserRepresentation user = identityAPIClient.findByIdentityProviderAndFederatedUsername(request.getIssueInformation().getPlatform().name().toLowerCase(), claim.getSolver()); final Context context = new Context(); context.setVariable("platformBasepath", platformBasepath); context.setVariable("request", request); final String messageBody = githubTemplateEngine.process("notification-templates/claimed-claimer-notification", context); intercomApiClient.postMessage(AdminMessageBuilder.newInstanceWith() .messageType("email") .template("plain") .admin(AdminBuilder.newInstanceWith().id(adminId).build()) .subject("Your reward has been transferred to your account") .body(messageBody) .user(UserBuilder.newInstanceWith().email(user.getEmail()).build()) .build()); }); } RequestClaimedUserNotificationHandler(@Value("${io.fundrequest.intercom.message.admin-id}") final String adminId,
                                                 @Value("${io.fundrequest.platform.base-path:https://fundrequest.io}") final String platformBasepath,
                                                 final ClaimService claimService,
                                                 final RequestService requestService,
                                                 final IdentityAPIClient identityAPIClient,
                                                 final ITemplateEngine githubTemplateEngine,
                                                 final IntercomApiClient intercomApiClient); @EventListener @Async("taskExecutor") @Transactional(readOnly = true, propagation = REQUIRES_NEW) void handle(final RequestClaimedNotificationDto notification); }
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 = requestService.findRequest(notification.getRequestId()); final UserRepresentation user = identityAPIClient.findByIdentityProviderAndFederatedUsername(request.getIssueInformation().getPlatform().name().toLowerCase(), claim.getSolver()); final Context context = new Context(); context.setVariable("platformBasepath", platformBasepath); context.setVariable("request", request); final String messageBody = githubTemplateEngine.process("notification-templates/claimed-claimer-notification", context); intercomApiClient.postMessage(AdminMessageBuilder.newInstanceWith() .messageType("email") .template("plain") .admin(AdminBuilder.newInstanceWith().id(adminId).build()) .subject("Your reward has been transferred to your account") .body(messageBody) .user(UserBuilder.newInstanceWith().email(user.getEmail()).build()) .build()); }); } RequestClaimedUserNotificationHandler(@Value("${io.fundrequest.intercom.message.admin-id}") final String adminId,
                                                 @Value("${io.fundrequest.platform.base-path:https://fundrequest.io}") final String platformBasepath,
                                                 final ClaimService claimService,
                                                 final RequestService requestService,
                                                 final IdentityAPIClient identityAPIClient,
                                                 final ITemplateEngine githubTemplateEngine,
                                                 final IntercomApiClient intercomApiClient); @EventListener @Async("taskExecutor") @Transactional(readOnly = true, propagation = REQUIRES_NEW) void handle(final RequestClaimedNotificationDto notification);  }