### Question:
BaseUploader { public final boolean uploadCalRecords(List<CalibrationEntry> calRecords) { if (calRecords == null) { return true; } boolean output = true; if (getPreferences().isCalibrationUploadEnabled()) { for (CalibrationEntry calRecord : calRecords) { try { output &= doUpload(calRecord); } catch (IOException e) { log.error("Error uploading calibration 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 testUploadCalRecords_Null() { preferences.setCalibrationUploadEnabled(true); try { mockUploader.uploadCalRecords(null); } catch (NullPointerException e) { fail("Shouldn't get a NPE"); } }
@Test public void testUploadCalRecords_Zero() { preferences.setCalibrationUploadEnabled(true); mockUploader.uploadCalRecords(new ArrayList<CalibrationEntry>()); assertThat(mockUploader.calRecords, is(empty())); }
@Test public void testUploadCalRecords_One() { preferences.setCalibrationUploadEnabled(true); List<CalibrationEntry> list = null; try { list = Lists.newArrayList(mockCalRecord()); } catch (InvalidRecordLengthException e) { fail("Shouldn't get an exception"); } mockUploader.uploadCalRecords(list); assertThat(mockUploader.calRecords, hasSize(1)); }
@Test public void testUploadCalRecords_Many() { preferences.setCalibrationUploadEnabled(true); List<CalibrationEntry> list = null; try { list = Lists.newArrayList( mockCalRecord(), mockCalRecord(), mockCalRecord()); } catch (InvalidRecordLengthException e) { fail("Shouldn't get an exception"); } mockUploader.uploadCalRecords(list); assertThat(mockUploader.calRecords, hasSize(3)); }
@Test public void testUploadCalRecords_Exception() { preferences.setCalibrationUploadEnabled(true); try { exceptionUploader.uploadCalRecords(Lists.newArrayList(mockCalRecord())); } catch (Exception e) { fail("Shouldn't throw an exception."); } }