@Test public void GeneratesCSVWithHeaderAndOneLine_WhenOneReading() throws IOException { final Date created = new Date(); List<GlucoseReading> values = new ArrayList<>(); values.add(new GlucoseReading(80, "type", created, "notes")); ReadingToCSV r = new ReadingToCSV(RuntimeEnvironment.application, Constants.Units.MG_DL); r.createCSVFile(values, osw); assertFileContentEqualsToString(outputStream.toString(), headerAsString(), valuesAsString(values.get(0), Constants.Units.MG_DL)); }
public void createCSVFile(@NonNull List<GlucoseReading> readings, @NonNull OutputStreamWriter osw) throws IOException { Resources resources = context.getResources(); writeLine(osw, resources.getString(R.string.dialog_add_date), resources.getString(R.string.dialog_add_time), resources.getString(R.string.dialog_add_concentration), resources.getString(R.string.helloactivity_spinner_preferred_glucose_unit), resources.getString(R.string.dialog_add_measured), resources.getString(R.string.dialog_add_notes) ); if (Constants.Units.MG_DL.equals(userMeasurements)) { for (GlucoseReading reading : readings) { writeLine(osw, dateTool.convertRawDate(reading.getCreated()), dateTool.convertRawTime(reading.getCreated()), formatter.format(reading.getReading()), Constants.Units.MG_DL, valueOrEmptyString(reading.getReading_type()), valueOrEmptyString(reading.getNotes()) ); } } else { for (GlucoseReading reading : readings) { writeLine(osw, this.dateTool.convertRawDate(reading.getCreated()), this.dateTool.convertRawTime(reading.getCreated()), formatter.format(GlucosioConverter.glucoseToMmolL(reading.getReading())), Constants.Units.MMOL_L, valueOrEmptyString(reading.getReading_type()), valueOrEmptyString(reading.getNotes()) ); } } osw.flush(); Log.i("Glucosio", "Done exporting readings"); }
ReadingToCSV { public void createCSVFile(@NonNull List<GlucoseReading> readings, @NonNull OutputStreamWriter osw) throws IOException { Resources resources = context.getResources(); writeLine(osw, resources.getString(R.string.dialog_add_date), resources.getString(R.string.dialog_add_time), resources.getString(R.string.dialog_add_concentration), resources.getString(R.string.helloactivity_spinner_preferred_glucose_unit), resources.getString(R.string.dialog_add_measured), resources.getString(R.string.dialog_add_notes) ); if (Constants.Units.MG_DL.equals(userMeasurements)) { for (GlucoseReading reading : readings) { writeLine(osw, dateTool.convertRawDate(reading.getCreated()), dateTool.convertRawTime(reading.getCreated()), formatter.format(reading.getReading()), Constants.Units.MG_DL, valueOrEmptyString(reading.getReading_type()), valueOrEmptyString(reading.getNotes()) ); } } else { for (GlucoseReading reading : readings) { writeLine(osw, this.dateTool.convertRawDate(reading.getCreated()), this.dateTool.convertRawTime(reading.getCreated()), formatter.format(GlucosioConverter.glucoseToMmolL(reading.getReading())), Constants.Units.MMOL_L, valueOrEmptyString(reading.getReading_type()), valueOrEmptyString(reading.getNotes()) ); } } osw.flush(); Log.i("Glucosio", "Done exporting readings"); } }
ReadingToCSV { public void createCSVFile(@NonNull List<GlucoseReading> readings, @NonNull OutputStreamWriter osw) throws IOException { Resources resources = context.getResources(); writeLine(osw, resources.getString(R.string.dialog_add_date), resources.getString(R.string.dialog_add_time), resources.getString(R.string.dialog_add_concentration), resources.getString(R.string.helloactivity_spinner_preferred_glucose_unit), resources.getString(R.string.dialog_add_measured), resources.getString(R.string.dialog_add_notes) ); if (Constants.Units.MG_DL.equals(userMeasurements)) { for (GlucoseReading reading : readings) { writeLine(osw, dateTool.convertRawDate(reading.getCreated()), dateTool.convertRawTime(reading.getCreated()), formatter.format(reading.getReading()), Constants.Units.MG_DL, valueOrEmptyString(reading.getReading_type()), valueOrEmptyString(reading.getNotes()) ); } } else { for (GlucoseReading reading : readings) { writeLine(osw, this.dateTool.convertRawDate(reading.getCreated()), this.dateTool.convertRawTime(reading.getCreated()), formatter.format(GlucosioConverter.glucoseToMmolL(reading.getReading())), Constants.Units.MMOL_L, valueOrEmptyString(reading.getReading_type()), valueOrEmptyString(reading.getNotes()) ); } } osw.flush(); Log.i("Glucosio", "Done exporting readings"); } ReadingToCSV(@NonNull Context context, @NonNull String userMeasurements); }
ReadingToCSV { public void createCSVFile(@NonNull List<GlucoseReading> readings, @NonNull OutputStreamWriter osw) throws IOException { Resources resources = context.getResources(); writeLine(osw, resources.getString(R.string.dialog_add_date), resources.getString(R.string.dialog_add_time), resources.getString(R.string.dialog_add_concentration), resources.getString(R.string.helloactivity_spinner_preferred_glucose_unit), resources.getString(R.string.dialog_add_measured), resources.getString(R.string.dialog_add_notes) ); if (Constants.Units.MG_DL.equals(userMeasurements)) { for (GlucoseReading reading : readings) { writeLine(osw, dateTool.convertRawDate(reading.getCreated()), dateTool.convertRawTime(reading.getCreated()), formatter.format(reading.getReading()), Constants.Units.MG_DL, valueOrEmptyString(reading.getReading_type()), valueOrEmptyString(reading.getNotes()) ); } } else { for (GlucoseReading reading : readings) { writeLine(osw, this.dateTool.convertRawDate(reading.getCreated()), this.dateTool.convertRawTime(reading.getCreated()), formatter.format(GlucosioConverter.glucoseToMmolL(reading.getReading())), Constants.Units.MMOL_L, valueOrEmptyString(reading.getReading_type()), valueOrEmptyString(reading.getNotes()) ); } } osw.flush(); Log.i("Glucosio", "Done exporting readings"); } ReadingToCSV(@NonNull Context context, @NonNull String userMeasurements); void createCSVFile(@NonNull List<GlucoseReading> readings, @NonNull OutputStreamWriter osw); }
ReadingToCSV { public void createCSVFile(@NonNull List<GlucoseReading> readings, @NonNull OutputStreamWriter osw) throws IOException { Resources resources = context.getResources(); writeLine(osw, resources.getString(R.string.dialog_add_date), resources.getString(R.string.dialog_add_time), resources.getString(R.string.dialog_add_concentration), resources.getString(R.string.helloactivity_spinner_preferred_glucose_unit), resources.getString(R.string.dialog_add_measured), resources.getString(R.string.dialog_add_notes) ); if (Constants.Units.MG_DL.equals(userMeasurements)) { for (GlucoseReading reading : readings) { writeLine(osw, dateTool.convertRawDate(reading.getCreated()), dateTool.convertRawTime(reading.getCreated()), formatter.format(reading.getReading()), Constants.Units.MG_DL, valueOrEmptyString(reading.getReading_type()), valueOrEmptyString(reading.getNotes()) ); } } else { for (GlucoseReading reading : readings) { writeLine(osw, this.dateTool.convertRawDate(reading.getCreated()), this.dateTool.convertRawTime(reading.getCreated()), formatter.format(GlucosioConverter.glucoseToMmolL(reading.getReading())), Constants.Units.MMOL_L, valueOrEmptyString(reading.getReading_type()), valueOrEmptyString(reading.getNotes()) ); } } osw.flush(); Log.i("Glucosio", "Done exporting readings"); } ReadingToCSV(@NonNull Context context, @NonNull String userMeasurements); void createCSVFile(@NonNull List<GlucoseReading> readings, @NonNull OutputStreamWriter osw);  }