@Test public void readData() throws IOException { Mockito.when(filereader.fileExist(Mockito.anyString())).thenReturn(true); Mockito.when(filereader.readAllLine(Mockito.anyString())).thenReturn(new String[] { "1414108436 21" ,"1414108436 22" ,"1414108463 23" ,"1414108464 24" ,"1414108466 25" ,"1414108466 26" ,"1414108473 27" ,"1414108473 28" ,"1414108473 29" ,"1414108473 30" ,"1414108473 31" ,"1414108473 32" ,"1414108473 33" ,"1414108473 34" , }); List<TemperatureEvent> listTemperatureEvent = traceDataReader.readData(traceFolder, 0.0); assertEquals(14.0, listTemperatureEvent.size(), 0); assertEquals( 21, listTemperatureEvent.get(0).getcelciusTemperature()); assertEquals( 22, listTemperatureEvent.get(1).getcelciusTemperature()); assertEquals( 23, listTemperatureEvent.get(2).getcelciusTemperature()); assertEquals( 24, listTemperatureEvent.get(3).getcelciusTemperature()); assertEquals( 25, listTemperatureEvent.get(4).getcelciusTemperature()); assertEquals( 26, listTemperatureEvent.get(5).getcelciusTemperature()); assertEquals( 27, listTemperatureEvent.get(6).getcelciusTemperature()); assertEquals( 28, listTemperatureEvent.get(7).getcelciusTemperature()); assertEquals( 29, listTemperatureEvent.get(8).getcelciusTemperature()); assertEquals( 30, listTemperatureEvent.get(9).getcelciusTemperature()); assertEquals( 31, listTemperatureEvent.get(10).getcelciusTemperature()); assertEquals( 32, listTemperatureEvent.get(11).getcelciusTemperature()); assertEquals( 33, listTemperatureEvent.get(12).getcelciusTemperature()); assertEquals( 34, listTemperatureEvent.get(13).getcelciusTemperature()); assertEquals(1414108436, listTemperatureEvent.get(0).getTimeRecorded(), 0); assertEquals(1414108436, listTemperatureEvent.get(1).getTimeRecorded(), 0); assertEquals(1414108463, listTemperatureEvent.get(2).getTimeRecorded(), 0); assertEquals(1414108464, listTemperatureEvent.get(3).getTimeRecorded(), 0); assertEquals(1414108466, listTemperatureEvent.get(4).getTimeRecorded(), 0); assertEquals(1414108466, listTemperatureEvent.get(5).getTimeRecorded(), 0); assertEquals(1414108473, listTemperatureEvent.get(6).getTimeRecorded(), 0); assertEquals(1414108473, listTemperatureEvent.get(7).getTimeRecorded(), 0); assertEquals(1414108473, listTemperatureEvent.get(8).getTimeRecorded(), 0); assertEquals(1414108473, listTemperatureEvent.get(9).getTimeRecorded(), 0); assertEquals(1414108473, listTemperatureEvent.get(10).getTimeRecorded(), 0); assertEquals(1414108473, listTemperatureEvent.get(11).getTimeRecorded(), 0); assertEquals(1414108473, listTemperatureEvent.get(12).getTimeRecorded(), 0); assertEquals(1414108473, listTemperatureEvent.get(13).getTimeRecorded(), 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);  }