Search in sources :

Example 1 with SeoTags

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());
}
Also used : SeoTags(org.nextprot.api.web.seo.domain.SeoTags) WebIntegrationBaseTest(org.nextprot.api.web.dbunit.base.mvc.WebIntegrationBaseTest) Test(org.junit.Test)

Example 2 with SeoTags

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);
    }
}
Also used : NextProtException(org.nextprot.api.commons.exception.NextProtException) SeoTags(org.nextprot.api.web.seo.domain.SeoTags) NextProtException(org.nextprot.api.commons.exception.NextProtException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 3 with SeoTags

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());
}
Also used : SeoTags(org.nextprot.api.web.seo.domain.SeoTags) WebIntegrationBaseTest(org.nextprot.api.web.dbunit.base.mvc.WebIntegrationBaseTest) Test(org.junit.Test)

Example 4 with SeoTags

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);
}
Also used : SeoTags(org.nextprot.api.web.seo.domain.SeoTags) WebIntegrationBaseTest(org.nextprot.api.web.dbunit.base.mvc.WebIntegrationBaseTest) Test(org.junit.Test)

Example 5 with SeoTags

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());
// ...
}
Also used : SeoTags(org.nextprot.api.web.seo.domain.SeoTags) WebIntegrationBaseTest(org.nextprot.api.web.dbunit.base.mvc.WebIntegrationBaseTest) Test(org.junit.Test)

Aggregations

SeoTags (org.nextprot.api.web.seo.domain.SeoTags)11 Test (org.junit.Test)6 WebIntegrationBaseTest (org.nextprot.api.web.dbunit.base.mvc.WebIntegrationBaseTest)6 SimpleDateFormat (java.text.SimpleDateFormat)1 NextProtException (org.nextprot.api.commons.exception.NextProtException)1 CvTerm (org.nextprot.api.core.domain.CvTerm)1 Entry (org.nextprot.api.core.domain.Entry)1 Publication (org.nextprot.api.core.domain.Publication)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1