### Question:
AbstractCompilerAdder { protected void addDependency(final File dependency) { if (dependency == null) throw new NullPointerException("Dependent file cannot be a null reference."); dependencies.add(dependency); }    }### Answer:
@Test public void testAddDependency() { final File dependency = mock(File.class); adder.addDependency(dependency); assertThat(adder.getDependencies()).containsOnly(dependency); }
@Test public void testAddDependencyNullFile() { NullPointerException e = assertThrows(NullPointerException.class, () -> { adder.addDependency(null); }); assertThat(e.getMessage()).isEqualTo("Dependent file cannot be a null reference."); }