use of org.nextprot.api.web.seo.domain.SeoTags in project nextprot-api by calipho-sib.
the class SeoServiceIntegrationTest method testSeoTagsForNews.
@Test
public void testSeoTagsForNews() throws Exception {
SeoTags tags;
// get default news (most recent one)
tags = seoTagsService.getNewsSeoTags("/news");
Assert.assertTrue(tags != null);
// get default news (most recent one)
tags = seoTagsService.getNewsSeoTags("/news/");
Assert.assertTrue(tags != null);
// get old specific news
tags = seoTagsService.getNewsSeoTags("/news/the-nextprot-hupo2014-release");
Assert.assertTrue(tags != null);
Assert.assertEquals("News - The neXtProt HUPO2014 release", tags.getTitle());
}
use of org.nextprot.api.web.seo.domain.SeoTags in project nextprot-api by calipho-sib.
the class SeoController method getSeoTags.
@RequestMapping(value = { "/seo/tags/**" }, method = { RequestMethod.GET }, produces = { MediaType.APPLICATION_JSON_VALUE })
@ResponseBody
public SeoTags getSeoTags(HttpServletRequest request) {
try {
String fullUrl = request.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE).toString();
String url = fullUrl.substring("/seo/tags".length());
SeoTags tags = seoTagsService.getGitHubSeoTags(url);
if (tags != null)
return tags;
String firstElement = RelativeUrlUtils.getPathElements(url)[0];
if ("entry".equals(firstElement)) {
return seoTagsService.getEntrySeoTags(url);
}
if ("term".equals(firstElement)) {
return seoTagsService.getTermSeoTags(url);
}
if ("publication".equals(firstElement)) {
return seoTagsService.getPublicationSeoTags(url);
}
if ("news".equals(firstElement)) {
return seoTagsService.getNewsSeoTags(url);
}
// default behavior
Logger.warn("No explicit SEO tags were found for this page: " + url);
return seoTagsService.getDefaultSeoTags(url);
} catch (Exception e) {
throw new NextProtException("Error while search SEO tags for this page: " + url, e);
}
}
use of org.nextprot.api.web.seo.domain.SeoTags in project nextprot-api by calipho-sib.
the class SeoServiceIntegrationTest method testSeoTagsForPubli.
@Test
public void testSeoTagsForPubli() throws Exception {
SeoTags tags;
tags = seoTagsService.getPublicationSeoTags("/publication/43778635");
Assert.assertTrue(tags != null);
String title = "Childhood adversity moderates the effect of ADH1B on risk for alcohol-related phenotypes in Jewish Israeli drinkers.";
title += " - Proteins";
Assert.assertEquals(title, tags.getTitle());
// just check that we have same tag with this url
tags = seoTagsService.getPublicationSeoTags("/publication/43778635/");
Assert.assertTrue(tags != null);
Assert.assertEquals(title, tags.getTitle());
// just check that we have same tag with this url
tags = seoTagsService.getPublicationSeoTags("/publication/43778635/proteins");
Assert.assertTrue(tags != null);
Assert.assertEquals(title, tags.getTitle());
}
use of org.nextprot.api.web.seo.domain.SeoTags in project nextprot-api by calipho-sib.
the class SeoServiceIntegrationTest method testSomeHardCodedTags.
@Test
public void testSomeHardCodedTags() throws Exception {
SeoTags tags;
tags = seoTagsService.getGitHubSeoTags("/about/nextprot");
Assert.assertTrue(tags != null);
}
use of org.nextprot.api.web.seo.domain.SeoTags in project nextprot-api by calipho-sib.
the class SeoServiceIntegrationTest method testSeoTagsForEntry.
@Test
public void testSeoTagsForEntry() throws Exception {
SeoTags tags;
tags = seoTagsService.getEntrySeoTags("/entry/NX_P01308");
Assert.assertTrue(tags != null);
Assert.assertEquals("INS - Insulin - Function", tags.getTitle());
tags = seoTagsService.getEntrySeoTags("/entry/NX_P01308/");
Assert.assertTrue(tags != null);
Assert.assertEquals("INS - Insulin - Function", tags.getTitle());
tags = seoTagsService.getEntrySeoTags("/entry/NX_P01308/function");
Assert.assertTrue(tags != null);
Assert.assertEquals("INS - Insulin - Function", tags.getTitle());
tags = seoTagsService.getEntrySeoTags("/entry/NX_P01308/medical");
Assert.assertTrue(tags != null);
Assert.assertEquals("INS - Insulin - Medical", tags.getTitle());
tags = seoTagsService.getEntrySeoTags("/entry/NX_P01308/expression");
Assert.assertTrue(tags != null);
Assert.assertEquals("INS - Insulin - Expression", tags.getTitle());
// ...
}
Aggregations