8000 feat: Add a shortcut to get DeploymentConfiguration from UIInternals … · vaadin/flow@6428f99 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Commit 6428f99

Browse files
authored
feat: Add a shortcut to get DeploymentConfiguration from UIInternals (#21457)
Summary of Change: Added a helper method in UIInternals to get deployment configurations from the service from the session. Motivation and Context: There are many areas of code that need to access deployment configuration from UIInternals but accessing is quite clunky and long. Fixes # 21317
1 parent 12a6b4c commit 6428f99

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

flow-server/src/main/java/com/vaadin/flow/component/internal/UIInternals.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import java.util.stream.Stream;
3535

3636
import com.fasterxml.jackson.databind.node.BaseJsonNode;
37+
import com.vaadin.flow.function.DeploymentConfiguration;
3738
import org.slf4j.Logger;
3839
import org.slf4j.LoggerFactory;
3940

@@ -1458,4 +1459,13 @@ public String getContainerTag() {
14581459
return "flow-container-" + getFullAppId().toLowerCase(Locale.ENGLISH);
14591460

14601461
}
1462+
1463+
/**
1464+
* Returns the Deployment Configuration for the application
1465+
*
1466+
* @return The Deployment Configuration
1467+
*/
1468+
public DeploymentConfiguration getDeploymentConfiguration() {
1469+
return getSession().getService().getDeploymentConfiguration();
1470+
}
14611471
}

flow-server/src/test/java/com/vaadin/flow/component/internal/UIInternalsTest.java

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import java.util.Optional;
88
import java.util.concurrent.atomic.AtomicInteger;
99
import java.util.concurrent.atomic.AtomicReference;
10-
10+
import com.vaadin.tests.util.MockDeploymentConfiguration;
1111
import org.junit.Assert;
1212
import org.junit.Before;
1313
import org.junit.Test;
@@ -558,4 +558,25 @@ private PushConfiguration setUpInitialPush() {
558558
return pushConfig;
559559
}
560560

561+
@Test
562+
public void getDeploymentConfiguration() {
563+
AlwaysLockedVaadinSession session = Mockito
564+
.mock(AlwaysLockedVaadinSession.class);
565+
MockVaadinServletService mockVaadinServletService = Mockito
566+
.mock(MockVaadinServletService.class);
567+
568+
internals = new UIInternals(ui);
569+
internals.setSession(session);
570+
571+
Mockito.when(session.getService()).thenReturn(mockVaadinServletService);
572+
DeploymentConfiguration config = new MockDeploymentConfiguration();
573+
Mockito.when(mockVaadinServletService.getDeploymentConfiguration())
574+
.thenReturn(config);
575+
576+
DeploymentConfiguration result = internals.getDeploymentConfiguration();
577+
578+
Mockito.verify(session).getService();
579+
Mockito.verify(mockVaadinServletService).getDeploymentConfiguration();
580+
Assert.assertEquals(config, result);
581+
}
561582
}

0 commit comments

Comments
 (0)
0