BoreholeImpl extends UrlMarker implements Borehole, Renderable { public void addSample(BoreholeSample sample) { if (sample == null) { return; } if (sample.getBorehole() != this) { throw new IllegalArgumentException("Sample added from wrong borehole: " + sample.getBorehole() == null ? "null" : sample.getBorehole().toString()); } synchronized (sampleLock) { samples.add(sample); } } BoreholeImpl(BoreholeLayer layer, Position position, MarkerAttributes attrs); @Override List<BoreholeSample> getSamples(); void setSamples(List<BoreholeSample> samples); void addSample(BoreholeSample sample); void loadComplete(); @Override String getText(); @Override String getLink(); @Override void render(DrawContext dc);  }
@Test( expected = IllegalArgumentException.class ) public void testAddSampleFromWrongBorehole() { classUnderTest.addSample(createSampleForBoreHole(mockContext.mock(Borehole.class), 0, 15, Color.RED)); }