Skip to content

Commit

Permalink
Update Dockerfile to use java 21, remove lodafile endpoint.
Browse files Browse the repository at this point in the history
  • Loading branch information
ypiel-talend committed Mar 25, 2024
1 parent 383ba19 commit 1d08385
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 21 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM openjdk:11-jre-slim
FROM openjdk:21-jdk

COPY target/validation-server-0.0.1-SNAPSHOT.jar validation-server-0.0.1-SNAPSHOT.jar
EXPOSE 8080
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,6 @@ public Map<String, String> pingJson() {
return Collections.singletonMap("message", PONG);
}

@GetMapping("/loadfile")
public String loadFile(@RequestParam(name="file", required = false) String file) throws IOException {
String jsonContent = new String(Files.readAllBytes(Paths.get(file)), StandardCharsets.UTF_8);
return jsonContent;
}

@PostMapping(value = "/post", produces = "application/json")
public Map<String, String> postPlainText(@RequestBody String payload) throws IOException {
System.out.printf("Received Payload:\n%s\n--\nEND.\n", payload);
Expand Down Expand Up @@ -92,7 +86,7 @@ public List<Element> paginate(@RequestParam(name="offset", required = false) Int
}
System.out.printf("%s / %s / %s\n", offset, limit, total);

List<Element> result = IntStream.rangeClosed(1, total).mapToObj(i -> new Element(i, String.format("element_%s", i))).collect(Collectors.toList());
List<Element> result = IntStream.rangeClosed(1, total).mapToObj(i -> new Element(i)).collect(Collectors.toList());

if(offset >= total){
return Collections.emptyList();
Expand All @@ -104,9 +98,24 @@ public List<Element> paginate(@RequestParam(name="offset", required = false) Int
}

@Data
@AllArgsConstructor
public final static class Element{
private final int id;
private final String label;
private final Element nested;

private final String nestedAsJson;

public Element(int id){
this.id = id;
this.label = String.format("element_%s", id);
if(id >= 0) {
this.nested = new Element(id * -1);
this.nestedAsJson = String.format("{\"id\": %s, \"label\": \"nested json %s\"}", id, id);
}
else{
this.nested = null;
this.nestedAsJson = null;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,6 @@ public void pingPongTest(){
Assertions.assertEquals(NoAuthController.PONG, result);
}

@Test
public void loadFile() throws IOException {
URL resourceUrl = NoAuthControllerTest.class.getResource("/");
File f = new File(resourceUrl.getPath());
String file = f.getAbsolutePath() + "/loadFile/Simple.txt";
String content = controller.loadFile(file);
Assertions.assertEquals("This\nis\nan hellow world!", content);
}

@Test
public void paginate() {
List<NoAuthController.Element> paginate = controller.paginate(null, null, null);
Expand Down
3 changes: 0 additions & 3 deletions src/test/resources/loadFile/Simple.txt

This file was deleted.

0 comments on commit 1d08385

Please sign in to comment.