use of com.vaadin.flow.server.frontend.scanner.ClassFinder.DefaultClassFinder in project flow by vaadin.
the class NodeTasksTest method should_GenerateTsConfigAndTsDefinitions_When_Vaadin14BootstrapMode.
@Test
public void should_GenerateTsConfigAndTsDefinitions_When_Vaadin14BootstrapMode() throws ExecutionFailedException {
Lookup mockedLookup = mock(Lookup.class);
Mockito.doReturn(new DefaultClassFinder(this.getClass().getClassLoader())).when(mockedLookup).lookup(ClassFinder.class);
Builder builder = new Builder(mockedLookup, new File(userDir), TARGET).enablePackagesUpdate(false).useV14Bootstrap(true).enableImportsUpdate(true).runNpmInstall(false).withEmbeddableWebComponents(false).useV14Bootstrap(false);
builder.build().execute();
Assert.assertTrue(new File(userDir, "tsconfig.json").exists());
Assert.assertTrue(new File(userDir, "types.d.ts").exists());
}
use of com.vaadin.flow.server.frontend.scanner.ClassFinder.DefaultClassFinder in project flow by vaadin.
the class ClassFinderTest method should_Fail_when_DifferentClasLoader.
@Test
public void should_Fail_when_DifferentClasLoader() throws Exception {
ClassLoader loader = new ClassLoader() {
@Override
public Class<?> loadClass(String name) throws ClassNotFoundException {
throw new ClassNotFoundException();
}
};
exception.expect(ClassNotFoundException.class);
DefaultClassFinder finder = new DefaultClassFinder(loader, Component1.class);
finder.loadClass(Component1.class.getName());
}
use of com.vaadin.flow.server.frontend.scanner.ClassFinder.DefaultClassFinder in project flow by vaadin.
the class ClassFinderTest method orderIsDeterministic.
@Test
public void orderIsDeterministic() {
Set<Class<?>> testClasses = new HashSet<>();
testClasses.add(NodeTestComponents.ExtraImport.class);
testClasses.add(NodeTestComponents.VaadinBowerComponent.class);
testClasses.add(NodeTestComponents.TranslatedImports.class);
Set<Class<?>> allClasses = new DefaultClassFinder(testClasses).getSubTypesOf(Object.class);
LinkedHashSet<Class<?>> expected = new LinkedHashSet<>();
expected.add(NodeTestComponents.ExtraImport.class);
expected.add(NodeTestComponents.TranslatedImports.class);
expected.add(NodeTestComponents.VaadinBowerComponent.class);
Assert.assertEquals(expected, allClasses);
}
use of com.vaadin.flow.server.frontend.scanner.ClassFinder.DefaultClassFinder in project flow by vaadin.
the class ClassFinderTest method getSubTypesOf_returnsGenericSubtypes.
@Test
public void getSubTypesOf_returnsGenericSubtypes() {
DefaultClassFinder finder = new DefaultClassFinder(new HashSet<>(Arrays.asList(ArrayList.class, TestList.class, String.class)));
Set<Class<? extends List>> subTypes = finder.getSubTypesOf(List.class);
Assert.assertEquals(2, subTypes.size());
Assert.assertTrue(subTypes.contains(ArrayList.class));
Assert.assertTrue(subTypes.contains(TestList.class));
}
use of com.vaadin.flow.server.frontend.scanner.ClassFinder.DefaultClassFinder in project flow by vaadin.
the class ScannerThemeTest method should_visitDefaultTheme_when_noThemeAnnotationIsGiven.
@Test
public void should_visitDefaultTheme_when_noThemeAnnotationIsGiven() throws Exception {
DefaultClassFinder finder = spy(new DefaultClassFinder(Collections.singleton(RootViewWithoutThemeAnnotation.class)));
// we'll do a partial mock here since we want to keep the other
// behavior of the DefaultClassFinder. Theme4 is used as a fake Lumo
// since it has @JsModule annotation which makes it easy to verify
// that the Theme was actually visited and modules collected
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"));
}
Aggregations