Compare commits
1 Commits
playlist_s
...
400490e6a1
| Author | SHA1 | Date | |
|---|---|---|---|
| 400490e6a1 |
13
pom.xml
13
pom.xml
@@ -81,11 +81,6 @@
|
|||||||
<version>26.1.0</version>
|
<version>26.1.0</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.h2database</groupId>
|
|
||||||
<artifactId>h2</artifactId>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
@@ -105,14 +100,6 @@
|
|||||||
<cleanDisabled>false</cleanDisabled>
|
<cleanDisabled>false</cleanDisabled>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
|
||||||
<configuration>
|
|
||||||
<source>9</source>
|
|
||||||
<target>9</target>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
|||||||
@@ -37,15 +37,8 @@ public class VideoController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping(path = "/videos")
|
@PostMapping(path = "/videos")
|
||||||
//https://www.baeldung.com/exception-handling-for-rest-with-spring
|
public Video saveNewVideo(@RequestBody SaveNewVideoRequest request){
|
||||||
//global exception handling
|
return videoService.saveNewVideo(request);
|
||||||
|
|
||||||
public ResponseEntity saveNewVideo(@RequestBody SaveNewVideoRequest request){
|
|
||||||
try {
|
|
||||||
return ResponseEntity.ok(videoService.saveNewVideo(request));
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
return ResponseEntity.badRequest().build();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping(path = "/playlists")
|
@PostMapping(path = "/playlists")
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
spring.application.name=video_downloader
|
spring.application.name=video_downloader
|
||||||
spring.datasource.url = jdbc:postgresql://postgres.local:5432/video
|
spring.datasource.url = jdbc:postgresql://127.0.0.1:5432/videos
|
||||||
spring.datasource.username = istvan
|
spring.datasource.username = postgres
|
||||||
spring.datasource.password = .b0wU?#DXKRqfkgF,oB}da:naL4e^XjbL~}@!aNK,+n>CpKYPoDZ:%BH^W!W4U%^nrso-qMjbUw)5HVCD#2Dh=8%5]~fLsRsXW?*
|
spring.datasource.password = 5995
|
||||||
spring.jpa.hibernate.ddl-auto = none
|
spring.jpa.hibernate.ddl-auto = none
|
||||||
logging.level.org.flywaydb=DEBUG
|
logging.level.org.flywaydb=DEBUG
|
||||||
logging.level.org.springframework.boot.autoconfigure.flyway=DEBUG
|
logging.level.org.springframework.boot.autoconfigure.flyway=DEBUG
|
||||||
|
|||||||
@@ -1,70 +0,0 @@
|
|||||||
package com.example.video_downloader;
|
|
||||||
|
|
||||||
import com.example.video_downloader.entity.StatusEnum;
|
|
||||||
import com.example.video_downloader.entity.Video;
|
|
||||||
import com.example.video_downloader.repositories.VideoRepository;
|
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.boot.SpringApplication;
|
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
|
||||||
import org.springframework.http.MediaType;
|
|
||||||
import org.springframework.test.web.servlet.MockMvc;
|
|
||||||
import org.springframework.test.web.servlet.MvcResult;
|
|
||||||
import org.springframework.test.web.servlet.result.MockMvcResultHandlers;
|
|
||||||
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
|
||||||
import org.springframework.util.Assert;
|
|
||||||
import org.springframework.web.context.WebApplicationContext;
|
|
||||||
|
|
||||||
|
|
||||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
|
||||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
|
|
||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
|
|
||||||
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
|
|
||||||
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@SpringBootTest
|
|
||||||
public class VideoDownloaderApplicationTest {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
VideoRepository videoRepository;
|
|
||||||
|
|
||||||
|
|
||||||
private MockMvc mockMvc;
|
|
||||||
|
|
||||||
@BeforeEach
|
|
||||||
public void setUp(WebApplicationContext webApplicationContext) {
|
|
||||||
this.mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext)
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void contextLoads() {
|
|
||||||
Video v = new Video();
|
|
||||||
v.setStatus(StatusEnum.NEW);
|
|
||||||
videoRepository.save(v);
|
|
||||||
|
|
||||||
List<Video> findByStatusList = videoRepository.findByStatus(StatusEnum.NEW);
|
|
||||||
Assert.isTrue(findByStatusList.size() == 10,"Anyad");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void insertListIntoVideoTest() throws Exception {
|
|
||||||
mockMvc.perform(post("/v2/videos").contentType(MediaType.APPLICATION_JSON)
|
|
||||||
.content("{\"url\":\"https://www.youtube.com/watch?v=swiGWilMqeQ&list=RDswiGWilMqeQ\"}")).andDo(MockMvcResultHandlers.print())
|
|
||||||
.andExpect(status().isBadRequest())
|
|
||||||
.andReturn();;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void insertVideoTest() throws Exception {
|
|
||||||
MvcResult mvcResult = mockMvc.perform(post("/v2/videos").contentType(MediaType.APPLICATION_JSON)
|
|
||||||
.content("{\"url\":\"https://www.youtube.com/watch?v=pOq0pJ6QLhE\"}")).andDo(print())
|
|
||||||
.andExpect(status().isOk())
|
|
||||||
.andReturn();
|
|
||||||
System.out.println(mvcResult.getResponse().getContentAsString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
spring.application.name=video_downloader
|
|
||||||
spring.datasource.url=jdbc:h2:mem:testdb
|
|
||||||
spring.datasource.driverClassName=org.h2.Driver
|
|
||||||
spring.datasource.username=sa
|
|
||||||
spring.datasource.password=password
|
|
||||||
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
|
|
||||||
spring.jpa.hibernate.ddl-auto = update
|
|
||||||
logging.level.org.flywaydb=DEBUG
|
|
||||||
logging.level.org.springframework.boot.autoconfigure.flyway=DEBUG
|
|
||||||
spring.flyway.enabled=false
|
|
||||||
spring.flyway.baseline-on-migrate=true
|
|
||||||
Reference in New Issue
Block a user