Skip to content

Commit 07a8e30

Browse files
committed
test: remove redundant casts after generic proxy method
Signed-off-by: dae won <eodnjs01477@gmail.com>
1 parent d5004cb commit 07a8e30

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

config/src/test/java/org/springframework/security/config/annotation/method/configuration/AuthorizationProxyConfigurationTests.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 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.
@@ -58,7 +58,7 @@ public class AuthorizationProxyConfigurationTests {
5858
@Test
5959
public void proxyWhenNotPreAuthorizedThenDenies() {
6060
this.spring.register(DefaultsConfig.class).autowire();
61-
Toaster toaster = (Toaster) this.proxyFactory.proxy(new Toaster());
61+
Toaster toaster = this.proxyFactory.proxy(new Toaster());
6262
assertThatExceptionOfType(AccessDeniedException.class).isThrownBy(toaster::makeToast)
6363
.withMessage("Access Denied");
6464
assertThatExceptionOfType(AccessDeniedException.class).isThrownBy(toaster::extractBread)
@@ -69,15 +69,15 @@ public void proxyWhenNotPreAuthorizedThenDenies() {
6969
@Test
7070
public void proxyWhenPreAuthorizedThenAllows() {
7171
this.spring.register(DefaultsConfig.class).autowire();
72-
Toaster toaster = (Toaster) this.proxyFactory.proxy(new Toaster());
72+
Toaster toaster = this.proxyFactory.proxy(new Toaster());
7373
toaster.makeToast();
7474
assertThat(toaster.extractBread()).isEqualTo("yummy");
7575
}
7676

7777
@Test
7878
public void proxyReactiveWhenNotPreAuthorizedThenDenies() {
7979
this.spring.register(ReactiveDefaultsConfig.class).autowire();
80-
Toaster toaster = (Toaster) this.proxyFactory.proxy(new Toaster());
80+
Toaster toaster = this.proxyFactory.proxy(new Toaster());
8181
Authentication user = TestAuthentication.authenticatedUser();
8282
StepVerifier
8383
.create(toaster.reactiveMakeToast().contextWrite(ReactiveSecurityContextHolder.withAuthentication(user)))
@@ -90,7 +90,7 @@ public void proxyReactiveWhenNotPreAuthorizedThenDenies() {
9090
@Test
9191
public void proxyReactiveWhenPreAuthorizedThenAllows() {
9292
this.spring.register(ReactiveDefaultsConfig.class).autowire();
93-
Toaster toaster = (Toaster) this.proxyFactory.proxy(new Toaster());
93+
Toaster toaster = this.proxyFactory.proxy(new Toaster());
9494
Authentication admin = TestAuthentication.authenticatedAdmin();
9595
StepVerifier
9696
.create(toaster.reactiveMakeToast().contextWrite(ReactiveSecurityContextHolder.withAuthentication(admin)))

core/src/main/java/org/springframework/security/aot/hint/AuthorizeReturnObjectHintsRegistrar.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 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.

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 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.

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ public void setTargetVisitorThenUses() {
335335
@Test
336336
public void setTargetVisitorIgnoreValueTypesThenIgnores() {
337337
AuthorizationAdvisorProxyFactory factory = AuthorizationAdvisorProxyFactory.withDefaults();
338-
assertThatExceptionOfType(ClassCastException.class).isThrownBy(() -> ((Integer) factory.proxy(35)).intValue());
338+
assertThatExceptionOfType(ClassCastException.class).isThrownBy(() -> factory.proxy(35).intValue());
339339
factory.setTargetVisitor(TargetVisitor.defaultsSkipValueTypes());
340340
assertThat(factory.proxy(35)).isEqualTo(35);
341341
}

0 commit comments

Comments
 (0)