Skip to content

Commit

Permalink
fix exising tests and add a new test for endpoint usage detector
Browse files Browse the repository at this point in the history
  • Loading branch information
mshabarov committed Dec 19, 2024
1 parent e21306f commit ed89b41
Show file tree
Hide file tree
Showing 33 changed files with 6,315 additions and 6,149 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ public boolean areEndpointsUsed(Options options) {
return Stream.concat(
classFinder.getAnnotatedClasses(Endpoint.class).stream(),
classFinder.getAnnotatedClasses(BrowserCallable.class).stream())
.anyMatch(annotatedClass -> !annotatedClass.isAnnotationPresent(InternalBrowserCallable.class));
.anyMatch(annotatedClass -> !annotatedClass
.isAnnotationPresent(InternalBrowserCallable.class));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import com.vaadin.flow.di.Lookup;
import com.vaadin.flow.server.frontend.EndpointGeneratorTaskFactory;
import com.vaadin.flow.server.frontend.EndpointUsageDetector;
import com.vaadin.flow.server.frontend.NodeTasks;
import com.vaadin.flow.server.frontend.Options;
import com.vaadin.flow.server.frontend.scanner.ClassFinder;
Expand All @@ -31,6 +32,12 @@ public static class ConnectEndpointsForTesting {
@BeforeEach
public void setUp() throws IOException {
Lookup mockLookup = Mockito.mock(Lookup.class);
EndpointUsageDetector endpointUsageDetector = Mockito
.mock(EndpointUsageDetector.class);
Mockito.when(endpointUsageDetector
.areEndpointsUsed(Mockito.any(Options.class))).thenReturn(true);
Mockito.doReturn(endpointUsageDetector).when(mockLookup)
.lookup(EndpointUsageDetector.class);
Mockito.doReturn(new EndpointGeneratorTaskFactoryImpl())
.when(mockLookup).lookup(EndpointGeneratorTaskFactory.class);
Mockito.doReturn(new DefaultClassFinder(Set.of(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void testBrowserCallableAndEndpointAnnotationsMarkedAsInternal() {
if (!clazz.getName().contains(".test.") && !clazz
.isAnnotationPresent(InternalBrowserCallable.class)) {
Assertions.fail("Class " + clazz.getName()
+ " is annotated with @BrowserCallable or @Endpoint, but missing @InternalBrowserCallable.");
+ " is annotated with @BrowserCallable or @Endpoint, but missing @InternalBrowserCallable.");
}
}
}
Expand All @@ -47,7 +47,7 @@ public void testInternalBrowserCallableHasBrowserCallableOrEndpoint()
if (!clazz.isAnnotationPresent(BrowserCallable.class)
&& !clazz.isAnnotationPresent(Endpoint.class)) {
Assertions.fail("Class " + clazz.getName()
+ " is annotated with @InternalBrowserCallable and must be annotated with @BrowserCallable or @Endpoint.");
+ " is annotated with @InternalBrowserCallable and must be annotated with @BrowserCallable or @Endpoint.");
}
}
}
Expand Down
28 changes: 14 additions & 14 deletions packages/java/tests/csrf-context/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 17 additions & 17 deletions packages/java/tests/csrf-context/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"lit": "3.2.1"
},
"devDependencies": {
"@babel/preset-react": "7.26.3",
"@babel/preset-react": "7.25.9",
"@preact/signals-react-transform": "0.4.0",
"@rollup/plugin-replace": "6.0.1",
"@rollup/pluginutils": "5.1.3",
Expand All @@ -40,7 +40,7 @@
"strip-css-comments": "5.0.0",
"transform-ast": "2.4.4",
"typescript": "5.7.2",
"vite": "6.0.3",
"vite": "6.0.2",
"vite-plugin-checker": "0.8.0",
"workbox-build": "7.3.0",
"workbox-core": "7.3.0",
Expand All @@ -50,8 +50,8 @@
"dependencies": {
"@polymer/polymer": "3.5.2",
"@vaadin/common-frontend": "0.0.19",
"@vaadin/hilla-frontend": "24.6.0",
"@vaadin/hilla-lit-form": "24.6.0",
"@vaadin/hilla-frontend": "24.6.0-beta3",
"@vaadin/hilla-lit-form": "24.6.0-beta3",
"@vaadin/icon": "24.6.0",
"@vaadin/icons": "24.6.0",
"@vaadin/polymer-legacy-adapter": "24.6.0",
Expand All @@ -63,20 +63,20 @@
"lit": "3.2.1"
},
"devDependencies": {
"@babel/preset-react": "7.26.3",
"@babel/preset-react": "7.25.9",
"@preact/signals-react-transform": "0.4.0",
"@rollup/plugin-replace": "6.0.1",
"@rollup/pluginutils": "5.1.3",
"@vaadin/hilla-generator-cli": "24.6.0",
"@vaadin/hilla-generator-core": "24.6.0",
"@vaadin/hilla-generator-plugin-backbone": "24.6.0",
"@vaadin/hilla-generator-plugin-barrel": "24.6.0",
"@vaadin/hilla-generator-plugin-client": "24.6.0",
"@vaadin/hilla-generator-plugin-model": "24.6.0",
"@vaadin/hilla-generator-plugin-push": "24.6.0",
"@vaadin/hilla-generator-plugin-signals": "24.6.0",
"@vaadin/hilla-generator-plugin-subtypes": "24.6.0",
"@vaadin/hilla-generator-utils": "24.6.0",
"@vaadin/hilla-generator-cli": "24.6.0-beta3",
"@vaadin/hilla-generator-core": "24.6.0-beta3",
"@vaadin/hilla-generator-plugin-backbone": "24.6.0-beta3",
"@vaadin/hilla-generator-plugin-barrel": "24.6.0-beta3",
"@vaadin/hilla-generator-plugin-client": "24.6.0-beta3",
"@vaadin/hilla-generator-plugin-model": "24.6.0-beta3",
"@vaadin/hilla-generator-plugin-push": "24.6.0-beta3",
"@vaadin/hilla-generator-plugin-signals": "24.6.0-beta3",
"@vaadin/hilla-generator-plugin-subtypes": "24.6.0-beta3",
"@vaadin/hilla-generator-utils": "24.6.0-beta3",
"@vitejs/plugin-react": "4.3.4",
"async": "3.2.6",
"glob": "10.4.5",
Expand All @@ -85,13 +85,13 @@
"strip-css-comments": "5.0.0",
"transform-ast": "2.4.4",
"typescript": "5.7.2",
"vite": "6.0.3",
"vite": "6.0.2",
"vite-plugin-checker": "0.8.0",
"workbox-build": "7.3.0",
"workbox-core": "7.3.0",
"workbox-precaching": "7.3.0"
},
"hash": "6503b571da76b051fa4867f362de942e61a53678e38210ac16f19c364fd38aeb"
"hash": "7a3e995bf2b1a9a6cad0a907dfcb4df90824cd2566bbf6cc9c3dcc35f67676cd"
},
"overrides": {
"@vaadin/common-frontend": "$@vaadin/common-frontend",
Expand Down
28 changes: 14 additions & 14 deletions packages/java/tests/csrf/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 17 additions & 17 deletions packages/java/tests/csrf/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"lit": "3.2.1"
},
"devDependencies": {
"@babel/preset-react": "7.26.3",
"@babel/preset-react": "7.25.9",
"@preact/signals-react-transform": "0.4.0",
"@rollup/plugin-replace": "6.0.1",
"@rollup/pluginutils": "5.1.3",
Expand All @@ -40,7 +40,7 @@
"strip-css-comments": "5.0.0",
"transform-ast": "2.4.4",
"typescript": "5.7.2",
"vite": "6.0.3",
"vite": "6.0.2",
"vite-plugin-checker": "0.8.0",
"workbox-build": "7.3.0",
"workbox-core": "7.3.0",
Expand All @@ -50,8 +50,8 @@
"dependencies": {
"@polymer/polymer": "3.5.2",
"@vaadin/common-frontend": "0.0.19",
"@vaadin/hilla-frontend": "24.6.0",
"@vaadin/hilla-lit-form": "24.6.0",
"@vaadin/hilla-frontend": "24.6.0-beta3",
"@vaadin/hilla-lit-form": "24.6.0-beta3",
"@vaadin/icon": "24.6.0",
"@vaadin/icons": "24.6.0",
"@vaadin/polymer-legacy-adapter": "24.6.0",
Expand All @@ -63,20 +63,20 @@
"lit": "3.2.1"
},
"devDependencies": {
"@babel/preset-react": "7.26.3",
"@babel/preset-react": "7.25.9",
"@preact/signals-react-transform": "0.4.0",
"@rollup/plugin-replace": "6.0.1",
"@rollup/pluginutils": "5.1.3",
"@vaadin/hilla-generator-cli": "24.6.0",
"@vaadin/hilla-generator-core": "24.6.0",
"@vaadin/hilla-generator-plugin-backbone": "24.6.0",
"@vaadin/hilla-generator-plugin-barrel": "24.6.0",
"@vaadin/hilla-generator-plugin-client": "24.6.0",
"@vaadin/hilla-generator-plugin-model": "24.6.0",
"@vaadin/hilla-generator-plugin-push": "24.6.0",
"@vaadin/hilla-generator-plugin-signals": "24.6.0",
"@vaadin/hilla-generator-plugin-subtypes": "24.6.0",
"@vaadin/hilla-generator-utils": "24.6.0",
"@vaadin/hilla-generator-cli": "24.6.0-beta3",
"@vaadin/hilla-generator-core": "24.6.0-beta3",
"@vaadin/hilla-generator-plugin-backbone": "24.6.0-beta3",
"@vaadin/hilla-generator-plugin-barrel": "24.6.0-beta3",
"@vaadin/hilla-generator-plugin-client": "24.6.0-beta3",
"@vaadin/hilla-generator-plugin-model": "24.6.0-beta3",
"@vaadin/hilla-generator-plugin-push": "24.6.0-beta3",
"@vaadin/hilla-generator-plugin-signals": "24.6.0-beta3",
"@vaadin/hilla-generator-plugin-subtypes": "24.6.0-beta3",
"@vaadin/hilla-generator-utils": "24.6.0-beta3",
"@vitejs/plugin-react": "4.3.4",
"async": "3.2.6",
"glob": "10.4.5",
Expand All @@ -85,13 +85,13 @@
"strip-css-comments": "5.0.0",
"transform-ast": "2.4.4",
"typescript": "5.7.2",
"vite": "6.0.3",
"vite": "6.0.2",
"vite-plugin-checker": "0.8.0",
"workbox-build": "7.3.0",
"workbox-core": "7.3.0",
"workbox-precaching": "7.3.0"
},
"hash": "6503b571da76b051fa4867f362de942e61a53678e38210ac16f19c364fd38aeb"
"hash": "7a3e995bf2b1a9a6cad0a907dfcb4df90824cd2566bbf6cc9c3dcc35f67676cd"
},
"overrides": {
"@vaadin/common-frontend": "$@vaadin/common-frontend",
Expand Down
Loading

0 comments on commit ed89b41

Please sign in to comment.