org.springframework.ui.ConcurrentModel Java Examples
The following examples show how to use
org.springframework.ui.ConcurrentModel.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GatewayHomepageControllerTest.java From api-layer with Eclipse Public License 2.0 | 6 votes |
@Test public void givenZOSMFProviderWithOneInstance_whenHomePageCalled_thenHomePageModelShouldContain() { ServiceInstance serviceInstance = new DefaultServiceInstance("instanceId", "serviceId", "host", 10000, true); when(discoveryClient.getInstances("zosmf")).thenReturn( Arrays.asList(serviceInstance) ); authConfigurationProperties.setProvider("zosmf"); authConfigurationProperties.setZosmfServiceId("zosmf"); Model model = new ConcurrentModel(); gatewayHomepageController.home(model); Map<String, Object> actualModelMap = model.asMap(); assertThat(actualModelMap, IsMapContaining.hasEntry("authIconName", "success")); assertThat(actualModelMap, IsMapContaining.hasEntry("authStatusText", "The Authentication service is running")); }
Example #2
Source File: GatewayHomepageControllerTest.java From api-layer with Eclipse Public License 2.0 | 6 votes |
@Test public void givenSpecificBuildVersion_whenHomePageCalled_thenBuildInfoShouldBeGivenVersionAndNumber() { BuildInfo buildInfo = mock(BuildInfo.class); Properties buildProperties = new Properties(); buildProperties.setProperty("build.version", "test-version"); buildProperties.setProperty("build.number", "test-number"); BuildInfoDetails buildInfoDetails = new BuildInfoDetails(buildProperties, new Properties()); when(buildInfo.getBuildInfoDetails()).thenReturn(buildInfoDetails); GatewayHomepageController gatewayHomepageController = new GatewayHomepageController( discoveryClient, authConfigurationProperties, buildInfo); Model model = new ConcurrentModel(); gatewayHomepageController.home(model); Map<String, Object> actualModelMap = model.asMap(); assertThat(actualModelMap, IsMapContaining.hasEntry("buildInfoText", "Version test-version build # test-number")); }
Example #3
Source File: GatewayHomepageControllerTest.java From api-layer with Eclipse Public License 2.0 | 5 votes |
@Test public void givenApiCatalogInstance_whenHomePageCalled_thenHomePageModelShouldContain() { discoveryReturnValidZosmfAuthorizationInstance(); discoveryReturnValidApiCatalog(); Model model = new ConcurrentModel(); gatewayHomepageController.home(model); assertCatalogIsUpMessageShown(model.asMap()); }
Example #4
Source File: ModelRequestArgumentBinder.java From micronaut-spring with Apache License 2.0 | 5 votes |
@Override public BindingResult<Model> bind(ArgumentConversionContext<Model> context, HttpRequest<?> source) { final Optional<Model> attribute = source.getAttribute(ATTRIBUTE, Model.class); if (!attribute.isPresent()) { final ConcurrentModel concurrentModel = new ConcurrentModel(); source.setAttribute(ATTRIBUTE, concurrentModel); return () -> Optional.of(concurrentModel); } return () -> attribute; }
Example #5
Source File: GatewayHomepageControllerTest.java From api-layer with Eclipse Public License 2.0 | 5 votes |
@Test public void givenZOSMFProviderWithEmptyInstances_whenHomePageCalled_thenHomePageModelShouldContain() { when(discoveryClient.getInstances("zosmf")).thenReturn(Collections.EMPTY_LIST); authConfigurationProperties.setProvider("zosmf"); authConfigurationProperties.setZosmfServiceId("zosmf"); Model model = new ConcurrentModel(); gatewayHomepageController.home(model); Map<String, Object> actualModelMap = model.asMap(); assertThat(actualModelMap, IsMapContaining.hasEntry("authIconName", "warning")); assertThat(actualModelMap, IsMapContaining.hasEntry("authStatusText", "The Authentication service is not running")); }
Example #6
Source File: GatewayHomepageControllerTest.java From api-layer with Eclipse Public License 2.0 | 5 votes |
@Test public void givenZOSMFProviderWithNullInstances_whenHomePageCalled_thenHomePageModelShouldContain() { authConfigurationProperties.setProvider("zosmf"); authConfigurationProperties.setZosmfServiceId("zosmf"); Model model = new ConcurrentModel(); gatewayHomepageController.home(model); Map<String, Object> actualModelMap = model.asMap(); assertThat(actualModelMap, IsMapContaining.hasEntry("authIconName", "warning")); assertThat(actualModelMap, IsMapContaining.hasEntry("authStatusText", "The Authentication service is not running")); }
Example #7
Source File: GatewayHomepageControllerTest.java From api-layer with Eclipse Public License 2.0 | 5 votes |
@Test public void givenDummyProvider_whenHomePageCalled_thenHomePageModelShouldContain() { Model model = new ConcurrentModel(); gatewayHomepageController.home(model); Map<String, Object> actualModelMap = model.asMap(); assertThat(actualModelMap, IsMapContaining.hasEntry("authIconName", "success")); assertThat(actualModelMap, IsMapContaining.hasEntry("authStatusText", "The Authentication service is running")); }
Example #8
Source File: GatewayHomepageControllerTest.java From api-layer with Eclipse Public License 2.0 | 5 votes |
@Test public void givenDiscoveryServiceWithMoreThanOneInstance_whenHomePageCalled_thenHomePageModelShouldContain() { ServiceInstance serviceInstance = new DefaultServiceInstance("instanceId", "serviceId", "host", 10000, true); when(discoveryClient.getInstances("discovery")).thenReturn(Arrays.asList(serviceInstance, serviceInstance)); Model model = new ConcurrentModel(); gatewayHomepageController.home(model); Map<String, Object> actualModelMap = model.asMap(); assertThat(actualModelMap, IsMapContaining.hasEntry("discoveryIconName", "success")); assertThat(actualModelMap, IsMapContaining.hasEntry("discoveryStatusText", "2 Discovery Service instances are running")); }
Example #9
Source File: GatewayHomepageControllerTest.java From api-layer with Eclipse Public License 2.0 | 5 votes |
@Test public void givenDiscoveryServiceWithOneInstance_whenHomePageCalled_thenHomePageModelShouldContain() { ServiceInstance serviceInstance = new DefaultServiceInstance("instanceId", "serviceId", "host", 10000, true); when(discoveryClient.getInstances("discovery")).thenReturn(Arrays.asList(serviceInstance)); Model model = new ConcurrentModel(); gatewayHomepageController.home(model); Map<String, Object> actualModelMap = model.asMap(); assertThat(actualModelMap, IsMapContaining.hasEntry("discoveryIconName", "success")); assertThat(actualModelMap, IsMapContaining.hasEntry("discoveryStatusText", "The Discovery Service is running")); }
Example #10
Source File: GatewayHomepageControllerTest.java From api-layer with Eclipse Public License 2.0 | 5 votes |
@Test public void givenDiscoveryServiceWithEmptyInstances_whenHomePageCalled_thenHomePageModelShouldContain() { when(discoveryClient.getInstances("apicatalog")).thenReturn(Collections.EMPTY_LIST); Model model = new ConcurrentModel(); gatewayHomepageController.home(model); Map<String, Object> actualModelMap = model.asMap(); assertThat(actualModelMap, IsMapContaining.hasEntry("discoveryIconName", "danger")); assertThat(actualModelMap, IsMapContaining.hasEntry("discoveryStatusText", "The Discovery Service is not running")); }
Example #11
Source File: GatewayHomepageControllerTest.java From api-layer with Eclipse Public License 2.0 | 5 votes |
@Test public void givenDiscoveryServiceWithNullInstances_whenHomePageCalled_thenHomePageModelShouldContain() { Model model = new ConcurrentModel(); gatewayHomepageController.home(model); Map<String, Object> actualModelMap = model.asMap(); assertThat(actualModelMap, IsMapContaining.hasEntry("discoveryIconName", "danger")); assertThat(actualModelMap, IsMapContaining.hasEntry("discoveryStatusText", "The Discovery Service is not running")); }
Example #12
Source File: GatewayHomepageControllerTest.java From api-layer with Eclipse Public License 2.0 | 5 votes |
@Test public void givenApiCatalogWithEmptyInstances_whenHomePageCalled_thenHomePageModelShouldContain() { discoveryReturnValidZosmfAuthorizationInstance(); when(discoveryClient.getInstances(API_CATALOG_ID)).thenReturn(Collections.EMPTY_LIST); Model model = new ConcurrentModel(); gatewayHomepageController.home(model); assertCatalogIsDownMessageShown(model.asMap()); }
Example #13
Source File: GatewayHomepageControllerTest.java From api-layer with Eclipse Public License 2.0 | 5 votes |
@Test public void givenApiCatalogWithEmptyInstancesWithEmptyAuthService_whenHomePageCalled_thenHomePageModelShouldBeReportedDown() { when(discoveryClient.getInstances(API_CATALOG_ID)).thenReturn(Collections.EMPTY_LIST); when(discoveryClient.getInstances(AUTHORIZATION_SERVICE_ID)).thenReturn(Collections.EMPTY_LIST); Model model = new ConcurrentModel(); gatewayHomepageController.home(model); assertCatalogIsDownMessageShown(model.asMap()); }
Example #14
Source File: GatewayHomepageControllerTest.java From api-layer with Eclipse Public License 2.0 | 5 votes |
@Test public void givenApiCatalogInstanceWithEmptyAuthService_whenHomePageCalled_thenHomePageModelShouldBeReportedDown() { discoveryReturnValidApiCatalog(); when(discoveryClient.getInstances(AUTHORIZATION_SERVICE_ID)).thenReturn(Collections.EMPTY_LIST); Model model = new ConcurrentModel(); gatewayHomepageController.home(model); assertCatalogIsDownMessageShown(model.asMap()); }
Example #15
Source File: GatewayHomepageControllerTest.java From api-layer with Eclipse Public License 2.0 | 5 votes |
@Test public void givenApiCatalogWithNullInstances_whenHomePageCalled_thenHomePageModelShouldContain() { Model model = new ConcurrentModel(); gatewayHomepageController.home(model); assertCatalogIsDownMessageShown(model.asMap()); }
Example #16
Source File: GatewayHomepageControllerTest.java From api-layer with Eclipse Public License 2.0 | 5 votes |
@Test public void givenBuildVersionNull_whenHomePageCalled_thenBuildInfoShouldStaticText() { Model model = new ConcurrentModel(); gatewayHomepageController.home(model); Map<String, Object> actualModelMap = model.asMap(); assertThat(actualModelMap, IsMapContaining.hasEntry("buildInfoText", "Build information is not available")); }
Example #17
Source File: ViewResolutionResultHandlerTests.java From spring-analysis-note with MIT License | 4 votes |
@Test public void handleReturnValueTypes() { Object returnValue; MethodParameter returnType; ViewResolver resolver = new TestViewResolver("account"); returnType = on(Handler.class).resolveReturnType(View.class); returnValue = new TestView("account"); testHandle("/path", returnType, returnValue, "account: {id=123}"); returnType = on(Handler.class).resolveReturnType(Mono.class, View.class); returnValue = Mono.just(new TestView("account")); testHandle("/path", returnType, returnValue, "account: {id=123}"); returnType = on(Handler.class).annotNotPresent(ModelAttribute.class).resolveReturnType(String.class); returnValue = "account"; testHandle("/path", returnType, returnValue, "account: {id=123}", resolver); returnType = on(Handler.class).annotPresent(ModelAttribute.class).resolveReturnType(String.class); returnValue = "123"; testHandle("/account", returnType, returnValue, "account: {id=123, myString=123}", resolver); returnType = on(Handler.class).resolveReturnType(Mono.class, String.class); returnValue = Mono.just("account"); testHandle("/path", returnType, returnValue, "account: {id=123}", resolver); returnType = on(Handler.class).resolveReturnType(Model.class); returnValue = new ConcurrentModel().addAttribute("name", "Joe").addAttribute("ignore", null); testHandle("/account", returnType, returnValue, "account: {id=123, name=Joe}", resolver); // Work around caching issue... ResolvableType.clearCache(); returnType = on(Handler.class).annotNotPresent(ModelAttribute.class).resolveReturnType(Map.class); returnValue = Collections.singletonMap("name", "Joe"); testHandle("/account", returnType, returnValue, "account: {id=123, name=Joe}", resolver); // Work around caching issue... ResolvableType.clearCache(); returnType = on(Handler.class).annotPresent(ModelAttribute.class).resolveReturnType(Map.class); returnValue = Collections.singletonMap("name", "Joe"); testHandle("/account", returnType, returnValue, "account: {id=123, myMap={name=Joe}}", resolver); returnType = on(Handler.class).resolveReturnType(TestBean.class); returnValue = new TestBean("Joe"); String responseBody = "account: {id=123, " + "org.springframework.validation.BindingResult.testBean=" + "org.springframework.validation.BeanPropertyBindingResult: 0 errors, " + "testBean=TestBean[name=Joe]}"; testHandle("/account", returnType, returnValue, responseBody, resolver); returnType = on(Handler.class).annotPresent(ModelAttribute.class).resolveReturnType(Long.class); testHandle("/account", returnType, 99L, "account: {id=123, myLong=99}", resolver); returnType = on(Handler.class).resolveReturnType(Rendering.class); HttpStatus status = HttpStatus.UNPROCESSABLE_ENTITY; returnValue = Rendering.view("account").modelAttribute("a", "a1").status(status).header("h", "h1").build(); String expected = "account: {a=a1, id=123}"; ServerWebExchange exchange = testHandle("/path", returnType, returnValue, expected, resolver); assertEquals(status, exchange.getResponse().getStatusCode()); assertEquals("h1", exchange.getResponse().getHeaders().getFirst("h")); }
Example #18
Source File: GatewayHomepageControllerTest.java From api-layer with Eclipse Public License 2.0 | 4 votes |
@Test public void givenBuildInfo_whenHomePageCalled_thenHomePageShouldReturnHomeLiteral() { String redirectedPage = gatewayHomepageController.home(new ConcurrentModel()); assertEquals("home", redirectedPage, "Expected page is not 'home'"); }
Example #19
Source File: ViewResolutionResultHandlerTests.java From java-technology-stack with MIT License | 4 votes |
@Test public void handleReturnValueTypes() { Object returnValue; MethodParameter returnType; ViewResolver resolver = new TestViewResolver("account"); returnType = on(Handler.class).resolveReturnType(View.class); returnValue = new TestView("account"); testHandle("/path", returnType, returnValue, "account: {id=123}"); returnType = on(Handler.class).resolveReturnType(Mono.class, View.class); returnValue = Mono.just(new TestView("account")); testHandle("/path", returnType, returnValue, "account: {id=123}"); returnType = on(Handler.class).annotNotPresent(ModelAttribute.class).resolveReturnType(String.class); returnValue = "account"; testHandle("/path", returnType, returnValue, "account: {id=123}", resolver); returnType = on(Handler.class).annotPresent(ModelAttribute.class).resolveReturnType(String.class); returnValue = "123"; testHandle("/account", returnType, returnValue, "account: {id=123, myString=123}", resolver); returnType = on(Handler.class).resolveReturnType(Mono.class, String.class); returnValue = Mono.just("account"); testHandle("/path", returnType, returnValue, "account: {id=123}", resolver); returnType = on(Handler.class).resolveReturnType(Model.class); returnValue = new ConcurrentModel().addAttribute("name", "Joe").addAttribute("ignore", null); testHandle("/account", returnType, returnValue, "account: {id=123, name=Joe}", resolver); // Work around caching issue... ResolvableType.clearCache(); returnType = on(Handler.class).annotNotPresent(ModelAttribute.class).resolveReturnType(Map.class); returnValue = Collections.singletonMap("name", "Joe"); testHandle("/account", returnType, returnValue, "account: {id=123, name=Joe}", resolver); // Work around caching issue... ResolvableType.clearCache(); returnType = on(Handler.class).annotPresent(ModelAttribute.class).resolveReturnType(Map.class); returnValue = Collections.singletonMap("name", "Joe"); testHandle("/account", returnType, returnValue, "account: {id=123, myMap={name=Joe}}", resolver); returnType = on(Handler.class).resolveReturnType(TestBean.class); returnValue = new TestBean("Joe"); String responseBody = "account: {id=123, " + "org.springframework.validation.BindingResult.testBean=" + "org.springframework.validation.BeanPropertyBindingResult: 0 errors, " + "testBean=TestBean[name=Joe]}"; testHandle("/account", returnType, returnValue, responseBody, resolver); returnType = on(Handler.class).annotPresent(ModelAttribute.class).resolveReturnType(Long.class); testHandle("/account", returnType, 99L, "account: {id=123, myLong=99}", resolver); returnType = on(Handler.class).resolveReturnType(Rendering.class); HttpStatus status = HttpStatus.UNPROCESSABLE_ENTITY; returnValue = Rendering.view("account").modelAttribute("a", "a1").status(status).header("h", "h1").build(); String expected = "account: {a=a1, id=123}"; ServerWebExchange exchange = testHandle("/path", returnType, returnValue, expected, resolver); assertEquals(status, exchange.getResponse().getStatusCode()); assertEquals("h1", exchange.getResponse().getHeaders().getFirst("h")); }