### Question:
FlowService { public FlowLogResponse getLastFlowById(String flowId) { LOGGER.info("Getting last flow log by flow id {}", flowId); Optional<FlowLog> lastFlowLog = flowLogDBService.getLastFlowLog(flowId); if (lastFlowLog.isPresent()) { return conversionService.convert(lastFlowLog.get(), FlowLogResponse.class); } throw new BadRequestException("Not found flow for this flow id!"); }  FlowLogResponse getLastFlowById(String flowId); List<FlowLogResponse> getFlowLogsByFlowId(String flowId); FlowLogResponse getLastFlowByResourceName(String resourceName); FlowLogResponse getLastFlowByResourceCrn(String resourceCrn); List<FlowLogResponse> getFlowLogsByResourceCrn(String resourceCrn); List<FlowLogResponse> getFlowLogsByResourceName(String resourceName); FlowCheckResponse getFlowChainStateByResourceCrn(String chainId, String resourceCrn); FlowCheckResponse getFlowChainState(String chainId); FlowCheckResponse getFlowChainStateSafe(Long resourceId, String chainId); FlowCheckResponse getFlowState(String flowId);  }### Answer:
@Test public void testGetLastFlowById() { when(flowLogDBService.getLastFlowLog(anyString())).thenReturn(Optional.of(new FlowLog())); underTest.getLastFlowById(FLOW_ID); verify(flowLogDBService).getLastFlowLog(anyString()); verify(conversionService).convert(any(), eq(FlowLogResponse.class)); }
@Test public void testGetLastFlowByIdException() { when(flowLogDBService.getLastFlowLog(anyString())).thenReturn(Optional.empty()); thrown.expect(BadRequestException.class); thrown.expectMessage("Not found flow for this flow id!"); underTest.getLastFlowById(FLOW_ID); verify(flowLogDBService).getLastFlowLog(anyString()); verifyZeroInteractions(conversionService); }