хромая третья лаба
This commit is contained in:
parent
10311a3b0c
commit
aeda331958
14
.vscode/launch.json
vendored
Normal file
14
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"type": "java",
|
||||||
|
"name": "Spring Boot-BackendApplication<backend>",
|
||||||
|
"request": "launch",
|
||||||
|
"cwd": "${workspaceFolder}",
|
||||||
|
"mainClass": "com.example.backend.BackendApplication",
|
||||||
|
"projectName": "backend",
|
||||||
|
"args": "",
|
||||||
|
"envFile": "${workspaceFolder}/.env"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@ -40,20 +40,19 @@ public class BackendApplication implements CommandLineRunner {
|
|||||||
_logger.info("Create default categories values");
|
_logger.info("Create default categories values");
|
||||||
|
|
||||||
final var genre1 = genreService.create(new GenreEntity(1,
|
final var genre1 = genreService.create(new GenreEntity(1,
|
||||||
"Драма"));
|
"Психологический реализм"));
|
||||||
final var genre2 = genreService.create(new GenreEntity(2,
|
final var genre2 = genreService.create(new GenreEntity(2,
|
||||||
"Комедия"));
|
"Философская проза"));
|
||||||
final var genre3 = genreService.create(new GenreEntity(4,
|
final var genre3 = genreService.create(new GenreEntity(4,
|
||||||
"Хоррор"));
|
"Научная фантастика"));
|
||||||
|
|
||||||
_logger.info("Create default movies values");
|
_logger.info("Create default movies values");
|
||||||
|
|
||||||
bookService.create(new BookEntity(1, genre3, "Астрал", "1", "1", "1"));
|
bookService.create(new BookEntity(1, genre3, "dd", "1", 4));
|
||||||
bookService.create(new BookEntity(1, genre1, "Хатико", "2", "2", "2"));
|
bookService.create(new BookEntity(1, genre1, "ff", "2", 6));
|
||||||
bookService.create(new BookEntity(1, genre2, "Бабушка легкого ", "3", "3", "3"));
|
bookService.create(new BookEntity(1, genre2, "ffd ", "3", 3));
|
||||||
bookService.create(new BookEntity(1, genre3, "Пиковая дама", "4", "4",
|
bookService.create(new BookEntity(1, genre3, "gggfg", "4", 7));
|
||||||
"4"));
|
bookService.create(new BookEntity(1, genre3, "erer", "5", 8));
|
||||||
bookService.create(new BookEntity(1, genre3, "Баба-Яга", "5", "5", "5"));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,10 +25,9 @@ public class BookDTO {
|
|||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
@NotBlank
|
@NotBlank
|
||||||
@Size(min = 2, max = 50)
|
@Size(min = 0, max = 50)
|
||||||
private String duration;
|
private Integer count;
|
||||||
|
|
||||||
private String image;
|
|
||||||
|
|
||||||
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
|
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
|
||||||
public Integer getId() {
|
public Integer getId() {
|
||||||
@ -55,27 +54,15 @@ public class BookDTO {
|
|||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDescription() {
|
|
||||||
return description;
|
|
||||||
|
public Integer getCount() {
|
||||||
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDescription(String description) {
|
public void setDuration(Integer count) {
|
||||||
this.description = description;
|
this.count = count;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDuration() {
|
|
||||||
return duration;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDuration(String duration) {
|
|
||||||
this.duration = duration;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getImage() {
|
|
||||||
return image;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setImage(String image) {
|
|
||||||
this.image = image;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -26,23 +26,21 @@ public class BookEntity extends BaseEntity {
|
|||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
@Column(nullable = false, unique = true, length = 50)
|
@Column(nullable = false, unique = true, length = 50)
|
||||||
private String duration;
|
private Integer count;
|
||||||
|
|
||||||
|
|
||||||
@Column(nullable = true)
|
|
||||||
private String image;
|
|
||||||
|
|
||||||
public BookEntity() {
|
public BookEntity() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public BookEntity(Integer id, GenreEntity genre, String name, String description, String duration,
|
public BookEntity(Integer id, GenreEntity genre, String name, String description, Integer count) {
|
||||||
String image) {
|
|
||||||
|
|
||||||
this.genre = genre;
|
this.genre = genre;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
this.duration = duration;
|
this.count = count;
|
||||||
this.image = image;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public GenreEntity getGenre() {
|
public GenreEntity getGenre() {
|
||||||
@ -69,25 +67,19 @@ public class BookEntity extends BaseEntity {
|
|||||||
this.description = description;
|
this.description = description;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDuration() {
|
public Integer getCount() {
|
||||||
return duration;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDuration(String duration) {
|
public void setCount(Integer count) {
|
||||||
this.duration = duration;
|
this.count = count;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getImage() {
|
|
||||||
return image;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setImage(String image) {
|
|
||||||
this.image = image;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(id, genre, name, description, duration, image);
|
return Objects.hash(id, genre, name, description, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -101,8 +93,8 @@ public class BookEntity extends BaseEntity {
|
|||||||
&& Objects.equals(other.getGenre(), genre)
|
&& Objects.equals(other.getGenre(), genre)
|
||||||
&& Objects.equals(other.getName(), name)
|
&& Objects.equals(other.getName(), name)
|
||||||
&& Objects.equals(other.getDescription(), description)
|
&& Objects.equals(other.getDescription(), description)
|
||||||
&& Objects.equals(other.getDuration(), duration)
|
&& Objects.equals(other.getCount(), count);
|
||||||
&& Objects.equals(other.getImage(), image);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -56,8 +56,8 @@ public class BookService {
|
|||||||
exisEntity.setGenre(entity.getGenre());
|
exisEntity.setGenre(entity.getGenre());
|
||||||
exisEntity.setName(entity.getName());
|
exisEntity.setName(entity.getName());
|
||||||
exisEntity.setDescription(entity.getDescription());
|
exisEntity.setDescription(entity.getDescription());
|
||||||
exisEntity.setDuration(entity.getDuration());
|
exisEntity.setCount(entity.getCount());
|
||||||
exisEntity.setImage(entity.getImage());
|
|
||||||
return repository.save(exisEntity);
|
return repository.save(exisEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,8 +8,8 @@ logging.level.com.example.demo=DEBUG
|
|||||||
|
|
||||||
# JPA Settings
|
# JPA Settings
|
||||||
spring.datasource.url=jdbc:h2:file:./data
|
spring.datasource.url=jdbc:h2:file:./data
|
||||||
spring.datasource.username=alyona
|
spring.datasource.username=sa
|
||||||
spring.datasource.password=alyona
|
spring.datasource.password=password
|
||||||
spring.datasource.driver-class-name=org.h2.Driver
|
spring.datasource.driver-class-name=org.h2.Driver
|
||||||
spring.jpa.hibernate.ddl-auto=create
|
spring.jpa.hibernate.ddl-auto=create
|
||||||
spring.jpa.open-in-view=false
|
spring.jpa.open-in-view=false
|
||||||
|
@ -57,8 +57,8 @@ class BookServiceTest {
|
|||||||
user2 = userService.create(new UserEntity(0, "3", "3", true));
|
user2 = userService.create(new UserEntity(0, "3", "3", true));
|
||||||
user3 = userService.create(new UserEntity(0, "4", "4", true));
|
user3 = userService.create(new UserEntity(0, "4", "4", true));
|
||||||
|
|
||||||
book = bookService.create(new BookEntity(0, cat, "1", "1", "1", "1"));
|
book = bookService.create(new BookEntity(0, cat, "1", "6", 6));
|
||||||
book2 = bookService.create(new BookEntity(0, cat, "2", "2", "2", "2"));
|
book2 = bookService.create(new BookEntity(0, cat, "2", "2", 9));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -88,16 +88,14 @@ class BookServiceTest {
|
|||||||
@Test
|
@Test
|
||||||
@Order(3)
|
@Order(3)
|
||||||
void createNotUniqueTest() {
|
void createNotUniqueTest() {
|
||||||
final BookEntity nonUniqueGenre = new BookEntity(3, cat, "1", "1", "1",
|
final BookEntity nonUniqueGenre = new BookEntity(3, cat, "1", "1", 7);
|
||||||
"1");
|
|
||||||
Assertions.assertThrows(IllegalArgumentException.class, () -> bookService.create(nonUniqueGenre));
|
Assertions.assertThrows(IllegalArgumentException.class, () -> bookService.create(nonUniqueGenre));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Order(4)
|
@Order(4)
|
||||||
void createNullableTest() {
|
void createNullableTest() {
|
||||||
final BookEntity nullableGenre = new BookEntity(1, cat, null, "1", "1",
|
final BookEntity nullableGenre = new BookEntity(1, cat, null, "1",9);
|
||||||
"1");
|
|
||||||
Assertions.assertThrows(DataIntegrityViolationException.class, () -> bookService.create(
|
Assertions.assertThrows(DataIntegrityViolationException.class, () -> bookService.create(
|
||||||
nullableGenre));
|
nullableGenre));
|
||||||
}
|
}
|
||||||
@ -109,7 +107,7 @@ class BookServiceTest {
|
|||||||
final String oldName = book.getName();
|
final String oldName = book.getName();
|
||||||
final BookEntity mov = new BookEntity(book.getId(), book.getGenre(),
|
final BookEntity mov = new BookEntity(book.getId(), book.getGenre(),
|
||||||
newName, book.getDescription(),
|
newName, book.getDescription(),
|
||||||
book.getDuration(), book.getImage());
|
book.getCount());
|
||||||
final BookEntity newEntity = bookService.update(book.getId(), mov);
|
final BookEntity newEntity = bookService.update(book.getId(), mov);
|
||||||
Assertions.assertEquals(newName, newEntity.getName());
|
Assertions.assertEquals(newName, newEntity.getName());
|
||||||
Assertions.assertNotEquals(oldName, newEntity.getName());
|
Assertions.assertNotEquals(oldName, newEntity.getName());
|
||||||
|
@ -50,12 +50,11 @@ public class FavoriteServiceTests {
|
|||||||
|
|
||||||
cat1 = genreService.create(new GenreEntity(null, "Драма"));
|
cat1 = genreService.create(new GenreEntity(null, "Драма"));
|
||||||
|
|
||||||
mov1 = bookService.create(new BookEntity(null, cat1, "Хатико", "какой-то фильм",
|
mov1 = bookService.create(new BookEntity(null, cat1, "gffg", "gffg", 0));
|
||||||
"1", "1"));
|
mov2 = bookService.create(new BookEntity(null, cat1, "lol",
|
||||||
mov2 = bookService.create(new BookEntity(null, cat1, "Унесеснные призраками",
|
"2",8));
|
||||||
"2", "2", "2"));
|
|
||||||
|
|
||||||
us1 = userService.create(new UserEntity(null, "elina", "123", true));
|
us1 = userService.create(new UserEntity(null, "alyona", "123", true));
|
||||||
|
|
||||||
lastFavorite = favoriteService.create(new FavoriteEntity(null, us1, mov1));
|
lastFavorite = favoriteService.create(new FavoriteEntity(null, us1, mov1));
|
||||||
lastFavorite2 = favoriteService.create(new FavoriteEntity(null, us1, mov2));
|
lastFavorite2 = favoriteService.create(new FavoriteEntity(null, us1, mov2));
|
||||||
|
Binary file not shown.
@ -1,74 +0,0 @@
|
|||||||
2024-04-15 12:19:20.050452+04:00 database: wrong user or password; user: "SA"
|
|
||||||
org.h2.message.DbException: Неверное имя пользователя или пароль
|
|
||||||
Wrong user name or password [28000-224]
|
|
||||||
at org.h2.message.DbException.get(DbException.java:223)
|
|
||||||
at org.h2.message.DbException.get(DbException.java:199)
|
|
||||||
at org.h2.message.DbException.get(DbException.java:188)
|
|
||||||
at org.h2.engine.Engine.openSession(Engine.java:154)
|
|
||||||
at org.h2.engine.Engine.openSession(Engine.java:222)
|
|
||||||
at org.h2.engine.Engine.createSession(Engine.java:201)
|
|
||||||
at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:343)
|
|
||||||
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:125)
|
|
||||||
at org.h2.util.JdbcUtils.getConnection(JdbcUtils.java:288)
|
|
||||||
at org.h2.server.web.WebServer.getConnection(WebServer.java:811)
|
|
||||||
at org.h2.server.web.WebApp.login(WebApp.java:1039)
|
|
||||||
at org.h2.server.web.WebApp.process(WebApp.java:227)
|
|
||||||
at org.h2.server.web.WebApp.processRequest(WebApp.java:177)
|
|
||||||
at org.h2.server.web.JakartaWebServlet.doGet(JakartaWebServlet.java:129)
|
|
||||||
at org.h2.server.web.JakartaWebServlet.doPost(JakartaWebServlet.java:166)
|
|
||||||
at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:590)
|
|
||||||
at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:658)
|
|
||||||
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:205)
|
|
||||||
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149)
|
|
||||||
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
|
|
||||||
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174)
|
|
||||||
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149)
|
|
||||||
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
|
|
||||||
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
|
|
||||||
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174)
|
|
||||||
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149)
|
|
||||||
at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
|
|
||||||
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
|
|
||||||
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174)
|
|
||||||
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149)
|
|
||||||
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
|
|
||||||
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
|
|
||||||
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174)
|
|
||||||
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149)
|
|
||||||
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:167)
|
|
||||||
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:90)
|
|
||||||
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:482)
|
|
||||||
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:115)
|
|
||||||
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:93)
|
|
||||||
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
|
|
||||||
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:344)
|
|
||||||
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:391)
|
|
||||||
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:63)
|
|
||||||
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:896)
|
|
||||||
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1744)
|
|
||||||
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52)
|
|
||||||
at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
|
|
||||||
at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
|
|
||||||
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:63)
|
|
||||||
at java.base/java.lang.Thread.run(Thread.java:842)
|
|
||||||
Caused by: org.h2.jdbc.JdbcSQLInvalidAuthorizationSpecException: Неверное имя пользователя или пароль
|
|
||||||
Wrong user name or password [28000-224]
|
|
||||||
at org.h2.message.DbException.getJdbcSQLException(DbException.java:522)
|
|
||||||
at org.h2.message.DbException.getJdbcSQLException(DbException.java:489)
|
|
||||||
... 50 more
|
|
||||||
2024-04-15 12:20:09.391447+04:00 jdbc[13]: exception
|
|
||||||
org.h2.jdbc.JdbcSQLSyntaxErrorException: Синтаксическая ошибка в выражении SQL "SELECT * FROM CATEGORIES CATEGORIES [*]FAVORITES"
|
|
||||||
Syntax error in SQL statement "SELECT * FROM CATEGORIES CATEGORIES [*]FAVORITES"; SQL statement:
|
|
||||||
SELECT * FROM CATEGORIES CATEGORIES FAVORITES [42000-224]
|
|
||||||
2024-04-15 16:29:01.404545+04:00 jdbc[3]: exception
|
|
||||||
org.h2.jdbc.JdbcSQLDataException: Значение слишком длинное для поля "PASSWORD CHARACTER VARYING(5)": "'string' (6)"
|
|
||||||
Value too long for column "PASSWORD CHARACTER VARYING(5)": "'string' (6)"; SQL statement:
|
|
||||||
insert into users (is_admin,password,username,id) values (?,?,?,?) [22001-224]
|
|
||||||
2024-04-15 16:29:07.847974+04:00 jdbc[3]: exception
|
|
||||||
org.h2.jdbc.JdbcSQLDataException: Значение слишком длинное для поля "PASSWORD CHARACTER VARYING(5)": "'string' (6)"
|
|
||||||
Value too long for column "PASSWORD CHARACTER VARYING(5)": "'string' (6)"; SQL statement:
|
|
||||||
insert into users (is_admin,password,username,id) values (?,?,?,?) [22001-224]
|
|
||||||
2024-04-29 00:12:28.578523+04:00 jdbc[3]: exception
|
|
||||||
org.h2.jdbc.JdbcSQLDataException: Значение слишком длинное для поля "PASSWORD CHARACTER VARYING(5)": "'string' (6)"
|
|
||||||
Value too long for column "PASSWORD CHARACTER VARYING(5)": "'string' (6)"; SQL statement:
|
|
||||||
insert into users (is_admin,password,username,id) values (?,?,?,?) [22001-224]
|
|
Loading…
Reference in New Issue
Block a user