Skip to content

Commit 70bab2b

Browse files
committed
test: remove redundant casts after generic proxy method
Signed-off-by: dae won <[email protected]>
1 parent d5004cb commit 70bab2b

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -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/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)