use of org.ambraproject.wombat.config.site.Site in project wombat by PLOS.
the class ThemeGraphTest method testInheritPropertyFromRoot.
@Test
public void testInheritPropertyFromRoot() throws IOException {
Site site = MockSiteUtil.getByUniqueJournalKey(siteSet, "journal1Key");
Map<String, Object> journal = site.getTheme().getConfigMap("homepage");
Object inheritedValue = journal.get("defaultSelection");
// expected to match src/main/webapp/WEB-INF/themes/root/config/homepage.yaml
assertEquals(inheritedValue, null);
}
use of org.ambraproject.wombat.config.site.Site in project wombat by PLOS.
the class ArticleMetadataTest method testValidateVisibility.
@Test
public void testValidateVisibility() {
HashMap<String, String> journalMetadata = new HashMap<>();
journalMetadata.put("journalKey", "fakeKey");
HashMap<String, HashMap<String, String>> ingestionMetadata = new HashMap<>();
ingestionMetadata.put("journal", journalMetadata);
Theme theme = mock(Theme.class);
HashMap<String, Object> journalAttrs = new HashMap<>();
journalAttrs.put("journalKey", "fakeKey");
journalAttrs.put("journalName", "fakeName");
when(theme.getConfigMap(any())).thenReturn(journalAttrs);
Site site = new Site("foo", theme, mock(SiteRequestScheme.class), "foo");
ArticleMetadata articleMetadata = articleMetadataFactory.newInstance(site, mock(RequestedDoiVersion.class), mock(ArticlePointer.class), ingestionMetadata, new HashMap(), new ArrayList());
articleMetadata.validateVisibility("whatever");
}
use of org.ambraproject.wombat.config.site.Site in project wombat by PLOS.
the class ArticleMetadataTest method testValidateVisibilityFail.
@Test(expected = InternalRedirectException.class)
public void testValidateVisibilityFail() {
HashMap<String, String> journalMetadata = new HashMap<>();
journalMetadata.put("journalKey", "someKey");
HashMap<String, HashMap<String, String>> ingestionMetadata = new HashMap<>();
ingestionMetadata.put("journal", journalMetadata);
Theme theme = mock(Theme.class);
HashMap<String, Object> journalAttrs = new HashMap<>();
journalAttrs.put("journalKey", "fakeKey");
journalAttrs.put("journalName", "fakeName");
when(theme.getConfigMap(any())).thenReturn(journalAttrs);
Site site = new Site("foo", theme, mock(SiteRequestScheme.class), "foo");
when(theme.resolveForeignJournalKey(any(), any())).thenReturn(site);
ArticleMetadata articleMetadata = spy(articleMetadataFactory.newInstance(site, mock(RequestedDoiVersion.class), mock(ArticlePointer.class), ingestionMetadata, new HashMap(), new ArrayList()));
Link mockLink = mock(Link.class);
doReturn(mockLink).when(articleMetadata).buildCrossSiteRedirect(any(), any());
articleMetadata.validateVisibility("whatever");
}
use of org.ambraproject.wombat.config.site.Site in project wombat by PLOS.
the class ControllerTestConfiguration method activeSite.
/**
* Unit test can only work with a single site.
*/
@Bean
protected Site activeSite(Theme theme) {
final SiteRequestScheme mockRequestScheme = mock(SiteRequestScheme.class);
doAnswer(invocation -> {
final Object[] args = invocation.getArguments();
final HttpServletRequest request = (HttpServletRequest) args[0];
return true;
}).when(mockRequestScheme).isForSite(any(HttpServletRequest.class));
final Site mockSite = mock(Site.class);
when(mockSite.getRequestScheme()).thenReturn(mockRequestScheme);
when(mockSite.getTheme()).thenReturn(theme);
when(mockSite.getKey()).thenReturn(DESKTOP_PLOS_ONE);
when(mockSite.toString()).thenReturn(DESKTOP_PLOS_ONE);
when(mockSite.getJournalKey()).thenReturn(DESKTOP_PLOS_ONE);
return mockSite;
}
use of org.ambraproject.wombat.config.site.Site in project wombat by PLOS.
the class ArticleMetadataTest method testGetFigureView.
@Test
public void testGetFigureView() {
Map<String, String> asset = new HashMap<>();
asset.put("doi", "fakeDoi");
List<Map<String, String>> assets = new ArrayList<>();
assets.add(asset);
HashMap<String, List<Map<String, String>>> ingestionMetadata = new HashMap<>();
ingestionMetadata.put("assetsLinkedFromManuscript", assets);
Map<String, String> item = new HashMap<>();
item.put("itemType", "figure");
Map<String, Map<String, String>> itemTable = new HashMap<>();
itemTable.put("fakeDoi", item);
Theme theme = mock(Theme.class);
HashMap<String, Object> journalAttrs = new HashMap<>();
journalAttrs.put("journalKey", "fakeKey");
journalAttrs.put("journalName", "fakeName");
when(theme.getConfigMap(any())).thenReturn(journalAttrs);
Site site = new Site("foo", theme, mock(SiteRequestScheme.class), "foo");
ArticleMetadata articleMetadata = articleMetadataFactory.newInstance(site, mock(RequestedDoiVersion.class), mock(ArticlePointer.class), ingestionMetadata, itemTable, new ArrayList());
HashMap<String, String> expected = new HashMap<>();
expected.put("type", "figure");
expected.put("doi", "fakeDoi");
List<Map<String, ?>> expectedFigureView = new ArrayList<>();
expectedFigureView.add(expected);
assertEquals(articleMetadata.getFigureView(), expectedFigureView);
}
Aggregations