### 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.setStatus(RequestStatus.FUNDED); requestRepository.saveAndFlush(request); } } ChangeRequestStatusOnFundedHandler(final RequestRepository requestRepository); @EventListener void handle(final RequestFundedEvent event);  }### Answer:
@Test void handle_requestOPEN() { final long requestId = 6578L; final RequestFundedEvent event = RequestFundedEvent.builder().requestId(requestId).build(); final Request request = RequestMother.fundRequestArea51().withStatus(OPEN).build(); when(requestRepository.findOne(requestId)).thenReturn(Optional.of(request)); handler.handle(event); assertThat(request.getStatus()).isEqualTo(FUNDED); verify(requestRepository).saveAndFlush(request); }
@Test void handle_requestNotFound() { final long requestId = 908978; 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"); } }