Skip to content

Commit 54db42d

Browse files
committed
Fixing tests
1 parent 0683296 commit 54db42d

File tree

5 files changed

+36
-40
lines changed

5 files changed

+36
-40
lines changed

components/jaxrs-recipes/src/test/java/org/springframework/sbm/JaxRsThroughAdapterTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public static List<Path> getDependencyJarsForClasspath(String pom) {
130130
@Test
131131
public void simple() {
132132
rewriteRun(
133-
(spec) -> spec.expectedCyclesThatMakeChanges(1),
133+
(spec) -> spec.expectedCyclesThatMakeChanges(2),
134134
mavenProject("project",
135135
Assertions.java(
136136
//language=Java
@@ -258,7 +258,7 @@ private boolean isResponseStatusSuccessful(Response.Status.Family family) {
258258
import javax.ws.rs.core.Response;
259259
260260
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
261-
import javax.ws.rs.core.Response.Status.Family;
261+
import static javax.ws.rs.core.Response.Status.Family;
262262
263263
264264
@RestController

components/jaxrs-recipes/src/test/java/org/springframework/sbm/jee/jaxrs/actions/MigrateJaxRsAnnotations_Test.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ void convertJaxRsMethodToSpringMvc() {
4040
import com.example.jeerest.Movie;
4141
import com.example.jeerest.MoviesBean;
4242
import org.springframework.beans.factory.annotation.Autowired;
43+
import org.springframework.web.bind.annotation.RequestMapping;
44+
import org.springframework.web.bind.annotation.RequestMethod;
4345
4446
import javax.ws.rs.DELETE;
4547
import javax.ws.rs.GET;
@@ -94,7 +96,9 @@ public List<Movie> getMovies(@QueryParam("first") Integer first, @QueryParam("ma
9496
import com.example.jeerest.Movie;
9597
import com.example.jeerest.MoviesBean;
9698
import org.springframework.beans.factory.annotation.Autowired;
97-
99+
import org.springframework.web.bind.annotation.RequestMapping;
100+
import org.springframework.web.bind.annotation.RequestMethod;
101+
98102
import javax.ws.rs.DELETE;
99103
import javax.ws.rs.PUT;
100104
import javax.ws.rs.Path;

components/jaxrs-recipes/src/test/java/org/springframework/sbm/jee/jaxrs/recipes/ReplaceMediaTypeTest.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -478,9 +478,8 @@ public MediaType respond() {
478478
""";
479479

480480
String expected = """
481-
import org.springframework.http.MediaType;
482-
483481
import java.util.Map;
482+
import org.springframework.http.MediaType;
484483
485484
public class TestController {
486485
@@ -530,7 +529,6 @@ public String getHelloWorldJSON(@PathParam("name") String name) {
530529
"""
531530
import javax.ws.rs.Path;
532531
import javax.ws.rs.PathParam;
533-
534532
import org.springframework.http.MediaType;
535533
import org.springframework.web.bind.annotation.RequestMapping;
536534
import org.springframework.web.bind.annotation.RequestMethod;

components/jaxrs-recipes/src/test/java/org/springframework/sbm/jee/jaxrs/recipes/ResponseBuilderTest.java

Lines changed: 28 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ void allow() {
6262

6363
String expected = ""
6464
+ "import java.util.Set;\n"
65-
+ "\n"
6665
+ "import org.springframework.http.HttpMethod;\n"
6766
+ "import org.springframework.http.ResponseEntity;\n"
6867
+ "\n"
@@ -110,20 +109,19 @@ void expires() {
110109
+ "}\n"
111110
+ "";
112111

113-
String expected = ""
114-
+ "import org.springframework.http.ResponseEntity;\n"
115-
+ "\n"
116-
+ "import java.util.Date;\n"
117-
+ "\n"
118-
+ "public class TestController {\n"
119-
+ "\n"
120-
+ " public ResponseEntity.BodyBuilder test() {\n"
121-
+ " ResponseEntity.BodyBuilder b;\n"
122-
+ " b.headers(h -> h.setExpires(new Date(100000).toInstant()));\n"
123-
+ " return b;\n"
124-
+ " }\n"
125-
+ "}\n"
126-
+ "";
112+
String expected = """
113+
import java.util.Date;
114+
import org.springframework.http.ResponseEntity;
115+
116+
public class TestController {
117+
118+
public ResponseEntity.BodyBuilder test() {
119+
ResponseEntity.BodyBuilder b;
120+
b.headers(h -> h.setExpires(new Date(100000).toInstant()));
121+
return b;
122+
}
123+
}
124+
""";
127125

128126
ProjectContext projectContext = TestProjectContext.buildProjectContext()
129127
.withBuildFileHavingDependencies("javax:javaee-api:8.0")
@@ -156,22 +154,21 @@ void language() {
156154
+ "}\n"
157155
+ "";
158156

159-
String expected = ""
160-
+ "import java.util.Locale;\n"
161-
+ "\n"
162-
+ "import org.springframework.http.HttpHeaders;\n"
163-
+ "import org.springframework.http.ResponseEntity;\n"
164-
+ "\n"
165-
+ "public class TestController {\n"
166-
+ "\n"
167-
+ " public ResponseEntity.BodyBuilder test() {\n"
168-
+ " ResponseEntity.BodyBuilder b;\n"
169-
+ " b.headers(h -> h.set(HttpHeaders.CONTENT_LANGUAGE, \"ua\"));\n"
170-
+ " b.headers(h -> h.setContentLanguage(Locale.ITALY));\n"
171-
+ " return b;\n"
172-
+ " }\n"
173-
+ "}\n"
174-
+ "";
157+
String expected = """
158+
import java.util.Locale;
159+
import org.springframework.http.HttpHeaders;
160+
import org.springframework.http.ResponseEntity;
161+
162+
public class TestController {
163+
164+
public ResponseEntity.BodyBuilder test() {
165+
ResponseEntity.BodyBuilder b;
166+
b.headers(h -> h.set(HttpHeaders.CONTENT_LANGUAGE, "ua"));
167+
b.headers(h -> h.setContentLanguage(Locale.ITALY));
168+
return b;
169+
}
170+
}
171+
""";
175172

176173
ProjectContext projectContext = TestProjectContext.buildProjectContext()
177174
.withBuildFileHavingDependencies(

components/jaxrs-recipes/src/test/java/org/springframework/sbm/jee/jaxrs/recipes/ResponseEntityReplacementTest.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,6 @@ void created() {
509509

510510
String expected = ""
511511
+ "import org.springframework.http.ResponseEntity;\n"
512-
+ "\n"
513512
+ "import java.net.URI;\n"
514513
+ "\n"
515514
+ "public class TestController {\n"
@@ -641,7 +640,6 @@ void seeOther() {
641640
String expected = ""
642641
+ "import org.springframework.http.HttpStatus;\n"
643642
+ "import org.springframework.http.ResponseEntity;\n"
644-
+ "\n"
645643
+ "import java.net.URI;\n"
646644
+ "\n"
647645
+ "public class TestController {\n"
@@ -730,7 +728,6 @@ void temporaryRedirect() {
730728
String expected = ""
731729
+ "import org.springframework.http.HttpStatus;\n"
732730
+ "import org.springframework.http.ResponseEntity;\n"
733-
+ "\n"
734731
+ "import java.net.URI;\n"
735732
+ "\n"
736733
+ "public class TestController {\n"

0 commit comments

Comments
 (0)