use of com.vaadin.flow.server.frontend.scanner.ClassFinder.DefaultClassFinder in project flow by vaadin.
the class NodeTasksTest method verifyEndpointGeneratorWithHillaTask.
private void verifyEndpointGeneratorWithHillaTask(boolean withHillaTask) 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).enableImportsUpdate(true).runNpmInstall(false).withEmbeddableWebComponents(false).withFrontendGeneratedFolder(new File(userDir)).withEndpointSourceFolder(new File(userDir)).withEndpointGeneratedOpenAPIFile(new File(userDir));
EndpointGeneratorTaskFactory endpointGeneratorFactory = mock(EndpointGeneratorTaskFactory.class);
TaskGenerateOpenAPI mockGenerateOpenAPI = mock(TaskGenerateOpenAPI.class);
TaskGenerateEndpoint mockGenerateEndpoint = mock(TaskGenerateEndpoint.class);
Mockito.doReturn(mockGenerateOpenAPI).when(endpointGeneratorFactory).createTaskGenerateOpenAPI(any(), any(), any(), any());
Mockito.doReturn(mockGenerateEndpoint).when(endpointGeneratorFactory).createTaskGenerateEndpoint(any(), any(), any(), any());
Mockito.doReturn(endpointGeneratorFactory).when(mockedLookup).lookup(EndpointGeneratorTaskFactory.class);
TaskGenerateHilla hillaTask = withHillaTask ? mock(TaskGenerateHilla.class) : null;
Mockito.doReturn(hillaTask).when(mockedLookup).lookup(TaskGenerateHilla.class);
builder.build().execute();
if (withHillaTask) {
Mockito.verify(hillaTask, times(1)).execute();
}
Mockito.verify(endpointGeneratorFactory, withHillaTask ? never() : times(1)).createTaskGenerateEndpoint(any(), any(), any(), any());
Mockito.verify(endpointGeneratorFactory, withHillaTask ? never() : times(1)).createTaskGenerateOpenAPI(any(), any(), any(), any());
Mockito.verify(mockGenerateOpenAPI, withHillaTask ? never() : times(1)).execute();
Mockito.verify(mockGenerateEndpoint, withHillaTask ? never() : times(1)).execute();
}
use of com.vaadin.flow.server.frontend.scanner.ClassFinder.DefaultClassFinder in project flow by vaadin.
the class NodeTasksTest method should_SetIsClientBootstrapMode_When_EnableClientSideBootstrapMode.
@Test
public void should_SetIsClientBootstrapMode_When_EnableClientSideBootstrapMode() throws ExecutionFailedException, IOException {
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).withWebpack(new File(userDir, TARGET + "webapp"), new File(userDir, TARGET + "classes")).enableImportsUpdate(true).runNpmInstall(false).withEmbeddableWebComponents(false).useV14Bootstrap(false).withFlowResourcesFolder(new File(userDir, TARGET + "flow-frontend")).withFrontendGeneratedFolder(new File(userDir, DEFAULT_PROJECT_FRONTEND_GENERATED_DIR));
builder.build().execute();
String webpackGeneratedContent = Files.lines(new File(userDir, WEBPACK_GENERATED).toPath()).collect(Collectors.joining("\n"));
Assert.assertTrue("useClientSideIndexFileForBootstrapping should be true", webpackGeneratedContent.contains("const useClientSideIndexFileForBootstrapping = true;"));
}
use of com.vaadin.flow.server.frontend.scanner.ClassFinder.DefaultClassFinder in project flow by vaadin.
the class ClassFinderTest method should_LoadClasses_when_NoClassListProvided.
@Test
public void should_LoadClasses_when_NoClassListProvided() throws Exception {
DefaultClassFinder finder = new DefaultClassFinder(Collections.emptySet());
Assert.assertNotNull(finder.loadClass(Component1.class.getName()));
}
use of com.vaadin.flow.server.frontend.scanner.ClassFinder.DefaultClassFinder in project flow by vaadin.
the class ClassFinderTest method getSubTypesOf_returnsPlainSubtypes.
@Test
public void getSubTypesOf_returnsPlainSubtypes() {
DefaultClassFinder finder = new DefaultClassFinder(new HashSet<>(Arrays.asList(Double.class, Integer.class, String.class)));
Set<Class<? extends Number>> subTypes = finder.getSubTypesOf(Number.class);
Assert.assertEquals(2, subTypes.size());
Assert.assertTrue(subTypes.contains(Double.class));
Assert.assertTrue(subTypes.contains(Integer.class));
}
use of com.vaadin.flow.server.frontend.scanner.ClassFinder.DefaultClassFinder in project flow by vaadin.
the class ClassFinderTest method should_LoadClasses.
@Test
public void should_LoadClasses() throws Exception {
DefaultClassFinder finder = new DefaultClassFinder(new HashSet<>(Arrays.asList(Component1.class)));
Assert.assertNotNull(finder.loadClass(Component1.class.getName()));
}
Aggregations