### Question:
FlowRetryUtil { public static Optional<FlowLog> getMostRecentFailedLog(List<FlowLog> flowLogs) { return flowLogs.stream() .filter(log -> StateStatus.FAILED.equals(log.getStateStatus())).max(Comparator.comparing(FlowLog::getCreated)); } private  FlowRetryUtil(); static FlowLog getLastSuccessfulStateLog(String failedState, List<FlowLog> flowLogs); static Optional<FlowLog> getMostRecentFailedLog(List<FlowLog> flowLogs); static boolean isFlowPending(List<FlowLog> flowLogs);  }### Answer:
@Test public void getMostRecentFailedLog() { List<FlowLog> flowLogs = new ArrayList<>(); FlowLog successfulFlowLog1 = new FlowLog(); successfulFlowLog1.setStateStatus(StateStatus.SUCCESSFUL); successfulFlowLog1.setNextEvent("NEXT_EVENT1"); successfulFlowLog1.setCreated(1L); successfulFlowLog1.setCurrentState("CURRENT_STATE1"); flowLogs.add(successfulFlowLog1); FlowLog failedFlowLog2 = new FlowLog(); failedFlowLog2.setStateStatus(StateStatus.FAILED); failedFlowLog2.setCurrentState("FAILED_CURRENT_STATE"); failedFlowLog2.setCreated(5L); flowLogs.add(failedFlowLog2); FlowLog successfulFlowLog4 = new FlowLog(); successfulFlowLog4.setStateStatus(StateStatus.SUCCESSFUL); successfulFlowLog4.setNextEvent("NEXT_EVENT3"); successfulFlowLog4.setCreated(4L); successfulFlowLog4.setCurrentState("CURRENT_STATE3"); flowLogs.add(successfulFlowLog4); FlowLog successfulFlowLog3 = new FlowLog(); successfulFlowLog3.setStateStatus(StateStatus.SUCCESSFUL); successfulFlowLog3.setNextEvent("NEXT_EVENT1"); successfulFlowLog3.setCreated(3L); successfulFlowLog3.setCurrentState("CURRENT_STATE1"); flowLogs.add(successfulFlowLog3); FlowLog failedFlowLog = new FlowLog(); failedFlowLog.setStateStatus(StateStatus.FAILED); failedFlowLog.setCurrentState("FAILED_CURRENT_STATE"); failedFlowLog.setCreated(2L); flowLogs.add(failedFlowLog); Optional<FlowLog> mostRecentFailedLog = FlowRetryUtil.getMostRecentFailedLog(flowLogs); assertEquals(mostRecentFailedLog.get(), failedFlowLog2); }