@Test public void readData_IOException() throws IOException { Mockito.when(filereader.fileExist(Mockito.anyString())).thenReturn(true); Mockito.when(filereader.readAllLine(Mockito.anyString())).thenThrow(new IOException("test exception")); List<UserEvent> listUserEvent = null; listUserEvent = traceDataReader.readData(traceFolder, 0, 0); assertEquals(0, listUserEvent.size(), 0); }
@Override public List<UserEvent> readData(String directory, double eventTime0, double startTime) { List<UserEvent> userEvents = new ArrayList<UserEvent>(); Map<UserEventType, Double> lastEvent = new EnumMap<UserEventType, Double>( UserEventType.class); String filepath = directory + Util.FILE_SEPARATOR + TraceDataConst.FileName.USER_EVENTS_FILE; String getEventsFilePath = directory + Util.FILE_SEPARATOR + TraceDataConst.FileName.USER_GETEVENTS_FILE; if(filereader.fileExist(filepath)) { userEvents = readUserInputFile(lastEvent, filepath, startTime, eventTime0); } else if (filereader.fileExist(getEventsFilePath)) { userEvents = readGetEventsFile(directory, eventTime0, startTime); } return userEvents; }
UserEventReaderImpl extends PeripheralBase implements IUserEventReader { @Override public List<UserEvent> readData(String directory, double eventTime0, double startTime) { List<UserEvent> userEvents = new ArrayList<UserEvent>(); Map<UserEventType, Double> lastEvent = new EnumMap<UserEventType, Double>( UserEventType.class); String filepath = directory + Util.FILE_SEPARATOR + TraceDataConst.FileName.USER_EVENTS_FILE; String getEventsFilePath = directory + Util.FILE_SEPARATOR + TraceDataConst.FileName.USER_GETEVENTS_FILE; if(filereader.fileExist(filepath)) { userEvents = readUserInputFile(lastEvent, filepath, startTime, eventTime0); } else if (filereader.fileExist(getEventsFilePath)) { userEvents = readGetEventsFile(directory, eventTime0, startTime); } return userEvents; } }
UserEventReaderImpl extends PeripheralBase implements IUserEventReader { @Override public List<UserEvent> readData(String directory, double eventTime0, double startTime) { List<UserEvent> userEvents = new ArrayList<UserEvent>(); Map<UserEventType, Double> lastEvent = new EnumMap<UserEventType, Double>( UserEventType.class); String filepath = directory + Util.FILE_SEPARATOR + TraceDataConst.FileName.USER_EVENTS_FILE; String getEventsFilePath = directory + Util.FILE_SEPARATOR + TraceDataConst.FileName.USER_GETEVENTS_FILE; if(filereader.fileExist(filepath)) { userEvents = readUserInputFile(lastEvent, filepath, startTime, eventTime0); } else if (filereader.fileExist(getEventsFilePath)) { userEvents = readGetEventsFile(directory, eventTime0, startTime); } return userEvents; }  }
UserEventReaderImpl extends PeripheralBase implements IUserEventReader { @Override public List<UserEvent> readData(String directory, double eventTime0, double startTime) { List<UserEvent> userEvents = new ArrayList<UserEvent>(); Map<UserEventType, Double> lastEvent = new EnumMap<UserEventType, Double>( UserEventType.class); String filepath = directory + Util.FILE_SEPARATOR + TraceDataConst.FileName.USER_EVENTS_FILE; String getEventsFilePath = directory + Util.FILE_SEPARATOR + TraceDataConst.FileName.USER_GETEVENTS_FILE; if(filereader.fileExist(filepath)) { userEvents = readUserInputFile(lastEvent, filepath, startTime, eventTime0); } else if (filereader.fileExist(getEventsFilePath)) { userEvents = readGetEventsFile(directory, eventTime0, startTime); } return userEvents; }  List<UserEvent> readGetEventsFile(String directory, double eventTime0, double startTime); @Override List<UserEvent> readData(String directory, double eventTime0, double startTime); }
UserEventReaderImpl extends PeripheralBase implements IUserEventReader { @Override public List<UserEvent> readData(String directory, double eventTime0, double startTime) { List<UserEvent> userEvents = new ArrayList<UserEvent>(); Map<UserEventType, Double> lastEvent = new EnumMap<UserEventType, Double>( UserEventType.class); String filepath = directory + Util.FILE_SEPARATOR + TraceDataConst.FileName.USER_EVENTS_FILE; String getEventsFilePath = directory + Util.FILE_SEPARATOR + TraceDataConst.FileName.USER_GETEVENTS_FILE; if(filereader.fileExist(filepath)) { userEvents = readUserInputFile(lastEvent, filepath, startTime, eventTime0); } else if (filereader.fileExist(getEventsFilePath)) { userEvents = readGetEventsFile(directory, eventTime0, startTime); } return userEvents; }  List<UserEvent> readGetEventsFile(String directory, double eventTime0, double startTime); @Override List<UserEvent> readData(String directory, double eventTime0, double startTime);  }