### Question:
FlowLogDBService implements FlowLogService { public FlowLog getLastFlowLogByResourceCrnOrName(String resource) { Long resourceId = getResourceIdByCrnOrName(resource); Iterator<FlowLog> iterator = findAllByResourceIdOrderByCreatedDesc(resourceId).iterator(); if (iterator.hasNext()) { return iterator.next(); } throw new NotFoundException("Flow log for resource not found!"); }  FlowLog save(FlowParameters flowParameters, String flowChanId, String key, Payload payload, Map<Object, Object> variables, Class<?> flowType,
            FlowState currentState); String getSerializedString(Object object); @Override Iterable<FlowLog> saveAll(Iterable<FlowLog> flowLogs); FlowLog close(Long stackId, String flowId); FlowLog cancel(Long stackId, String flowId); FlowLog terminate(Long stackId, String flowId); void saveChain(String flowChainId, String parentFlowChainId, Queue<Selectable> chain, String flowTriggerUserCrn); void updateLastFlowLogStatus(FlowLog lastFlowLog, boolean failureEvent); void cancelTooOldTerminationFlowForResource(Long resourceId, long olderThan); boolean isOtherNonTerminationFlowRunning(Long resourceId); boolean isOtherFlowRunning(Long resourceId); boolean repeatedFlowState(FlowLog lastFlowLog, String event); void updateLastFlowLogPayload(FlowLog lastFlowLog, Payload payload, Map<Object, Object> variables); Optional<FlowLog> getLastFlowLog(String flowId); @Override Set<String> findAllRunningNonTerminationFlowIdsByStackId(Long resourceId); @Override Optional<FlowLog> findFirstByFlowIdOrderByCreatedDesc(String flowId); @Override Optional<FlowChainLog> findFirstByFlowChainIdOrderByCreatedDesc(String flowChainId); @Override List<Object[]> findAllPending(); @Override Set<FlowLog> findAllUnassigned(); @Override Set<FlowLog> findAllByCloudbreakNodeId(String cloudbreakNodeId); List<FlowLog> findAllByResourceIdOrderByCreatedDesc(Long id); List<FlowLog> findAllByResourceIdAndFinalizedIsFalseOrderByCreatedDesc(Long id); @Override int purgeFinalizedFlowLogs(); List<FlowLog> findAllByFlowIdOrderByCreatedDesc(String flowId); Long getResourceIdByCrnOrName(String resource); FlowLog getLastFlowLogByResourceCrnOrName(String resource); List<FlowLog> getFlowLogsByResourceCrnOrName(String resource); Set<String> getFlowIdsByChainIds(Set<String> flowChainIds); List<FlowLog> getFlowLogsByFlowIdsCreatedDesc(Set<String> flowIds); Boolean hasPendingFlowEvent(List<FlowLog> flowLogs); Predicate<FlowLog> pendingFlowLogPredicate();  }### Answer:
@Test public void testGetLastFlowLogWhenThereIsNoFlow() { when(resourceIdProvider.getResourceIdByResourceCrn(anyString())).thenReturn(1L); thrown.expect(NotFoundException.class); thrown.expectMessage("Flow log for resource not found!"); underTest.getLastFlowLogByResourceCrnOrName(CLOUDBREAK_STACK_CRN); }