SourceService implements ISourceService { @Override public Source getSource(int sourceId) { if (sourceId < 0) { throw new IllegalArgumentException("Source identifier cannot be negative"); } return getSourceManager().get(sourceId); }  @Override int count(); @Override Source createSource(String url, String username, String password, Integer maxDownloads); @Override Source getSource(int sourceId); @Override Source getSource(SynchronizerSource synchronizerSource); @Override List<Source> getSource(List<SynchronizerSource> synchronizerSources); @Override boolean updateSource(Source source); @Override boolean deleteSource(Source source); @Override List<Source> list(); @Override List<Source> sortSources(List<Source> sources); @Override Source getBestSource(List<Source> sources);  }
@Test public void get() { int sourceId = 1; String expectedUrl = "https: String expectedUsername = "dhus1_username"; String expectedPassword = "dhus1_password"; Source source = service.getSource(sourceId); Assert.assertNotNull(source); Assert.assertEquals(source.getId(), sourceId); Assert.assertEquals(source.getUrl(), expectedUrl); Assert.assertEquals(source.getUsername(), expectedUsername); Assert.assertEquals(source.getPassword(), expectedPassword); sourceId = 512; source = service.getSource(sourceId); Assert.assertNull(source); sourceId = 1; SynchronizerSource synchronizerSource = new SynchronizerSource(); synchronizerSource.setSourceId(sourceId); source = service.getSource(synchronizerSource); Assert.assertNotNull(source); Assert.assertEquals(source.getId(), synchronizerSource.getSourceId()); Assert.assertEquals(source.getUrl(), expectedUrl); Assert.assertEquals(source.getUsername(), expectedUsername); Assert.assertEquals(source.getPassword(), expectedPassword); sourceId = 123; synchronizerSource.setSourceId(sourceId); source = service.getSource(synchronizerSource); Assert.assertNull(source); List<SynchronizerSource> synchronizerSources = new ArrayList<>(3); List<Source> sources = service.getSource(synchronizerSources); Assert.assertNotNull(sources); Assert.assertTrue(sources.isEmpty()); sourceId = 3; synchronizerSource.setSourceId(sourceId); SynchronizerSource synchronizerSourceFake = new SynchronizerSource(); synchronizerSourceFake.setSourceId(99); synchronizerSources.add(synchronizerSource); synchronizerSources.add(synchronizerSourceFake); sources = service.getSource(synchronizerSources); Assert.assertNotNull(sources); Assert.assertEquals(sources.size(), 1); source = sources.get(0); Assert.assertNotNull(source); Assert.assertEquals(source.getId(), sourceId); }