Search in sources :

Example 1 with ModuleRegistry

use of info.magnolia.module.ModuleRegistry in project magnolia-vanity-url by aperto.

the class VirtualVanityUriMappingTest method setUp.

@Before
public void setUp() throws Exception {
    _uriMapping = new VirtualVanityUriMapping();
    Provider moduleProvider = mock(Provider.class);
    VanityUrlModule module = new VanityUrlModule();
    Map<String, String> excludes = new HashMap<>();
    excludes.put("pages", ".*\\..*");
    module.setExcludes(excludes);
    when(moduleProvider.get()).thenReturn(module);
    _uriMapping.setVanityUrlModule(moduleProvider);
    Provider serviceProvider = mock(Provider.class);
    VanityUrlService vanityUrlService = mock(VanityUrlService.class);
    when(vanityUrlService.queryForVanityUrlNode("/home", "default")).thenReturn(null);
    MockNode mockNode = new MockNode("xmas");
    when(vanityUrlService.queryForVanityUrlNode("/xmas", "default")).thenReturn(mockNode);
    when(vanityUrlService.createRedirectUrl(mockNode)).thenReturn("redirect:/internal/page.html");
    when(serviceProvider.get()).thenReturn(vanityUrlService);
    _uriMapping.setVanityUrlService(serviceProvider);
    Provider registryProvider = mock(Provider.class);
    ModuleRegistry moduleRegistry = mock(ModuleRegistry.class);
    when(registryProvider.get()).thenReturn(moduleRegistry);
    _uriMapping.setModuleRegistry(registryProvider);
    initWebContext();
    initComponentProvider();
}
Also used : HashMap(java.util.HashMap) ModuleRegistry(info.magnolia.module.ModuleRegistry) MockNode(info.magnolia.test.mock.jcr.MockNode) Provider(javax.inject.Provider) Before(org.junit.Before)

Aggregations

ModuleRegistry (info.magnolia.module.ModuleRegistry)1 MockNode (info.magnolia.test.mock.jcr.MockNode)1 HashMap (java.util.HashMap)1 Provider (javax.inject.Provider)1 Before (org.junit.Before)1