### Question:
MavenCentralLibraryService implements ExternalLibraryService { @Override public LibraryDTO getLibrary(String groupId, String artifactId, String version) { return getMavenLibrary(groupId, artifactId, version); } @Inject  MavenCentralLibraryService(@Named(ServiceConsts.MAVEN_SEARCH_API) RESTService restClient); @Override LibraryDTO getLibrary(String groupId, String artifactId, String version);  }### Answer:
@Test public void getLibraryId() { when(client.get(any(URI.class), any())).thenReturn(getMavenResponse()); final LibraryDTO libDTO = mavenCentralLibraryService.getLibrary("groupId", "artifactId", "version"); assertNotNull(libDTO); assertEquals("groupId:artifactId", libDTO.getName()); assertEquals("version", libDTO.getVersion()); verify(client).get(refEq(URI.create("/solrsearch/select?q=a:%22artifactId%22+AND+g" + ":%22groupId%22+AND+v:%22version%22+AND+(p:%22jar%22%20OR%20p:%22bundle%22)" + "&rows=20&wt=json&core=gav&p=jar")), eq(MavenSearchArtifactResponse.class)); }
@Test public void getLibraryIdWithException() { when(client.get(any(URI.class), any())).thenThrow(new DlabException("Can not get artifact info from maven " + "central due to: Exception")); expectedException.expect(DlabException.class); expectedException.expectMessage("Can not get artifact info from maven central due to: Exception"); mavenCentralLibraryService.getLibrary("groupId", "artifactId", "version"); }