@Ignore @Test(expected=NumberFormatException.class) public void readData_FailedToParse() throws IOException { Mockito.when(filereader.fileExist(Mockito.anyString())).thenReturn(true); Mockito.when(filereader.readAllLine(Mockito.anyString())).thenReturn(new String[] { "14141z8436 21" ,"1414108436 22" ,"1414108436 23" ,"1414108463 24" ,"1414108464 25" }); List<TemperatureEvent> listTemperatureEvent = traceDataReader.readData(traceFolder, 0.0); assertEquals(0, listTemperatureEvent.size(), 0); }
@Override public List<TemperatureEvent> readData(String directory, double startTime) { List<TemperatureEvent> temperatureEvents = new ArrayList<TemperatureEvent>(); String filePath = directory + Util.FILE_SEPARATOR + TraceDataConst.FileName.TEMPERATURE_FILE; if (!filereader.fileExist(filePath)) { return temperatureEvents; } String[] contents = null; try { contents = filereader.readAllLine(filePath); } catch (IOException e) { LOGGER.error("failed to read user event file: " + filePath); } if(contents != null && contents.length > 0){ for (String contentBuf : contents) { if (contentBuf.trim().isEmpty()) { continue; } String splitContents[] = contentBuf.split(" "); if (splitContents.length <= 1) { LOGGER.warn("Found invalid user event entry: " + contentBuf); continue; } double timeStamp = Double.parseDouble(splitContents[0]); if (timeStamp > 1.0e9) { timeStamp = Util.normalizeTime(timeStamp, startTime); } int temperatureC = 0; int temperatureF = 0; if (splitContents.length > 1 && splitContents[0].length() > 0) { temperatureC = Integer.parseInt(splitContents[1]); if (temperatureC != 0) { if (splitContents[1].length() > 2) { temperatureC = temperatureC / (int) Math.pow(10, splitContents[1].length() - 2); } temperatureF = (((temperatureC * 9) / 5) + 32); temperatureEvents.add(new TemperatureEvent(timeStamp, temperatureC, temperatureF)); } } } } return temperatureEvents; }
CpuTemperatureReaderImpl extends PeripheralBase implements ICpuTemperatureReader { @Override public List<TemperatureEvent> readData(String directory, double startTime) { List<TemperatureEvent> temperatureEvents = new ArrayList<TemperatureEvent>(); String filePath = directory + Util.FILE_SEPARATOR + TraceDataConst.FileName.TEMPERATURE_FILE; if (!filereader.fileExist(filePath)) { return temperatureEvents; } String[] contents = null; try { contents = filereader.readAllLine(filePath); } catch (IOException e) { LOGGER.error("failed to read user event file: " + filePath); } if(contents != null && contents.length > 0){ for (String contentBuf : contents) { if (contentBuf.trim().isEmpty()) { continue; } String splitContents[] = contentBuf.split(" "); if (splitContents.length <= 1) { LOGGER.warn("Found invalid user event entry: " + contentBuf); continue; } double timeStamp = Double.parseDouble(splitContents[0]); if (timeStamp > 1.0e9) { timeStamp = Util.normalizeTime(timeStamp, startTime); } int temperatureC = 0; int temperatureF = 0; if (splitContents.length > 1 && splitContents[0].length() > 0) { temperatureC = Integer.parseInt(splitContents[1]); if (temperatureC != 0) { if (splitContents[1].length() > 2) { temperatureC = temperatureC / (int) Math.pow(10, splitContents[1].length() - 2); } temperatureF = (((temperatureC * 9) / 5) + 32); temperatureEvents.add(new TemperatureEvent(timeStamp, temperatureC, temperatureF)); } } } } return temperatureEvents; } }
CpuTemperatureReaderImpl extends PeripheralBase implements ICpuTemperatureReader { @Override public List<TemperatureEvent> readData(String directory, double startTime) { List<TemperatureEvent> temperatureEvents = new ArrayList<TemperatureEvent>(); String filePath = directory + Util.FILE_SEPARATOR + TraceDataConst.FileName.TEMPERATURE_FILE; if (!filereader.fileExist(filePath)) { return temperatureEvents; } String[] contents = null; try { contents = filereader.readAllLine(filePath); } catch (IOException e) { LOGGER.error("failed to read user event file: " + filePath); } if(contents != null && contents.length > 0){ for (String contentBuf : contents) { if (contentBuf.trim().isEmpty()) { continue; } String splitContents[] = contentBuf.split(" "); if (splitContents.length <= 1) { LOGGER.warn("Found invalid user event entry: " + contentBuf); continue; } double timeStamp = Double.parseDouble(splitContents[0]); if (timeStamp > 1.0e9) { timeStamp = Util.normalizeTime(timeStamp, startTime); } int temperatureC = 0; int temperatureF = 0; if (splitContents.length > 1 && splitContents[0].length() > 0) { temperatureC = Integer.parseInt(splitContents[1]); if (temperatureC != 0) { if (splitContents[1].length() > 2) { temperatureC = temperatureC / (int) Math.pow(10, splitContents[1].length() - 2); } temperatureF = (((temperatureC * 9) / 5) + 32); temperatureEvents.add(new TemperatureEvent(timeStamp, temperatureC, temperatureF)); } } } } return temperatureEvents; }  }
CpuTemperatureReaderImpl extends PeripheralBase implements ICpuTemperatureReader { @Override public List<TemperatureEvent> readData(String directory, double startTime) { List<TemperatureEvent> temperatureEvents = new ArrayList<TemperatureEvent>(); String filePath = directory + Util.FILE_SEPARATOR + TraceDataConst.FileName.TEMPERATURE_FILE; if (!filereader.fileExist(filePath)) { return temperatureEvents; } String[] contents = null; try { contents = filereader.readAllLine(filePath); } catch (IOException e) { LOGGER.error("failed to read user event file: " + filePath); } if(contents != null && contents.length > 0){ for (String contentBuf : contents) { if (contentBuf.trim().isEmpty()) { continue; } String splitContents[] = contentBuf.split(" "); if (splitContents.length <= 1) { LOGGER.warn("Found invalid user event entry: " + contentBuf); continue; } double timeStamp = Double.parseDouble(splitContents[0]); if (timeStamp > 1.0e9) { timeStamp = Util.normalizeTime(timeStamp, startTime); } int temperatureC = 0; int temperatureF = 0; if (splitContents.length > 1 && splitContents[0].length() > 0) { temperatureC = Integer.parseInt(splitContents[1]); if (temperatureC != 0) { if (splitContents[1].length() > 2) { temperatureC = temperatureC / (int) Math.pow(10, splitContents[1].length() - 2); } temperatureF = (((temperatureC * 9) / 5) + 32); temperatureEvents.add(new TemperatureEvent(timeStamp, temperatureC, temperatureF)); } } } } return temperatureEvents; }  @Override List<TemperatureEvent> readData(String directory, double startTime); }
CpuTemperatureReaderImpl extends PeripheralBase implements ICpuTemperatureReader { @Override public List<TemperatureEvent> readData(String directory, double startTime) { List<TemperatureEvent> temperatureEvents = new ArrayList<TemperatureEvent>(); String filePath = directory + Util.FILE_SEPARATOR + TraceDataConst.FileName.TEMPERATURE_FILE; if (!filereader.fileExist(filePath)) { return temperatureEvents; } String[] contents = null; try { contents = filereader.readAllLine(filePath); } catch (IOException e) { LOGGER.error("failed to read user event file: " + filePath); } if(contents != null && contents.length > 0){ for (String contentBuf : contents) { if (contentBuf.trim().isEmpty()) { continue; } String splitContents[] = contentBuf.split(" "); if (splitContents.length <= 1) { LOGGER.warn("Found invalid user event entry: " + contentBuf); continue; } double timeStamp = Double.parseDouble(splitContents[0]); if (timeStamp > 1.0e9) { timeStamp = Util.normalizeTime(timeStamp, startTime); } int temperatureC = 0; int temperatureF = 0; if (splitContents.length > 1 && splitContents[0].length() > 0) { temperatureC = Integer.parseInt(splitContents[1]); if (temperatureC != 0) { if (splitContents[1].length() > 2) { temperatureC = temperatureC / (int) Math.pow(10, splitContents[1].length() - 2); } temperatureF = (((temperatureC * 9) / 5) + 32); temperatureEvents.add(new TemperatureEvent(timeStamp, temperatureC, temperatureF)); } } } } return temperatureEvents; }  @Override List<TemperatureEvent> readData(String directory, double startTime);  }