11/*
2- * Copyright 2002-2022 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.
3131
3232/**
3333 * @author Markus Heiden
34- * @since 5.8
34+ * @since 6.3
3535 */
36- public class SwitchUserGrantedAuthorityMixInTest extends AbstractMixinTests {
36+ public class SwitchUserGrantedAuthorityMixInTests extends AbstractMixinTests {
3737
3838 // language=JSON
3939 private static final String SWITCH_JSON = """
@@ -50,25 +50,24 @@ public class SwitchUserGrantedAuthorityMixInTest extends AbstractMixinTests {
5050 }
5151 }
5252 """ .formatted (SimpleGrantedAuthorityMixinTests .AUTHORITIES_ARRAYLIST_JSON );
53- SwitchUserGrantedAuthority expected ;
5453
55- Authentication source ;
54+ private Authentication source ;
5655
5756 @ BeforeEach
58- public void setupExpected () {
57+ public void setUp () {
5958 this .source = new UsernamePasswordAuthenticationToken ("principal" , "credentials" ,
6059 AuthorityUtils .createAuthorityList ("ROLE_USER" ));
61- this .expected = new SwitchUserGrantedAuthority ("switched" , this .source );
6260 }
6361
6462 @ Test
6563 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 );
6766 JSONAssert .assertEquals (SWITCH_JSON , serializedJson , true );
6867 }
6968
7069 @ Test
71- public void deserializeAuthenticatedUsernamePasswordAuthenticationTokenMixinTest () throws Exception {
70+ public void deserializeWhenSourceIsUsernamePasswordAuthenticationTokenThenSuccess () throws Exception {
7271 SwitchUserGrantedAuthority deserialized = this .mapper .readValue (SWITCH_JSON , SwitchUserGrantedAuthority .class );
7372 assertThat (deserialized ).isNotNull ();
7473 assertThat (deserialized .getAuthority ()).isEqualTo ("switched" );
0 commit comments