11/*
2- * Copyright 2002-2023 the original author or authors.
2+ * Copyright 2002-2024 the original author or authors.
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
5151 *
5252 * @author Rossen Stoyanchev
5353 */
54- public class ModelFactoryTests {
54+ class ModelFactoryTests {
5555
5656 private NativeWebRequest webRequest ;
5757
@@ -65,7 +65,7 @@ public class ModelFactoryTests {
6565
6666
6767 @ BeforeEach
68- public void setUp () throws Exception {
68+ void setup () {
6969 this .webRequest = new ServletWebRequest (new MockHttpServletRequest ());
7070 this .attributeStore = new DefaultSessionAttributeStore ();
7171 this .attributeHandler = new SessionAttributesHandler (TestController .class , this .attributeStore );
@@ -75,7 +75,7 @@ public void setUp() throws Exception {
7575
7676
7777 @ Test
78- public void modelAttributeMethod () throws Exception {
78+ void modelAttributeMethod () throws Exception {
7979 ModelFactory modelFactory = createModelFactory ("modelAttr" , Model .class );
8080 HandlerMethod handlerMethod = createHandlerMethod ("handle" );
8181 modelFactory .initModel (this .webRequest , this .mavContainer , handlerMethod );
@@ -84,7 +84,7 @@ public void modelAttributeMethod() throws Exception {
8484 }
8585
8686 @ Test
87- public void modelAttributeMethodWithExplicitName () throws Exception {
87+ void modelAttributeMethodWithExplicitName () throws Exception {
8888 ModelFactory modelFactory = createModelFactory ("modelAttrWithName" );
8989 HandlerMethod handlerMethod = createHandlerMethod ("handle" );
9090 modelFactory .initModel (this .webRequest , this .mavContainer , handlerMethod );
@@ -93,7 +93,7 @@ public void modelAttributeMethodWithExplicitName() throws Exception {
9393 }
9494
9595 @ Test
96- public void modelAttributeMethodWithNameByConvention () throws Exception {
96+ void modelAttributeMethodWithNameByConvention () throws Exception {
9797 ModelFactory modelFactory = createModelFactory ("modelAttrConvention" );
9898 HandlerMethod handlerMethod = createHandlerMethod ("handle" );
9999 modelFactory .initModel (this .webRequest , this .mavContainer , handlerMethod );
@@ -102,7 +102,7 @@ public void modelAttributeMethodWithNameByConvention() throws Exception {
102102 }
103103
104104 @ Test
105- public void modelAttributeMethodWithNullReturnValue () throws Exception {
105+ void modelAttributeMethodWithNullReturnValue () throws Exception {
106106 ModelFactory modelFactory = createModelFactory ("nullModelAttr" );
107107 HandlerMethod handlerMethod = createHandlerMethod ("handle" );
108108 modelFactory .initModel (this .webRequest , this .mavContainer , handlerMethod );
@@ -112,7 +112,7 @@ public void modelAttributeMethodWithNullReturnValue() throws Exception {
112112 }
113113
114114 @ Test
115- public void modelAttributeWithBindingDisabled () throws Exception {
115+ void modelAttributeWithBindingDisabled () throws Exception {
116116 ModelFactory modelFactory = createModelFactory ("modelAttrWithBindingDisabled" );
117117 HandlerMethod handlerMethod = createHandlerMethod ("handle" );
118118 modelFactory .initModel (this .webRequest , this .mavContainer , handlerMethod );
@@ -122,7 +122,7 @@ public void modelAttributeWithBindingDisabled() throws Exception {
122122 }
123123
124124 @ Test
125- public void modelAttributeFromSessionWithBindingDisabled () throws Exception {
125+ void modelAttributeFromSessionWithBindingDisabled () throws Exception {
126126 Foo foo = new Foo ();
127127 this .attributeStore .storeAttribute (this .webRequest , "foo" , foo );
128128
@@ -136,7 +136,7 @@ public void modelAttributeFromSessionWithBindingDisabled() throws Exception {
136136 }
137137
138138 @ Test
139- public void sessionAttribute () throws Exception {
139+ void sessionAttribute () throws Exception {
140140 this .attributeStore .storeAttribute (this .webRequest , "sessionAttr" , "sessionAttrValue" );
141141
142142 ModelFactory modelFactory = createModelFactory ("modelAttr" , Model .class );
@@ -147,21 +147,20 @@ public void sessionAttribute() throws Exception {
147147 }
148148
149149 @ Test
150- public void sessionAttributeNotPresent () throws Exception {
150+ void sessionAttributeNotPresent () throws Exception {
151151 ModelFactory modelFactory = new ModelFactory (null , null , this .attributeHandler );
152152 HandlerMethod handlerMethod = createHandlerMethod ("handleSessionAttr" , String .class );
153153 assertThatExceptionOfType (HttpSessionRequiredException .class ).isThrownBy (() ->
154154 modelFactory .initModel (this .webRequest , this .mavContainer , handlerMethod ));
155155
156156 // Now add attribute and try again
157157 this .attributeStore .storeAttribute (this .webRequest , "sessionAttr" , "sessionAttrValue" );
158-
159158 modelFactory .initModel (this .webRequest , this .mavContainer , handlerMethod );
160159 assertThat (this .mavContainer .getModel ().get ("sessionAttr" )).isEqualTo ("sessionAttrValue" );
161160 }
162161
163162 @ Test
164- public void updateModelBindingResult () throws Exception {
163+ void updateModelBindingResult () throws Exception {
165164 String commandName = "attr1" ;
166165 Object command = new Object ();
167166 ModelAndViewContainer container = new ModelAndViewContainer ();
@@ -181,7 +180,7 @@ public void updateModelBindingResult() throws Exception {
181180 }
182181
183182 @ Test
184- public void updateModelSessionAttributesSaved () throws Exception {
183+ void updateModelSessionAttributesSaved () throws Exception {
185184 String attributeName = "sessionAttr" ;
186185 String attribute = "value" ;
187186 ModelAndViewContainer container = new ModelAndViewContainer ();
@@ -199,7 +198,7 @@ public void updateModelSessionAttributesSaved() throws Exception {
199198 }
200199
201200 @ Test
202- public void updateModelSessionAttributesRemoved () throws Exception {
201+ void updateModelSessionAttributesRemoved () throws Exception {
203202 String attributeName = "sessionAttr" ;
204203 String attribute = "value" ;
205204 ModelAndViewContainer container = new ModelAndViewContainer ();
@@ -221,7 +220,7 @@ public void updateModelSessionAttributesRemoved() throws Exception {
221220 }
222221
223222 @ Test // SPR-12542
224- public void updateModelWhenRedirecting () throws Exception {
223+ void updateModelWhenRedirecting () throws Exception {
225224 String attributeName = "sessionAttr" ;
226225 String attribute = "value" ;
227226 ModelAndViewContainer container = new ModelAndViewContainer ();
@@ -286,7 +285,7 @@ public Boolean nullModelAttr() {
286285 return null ;
287286 }
288287
289- @ ModelAttribute (name = "foo" , binding = false )
288+ @ ModelAttribute (name = "foo" , binding = false )
290289 public Foo modelAttrWithBindingDisabled () {
291290 return new Foo ();
292291 }
0 commit comments