Skip to content

Commit 607e40d

Browse files
committed
Polish ObservationConvention Configuration
Change to setObservationConvention so that it reads more clearly when used, for example `authenticationManager.setObservationConvention` is clearer than `authenticationManager.setConvention`. Change unit test names to follow team conventions. Issue gh-12534
1 parent f1b14de commit 607e40d

8 files changed

+16
-12
lines changed

core/src/main/java/org/springframework/security/authentication/ObservationAuthenticationManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public Authentication authenticate(Authentication authentication) throws Authent
6363
*
6464
* @since 6.1
6565
*/
66-
public void setConvention(ObservationConvention<AuthenticationObservationContext> convention) {
66+
public void setObservationConvention(ObservationConvention<AuthenticationObservationContext> convention) {
6767
Assert.notNull(convention, "The observation convention cannot be null");
6868
this.convention = convention;
6969
}

core/src/main/java/org/springframework/security/authentication/ObservationReactiveAuthenticationManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public Mono<Authentication> authenticate(Authentication authentication) throws A
7070
*
7171
* @since 6.1
7272
*/
73-
public void setConvention(ObservationConvention<AuthenticationObservationContext> convention) {
73+
public void setObservationConvention(ObservationConvention<AuthenticationObservationContext> convention) {
7474
Assert.notNull(convention, "The observation convention cannot be null");
7575
this.convention = convention;
7676
}

core/src/main/java/org/springframework/security/authorization/ObservationAuthorizationManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public AuthorizationDecision check(Supplier<Authentication> authentication, T ob
7676
*
7777
* @since 6.1
7878
*/
79-
public void setConvention(ObservationConvention<AuthorizationObservationContext<?>> convention) {
79+
public void setObservationConvention(ObservationConvention<AuthorizationObservationContext<?>> convention) {
8080
Assert.notNull(convention, "The observation convention cannot be null");
8181
this.convention = convention;
8282
}

core/src/main/java/org/springframework/security/authorization/ObservationReactiveAuthorizationManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public Mono<AuthorizationDecision> check(Mono<Authentication> authentication, T
7575
*
7676
* @since 6.1
7777
*/
78-
public void setConvention(ObservationConvention<AuthorizationObservationContext<?>> convention) {
78+
public void setObservationConvention(ObservationConvention<AuthorizationObservationContext<?>> convention) {
7979
Assert.notNull(convention, "The observation convention cannot be null");
8080
this.convention = convention;
8181
}

core/src/test/java/org/springframework/security/authentication/ObservationAuthenticationManagerTests.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,9 @@ void authenticationWhenErrorsThenObserves() {
9494
}
9595

9696
@Test
97-
void conventionSetterThrowsWhenNull() {
98-
assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(() -> this.tested.setConvention(null));
97+
void setObservationConventionWhenNullThenException() {
98+
assertThatExceptionOfType(IllegalArgumentException.class)
99+
.isThrownBy(() -> this.tested.setObservationConvention(null));
99100
}
100101

101102
}

core/src/test/java/org/springframework/security/authentication/ObservationReactiveAuthenticationManagerTests.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,9 @@ void authenticationWhenErrorsThenObserves() {
9797
}
9898

9999
@Test
100-
void conventionSetterThrowsWhenNull() {
101-
assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(() -> this.tested.setConvention(null));
100+
void setObservationConventionWhenNullThenException() {
101+
assertThatExceptionOfType(IllegalArgumentException.class)
102+
.isThrownBy(() -> this.tested.setObservationConvention(null));
102103
}
103104

104105
}

core/src/test/java/org/springframework/security/authorization/ObservationAuthorizationManagerTests.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,9 @@ void verifyWhenLooksUpAuthenticationThenObserves() {
119119
}
120120

121121
@Test
122-
void conventionSetterThrowsWhenNull() {
123-
assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(() -> this.tested.setConvention(null));
122+
void setObservationConventionWhenNullThenException() {
123+
assertThatExceptionOfType(IllegalArgumentException.class)
124+
.isThrownBy(() -> this.tested.setObservationConvention(null));
124125
}
125126

126127
}

core/src/test/java/org/springframework/security/authorization/ObservationReactiveAuthorizationManagerTests.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,9 @@ void verifyWhenLooksUpAuthenticationThenObserves() {
118118
}
119119

120120
@Test
121-
void conventionSetterThrowsWhenNull() {
122-
assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(() -> this.tested.setConvention(null));
121+
void setObservationConventionWhenNullThenException() {
122+
assertThatExceptionOfType(IllegalArgumentException.class)
123+
.isThrownBy(() -> this.tested.setObservationConvention(null));
123124
}
124125

125126
}

0 commit comments

Comments
 (0)