diff --git a/pom.xml b/pom.xml
index 807f047..9363ceb 100644
--- a/pom.xml
+++ b/pom.xml
@@ -16,13 +16,16 @@
1.8
+ 5.7.0
+
org.springframework.boot
spring-boot-starter-data-jpa
+
org.springframework.boot
spring-boot-starter-web
@@ -34,38 +37,80 @@
runtime
true
+
com.h2database
h2
runtime
+
mysql
mysql-connector-java
runtime
+
org.projectlombok
lombok
true
+
org.springframework.boot
spring-boot-starter-test
test
+
+ org.junit.jupiter
+ junit-jupiter-api
+
+
+ org.junit.jupiter
+ junit-jupiter-params
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
+
org.junit.vintage
junit-vintage-engine
+
+ org.mockito
+ mockito-core
+
+
+
+ org.junit.jupiter
+ junit-jupiter-api
+ ${junit-jupiter.version}
+
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
+ ${junit-jupiter.version}
+
+
+
+
+ org.mockito
+ mockito-junit-jupiter
+ 3.5.15
+ test
+
+
com.github.javafaker
javafaker
1.0.2
+
diff --git a/src/main/java/com/birichani/code/restapi/api/VideoApiController.java b/src/main/java/com/birichani/code/restapi/api/VideoApiController.java
index 9739c7d..e8e76ee 100644
--- a/src/main/java/com/birichani/code/restapi/api/VideoApiController.java
+++ b/src/main/java/com/birichani/code/restapi/api/VideoApiController.java
@@ -5,36 +5,30 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
+import com.birichani.code.restapi.service.VideoService;
import java.util.List;
+@RequestMapping("/videos")
@RestController
public class VideoApiController {
- private VideoRepository videoRepository;
+ private final VideoRepository videoRepository;
+ private final VideoService videoService;
@Autowired
- public VideoApiController(VideoRepository videoRepository) {
+ public VideoApiController(VideoRepository videoRepository, VideoService videoService) {
this.videoRepository = videoRepository;
+ this.videoService = videoService;
}
- @GetMapping("/Getvideos/{videoTopic}")
- public String video(@PathVariable String videoTopic) {
-
- switch(videoTopic) {
- case"python":
-
- return String.format("This is our python contents") ;
- case "java":
- return String.format("This is our java contents") ;
- default:
- return String.format("sorry,Incorrect input") ;
-
+ @GetMapping("/{videoTopic}")
+ public String getVideosByTopic(@PathVariable String videoTopic) {
+ return videoService.getVideosByTopic(videoTopic);
}
-
-}
- @GetMapping("/GetAll")
- public List