### Question:
BaseUploader { public final boolean uploadMeterRecords(List<MeterEntry> meterRecords) { if (meterRecords == null) { return true; } boolean output = true; for (MeterEntry meterRecord : meterRecords) { try { output &= doUpload(meterRecord); } catch (IOException e) { log.error("Error uploading meter record.", e); output = false; } } return output; } BaseUploader(NightscoutPreferences preferences); final boolean uploadGlucoseDataSets(List<GlucoseDataSet> glucoseDataSets); final boolean uploadMeterRecords(List<MeterEntry> meterRecords); final boolean uploadCalRecords(List<CalibrationEntry> calRecords); final boolean uploadDeviceStatus(AbstractUploaderDevice deviceStatus); boolean uploadRecords(List<GlucoseDataSet> glucoseDataSets, List<MeterEntry> meterRecords, List<CalibrationEntry> calRecords, AbstractUploaderDevice deviceStatus);  }### Answer:
@Test public void testUploadMeterRecords_Null() { try { mockUploader.uploadMeterRecords(null); } catch (NullPointerException e) { fail("Shouldn't get a NPE"); } }
@Test public void testUploadMeterRecords_Zero() { mockUploader.uploadMeterRecords(new ArrayList<MeterEntry>()); assertThat(mockUploader.meterRecords, is(empty())); }
@Test public void testUploadMeterRecords_One() throws Exception { List<MeterEntry> list = Lists.newArrayList(mockMeterRecord()); mockUploader.uploadMeterRecords(list); assertThat(mockUploader.meterRecords, hasSize(1)); }
@Test public void testUploadMeterRecords_Many() throws Exception { List<MeterEntry> list = Lists.newArrayList( mockMeterRecord(), mockMeterRecord(), mockMeterRecord()); mockUploader.uploadMeterRecords(list); assertThat(mockUploader.meterRecords, hasSize(3)); }
@Test public void testUploadMeterRecords_Exception() { try { exceptionUploader.uploadMeterRecords(Lists.newArrayList(mockMeterRecord())); } catch (Exception e) { fail("Shouldn't throw an exception."); } }