Search in sources :

Example 21 with DefaultClassFinder

use of com.vaadin.flow.server.frontend.scanner.ClassFinder.DefaultClassFinder in project flow by vaadin.

the class ScannerThemeTest method should_defaultToLumoTheme_when_noThemeDefinedByExporter.

@Test
public void should_defaultToLumoTheme_when_noThemeDefinedByExporter() throws Exception {
    // RootViewWithTheme is added to the list just to make sure exporter
    // handles theming default, not the other crawlers
    DefaultClassFinder finder = spy(new DefaultClassFinder(new HashSet<>(Arrays.asList(NoThemeExporter.class, RootViewWithTheme.class))));
    Mockito.doReturn(Theme4.class).when(finder).loadClass(FrontendDependencies.LUMO);
    FrontendDependencies deps = new FrontendDependencies(finder);
    assertEquals("Theme4 should have been returned when default theme was selected", Theme4.class, deps.getThemeDefinition().getTheme());
    assertTrue("Theme4 should have been visited and JsModule collected", deps.getModules().contains("./theme-4.js"));
}
Also used : DefaultClassFinder(com.vaadin.flow.server.frontend.scanner.ClassFinder.DefaultClassFinder) NoThemeExporter(com.vaadin.flow.server.frontend.scanner.ScannerTestComponents.NoThemeExporter) RootViewWithTheme(com.vaadin.flow.server.frontend.scanner.ScannerTestComponents.RootViewWithTheme) ScannerDependenciesTest.getFrontendDependencies(com.vaadin.flow.server.frontend.scanner.ScannerDependenciesTest.getFrontendDependencies) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 22 with DefaultClassFinder

use of com.vaadin.flow.server.frontend.scanner.ClassFinder.DefaultClassFinder in project flow by vaadin.

the class ScannerThemeTest method should_notAttemptToOverrideTheme_when_noExportersFound.

// flow#5715
@Test
public void should_notAttemptToOverrideTheme_when_noExportersFound() throws ClassNotFoundException {
    DefaultClassFinder finder = spy(new DefaultClassFinder(Collections.singleton(RootViewWithTheme.class)));
    new FrontendDependencies(finder);
    verify(finder, times(0)).loadClass(FrontendDependencies.LUMO);
}
Also used : DefaultClassFinder(com.vaadin.flow.server.frontend.scanner.ClassFinder.DefaultClassFinder) ScannerDependenciesTest.getFrontendDependencies(com.vaadin.flow.server.frontend.scanner.ScannerDependenciesTest.getFrontendDependencies) Test(org.junit.Test)

Aggregations

DefaultClassFinder (com.vaadin.flow.server.frontend.scanner.ClassFinder.DefaultClassFinder)22 Test (org.junit.Test)19 File (java.io.File)12 Lookup (com.vaadin.flow.di.Lookup)7 Builder (com.vaadin.flow.server.frontend.NodeTasks.Builder)7 HashSet (java.util.HashSet)7 ClassFinder (com.vaadin.flow.server.frontend.scanner.ClassFinder)6 Before (org.junit.Before)6 FeatureFlags (com.vaadin.experimental.FeatureFlags)5 TARGET (com.vaadin.flow.server.Constants.TARGET)5 DEFAULT_FRONTEND_DIR (com.vaadin.flow.server.frontend.FrontendUtils.DEFAULT_FRONTEND_DIR)5 DEFAULT_GENERATED_DIR (com.vaadin.flow.server.frontend.FrontendUtils.DEFAULT_GENERATED_DIR)5 FLOW_NPM_PACKAGE_NAME (com.vaadin.flow.server.frontend.FrontendUtils.FLOW_NPM_PACKAGE_NAME)5 IMPORTS_D_TS_NAME (com.vaadin.flow.server.frontend.FrontendUtils.IMPORTS_D_TS_NAME)5 IMPORTS_NAME (com.vaadin.flow.server.frontend.FrontendUtils.IMPORTS_NAME)5 NODE_MODULES (com.vaadin.flow.server.frontend.FrontendUtils.NODE_MODULES)5 FrontendDependenciesScannerFactory (com.vaadin.flow.server.frontend.scanner.FrontendDependenciesScanner.FrontendDependenciesScannerFactory)5 Json (elemental.json.Json)5 JsonArray (elemental.json.JsonArray)5 JsonObject (elemental.json.JsonObject)5