Skip to content

Commit

Permalink
Fix publication repository tests with workaround (ZFIN#1215)
Browse files Browse the repository at this point in the history
  • Loading branch information
rtaylorzfin authored Nov 12, 2024
1 parent a085156 commit ca6b5eb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,19 @@ public DashboardPublicationBean toDashboardPublicationBean(PublicationTrackingHi

public void setRelatedLinks(DashboardPublicationList result) {
List<String> ids = result.getPublications().stream().map(DashboardPublicationBean::getZdbId).toList();
Map<String, List<String>> relatedLinks = relatedDataService.getRelatedLinksForPubIDs(ids);
Map<String, List<String>> relatedLinks = getRelatedDataService().getRelatedLinksForPubIDs(ids);

for (DashboardPublicationBean bean : result.getPublications()) {
bean.setRelatedLinks(relatedLinks.get(bean.getZdbId()));
}
}

private RelatedDataService getRelatedDataService() {
//TODO: This method shouldn't be necessary, but for some reason
// tests like PublicationRepositoryTest don't autowire multiple levels
if (relatedDataService == null) {
relatedDataService = new RelatedDataService();
}
return relatedDataService;
}
}
11 changes: 10 additions & 1 deletion source/org/zfin/search/service/RelatedDataService.java
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ public List<String> getXrefLinks(SearchResult result) {

public List<String> getXrefsLinks(String id, String category, String type) {
List<String> links = new ArrayList<>();
QueryResponse response = solrService.getRelatedDataResponse(id);
QueryResponse response = getSolrService().getRelatedDataResponse(id);

FacetField facetField = response.getFacetField("category");

Expand Down Expand Up @@ -603,4 +603,13 @@ public static String lookup(String resultCategory, String resultType, String rel
}
}

private SolrService getSolrService() {
//TODO: This method shouldn't be necessary, but for some reason
// tests like PublicationRepositoryTest don't autowire multiple levels
if (solrService == null) {
solrService = new SolrService();
}
return solrService;
}

}

0 comments on commit ca6b5eb

Please sign in to comment.