1
1
/*
2
- * Copyright 2002-2022 the original author or authors.
2
+ * Copyright 2002-2024 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
31
31
32
32
/**
33
33
* @author Markus Heiden
34
- * @since 5.8
34
+ * @since 6.3
35
35
*/
36
- public class SwitchUserGrantedAuthorityMixInTest extends AbstractMixinTests {
36
+ public class SwitchUserGrantedAuthorityMixInTests extends AbstractMixinTests {
37
37
38
38
// language=JSON
39
39
private static final String SWITCH_JSON = """
@@ -50,25 +50,24 @@ public class SwitchUserGrantedAuthorityMixInTest extends AbstractMixinTests {
50
50
}
51
51
}
52
52
""" .formatted (SimpleGrantedAuthorityMixinTests .AUTHORITIES_ARRAYLIST_JSON );
53
- SwitchUserGrantedAuthority expected ;
54
53
55
- Authentication source ;
54
+ private Authentication source ;
56
55
57
56
@ BeforeEach
58
- public void setupExpected () {
57
+ public void setUp () {
59
58
this .source = new UsernamePasswordAuthenticationToken ("principal" , "credentials" ,
60
59
AuthorityUtils .createAuthorityList ("ROLE_USER" ));
61
- this .expected = new SwitchUserGrantedAuthority ("switched" , this .source );
62
60
}
63
61
64
62
@ Test
65
63
public void serializeWhenPrincipalCredentialsAuthoritiesThenSuccess () throws Exception {
66
- String serializedJson = this .mapper .writeValueAsString (this .expected );
64
+ SwitchUserGrantedAuthority expected = new SwitchUserGrantedAuthority ("switched" , this .source );
65
+ String serializedJson = this .mapper .writeValueAsString (expected );
67
66
JSONAssert .assertEquals (SWITCH_JSON , serializedJson , true );
68
67
}
69
68
70
69
@ Test
71
- public void deserializeAuthenticatedUsernamePasswordAuthenticationTokenMixinTest () throws Exception {
70
+ public void deserializeWhenSourceIsUsernamePasswordAuthenticationTokenThenSuccess () throws Exception {
72
71
SwitchUserGrantedAuthority deserialized = this .mapper .readValue (SWITCH_JSON , SwitchUserGrantedAuthority .class );
73
72
assertThat (deserialized ).isNotNull ();
74
73
assertThat (deserialized .getAuthority ()).isEqualTo ("switched" );
0 commit comments