Search in sources :

Example 1 with AssetManager

use of com.eden.orchid.api.theme.assets.AssetManager in project Orchid by JavaEden.

the class ThemeServiceTest method setUp.

@BeforeEach
public void setUp() {
    themes = new HashSet<>();
    theme1 = mock(Theme1.class);
    theme2 = mock(Theme2.class);
    when(theme1.getKey()).thenReturn("theme1");
    when(theme2.getKey()).thenReturn("theme2");
    when(theme1.toString()).thenReturn("theme1.toString()");
    when(theme2.toString()).thenReturn("theme2.toString()");
    themes.add(theme1);
    adminThemes = new HashSet<>();
    adminTheme1 = mock(AdminTheme1.class);
    adminTheme2 = mock(AdminTheme2.class);
    when(adminTheme1.getKey()).thenReturn("adminTheme1");
    when(adminTheme2.getKey()).thenReturn("adminTheme2");
    when(adminTheme1.toString()).thenReturn("adminTheme1.toString()");
    when(adminTheme2.toString()).thenReturn("adminTheme2.toString()");
    adminThemes.add(adminTheme1);
    assetManager = mock(AssetManager.class);
    themeContextOptions = new JSONObject();
    theme2ContextOptions = new JSONObject();
    adminThemeContextOptions = new JSONObject();
    adminTheme2ContextOptions = new JSONObject();
    // Mock Injector
    // Mock Context
    context = mock(OrchidContext.class);
    when(context.query("theme")).thenReturn(new JSONElement(themeContextOptions));
    when(context.query("theme2")).thenReturn(new JSONElement(theme2ContextOptions));
    when(context.query("adminTheme")).thenReturn(new JSONElement(adminThemeContextOptions));
    when(context.query("adminTheme2")).thenReturn(new JSONElement(adminTheme2ContextOptions));
    when(context.resolve((Class<Theme>) theme1.getClass())).thenReturn(theme1);
    when(context.resolve((Class<Theme>) theme2.getClass())).thenReturn(theme2);
    when(context.resolve((Class<AdminTheme>) adminTheme1.getClass())).thenReturn(adminTheme1);
    when(context.resolve((Class<AdminTheme>) adminTheme2.getClass())).thenReturn(adminTheme2);
    // Create instance of Service Implementation
    ThemeServiceImpl service = new ThemeServiceImpl(assetManager, () -> themes, "theme1", () -> adminThemes, "adminTheme1");
    service.initialize(context);
    // Create wrapper around the Implementation to verify it works in composition
    underTest = new ThemeService() {

        public void initialize(OrchidContext context) {
        }

        public <T extends OrchidService> T getService(Class<T> serviceClass) {
            return (T) service;
        }
    };
}
Also used : AssetManager(com.eden.orchid.api.theme.assets.AssetManager) OrchidContext(com.eden.orchid.api.OrchidContext) JSONObject(org.json.JSONObject) JSONElement(com.eden.common.json.JSONElement) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

JSONElement (com.eden.common.json.JSONElement)1 OrchidContext (com.eden.orchid.api.OrchidContext)1 AssetManager (com.eden.orchid.api.theme.assets.AssetManager)1 JSONObject (org.json.JSONObject)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1