@Test void handle_noFundedNotificationChannels() { long fundId = 243L; long requestId = 764L; final String message = "ewfegdbf"; final RequestFundedNotificationDto notification = RequestFundedNotificationDto.builder().fundId(fundId).requestId(requestId).build(); final TokenValueDto tokenValue = TokenValueDtoMother.FND().build(); final FundDto fund = FundDto.builder().tokenValue(tokenValue).build(); final Context context = new Context(); final List<String> fundedNotificationChannels = Arrays.asList(allRooms.get(0).getName(), allRooms.get(2).getName()); context.setVariable("platformBasePath", platformBasePath); context.setVariable("fund", fund); when(fundService.findOne(fundId)).thenReturn(fund); when(templateEngine.process(eq("notification-templates/request-funded-gitter"), refEq(context, "locale"))).thenReturn(message); when(gitterService.listFundedNotificationRooms()).thenReturn(new ArrayList<>()); handler.handle(notification); verifyZeroInteractions(gitter); }
@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.setVariable("platformBasePath", platformBasePath); context.setVariable("fund", fund); final List<String> fundedNotificationChannels = gitterService.listFundedNotificationRooms(); if (fundedNotificationChannels.size() > 0) { final String message = githubTemplateEngine.process("notification-templates/request-funded-gitter", context); gitter.roomResource() .listRooms() .stream() .filter(room -> fundedNotificationChannels.contains(room.getName())) .forEach(room -> gitter.messageResource().sendMessage(room.getId(), message)); } }
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.setVariable("platformBasePath", platformBasePath); context.setVariable("fund", fund); final List<String> fundedNotificationChannels = gitterService.listFundedNotificationRooms(); if (fundedNotificationChannels.size() > 0) { final String message = githubTemplateEngine.process("notification-templates/request-funded-gitter", context); gitter.roomResource() .listRooms() .stream() .filter(room -> fundedNotificationChannels.contains(room.getName())) .forEach(room -> gitter.messageResource().sendMessage(room.getId(), message)); } } }
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.setVariable("platformBasePath", platformBasePath); context.setVariable("fund", fund); final List<String> fundedNotificationChannels = gitterService.listFundedNotificationRooms(); if (fundedNotificationChannels.size() > 0) { final String message = githubTemplateEngine.process("notification-templates/request-funded-gitter", context); gitter.roomResource() .listRooms() .stream() .filter(room -> fundedNotificationChannels.contains(room.getName())) .forEach(room -> gitter.messageResource().sendMessage(room.getId(), message)); } } RequestFundedGitterHandler(final Gitter gitter,
                                      final ITemplateEngine githubTemplateEngine,
                                      final FundService fundService,
                                      final String platformBasePath,
                                      final GitterService gitterService); }
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.setVariable("platformBasePath", platformBasePath); context.setVariable("fund", fund); final List<String> fundedNotificationChannels = gitterService.listFundedNotificationRooms(); if (fundedNotificationChannels.size() > 0) { final String message = githubTemplateEngine.process("notification-templates/request-funded-gitter", context); gitter.roomResource() .listRooms() .stream() .filter(room -> fundedNotificationChannels.contains(room.getName())) .forEach(room -> gitter.messageResource().sendMessage(room.getId(), message)); } } RequestFundedGitterHandler(final Gitter gitter,
                                      final ITemplateEngine githubTemplateEngine,
                                      final FundService fundService,
                                      final String platformBasePath,
                                      final GitterService gitterService); @EventListener @Async("taskExecutor") @Transactional(readOnly = true, propagation = REQUIRES_NEW) void handle(final RequestFundedNotificationDto notification); }
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.setVariable("platformBasePath", platformBasePath); context.setVariable("fund", fund); final List<String> fundedNotificationChannels = gitterService.listFundedNotificationRooms(); if (fundedNotificationChannels.size() > 0) { final String message = githubTemplateEngine.process("notification-templates/request-funded-gitter", context); gitter.roomResource() .listRooms() .stream() .filter(room -> fundedNotificationChannels.contains(room.getName())) .forEach(room -> gitter.messageResource().sendMessage(room.getId(), message)); } } RequestFundedGitterHandler(final Gitter gitter,
                                      final ITemplateEngine githubTemplateEngine,
                                      final FundService fundService,
                                      final String platformBasePath,
                                      final GitterService gitterService); @EventListener @Async("taskExecutor") @Transactional(readOnly = true, propagation = REQUIRES_NEW) void handle(final RequestFundedNotificationDto notification);  }