From a26a253931768b071c65adff38ce1befebf6c8bb Mon Sep 17 00:00:00 2001 From: Luke Sikina Date: Fri, 20 Sep 2024 07:20:54 -0400 Subject: [PATCH] [ALS-7349] Info endpoint --- .../dictionary/info/InfoController.java | 15 ++++++++++++ .../dictionary/info/InfoResponse.java | 4 ++++ .../dictionary/info/InfoControllerTest.java | 24 +++++++++++++++++++ 3 files changed, 43 insertions(+) create mode 100644 src/main/java/edu/harvard/dbmi/avillach/dictionary/info/InfoController.java create mode 100644 src/main/java/edu/harvard/dbmi/avillach/dictionary/info/InfoResponse.java create mode 100644 src/test/java/edu/harvard/dbmi/avillach/dictionary/info/InfoControllerTest.java diff --git a/src/main/java/edu/harvard/dbmi/avillach/dictionary/info/InfoController.java b/src/main/java/edu/harvard/dbmi/avillach/dictionary/info/InfoController.java new file mode 100644 index 0000000..c60677c --- /dev/null +++ b/src/main/java/edu/harvard/dbmi/avillach/dictionary/info/InfoController.java @@ -0,0 +1,15 @@ +package edu.harvard.dbmi.avillach.dictionary.info; + +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; + +@Controller +public class InfoController { + + @PostMapping("/info") + public ResponseEntity getInfo(@RequestBody Object ignored) { + return ResponseEntity.ok(new InfoResponse(":)")); + } +} diff --git a/src/main/java/edu/harvard/dbmi/avillach/dictionary/info/InfoResponse.java b/src/main/java/edu/harvard/dbmi/avillach/dictionary/info/InfoResponse.java new file mode 100644 index 0000000..5810c02 --- /dev/null +++ b/src/main/java/edu/harvard/dbmi/avillach/dictionary/info/InfoResponse.java @@ -0,0 +1,4 @@ +package edu.harvard.dbmi.avillach.dictionary.info; + +public record InfoResponse(String response) { +} diff --git a/src/test/java/edu/harvard/dbmi/avillach/dictionary/info/InfoControllerTest.java b/src/test/java/edu/harvard/dbmi/avillach/dictionary/info/InfoControllerTest.java new file mode 100644 index 0000000..ccf8e0d --- /dev/null +++ b/src/test/java/edu/harvard/dbmi/avillach/dictionary/info/InfoControllerTest.java @@ -0,0 +1,24 @@ +package edu.harvard.dbmi.avillach.dictionary.info; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; + + +@SpringBootTest +class InfoControllerTest { + + @Autowired + InfoController infoController; + + @Test + void shouldGetInfo() { + ResponseEntity actual = infoController.getInfo(new Object()); + + Assertions.assertEquals(HttpStatus.OK, actual.getStatusCode()); + Assertions.assertEquals(new InfoResponse(":)"), actual.getBody()); + } +} \ No newline at end of file