@Test public void testExportGlucoseRead() throws Exception { XmlDataExporter xmlDataExporter = new XmlDataExporter(this.bloodShepherdProperties); List<InsulinInjection> injections = Collections.emptyList(); List<FoodEvent> foods = Collections.emptyList(); List<ExerciseSession> exerciseSessions = Collections.emptyList(); xmlDataExporter.exportData(new SyncData(Arrays.asList(new GlucoseRead(Instant.EPOCH, LocalDateTime.of(2013, 10, 10, 12, 00), 83f, GlucoseRead.Unit.MG_PER_DL)), injections, foods, exerciseSessions, new DeviceInfo("serialNumber", "hId", "hRv"), Instant.now())); }
@Override public void exportData(SyncData syncData) { String outputPath = properties.getProperty(OUTPUT_PATH); checkNotNull(outputPath, "Missing %s in properties", OUTPUT_PATH); File outputDirectory = new File(outputPath); checkState(outputDirectory.exists(), "Invalid destination: %s doesn't exist", outputPath); checkState(outputDirectory.isDirectory(), "Invalid destination: %s is not a directory", outputPath); XmlMapper xmlMapper = new XmlMapper(); ObjectWriter objectWriter = xmlMapper.writerWithDefaultPrettyPrinter(); Patient patient = new Patient(); patient.SerialNumber = syncData.getDeviceInfo().getSerialNumber(); sort(syncData.getGlucoseReads()); patient.Glucose = newArrayList(Collections2.transform(syncData.getGlucoseReads(), GLUCOSE_READ_TO_TIMESTAMPED_VALUE)); List<EventMarker> eventMarkers = newArrayList( Collections2.transform(syncData.getExerciseSessions(), EXERCISE_SESSION_TO_EVENT_MARKER)); eventMarkers.addAll(Collections2.transform(syncData.getFoodEvents(), FOOD_EVENT_TO_EVENT_MARKER)); eventMarkers.addAll(Collections2.transform(syncData.getInsulinInjections(), INSULIN_INJECTION_TO_EVENT_MARKER)); sort(eventMarkers); patient.Event = eventMarkers; try { OutputStream outputStream = getOutputStream(outputDirectory, syncData); objectWriter.writeValue(outputStream, patient); outputStream.close(); } catch (IOException e) { throw Throwables.propagate(e); } }
XmlDataExporter implements DataExporter { @Override public void exportData(SyncData syncData) { String outputPath = properties.getProperty(OUTPUT_PATH); checkNotNull(outputPath, "Missing %s in properties", OUTPUT_PATH); File outputDirectory = new File(outputPath); checkState(outputDirectory.exists(), "Invalid destination: %s doesn't exist", outputPath); checkState(outputDirectory.isDirectory(), "Invalid destination: %s is not a directory", outputPath); XmlMapper xmlMapper = new XmlMapper(); ObjectWriter objectWriter = xmlMapper.writerWithDefaultPrettyPrinter(); Patient patient = new Patient(); patient.SerialNumber = syncData.getDeviceInfo().getSerialNumber(); sort(syncData.getGlucoseReads()); patient.Glucose = newArrayList(Collections2.transform(syncData.getGlucoseReads(), GLUCOSE_READ_TO_TIMESTAMPED_VALUE)); List<EventMarker> eventMarkers = newArrayList( Collections2.transform(syncData.getExerciseSessions(), EXERCISE_SESSION_TO_EVENT_MARKER)); eventMarkers.addAll(Collections2.transform(syncData.getFoodEvents(), FOOD_EVENT_TO_EVENT_MARKER)); eventMarkers.addAll(Collections2.transform(syncData.getInsulinInjections(), INSULIN_INJECTION_TO_EVENT_MARKER)); sort(eventMarkers); patient.Event = eventMarkers; try { OutputStream outputStream = getOutputStream(outputDirectory, syncData); objectWriter.writeValue(outputStream, patient); outputStream.close(); } catch (IOException e) { throw Throwables.propagate(e); } } }
XmlDataExporter implements DataExporter { @Override public void exportData(SyncData syncData) { String outputPath = properties.getProperty(OUTPUT_PATH); checkNotNull(outputPath, "Missing %s in properties", OUTPUT_PATH); File outputDirectory = new File(outputPath); checkState(outputDirectory.exists(), "Invalid destination: %s doesn't exist", outputPath); checkState(outputDirectory.isDirectory(), "Invalid destination: %s is not a directory", outputPath); XmlMapper xmlMapper = new XmlMapper(); ObjectWriter objectWriter = xmlMapper.writerWithDefaultPrettyPrinter(); Patient patient = new Patient(); patient.SerialNumber = syncData.getDeviceInfo().getSerialNumber(); sort(syncData.getGlucoseReads()); patient.Glucose = newArrayList(Collections2.transform(syncData.getGlucoseReads(), GLUCOSE_READ_TO_TIMESTAMPED_VALUE)); List<EventMarker> eventMarkers = newArrayList( Collections2.transform(syncData.getExerciseSessions(), EXERCISE_SESSION_TO_EVENT_MARKER)); eventMarkers.addAll(Collections2.transform(syncData.getFoodEvents(), FOOD_EVENT_TO_EVENT_MARKER)); eventMarkers.addAll(Collections2.transform(syncData.getInsulinInjections(), INSULIN_INJECTION_TO_EVENT_MARKER)); sort(eventMarkers); patient.Event = eventMarkers; try { OutputStream outputStream = getOutputStream(outputDirectory, syncData); objectWriter.writeValue(outputStream, patient); outputStream.close(); } catch (IOException e) { throw Throwables.propagate(e); } } @Inject  XmlDataExporter(BloodShepherdProperties properties); }
XmlDataExporter implements DataExporter { @Override public void exportData(SyncData syncData) { String outputPath = properties.getProperty(OUTPUT_PATH); checkNotNull(outputPath, "Missing %s in properties", OUTPUT_PATH); File outputDirectory = new File(outputPath); checkState(outputDirectory.exists(), "Invalid destination: %s doesn't exist", outputPath); checkState(outputDirectory.isDirectory(), "Invalid destination: %s is not a directory", outputPath); XmlMapper xmlMapper = new XmlMapper(); ObjectWriter objectWriter = xmlMapper.writerWithDefaultPrettyPrinter(); Patient patient = new Patient(); patient.SerialNumber = syncData.getDeviceInfo().getSerialNumber(); sort(syncData.getGlucoseReads()); patient.Glucose = newArrayList(Collections2.transform(syncData.getGlucoseReads(), GLUCOSE_READ_TO_TIMESTAMPED_VALUE)); List<EventMarker> eventMarkers = newArrayList( Collections2.transform(syncData.getExerciseSessions(), EXERCISE_SESSION_TO_EVENT_MARKER)); eventMarkers.addAll(Collections2.transform(syncData.getFoodEvents(), FOOD_EVENT_TO_EVENT_MARKER)); eventMarkers.addAll(Collections2.transform(syncData.getInsulinInjections(), INSULIN_INJECTION_TO_EVENT_MARKER)); sort(eventMarkers); patient.Event = eventMarkers; try { OutputStream outputStream = getOutputStream(outputDirectory, syncData); objectWriter.writeValue(outputStream, patient); outputStream.close(); } catch (IOException e) { throw Throwables.propagate(e); } } @Inject  XmlDataExporter(BloodShepherdProperties properties); @Override void exportData(SyncData syncData); }
XmlDataExporter implements DataExporter { @Override public void exportData(SyncData syncData) { String outputPath = properties.getProperty(OUTPUT_PATH); checkNotNull(outputPath, "Missing %s in properties", OUTPUT_PATH); File outputDirectory = new File(outputPath); checkState(outputDirectory.exists(), "Invalid destination: %s doesn't exist", outputPath); checkState(outputDirectory.isDirectory(), "Invalid destination: %s is not a directory", outputPath); XmlMapper xmlMapper = new XmlMapper(); ObjectWriter objectWriter = xmlMapper.writerWithDefaultPrettyPrinter(); Patient patient = new Patient(); patient.SerialNumber = syncData.getDeviceInfo().getSerialNumber(); sort(syncData.getGlucoseReads()); patient.Glucose = newArrayList(Collections2.transform(syncData.getGlucoseReads(), GLUCOSE_READ_TO_TIMESTAMPED_VALUE)); List<EventMarker> eventMarkers = newArrayList( Collections2.transform(syncData.getExerciseSessions(), EXERCISE_SESSION_TO_EVENT_MARKER)); eventMarkers.addAll(Collections2.transform(syncData.getFoodEvents(), FOOD_EVENT_TO_EVENT_MARKER)); eventMarkers.addAll(Collections2.transform(syncData.getInsulinInjections(), INSULIN_INJECTION_TO_EVENT_MARKER)); sort(eventMarkers); patient.Event = eventMarkers; try { OutputStream outputStream = getOutputStream(outputDirectory, syncData); objectWriter.writeValue(outputStream, patient); outputStream.close(); } catch (IOException e) { throw Throwables.propagate(e); } } @Inject  XmlDataExporter(BloodShepherdProperties properties); @Override void exportData(SyncData syncData);  }