Skip to content

Commit

Permalink
Revert "feat: execute Hilla tasks whenever Hilla is available (#20567)…
Browse files Browse the repository at this point in the history
…" (#21048)

This reverts commit 21a4145.
  • Loading branch information
mshabarov authored Feb 25, 2025
1 parent 0afeb5f commit e736cc8
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@

import com.vaadin.experimental.FeatureFlags;
import com.vaadin.flow.di.Lookup;
import com.vaadin.flow.internal.hilla.EndpointRequestUtil;
import com.vaadin.flow.server.Constants;
import com.vaadin.flow.server.ExecutionFailedException;
import com.vaadin.flow.server.InitParameters;
Expand Down Expand Up @@ -152,10 +151,10 @@ public void should_useHillaEngine_withNodeUpdater()
.when(endpointGeneratorTaskFactory)
.createTaskGenerateEndpoint(Mockito.any());

try (MockedStatic<EndpointRequestUtil> util = Mockito.mockStatic(
EndpointRequestUtil.class, Mockito.CALLS_REAL_METHODS)) {
util.when(() -> EndpointRequestUtil.isHillaAvailable(Mockito.any()))
.thenReturn(true);
try (MockedStatic<FrontendUtils> util = Mockito
.mockStatic(FrontendUtils.class, Mockito.CALLS_REAL_METHODS)) {
util.when(() -> FrontendUtils.isHillaUsed(Mockito.any(),
Mockito.any())).thenReturn(true);
BuildFrontendUtil.runNodeUpdater(adapter);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@

import com.vaadin.flow.di.Lookup;
import com.vaadin.flow.internal.UsageStatistics;
import com.vaadin.flow.internal.hilla.EndpointRequestUtil;
import com.vaadin.flow.server.Constants;
import com.vaadin.flow.server.ExecutionFailedException;
import com.vaadin.flow.server.Mode;
Expand Down Expand Up @@ -316,7 +315,8 @@ private void addGenerateServiceWorkerTask(Options options,
}

private void addEndpointServicesTasks(Options options) {
if (!EndpointRequestUtil.isHillaAvailable(options.getClassFinder())) {
if (!FrontendUtils.isHillaUsed(options.getFrontendDirectory(),
options.getClassFinder())) {
return;
}
Lookup lookup = options.getLookup();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import org.mockito.junit.MockitoRule;

import com.vaadin.flow.di.Lookup;
import com.vaadin.flow.internal.hilla.EndpointRequestUtil;
import com.vaadin.flow.server.ExecutionFailedException;
import com.vaadin.flow.server.frontend.scanner.ClassFinder;
import com.vaadin.flow.server.frontend.scanner.ClassFinder.DefaultClassFinder;
Expand Down Expand Up @@ -118,10 +117,10 @@ public void should_useHillaEngine_whenEnabled()
Mockito.doReturn(endpointGeneratorTaskFactory).when(options.getLookup())
.lookup(EndpointGeneratorTaskFactory.class);

try (MockedStatic<EndpointRequestUtil> util = Mockito.mockStatic(
EndpointRequestUtil.class, Mockito.CALLS_REAL_METHODS)) {
util.when(() -> EndpointRequestUtil.isHillaAvailable(Mockito.any()))
.thenReturn(true);
try (MockedStatic<FrontendUtils> util = Mockito
.mockStatic(FrontendUtils.class, Mockito.CALLS_REAL_METHODS)) {
util.when(() -> FrontendUtils.isHillaUsed(Mockito.any(),
Mockito.any())).thenReturn(true);

new NodeTasks(options).execute();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import com.vaadin.base.devserver.startup.DevModeStartupListener;
import com.vaadin.flow.di.ResourceProvider;
import com.vaadin.flow.internal.DevModeHandlerManager;
import com.vaadin.flow.internal.hilla.EndpointRequestUtil;
import com.vaadin.flow.server.VaadinServlet;
import com.vaadin.flow.server.VaadinServletContext;
import com.vaadin.flow.server.frontend.EndpointGeneratorTaskFactory;
Expand Down Expand Up @@ -108,10 +107,10 @@ public void should_generateOpenApi() throws Exception {
.toFile();

Assert.assertFalse(generatedOpenApiJson.exists());
try (MockedStatic<EndpointRequestUtil> util = Mockito.mockStatic(
EndpointRequestUtil.class, Mockito.CALLS_REAL_METHODS)) {
util.when(() -> EndpointRequestUtil.isHillaAvailable(Mockito.any()))
.thenReturn(true);
try (MockedStatic<FrontendUtils> util = Mockito
.mockStatic(FrontendUtils.class, Mockito.CALLS_REAL_METHODS)) {
util.when(() -> FrontendUtils.isHillaUsed(Mockito.any(),
Mockito.any())).thenReturn(true);
devModeStartupListener.onStartup(classes, servletContext);
handler = getDevModeHandler();
waitForDevServer();
Expand Down Expand Up @@ -140,10 +139,10 @@ public void should_generateTs_files() throws Exception {

assertFalse(ts1.exists());
assertFalse(ts2.exists());
try (MockedStatic<EndpointRequestUtil> util = Mockito.mockStatic(
EndpointRequestUtil.class, Mockito.CALLS_REAL_METHODS)) {
util.when(() -> EndpointRequestUtil.isHillaAvailable(Mockito.any()))
.thenReturn(true);
try (MockedStatic<FrontendUtils> util = Mockito
.mockStatic(FrontendUtils.class, Mockito.CALLS_REAL_METHODS)) {
util.when(() -> FrontendUtils.isHillaUsed(Mockito.any(),
Mockito.any())).thenReturn(true);
devModeStartupListener.onStartup(classes, servletContext);
handler = getDevModeHandler();
waitForDevServer();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import com.vaadin.flow.component.dependency.JsModule;
import com.vaadin.flow.component.page.AppShellConfigurator;
import com.vaadin.flow.di.Lookup;
import com.vaadin.flow.internal.hilla.EndpointRequestUtil;
import com.vaadin.flow.router.Route;
import com.vaadin.flow.server.InitParameters;
import com.vaadin.flow.server.LoadDependenciesOnStartup;
Expand Down Expand Up @@ -353,10 +352,10 @@ public void should_generateOpenApi_when_EndpointPresents()
javaSourceFolder.getRoot().getAbsolutePath());

Assert.assertFalse(generatedOpenApiJson.exists());
try (MockedStatic<EndpointRequestUtil> util = Mockito.mockStatic(
EndpointRequestUtil.class, Mockito.CALLS_REAL_METHODS)) {
util.when(() -> EndpointRequestUtil
.isHillaAvailable(Mockito.any())).thenReturn(true);
try (MockedStatic<FrontendUtils> util = Mockito.mockStatic(
FrontendUtils.class, Mockito.CALLS_REAL_METHODS)) {
util.when(() -> FrontendUtils.isHillaUsed(Mockito.any(),
Mockito.any())).thenReturn(true);
devModeStartupListener.onStartup(classes, servletContext);
handler = getDevModeHandler();
waitForDevServer();
Expand Down Expand Up @@ -421,10 +420,10 @@ public void should_generateTs_files() throws Exception {
System.setProperty("vaadin." + CONNECT_JAVA_SOURCE_FOLDER_TOKEN,
javaSourceFolder.getRoot().getAbsolutePath());

try (MockedStatic<EndpointRequestUtil> util = Mockito.mockStatic(
EndpointRequestUtil.class, Mockito.CALLS_REAL_METHODS)) {
util.when(() -> EndpointRequestUtil
.isHillaAvailable(Mockito.any())).thenReturn(true);
try (MockedStatic<FrontendUtils> util = Mockito.mockStatic(
FrontendUtils.class, Mockito.CALLS_REAL_METHODS)) {
util.when(() -> FrontendUtils.isHillaUsed(Mockito.any(),
Mockito.any())).thenReturn(true);
devModeStartupListener.onStartup(classes, servletContext);
handler = getDevModeHandler();
waitForDevServer();
Expand Down

0 comments on commit e736cc8

Please sign in to comment.