annotate spring-boot-playground/src/main/java/de/comline/spring/service/MovieService.java @ 5:227f3105fedd

Erster Unit Test, der das repository einfach nur mockt
author Dirk Olmes <dirk.olmes@codedo.de>
date Thu, 13 Aug 2020 15:58:57 +0200
parents 92d52e4ac567
children d57d0c6a841b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4
92d52e4ac567 JPA hinzugefuegt.
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff changeset
1 package de.comline.spring.service;
92d52e4ac567 JPA hinzugefuegt.
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff changeset
2
92d52e4ac567 JPA hinzugefuegt.
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff changeset
3 import javax.transaction.Transactional;
92d52e4ac567 JPA hinzugefuegt.
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff changeset
4
92d52e4ac567 JPA hinzugefuegt.
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff changeset
5 import org.springframework.beans.factory.annotation.Autowired;
92d52e4ac567 JPA hinzugefuegt.
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff changeset
6 import org.springframework.stereotype.Service;
92d52e4ac567 JPA hinzugefuegt.
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff changeset
7
92d52e4ac567 JPA hinzugefuegt.
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff changeset
8 import de.comline.spring.entity.Movie;
92d52e4ac567 JPA hinzugefuegt.
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff changeset
9 import de.comline.spring.repository.MovieRepository;
92d52e4ac567 JPA hinzugefuegt.
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff changeset
10
92d52e4ac567 JPA hinzugefuegt.
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff changeset
11 @Service
92d52e4ac567 JPA hinzugefuegt.
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff changeset
12 public class MovieService {
92d52e4ac567 JPA hinzugefuegt.
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff changeset
13 @Autowired
92d52e4ac567 JPA hinzugefuegt.
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff changeset
14 private MovieRepository repository;
92d52e4ac567 JPA hinzugefuegt.
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff changeset
15
92d52e4ac567 JPA hinzugefuegt.
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff changeset
16 @Transactional
92d52e4ac567 JPA hinzugefuegt.
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff changeset
17 public Movie createMovie(String title) {
92d52e4ac567 JPA hinzugefuegt.
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff changeset
18 Movie movie = new Movie(title);
92d52e4ac567 JPA hinzugefuegt.
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff changeset
19 movie = repository.save(movie);
92d52e4ac567 JPA hinzugefuegt.
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff changeset
20 return movie;
92d52e4ac567 JPA hinzugefuegt.
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff changeset
21 }
92d52e4ac567 JPA hinzugefuegt.
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff changeset
22 }