Search in sources :

Example 6 with SiteRequestScheme

use of org.ambraproject.wombat.config.site.url.SiteRequestScheme in project wombat by PLOS.

the class TestTheme method testResolveForeignJournalKey.

@Test
public void testResolveForeignJournalKey() throws Exception {
    SiteRequestScheme dummyScheme = SiteRequestScheme.builder().build();
    Theme homeTheme = new StubTheme("homeTheme", "homeJournal") {

        @Override
        protected Map<String, Object> getJournalConfigMap() {
            Map<String, Object> map = super.getJournalConfigMap();
            if (useJournalKeyMap) {
                ImmutableMap<String, String> otherJournals = ImmutableMap.of("targetJournal", "targetSite");
                map.put("otherJournals", otherJournals);
            }
            return map;
        }
    };
    Site homeSite = new Site("homeSite", homeTheme, dummyScheme, "");
    Theme targetTheme = new StubTheme("targetTheme", "targetJournal");
    Site targetSite = new Site("targetSite", targetTheme, dummyScheme, "");
    SiteSet siteSet = new SiteSet(ImmutableList.of(homeSite, targetSite));
    Site resolved = homeTheme.resolveForeignJournalKey(siteSet, "targetJournal");
    assertEquals(targetSite, resolved);
}
Also used : Site(org.ambraproject.wombat.config.site.Site) SiteRequestScheme(org.ambraproject.wombat.config.site.url.SiteRequestScheme) SiteSet(org.ambraproject.wombat.config.site.SiteSet) Test(org.junit.Test)

Aggregations

SiteRequestScheme (org.ambraproject.wombat.config.site.url.SiteRequestScheme)6 Site (org.ambraproject.wombat.config.site.Site)4 SiteSet (org.ambraproject.wombat.config.site.SiteSet)3 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 Bean (org.springframework.context.annotation.Bean)2 BiMap (com.google.common.collect.BiMap)1 HashBiMap (com.google.common.collect.HashBiMap)1 ImmutableBiMap (com.google.common.collect.ImmutableBiMap)1 Map (java.util.Map)1 RuntimeConfigurationException (org.ambraproject.wombat.config.RuntimeConfigurationException)1 Theme (org.ambraproject.wombat.config.theme.Theme)1 Test (org.junit.Test)1 Test (org.testng.annotations.Test)1