diff --git a/build.gradle b/build.gradle index dca68fa..e8e6fc0 100644 --- a/build.gradle +++ b/build.gradle @@ -44,3 +44,7 @@ dependencies { testImplementation group: 'org.springframework.security', name: 'spring-security-test', version: springSecurityVersion testImplementation 'org.springframework.boot:spring-boot-starter-test' } + +test { + useJUnitPlatform() +} \ No newline at end of file diff --git a/src/main/java/eu/openaire/urls_controller/controllers/UrlController.java b/src/main/java/eu/openaire/urls_controller/controllers/UrlController.java index 184e856..5592b47 100644 --- a/src/main/java/eu/openaire/urls_controller/controllers/UrlController.java +++ b/src/main/java/eu/openaire/urls_controller/controllers/UrlController.java @@ -1,14 +1,12 @@ package eu.openaire.urls_controller.controllers; import eu.openaire.urls_controller.models.UrlToCheck; +import eu.openaire.urls_controller.payloads.requests.UrlsRequest; import eu.openaire.urls_controller.payloads.responces.UrlsResponse; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import java.util.ArrayList; import java.util.List; @@ -49,22 +47,15 @@ public class UrlController { @PostMapping("") // TODO - Add authorization to edit the database. - public ResponseEntity addResults() { + public ResponseEntity addResults(@RequestBody UrlsRequest urlsRequest) { - UrlToCheck urlToCheck = new UrlToCheck(); - - List urlsToCheck = new ArrayList<>(); + logger.debug(urlsRequest.toString()); - // TODO - Retrieve the ID-URL pairs from the database. - - // For now, we give static data. - urlsToCheck.add(new UrlToCheck("ID-1", "URL-1")); + // TODO - Add data in the DataBase.. - logger.debug("ID-URL pairs to return: " + urlsToCheck); - - return ResponseEntity.ok(new UrlsResponse(urlsToCheck)); + return ResponseEntity.ok().build(); } diff --git a/src/main/java/eu/openaire/urls_controller/payloads/requests/UrlsRequest.java b/src/main/java/eu/openaire/urls_controller/payloads/requests/UrlsRequest.java new file mode 100644 index 0000000..0db124b --- /dev/null +++ b/src/main/java/eu/openaire/urls_controller/payloads/requests/UrlsRequest.java @@ -0,0 +1,36 @@ +package eu.openaire.urls_controller.payloads.requests; + +import eu.openaire.urls_controller.models.Payload; + +import java.util.List; + +public class UrlsRequest { + + private List payloads; + + public void UrlsResponse() { + } + + public void UrlsResponse(List payloads) { + this.payloads = payloads; + } + + public UrlsRequest get() { + return this; + } + + public List getUrlsToCheck() { + return payloads; + } + + public void setUrlsToCheck(List payloads) { + this.payloads = payloads; + } + + @Override + public String toString() { + return "UrlsRequest{" + + "payloads=" + payloads + + '}'; + } +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 33fe87d..6c2cf20 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -4,7 +4,7 @@ #server.ssl.key-store = src/main/resources/keystore.p12 #server.ssl.key-store-type = PKCS12 #server.ssl.key-alias = tomcat -#server.ssl.key-store-password = rent_project +#server.ssl.key-store-password = urls_controller_project #server.tomcat.remoteip.remote-ip-header = x-your-remote-ip-header #server.tomcat.remoteip.protocol-header = x-your-protocol-header #server.error.include-stacktrace=never