Skip to content

Commit

Permalink
Minor touch ups
Browse files Browse the repository at this point in the history
  • Loading branch information
timtebeek committed Aug 16, 2024
1 parent 56f12f6 commit 8b09852
Showing 1 changed file with 17 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@
package org.openrewrite.spring.security5;

import org.junit.jupiter.api.Test;
import org.openrewrite.DocumentExample;
import org.openrewrite.java.JavaParser;
import org.openrewrite.test.RecipeSpec;
import org.openrewrite.test.RewriteTest;

import static org.openrewrite.java.Assertions.java;

public class MigrateTo6_1Test implements RewriteTest {
class UpgradeSpringSecurity61Test implements RewriteTest {

@Override
public void defaults(RecipeSpec spec) {
Expand All @@ -31,10 +32,12 @@ public void defaults(RecipeSpec spec) {
.classpath("spring-security", "spring-web", "tomcat-embed", "spring-context", "spring-beans"));
}

@DocumentExample
@Test
void test_1() {
void shouldRetainAntMatchers() {
//language=java
rewriteRun(
spec -> spec.expectedCyclesThatMakeChanges(2),
java(
"""
import org.springframework.http.HttpMethod;
Expand All @@ -44,8 +47,7 @@ void test_1() {
import org.springframework.security.web.SecurityFilterChain;
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
http
Expand All @@ -56,16 +58,16 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
return http.build();
}
}
""", """
""",
"""
import org.springframework.http.HttpMethod;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.web.SecurityFilterChain;
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
http
Expand All @@ -81,9 +83,10 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
}

@Test
void test_2() {
void shouldRetainChainOfAntMatchers() {
//language=java
rewriteRun(
spec -> spec.expectedCyclesThatMakeChanges(2),
java(
"""
import org.springframework.http.HttpMethod;
Expand All @@ -93,8 +96,7 @@ void test_2() {
import org.springframework.security.web.SecurityFilterChain;
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
http
Expand All @@ -110,18 +112,18 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
return http.build();
}
}
""", """
""",
"""
import org.springframework.http.HttpMethod;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.web.SecurityFilterChain;
import static org.springframework.security.config.Customizer.withDefaults;
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
http
Expand Down

0 comments on commit 8b09852

Please sign in to comment.