@Test void handle_requestNotFound() { final long requestId = 234; final RequestFundedEvent event = RequestFundedEvent.builder().requestId(requestId).build(); when(requestRepository.findOne(requestId)).thenReturn(Optional.empty()); try { handler.handle(event); fail("Expected new RuntimeException(\"Unable to find request\") to be thrown"); } catch (RuntimeException e) { assertThat(e.getMessage()).isEqualTo("Unable to find request"); } }
@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()); requestRepository.saveAndFlush(request); }
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()); requestRepository.saveAndFlush(request); } }
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()); requestRepository.saveAndFlush(request); } UpdateRequestLastModifiedDateOnFundedHandler(final RequestRepository requestRepository); }
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()); requestRepository.saveAndFlush(request); } UpdateRequestLastModifiedDateOnFundedHandler(final RequestRepository requestRepository); @EventListener void handle(final RequestFundedEvent event); }
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()); requestRepository.saveAndFlush(request); } UpdateRequestLastModifiedDateOnFundedHandler(final RequestRepository requestRepository); @EventListener void handle(final RequestFundedEvent event);  }