@Test
public void testSiteCorrectionsOneStationEvent() throws Exception {

    //Testing a fix for a NPE caused when the following three statements are true.
    //1) You have a station that saw no calibration events ("InvalidEventStation")
    //2) That station shares a non-calibration event with a station that DID see a calibration event ("TEST" in this case)
    //3) The station with no calibration event ALSO has an event that no other station saw ("3456").
    Waveform w1 = createWaveform();
    Waveform w2 = createWaveform();
    w2.getEvent().setEventId("2345");
    Waveform w3 = createWaveform();
    w3.getEvent().setEventId("2345");
    w3.getStream().getStation().setStationName("InvalidEventStation");
    Waveform w4 = createWaveform();
    w4.getEvent().setEventId("3456");
    w4.getStream().getStation().setStationName("InvalidEventStation");
    SpectraMeasurement sm = new SpectraMeasurement();
    sm.setWaveform(w1);
    sm.setPathCorrected(1d);
    sm.setRawAtMeasurementTime(1d);
    sm.setRawAtStart(1d);
    SpectraMeasurement sm2 = new SpectraMeasurement();
    sm2.setWaveform(w2);
    sm2.setPathCorrected(1d);
    sm2.setRawAtMeasurementTime(1d);
    sm2.setRawAtStart(1d);
    SpectraMeasurement sm3 = new SpectraMeasurement();
    sm3.setWaveform(w3);
    sm3.setPathCorrected(1d);
    sm3.setRawAtMeasurementTime(1d);
    sm3.setRawAtStart(1d);
    SpectraMeasurement sm4 = new SpectraMeasurement();
    sm4.setWaveform(w4);
    sm4.setPathCorrected(1d);
    sm4.setRawAtMeasurementTime(1d);
    sm4.setRawAtStart(1d);
    List<SpectraMeasurement> spectra = new ArrayList<>(1);
    spectra.add(sm);
    spectra.add(sm2);
    spectra.add(sm3);
    spectra.add(sm4);
    Map<FrequencyBand, List<SpectraMeasurement>> spectraMap = new HashMap<>();
    spectraMap.put(new FrequencyBand(0d, 1d), spectra);
    Map<PICK_TYPES, MdacParametersPS> mdacPsMap = new HashMap<>();
    mdacPsMap.put(PICK_TYPES.LG, new MdacParametersPS());
    Map<FrequencyBand, SharedFrequencyBandParameters> frequencyBandParameterMap = new HashMap<>();
    frequencyBandParameterMap.put(new FrequencyBand(0d, 1d), new SharedFrequencyBandParameters());
    Map<String, List<ReferenceMwParameters>> refEventMap = new HashMap<>();
    refEventMap.put("1234", Collections.singletonList(new ReferenceMwParameters().setRefMw(5d).setEventId("1234")));
    Map<FrequencyBand, Map<Station, SiteFrequencyBandParameters>> results = siteCalibrationServiceImpl.measureSiteCorrections(
            spectraMap,
                new MdacParametersFI(),
                mdacPsMap,
                refEventMap,
                frequencyBandParameterMap,
                PICK_TYPES.LG);
    assertEquals(1, results.size(), "Should have one frequency band");
    Map<Station, SiteFrequencyBandParameters> stations = results.values().stream().findFirst().get();
    assertEquals(2, stations.size(), "Should have two stations");
    assertTrue(stations.values().stream().allMatch(sfb -> sfb.getSiteTerm() == 6.0), "Both stations should have the same site term");
}