-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3cdf0db
commit 3ad47be
Showing
16 changed files
with
204 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
backend/src/main/java/com/example/backend/controller/DirectorController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.example.backend.controller; | ||
|
||
import lombok.AllArgsConstructor; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@AllArgsConstructor | ||
@RequestMapping("/api/director") | ||
public class DirectorController { | ||
} |
11 changes: 11 additions & 0 deletions
11
backend/src/main/java/com/example/backend/controller/MovieController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.example.backend.controller; | ||
|
||
import lombok.AllArgsConstructor; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@AllArgsConstructor | ||
@RequestMapping("/api/movie") | ||
public class MovieController { | ||
} |
14 changes: 14 additions & 0 deletions
14
backend/src/main/java/com/example/backend/dto/ActorResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.example.backend.dto; | ||
|
||
import com.example.backend.model.Actor; | ||
import lombok.Builder; | ||
|
||
@Builder | ||
public record ActorResponse(Long id, String name) { | ||
public static ActorResponse from(Actor actor) { | ||
return ActorResponse.builder() | ||
.id(actor.getId()) | ||
.name(actor.getName()) | ||
.build(); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
backend/src/main/java/com/example/backend/dto/CreateActorRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.example.backend.dto; | ||
|
||
import com.example.backend.model.Actor; | ||
|
||
public record CreateActorRequest( | ||
String name | ||
) { | ||
public Actor toActor() { | ||
return Actor.builder().name(name).build(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
backend/src/main/java/com/example/backend/service/ActorService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,23 @@ | ||
package com.example.backend.service; | ||
|
||
import com.example.backend.dto.CreateActorRequest; | ||
import com.example.backend.model.Actor; | ||
import com.example.backend.model.ActorRepository; | ||
import lombok.AllArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.util.List; | ||
|
||
@Service | ||
@AllArgsConstructor | ||
public class ActorService { | ||
private final ActorRepository actorRepository; | ||
|
||
public Actor createActor(Actor actor) { | ||
return actorRepository.save(actor); | ||
} | ||
|
||
public List<Actor> getAllActors() { | ||
return actorRepository.findAll(); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
backend/src/main/java/com/example/backend/service/DirectorService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.example.backend.service; | ||
|
||
import com.example.backend.model.DirectorRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class DirectorService { | ||
private final DirectorRepository directorRepository; | ||
} |
11 changes: 11 additions & 0 deletions
11
backend/src/main/java/com/example/backend/service/MovieService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.example.backend.service; | ||
|
||
import com.example.backend.model.MovieRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class MovieService { | ||
private final MovieRepository movieRepository; | ||
} |
13 changes: 0 additions & 13 deletions
13
backend/src/test/java/com/example/backend/BackendApplicationTests.java
This file was deleted.
Oops, something went wrong.
61 changes: 61 additions & 0 deletions
61
backend/src/test/java/com/example/backend/controller/ActorControllerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package com.example.backend.controller; | ||
|
||
import com.example.backend.model.Actor; | ||
import com.example.backend.model.ActorRepository; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.data.domain.Example; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.test.annotation.DirtiesContext; | ||
import org.springframework.test.web.servlet.MockMvc; | ||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; | ||
|
||
import java.util.List; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
@SpringBootTest | ||
@AutoConfigureMockMvc | ||
class ActorControllerTest { | ||
@Autowired | ||
private MockMvc mvc; | ||
|
||
@Autowired | ||
private ActorRepository repository; | ||
|
||
@Test | ||
@DirtiesContext | ||
void save() throws Exception { | ||
mvc.perform(MockMvcRequestBuilders.post("/api/actor") | ||
.contentType(MediaType.APPLICATION_JSON) | ||
.content( | ||
""" | ||
{ | ||
"name": "John Doe" | ||
} | ||
""" | ||
)); | ||
|
||
List<Actor> actual = repository.findAll(); | ||
List<Actor> expected = List.of(Actor.builder().id(1L).name("John Doe").build()); | ||
assertEquals(expected, actual); | ||
} | ||
|
||
@Test | ||
void get() { | ||
} | ||
|
||
@Test | ||
void update() { | ||
} | ||
|
||
@Test | ||
void getAll() { | ||
} | ||
|
||
@Test | ||
void delete() { | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
backend/src/test/java/com/example/backend/service/ActorServiceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.example.backend.service; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
class ActorServiceTest { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
jdbc.driverClassName=org.h2.Driver | ||
jdbc.url=jdbc:h2:mem:myDb;DB_CLOSE_DELAY=-1;NON_KEYWORDS=KEY,VALUE | ||
|
||
hibernate.dialect=org.hibernate.dialect.H2Dialect | ||
hibernate.hbm2ddl.auto=create |