### Question:
AuthorityService implements IAuthorityService { @Override public IAuthorityEntry importAuthority(String uri) throws URISyntaxException, AuthorityServiceConnectionException { for (AuthorityImporter importer : importers) { if (importer.isResponsible(uri)) { IImportedAuthority importedAuthority = importer.retrieveAuthorityData(uri); if (importedAuthority == null) { return null; } IAuthorityEntry entry = new AuthorityEntry(); entry.setName(importedAuthority.getName()); entry.setUri(importedAuthority.getUri()); entry.setImporterId(importer.getId()); return entry; } } return null; }  @Override void register(AuthorityImporter importer); @Override IAuthorityEntry importAuthority(String uri); @Override IAuthorityEntry find(String id); @Override List<IAuthorityEntry> findByUri(IUser user, String uri); @Override Set<IAuthorityEntry> findByUriInDataset(String uri, String citationGroupId); @Override boolean deleteAuthority(String id); @Override List<IAuthorityEntry> getAll(IUser user); @Override IAuthorityEntry create(IAuthorityEntry entry, IUser user); @Override IAuthorityEntry save(IAuthorityEntry entry);  }### Answer:
@Test public void test_importAuthority_success() throws URISyntaxException, AuthorityServiceConnectionException { String testUri = "http: String importerId = "testId"; Mockito.when(testImporter.isResponsible(testUri)).thenReturn(true); Mockito.when(testImporter.getId()).thenReturn(importerId); String name = "Name"; IImportedAuthority authorityData = new ImportedAuthority(); authorityData.setName(name); authorityData.setUri(testUri); Mockito.when(testImporter.retrieveAuthorityData(testUri)).thenReturn(authorityData); IAuthorityEntry actualEntry = managerToTest.importAuthority(testUri); Assert.assertEquals(name, actualEntry.getName()); Assert.assertEquals(testUri, actualEntry.getUri()); Assert.assertEquals(importerId, actualEntry.getImporterId()); }
@Test public void test_importAuthority_failure() throws URISyntaxException, AuthorityServiceConnectionException { String testUri = "http: Mockito.when(testImporter.isResponsible(testUri)).thenReturn(false); IAuthorityEntry actualEntry = managerToTest.importAuthority(testUri); Assert.assertNull(actualEntry); }