@@ -29,55 +29,28 @@ void tearDown() {
2929 }
3030
3131 @ Nested
32- @ DisplayName ("Test method: setLocaleContext and getLocaleContext " )
32+ @ DisplayName ("Test method: setLocale and getLocale " )
3333 class TestSetAndGetLocaleContext {
3434 @ Test
35- @ DisplayName ("Given locale context with zh_CN then return the same locale context " )
35+ @ DisplayName ("Given locale with zh_CN then return the same locale" )
3636 void givenLocaleContextWithZhCNThenReturnSameLocaleContext () {
37- LocaleContext localeContext = new LocaleContext ( Locale .SIMPLIFIED_CHINESE ) ;
38- LocaleContextHolder .setLocaleContext ( localeContext );
39- assertThat (LocaleContextHolder .getLocaleContext ()).isEqualTo (localeContext );
37+ Locale locale = Locale .SIMPLIFIED_CHINESE ;
38+ LocaleContextHolder .setLocale ( locale );
39+ assertThat (LocaleContextHolder .getLocale ()).isEqualTo (locale );
4040 }
4141
4242 @ Test
43- @ DisplayName ("Given locale context with en_US then return the same locale context " )
43+ @ DisplayName ("Given locale with en_US then return the same locale" )
4444 void givenLocaleContextWithEnUSThenReturnSameLocaleContext () {
45- LocaleContext localeContext = new LocaleContext ( Locale .US ) ;
46- LocaleContextHolder .setLocaleContext ( localeContext );
47- assertThat (LocaleContextHolder .getLocaleContext ()).isEqualTo (localeContext );
45+ Locale locale = Locale .US ;
46+ LocaleContextHolder .setLocale ( locale );
47+ assertThat (LocaleContextHolder .getLocale ()).isEqualTo (locale );
4848 }
4949
5050 @ Test
51- @ DisplayName ("Given null locale context then not set and return null" )
51+ @ DisplayName ("Given null locale then not set and return null" )
5252 void givenNullLocaleContextThenReturnNull () {
53- LocaleContextHolder .setLocaleContext (null );
54- assertThat (LocaleContextHolder .getLocaleContext ()).isNull ();
55- }
56- }
57-
58- @ Nested
59- @ DisplayName ("Test method: getLocale" )
60- class TestGetLocale {
61- @ Test
62- @ DisplayName ("Given locale context with zh_CN then return zh_CN locale" )
63- void givenLocaleContextWithZhCNThenReturnZhCNLocale () {
64- LocaleContext localeContext = new LocaleContext (Locale .SIMPLIFIED_CHINESE );
65- LocaleContextHolder .setLocaleContext (localeContext );
66- assertThat (LocaleContextHolder .getLocale ()).isEqualTo (Locale .SIMPLIFIED_CHINESE );
67- }
68-
69- @ Test
70- @ DisplayName ("Given locale context with en_US then return en_US locale" )
71- void givenLocaleContextWithEnUSThenReturnEnUSLocale () {
72- LocaleContext localeContext = new LocaleContext (Locale .US );
73- LocaleContextHolder .setLocaleContext (localeContext );
74- assertThat (LocaleContextHolder .getLocale ()).isEqualTo (Locale .US );
75- }
76-
77- @ Test
78- @ DisplayName ("Given no locale context then return null" )
79- void givenNoLocaleContextThenReturnNull () {
80- LocaleContextHolder .clear ();
53+ LocaleContextHolder .setLocale (null );
8154 assertThat (LocaleContextHolder .getLocale ()).isNull ();
8255 }
8356 }
@@ -86,14 +59,14 @@ void givenNoLocaleContextThenReturnNull() {
8659 @ DisplayName ("Test method: clear" )
8760 class TestClear {
8861 @ Test
89- @ DisplayName ("Given existing locale context then clear it" )
62+ @ DisplayName ("Given existing locale then clear it" )
9063 void givenExistingLocaleContextThenClearIt () {
91- LocaleContext localeContext = new LocaleContext ( Locale .SIMPLIFIED_CHINESE ) ;
92- LocaleContextHolder .setLocaleContext ( localeContext );
93- assertThat (LocaleContextHolder .getLocaleContext ()).isNotNull ();
64+ Locale locale = Locale .SIMPLIFIED_CHINESE ;
65+ LocaleContextHolder .setLocale ( locale );
66+ assertThat (LocaleContextHolder .getLocale ()).isNotNull ();
9467
9568 LocaleContextHolder .clear ();
96- assertThat (LocaleContextHolder .getLocaleContext ()).isNull ();
69+ assertThat (LocaleContextHolder .getLocale ()).isNull ();
9770 }
9871 }
9972}
0 commit comments