-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement and test ConvertApiResponseCodesToStrings
- Loading branch information
Showing
4 changed files
with
108 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 0 additions & 41 deletions
41
src/test/java/org/openrewrite/openapi/Swagger2ToOpenApiV3MigrationTest.java
This file was deleted.
Oops, something went wrong.
60 changes: 60 additions & 0 deletions
60
src/test/java/org/openrewrite/openapi/swagger/ConvertApiResponseCodesToStringsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package org.openrewrite.openapi.swagger; | ||
|
||
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.*; | ||
|
||
class ConvertApiResponseCodesToStringsTest implements RewriteTest { | ||
@Override | ||
public void defaults(RecipeSpec spec) { | ||
spec.recipeFromResources("org.openrewrite.openapi.MigrateApiResponsesToApiResponses") | ||
.parser(JavaParser.fromJavaVersion().classpath("swagger-annotations-1.+", "swagger-annotations-2.+")); | ||
} | ||
|
||
@Test | ||
@DocumentExample | ||
void convertApiResponseCodesToStrings() { | ||
rewriteRun( | ||
//language=java | ||
java( | ||
""" | ||
import io.swagger.annotations.ApiResponse; | ||
class A { | ||
@ApiResponse(code = 200, message = "OK") | ||
void method() {} | ||
} | ||
""", | ||
""" | ||
import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
class A { | ||
@ApiResponse(responseCode = "200", description = "OK") | ||
void method() {} | ||
} | ||
""" | ||
) | ||
); | ||
} | ||
|
||
@Test | ||
void noChangeOnAlreadyConverted() { | ||
rewriteRun( | ||
//language=java | ||
java( | ||
""" | ||
import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
class A { | ||
@ApiResponse(responseCode = "200", description = "OK") | ||
void method() {} | ||
} | ||
""" | ||
) | ||
); | ||
} | ||
} |