Service { void addProvider(String provider) { if (provider == null) { throw new NullPointerException("provider"); } logger.note(LogLocation.LOG_FILE, "Adding " + provider + " to " + serviceName); providers.add(provider); } Service(Logger logger, String name); @Override String toString();  }
@Test public void testAddProvider() { Service service = new Service(logger, "service1"); logger.reset(); service.addProvider("provider1"); Assert.assertEquals(1, logger.records().size()); Assert.assertEquals("Adding provider1 to service1\n", logger.getFileContent()); }
@Test(expected=NullPointerException.class) public void testAddNullProvider() { Service service = new Service(logger, "service1"); service.addProvider(null); }