Something was fixed and now it works.
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
data.mv.db
BIN
data.mv.db
Binary file not shown.
2292
data.trace.db
2292
data.trace.db
File diff suppressed because it is too large
Load Diff
@@ -4,6 +4,7 @@ import ru.ulstu.is.sbapp.Genre.Model.Genre;
|
||||
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Objects;
|
||||
|
||||
@Entity
|
||||
@@ -16,10 +17,10 @@ public class Movie
|
||||
@NotBlank(message = "Movie's title can't be null or empty")
|
||||
private String title;
|
||||
@Column
|
||||
@NotBlank(message = "Movie's length can't be null or empty")
|
||||
@NotNull(message = "Movie's length can't be null or empty")
|
||||
private int length;
|
||||
@Column
|
||||
@NotBlank(message = "Movie's score can't be null or empty")
|
||||
@NotNull(message = "Movie's score can't be null or empty")
|
||||
private double score;
|
||||
@ManyToOne(fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "genre_fk")
|
||||
|
||||
@@ -48,7 +48,9 @@ public class MovieService
|
||||
}
|
||||
|
||||
final Movie movie = new Movie(title,length,score,specGenre.get());
|
||||
movie.getGenre().getMovies().add(movie);
|
||||
validatorUtil.validate(movie);
|
||||
|
||||
specGenre.get().getMovies().add(movie);
|
||||
|
||||
if(specCustomer.isEmpty())
|
||||
{
|
||||
@@ -56,7 +58,7 @@ public class MovieService
|
||||
}
|
||||
|
||||
specCustomer.get().getMovies().add(movie);
|
||||
validatorUtil.validate(movie);
|
||||
|
||||
return movieRepository.save(movie);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,11 +3,10 @@ package ru.ulstu.is.sbapp;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@SpringBootApplication
|
||||
@ComponentScan(basePackages = { "ru.ulstu.is.sbapp.Movie","ru.ulstu.is.sbapp.Customer","ru.ulstu.is.sbapp.Genre"})
|
||||
@RestController
|
||||
public class SbappApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
@@ -5,7 +5,7 @@ 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
|
||||
spring.jpa.hibernate.ddl-auto=create-drop
|
||||
spring.h2.console.enabled=true
|
||||
spring.h2.console.settings.trace=false
|
||||
spring.h2.console.settings.web-allow-others=false
|
||||
|
||||
@@ -6,10 +6,10 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import ru.ulstu.is.sbapp.Customer.Exception.CustomerNotFoundException;
|
||||
import ru.ulstu.is.sbapp.Customer.Model.Customer;
|
||||
import ru.ulstu.is.sbapp.Customer.Service.CustomerService;
|
||||
|
||||
import javax.persistence.EntityNotFoundException;
|
||||
import java.util.List;
|
||||
|
||||
@SpringBootTest
|
||||
@@ -44,7 +44,7 @@ public class JpaCustomerTests
|
||||
void testCustomerReadNotFound()
|
||||
{
|
||||
customerService.deleteAllCustomers();
|
||||
Assertions.assertThrows(EntityNotFoundException.class, () -> customerService.findCustomer(-1L));
|
||||
Assertions.assertThrows(CustomerNotFoundException.class, () -> customerService.findCustomer(-1L));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -86,7 +86,7 @@ public class JpaCustomerTests
|
||||
final Customer customer1 = customerService.addCustomer("Nikita Lisov","1234");
|
||||
final Customer customer2 = customerService.addCustomer("Evelina Potter","12345");
|
||||
customerService.deleteCustomer(customer1.getId());
|
||||
Assertions.assertThrows(EntityNotFoundException.class, () -> customerService.findCustomer(customer1.getId()));
|
||||
Assertions.assertThrows(CustomerNotFoundException.class, () -> customerService.findCustomer(customer1.getId()));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,10 +6,10 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import ru.ulstu.is.sbapp.Genre.Exception.GenreNotFoundException;
|
||||
import ru.ulstu.is.sbapp.Genre.Model.Genre;
|
||||
import ru.ulstu.is.sbapp.Genre.Service.GenreService;
|
||||
|
||||
import javax.persistence.EntityNotFoundException;
|
||||
import java.util.List;
|
||||
|
||||
@SpringBootTest
|
||||
@@ -44,7 +44,7 @@ public class JpaGenreTests
|
||||
void testCustomerReadNotFound()
|
||||
{
|
||||
genreService.deleteAllGenres();
|
||||
Assertions.assertThrows(EntityNotFoundException.class, () -> genreService.findGenre(-1L));
|
||||
Assertions.assertThrows(GenreNotFoundException.class, () -> genreService.findGenre(-1L));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -86,7 +86,7 @@ public class JpaGenreTests
|
||||
final Genre genre1 = genreService.addGenre("Nikita Lisov");
|
||||
final Genre genre2 = genreService.addGenre("Evelina Potter");
|
||||
genreService.deleteGenre(genre1.getId());
|
||||
Assertions.assertThrows(EntityNotFoundException.class, () -> genreService.findGenre(genre1.getId()));
|
||||
Assertions.assertThrows(GenreNotFoundException.class, () -> genreService.findGenre(genre1.getId()));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import ru.ulstu.is.sbapp.Movie.Exception.MovieNotFoundException;
|
||||
import ru.ulstu.is.sbapp.Movie.Service.MovieService;
|
||||
import ru.ulstu.is.sbapp.Movie.Model.Movie;
|
||||
import ru.ulstu.is.sbapp.Customer.Model.Customer;
|
||||
@@ -13,7 +14,6 @@ import ru.ulstu.is.sbapp.Customer.Service.CustomerService;
|
||||
import ru.ulstu.is.sbapp.Genre.Model.Genre;
|
||||
import ru.ulstu.is.sbapp.Genre.Service.GenreService;
|
||||
|
||||
import javax.persistence.EntityNotFoundException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -151,7 +151,7 @@ public class JpaMovieTests
|
||||
customerService.deleteAllCustomers();
|
||||
genreService.deleteAllGenres();
|
||||
|
||||
Assertions.assertThrows(EntityNotFoundException.class, () -> movieService.findMovie(-1L));
|
||||
Assertions.assertThrows(MovieNotFoundException.class, () -> movieService.findMovie(-1L));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user