@Test public void testRemoveNonExistingProvider() { Service service = new Service(logger, "service1"); service.addProvider("provider1"); logger.reset(); Assert.assertFalse(service.removeProvider("provider2")); Assert.assertTrue(logger.records().isEmpty()); }
@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 public void testFromProviderNameListProviderAndWhiteSpace() { Service service = new Service(logger, "service1"); logger.reset(); service.fromProviderNamesList("#\n \t provider1\t\n"); Assert.assertEquals(1, logger.records().size()); Assert.assertEquals("provider1\n", service.toProviderNamesList()); }
@Test public void testFromProviderNameListProviderAndComment() { Service service = new Service(logger, "service1"); logger.reset(); service.fromProviderNamesList("provider1# the provider"); Assert.assertEquals(1, logger.records().size()); Assert.assertEquals("provider1\n", service.toProviderNamesList()); }
@Test public void testFromProviderNameListOnlyComment() { Service service = new Service(logger, "service1"); logger.reset(); service.fromProviderNamesList("#hello world"); Assert.assertTrue(logger.records().isEmpty()); Assert.assertEquals("", service.toProviderNamesList()); }
@Test public void testFromProviderNameListJustNewLine() { Service service = new Service(logger, "service1"); logger.reset(); service.fromProviderNamesList("\n"); Assert.assertTrue(logger.records().isEmpty()); Assert.assertEquals("", service.toProviderNamesList()); }
@Test public void testRemoveExistingProvider() { Service service = new Service(logger, "service1"); service.addProvider("provider1"); logger.reset(); Assert.assertTrue(service.removeProvider("provider1")); Assert.assertEquals(1, logger.records().size()); Assert.assertEquals("Removing provider1 from service1\n", logger.getFileContent()); }
@Test public void testFromProviderNameListMoreProviders() { Service service = new Service(logger, "service1"); logger.reset(); service.fromProviderNamesList("provider1\nprovider2\nprovider17\nprovider3"); Assert.assertEquals(4, logger.records().size()); Assert.assertEquals( "provider1\nprovider17\nprovider2\nprovider3\n", service.toProviderNamesList()); }
@Test public void testFromProviderNameListWhiteSpaceAndComments() { Service service = new Service(logger, "service1"); logger.reset(); service.fromProviderNamesList( "\n\n \n\t\n#hello world\n\n\t# comment\tmore comment\n # no comment\n"); Assert.assertTrue(logger.records().isEmpty()); Assert.assertEquals("", service.toProviderNamesList()); }
@Test public void testConstructorLogs() { new Service(logger, "service1"); Assert.assertEquals(1, logger.records().size()); Assert.assertEquals("Creating service1\n", logger.getFileContent()); }