From 763feff798d791336b214888eb5654e6da94528f Mon Sep 17 00:00:00 2001 From: Allllen4a Date: Sat, 11 May 2024 16:39:25 +0400 Subject: [PATCH] =?UTF-8?q?=D0=92=D1=80=D0=BE=D0=B4=D0=B5=20=D0=B6=D0=B8?= =?UTF-8?q?=D0=B2=D0=B5=D1=82=20:D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 3 лаба/backend/data.mv.db | Bin 40960 -> 40960 bytes 3 лаба/backend/data.trace.db | 459 ++++++++++++++++++ .../example/backend/BackendApplication.java | 24 +- .../backend/authors/api/AuthorController.java | 69 +++ .../backend/authors/api/AuthorDTO.java | 37 ++ .../backend/authors/model/AuthorEntity.java | 53 ++ .../authors/repository/AuthorRepository.java | 11 + .../authors/service/AuthorService.java | 63 +++ .../backend/books/api/BookController.java | 17 +- .../example/backend/books/api/BookDTO.java | 22 +- .../backend/books/model/BookEntity.java | 20 +- .../books/repository/BookRepository.java | 6 + .../backend/books/service/BookService.java | 13 +- .../example/backend/AuthorServiceTests.java | 77 +++ .../com/example/backend/BookServiceTest.java | 69 +-- .../example/backend/FavoriteServiceTests.java | 60 ++- 16 files changed, 926 insertions(+), 74 deletions(-) create mode 100644 3 лаба/backend/data.trace.db create mode 100644 3 лаба/backend/src/main/java/com/example/backend/authors/api/AuthorController.java create mode 100644 3 лаба/backend/src/main/java/com/example/backend/authors/api/AuthorDTO.java create mode 100644 3 лаба/backend/src/main/java/com/example/backend/authors/model/AuthorEntity.java create mode 100644 3 лаба/backend/src/main/java/com/example/backend/authors/repository/AuthorRepository.java create mode 100644 3 лаба/backend/src/main/java/com/example/backend/authors/service/AuthorService.java create mode 100644 3 лаба/backend/src/test/java/com/example/backend/AuthorServiceTests.java diff --git a/3 лаба/backend/data.mv.db b/3 лаба/backend/data.mv.db index 1e5977a30ff3a2b5bded5878b9878a882a54f13e..8adfdd695639d6b520174d5d0abfa1cac3df34eb 100644 GIT binary patch literal 40960 zcmeHQ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Ir`%p>yC zSfyZM-u@ZJ|NA5fjQ@|4WD@ux5cZxrMjqq;Df7nT3Sj&{1iFuruFgHO{n@V&_cVPVgF!nGKeJVZM@&EDn@8OG$8+rd% zFZ%r-Ud7Vz|9!uCJkkMTPr|n`sODn%|7GO=BmaN6XTelYyXiRF$p43@(+j{A`Tvp4 zHxld$o~;1+|AWms(lE)9|Nm_?DB$})eg9vh{Qp0KU&D)mgkyyN{~zT4BmW=y|FNA8 z@ckd(|NWgrC@*d@Ywz3h{vT{k5;EV$HZQpt{{P>R|L?Ixk^g_n)*Q(H_hME!J8H9nmDZ{|S(B(7n|C4vck1*@q zF{--cZP^gI%^}u5A&5E3|98)U|DPPZKZTTT7}g(&w5I%j8W#}o|7jxN|I@_N5bD1g z=NcgYKaoR%7ZCwO01-e05CKF05kLeG0Ym^1Km?wB1cLbgLHzx|CID9k{C`Vy9Y=Th zGn44YDhT=iurs9>|3BPVFp>YSCo#z*b_}S+5C6Y7{{KHl`2P`ePiXiNc{KdQ`TrMW z_!;p3VW?W&p8WuR_HmR%GTfaq75|^wiekSmnP57D_M+1y!E{FX|7opKuu35RKlqVE z(MVStore.java:291) + at org.h2.mvstore.MVStore$Builder.open(MVStore.java:2035) + at org.h2.mvstore.db.Store.(Store.java:133) + at org.h2.engine.Database.(Database.java:326) + at org.h2.engine.Engine.openSession(Engine.java:92) + 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.(JdbcConnection.java:125) + at org.h2.Driver.connect(Driver.java:59) + at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:138) + at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:359) + at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:201) + at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:470) + at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:561) + at com.zaxxer.hikari.pool.HikariPool.(HikariPool.java:100) + at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112) + at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:122) + at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess.obtainConnection(JdbcEnvironmentInitiator.java:428) + at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcIsolationDelegate.delegateWork(JdbcIsolationDelegate.java:61) + at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.getJdbcEnvironmentUsingJdbcMetadata(JdbcEnvironmentInitiator.java:276) + at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:107) + at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:68) + at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:130) + at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:263) + at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:238) + at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:215) + at org.hibernate.boot.model.relational.Database.(Database.java:45) + at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.getDatabase(InFlightMetadataCollectorImpl.java:223) + at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.(InFlightMetadataCollectorImpl.java:191) + at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:170) + at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:1432) + at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1503) + at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:75) + at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:390) + at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:409) + at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:396) + at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:366) + at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1833) + at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1782) + at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:600) + at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:522) + at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326) + at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) + at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324) + at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) + at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1234) + at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:952) + at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:624) + at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754) + at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:456) + at org.springframework.boot.SpringApplication.run(SpringApplication.java:334) + at org.springframework.boot.test.context.SpringBootContextLoader.lambda$loadContext$3(SpringBootContextLoader.java:137) + at org.springframework.util.function.ThrowingSupplier.get(ThrowingSupplier.java:58) + at org.springframework.util.function.ThrowingSupplier.get(ThrowingSupplier.java:46) + at org.springframework.boot.SpringApplication.withHook(SpringApplication.java:1454) + at org.springframework.boot.test.context.SpringBootContextLoader$ContextLoaderHook.run(SpringBootContextLoader.java:553) + at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:137) + at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:108) + at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:225) + at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:152) + at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:130) + at org.springframework.test.context.web.ServletTestExecutionListener.setUpRequestContextIfNecessary(ServletTestExecutionListener.java:191) + at org.springframework.test.context.web.ServletTestExecutionListener.prepareTestInstance(ServletTestExecutionListener.java:130) + at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:260) + at org.springframework.test.context.junit.jupiter.SpringExtension.postProcessTestInstance(SpringExtension.java:163) + at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$invokeTestInstancePostProcessors$10(ClassBasedTestDescriptor.java:378) + at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.executeAndMaskThrowable(ClassBasedTestDescriptor.java:383) + at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$invokeTestInstancePostProcessors$11(ClassBasedTestDescriptor.java:378) + at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197) + at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179) + at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625) + at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) + at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) + at java.base/java.util.stream.StreamSpliterators$WrappingSpliterator.forEachRemaining(StreamSpliterators.java:310) + at java.base/java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:735) + at java.base/java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:734) + at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:762) + at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.invokeTestInstancePostProcessors(ClassBasedTestDescriptor.java:377) + at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$instantiateAndPostProcessTestInstance$6(ClassBasedTestDescriptor.java:290) + at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) + at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.instantiateAndPostProcessTestInstance(ClassBasedTestDescriptor.java:289) + at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$testInstancesProvider$4(ClassBasedTestDescriptor.java:279) + at java.base/java.util.Optional.orElseGet(Optional.java:364) + at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$testInstancesProvider$5(ClassBasedTestDescriptor.java:278) + at org.junit.jupiter.engine.execution.TestInstancesProvider.getTestInstances(TestInstancesProvider.java:31) + at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$prepare$0(TestMethodTestDescriptor.java:106) + at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) + at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.prepare(TestMethodTestDescriptor.java:105) + at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.prepare(TestMethodTestDescriptor.java:69) + at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$prepare$2(NodeTestTask.java:123) + at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) + at org.junit.platform.engine.support.hierarchical.NodeTestTask.prepare(NodeTestTask.java:123) + at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:90) + at java.base/java.util.ArrayList.forEach(ArrayList.java:1511) + at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41) + at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155) + at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) + at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141) + at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) + at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139) + at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) + at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138) + at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95) + at java.base/java.util.ArrayList.forEach(ArrayList.java:1511) + at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41) + at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155) + at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) + at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141) + at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) + at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139) + at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) + at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138) + at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95) + at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35) + at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57) + at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54) + at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:147) + at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:127) + at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:90) + at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:55) + at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:102) + at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:54) + at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:114) + at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:95) + at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:91) + at org.junit.platform.launcher.core.SessionPerRequestLauncher.execute(SessionPerRequestLauncher.java:60) + at org.eclipse.jdt.internal.junit5.runner.JUnit5TestReference.run(JUnit5TestReference.java:98) + at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:40) + at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:529) + at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:757) + at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:452) + at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:210) +Caused by: org.h2.jdbc.JdbcSQLNonTransientException: Внутренняя ошибка: "org.h2.mvstore.MVStoreException: The file is locked: C:/Users/a3012/OneDrive/Рабочий стол/PIbd-21_Zhirnova_A.E._INTERNET_PROGRAMMING_BACKEND/PIbd-21_Zhirnova_A.E._INTERNET_PROGRAMMING_BACKEND/3 лаба/backend/data.mv.db [2.2.224/7]" +General error: "org.h2.mvstore.MVStoreException: The file is locked: C:/Users/a3012/OneDrive/Рабочий стол/PIbd-21_Zhirnova_A.E._INTERNET_PROGRAMMING_BACKEND/PIbd-21_Zhirnova_A.E._INTERNET_PROGRAMMING_BACKEND/3 лаба/backend/data.mv.db [2.2.224/7]" [50000-224] + at org.h2.message.DbException.getJdbcSQLException(DbException.java:566) + at org.h2.message.DbException.getJdbcSQLException(DbException.java:489) + ... 138 more +Caused by: org.h2.mvstore.MVStoreException: The file is locked: C:/Users/a3012/OneDrive/Рабочий стол/PIbd-21_Zhirnova_A.E._INTERNET_PROGRAMMING_BACKEND/PIbd-21_Zhirnova_A.E._INTERNET_PROGRAMMING_BACKEND/3 лаба/backend/data.mv.db [2.2.224/7] + at org.h2.mvstore.DataUtils.newMVStoreException(DataUtils.java:996) + at org.h2.mvstore.SingleFileStore.lockFileChannel(SingleFileStore.java:143) + at org.h2.mvstore.SingleFileStore.open(SingleFileStore.java:117) + at org.h2.mvstore.SingleFileStore.open(SingleFileStore.java:81) + at org.h2.mvstore.MVStore.(MVStore.java:286) + ... 132 more +2024-05-11 16:23:54.366155+04:00 database: flush +org.h2.message.DbException: Внутренняя ошибка: "org.h2.mvstore.MVStoreException: The file is locked: C:/Users/a3012/OneDrive/Рабочий стол/PIbd-21_Zhirnova_A.E._INTERNET_PROGRAMMING_BACKEND/PIbd-21_Zhirnova_A.E._INTERNET_PROGRAMMING_BACKEND/3 лаба/backend/data.mv.db [2.2.224/7]" +General error: "org.h2.mvstore.MVStoreException: The file is locked: C:/Users/a3012/OneDrive/Рабочий стол/PIbd-21_Zhirnova_A.E._INTERNET_PROGRAMMING_BACKEND/PIbd-21_Zhirnova_A.E._INTERNET_PROGRAMMING_BACKEND/3 лаба/backend/data.mv.db [2.2.224/7]" [50000-224] + at org.h2.message.DbException.get(DbException.java:212) + at org.h2.message.DbException.convert(DbException.java:407) + at org.h2.mvstore.db.Store.lambda$new$0(Store.java:122) + at org.h2.mvstore.MVStore.handleException(MVStore.java:1546) + at org.h2.mvstore.MVStore.panic(MVStore.java:371) + at org.h2.mvstore.MVStore.(MVStore.java:291) + at org.h2.mvstore.MVStore$Builder.open(MVStore.java:2035) + at org.h2.mvstore.db.Store.(Store.java:133) + at org.h2.engine.Database.(Database.java:326) + at org.h2.engine.Engine.openSession(Engine.java:92) + 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.(JdbcConnection.java:125) + at org.h2.Driver.connect(Driver.java:59) + at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:138) + at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:359) + at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:201) + at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:470) + at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:561) + at com.zaxxer.hikari.pool.HikariPool.(HikariPool.java:100) + at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112) + at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:122) + at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess.obtainConnection(JdbcEnvironmentInitiator.java:428) + at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcIsolationDelegate.delegateWork(JdbcIsolationDelegate.java:61) + at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.getJdbcEnvironmentUsingJdbcMetadata(JdbcEnvironmentInitiator.java:276) + at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:107) + at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:68) + at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:130) + at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:263) + at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:238) + at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:215) + at org.hibernate.boot.model.relational.Database.(Database.java:45) + at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.getDatabase(InFlightMetadataCollectorImpl.java:223) + at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.(InFlightMetadataCollectorImpl.java:191) + at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:170) + at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:1432) + at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1503) + at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:75) + at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:390) + at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:409) + at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:396) + at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:366) + at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1833) + at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1782) + at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:600) + at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:522) + at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326) + at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) + at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324) + at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) + at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1234) + at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:952) + at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:624) + at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754) + at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:456) + at org.springframework.boot.SpringApplication.run(SpringApplication.java:334) + at org.springframework.boot.test.context.SpringBootContextLoader.lambda$loadContext$3(SpringBootContextLoader.java:137) + at org.springframework.util.function.ThrowingSupplier.get(ThrowingSupplier.java:58) + at org.springframework.util.function.ThrowingSupplier.get(ThrowingSupplier.java:46) + at org.springframework.boot.SpringApplication.withHook(SpringApplication.java:1454) + at org.springframework.boot.test.context.SpringBootContextLoader$ContextLoaderHook.run(SpringBootContextLoader.java:553) + at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:137) + at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:108) + at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:225) + at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:152) + at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:130) + at org.springframework.test.context.web.ServletTestExecutionListener.setUpRequestContextIfNecessary(ServletTestExecutionListener.java:191) + at org.springframework.test.context.web.ServletTestExecutionListener.prepareTestInstance(ServletTestExecutionListener.java:130) + at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:260) + at org.springframework.test.context.junit.jupiter.SpringExtension.postProcessTestInstance(SpringExtension.java:163) + at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$invokeTestInstancePostProcessors$10(ClassBasedTestDescriptor.java:378) + at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.executeAndMaskThrowable(ClassBasedTestDescriptor.java:383) + at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$invokeTestInstancePostProcessors$11(ClassBasedTestDescriptor.java:378) + at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197) + at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179) + at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625) + at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) + at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) + at java.base/java.util.stream.StreamSpliterators$WrappingSpliterator.forEachRemaining(StreamSpliterators.java:310) + at java.base/java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:735) + at java.base/java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:734) + at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:762) + at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.invokeTestInstancePostProcessors(ClassBasedTestDescriptor.java:377) + at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$instantiateAndPostProcessTestInstance$6(ClassBasedTestDescriptor.java:290) + at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) + at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.instantiateAndPostProcessTestInstance(ClassBasedTestDescriptor.java:289) + at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$testInstancesProvider$4(ClassBasedTestDescriptor.java:279) + at java.base/java.util.Optional.orElseGet(Optional.java:364) + at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$testInstancesProvider$5(ClassBasedTestDescriptor.java:278) + at org.junit.jupiter.engine.execution.TestInstancesProvider.getTestInstances(TestInstancesProvider.java:31) + at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$prepare$0(TestMethodTestDescriptor.java:106) + at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) + at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.prepare(TestMethodTestDescriptor.java:105) + at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.prepare(TestMethodTestDescriptor.java:69) + at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$prepare$2(NodeTestTask.java:123) + at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) + at org.junit.platform.engine.support.hierarchical.NodeTestTask.prepare(NodeTestTask.java:123) + at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:90) + at java.base/java.util.ArrayList.forEach(ArrayList.java:1511) + at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41) + at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155) + at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) + at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141) + at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) + at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139) + at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) + at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138) + at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95) + at java.base/java.util.ArrayList.forEach(ArrayList.java:1511) + at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41) + at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155) + at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) + at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141) + at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) + at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139) + at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) + at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138) + at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95) + at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35) + at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57) + at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54) + at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:147) + at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:127) + at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:90) + at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:55) + at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:102) + at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:54) + at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:114) + at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:95) + at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:91) + at org.junit.platform.launcher.core.SessionPerRequestLauncher.execute(SessionPerRequestLauncher.java:60) + at org.eclipse.jdt.internal.junit5.runner.JUnit5TestReference.run(JUnit5TestReference.java:98) + at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:40) + at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:529) + at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:757) + at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:452) + at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:210) +Caused by: org.h2.jdbc.JdbcSQLNonTransientException: Внутренняя ошибка: "org.h2.mvstore.MVStoreException: The file is locked: C:/Users/a3012/OneDrive/Рабочий стол/PIbd-21_Zhirnova_A.E._INTERNET_PROGRAMMING_BACKEND/PIbd-21_Zhirnova_A.E._INTERNET_PROGRAMMING_BACKEND/3 лаба/backend/data.mv.db [2.2.224/7]" +General error: "org.h2.mvstore.MVStoreException: The file is locked: C:/Users/a3012/OneDrive/Рабочий стол/PIbd-21_Zhirnova_A.E._INTERNET_PROGRAMMING_BACKEND/PIbd-21_Zhirnova_A.E._INTERNET_PROGRAMMING_BACKEND/3 лаба/backend/data.mv.db [2.2.224/7]" [50000-224] + at org.h2.message.DbException.getJdbcSQLException(DbException.java:566) + at org.h2.message.DbException.getJdbcSQLException(DbException.java:489) + ... 138 more +Caused by: org.h2.mvstore.MVStoreException: The file is locked: C:/Users/a3012/OneDrive/Рабочий стол/PIbd-21_Zhirnova_A.E._INTERNET_PROGRAMMING_BACKEND/PIbd-21_Zhirnova_A.E._INTERNET_PROGRAMMING_BACKEND/3 лаба/backend/data.mv.db [2.2.224/7] + at org.h2.mvstore.DataUtils.newMVStoreException(DataUtils.java:996) + at org.h2.mvstore.SingleFileStore.lockFileChannel(SingleFileStore.java:143) + at org.h2.mvstore.SingleFileStore.open(SingleFileStore.java:117) + at org.h2.mvstore.SingleFileStore.open(SingleFileStore.java:81) + at org.h2.mvstore.MVStore.(MVStore.java:286) + ... 132 more +2024-05-11 16:23:59.921353+04:00 database: flush +org.h2.message.DbException: Внутренняя ошибка: "org.h2.mvstore.MVStoreException: The file is locked: C:/Users/a3012/OneDrive/Рабочий стол/PIbd-21_Zhirnova_A.E._INTERNET_PROGRAMMING_BACKEND/PIbd-21_Zhirnova_A.E._INTERNET_PROGRAMMING_BACKEND/3 лаба/backend/data.mv.db [2.2.224/7]" +General error: "org.h2.mvstore.MVStoreException: The file is locked: C:/Users/a3012/OneDrive/Рабочий стол/PIbd-21_Zhirnova_A.E._INTERNET_PROGRAMMING_BACKEND/PIbd-21_Zhirnova_A.E._INTERNET_PROGRAMMING_BACKEND/3 лаба/backend/data.mv.db [2.2.224/7]" [50000-224] + at org.h2.message.DbException.get(DbException.java:212) + at org.h2.message.DbException.convert(DbException.java:407) + at org.h2.mvstore.db.Store.lambda$new$0(Store.java:122) + at org.h2.mvstore.MVStore.handleException(MVStore.java:1546) + at org.h2.mvstore.MVStore.panic(MVStore.java:371) + at org.h2.mvstore.MVStore.(MVStore.java:291) + at org.h2.mvstore.MVStore$Builder.open(MVStore.java:2035) + at org.h2.mvstore.db.Store.(Store.java:133) + at org.h2.engine.Database.(Database.java:326) + at org.h2.engine.Engine.openSession(Engine.java:92) + 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.(JdbcConnection.java:125) + at org.h2.Driver.connect(Driver.java:59) + at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:138) + at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:359) + at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:201) + at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:470) + at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:561) + at com.zaxxer.hikari.pool.HikariPool.(HikariPool.java:100) + at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112) + at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:122) + at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess.obtainConnection(JdbcEnvironmentInitiator.java:428) + at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcIsolationDelegate.delegateWork(JdbcIsolationDelegate.java:61) + at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.getJdbcEnvironmentUsingJdbcMetadata(JdbcEnvironmentInitiator.java:276) + at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:107) + at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:68) + at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:130) + at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:263) + at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:238) + at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:215) + at org.hibernate.boot.model.relational.Database.(Database.java:45) + at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.getDatabase(InFlightMetadataCollectorImpl.java:223) + at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.(InFlightMetadataCollectorImpl.java:191) + at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:170) + at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:1432) + at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1503) + at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:75) + at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:390) + at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:409) + at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:396) + at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:366) + at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1833) + at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1782) + at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:600) + at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:522) + at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326) + at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) + at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324) + at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) + at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1234) + at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:952) + at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:624) + at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754) + at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:456) + at org.springframework.boot.SpringApplication.run(SpringApplication.java:334) + at org.springframework.boot.test.context.SpringBootContextLoader.lambda$loadContext$3(SpringBootContextLoader.java:137) + at org.springframework.util.function.ThrowingSupplier.get(ThrowingSupplier.java:58) + at org.springframework.util.function.ThrowingSupplier.get(ThrowingSupplier.java:46) + at org.springframework.boot.SpringApplication.withHook(SpringApplication.java:1454) + at org.springframework.boot.test.context.SpringBootContextLoader$ContextLoaderHook.run(SpringBootContextLoader.java:553) + at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:137) + at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:108) + at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:225) + at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:152) + at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:130) + at org.springframework.test.context.web.ServletTestExecutionListener.setUpRequestContextIfNecessary(ServletTestExecutionListener.java:191) + at org.springframework.test.context.web.ServletTestExecutionListener.prepareTestInstance(ServletTestExecutionListener.java:130) + at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:260) + at org.springframework.test.context.junit.jupiter.SpringExtension.postProcessTestInstance(SpringExtension.java:163) + at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$invokeTestInstancePostProcessors$10(ClassBasedTestDescriptor.java:378) + at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.executeAndMaskThrowable(ClassBasedTestDescriptor.java:383) + at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$invokeTestInstancePostProcessors$11(ClassBasedTestDescriptor.java:378) + at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197) + at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179) + at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625) + at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) + at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) + at java.base/java.util.stream.StreamSpliterators$WrappingSpliterator.forEachRemaining(StreamSpliterators.java:310) + at java.base/java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:735) + at java.base/java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:734) + at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:762) + at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.invokeTestInstancePostProcessors(ClassBasedTestDescriptor.java:377) + at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$instantiateAndPostProcessTestInstance$6(ClassBasedTestDescriptor.java:290) + at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) + at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.instantiateAndPostProcessTestInstance(ClassBasedTestDescriptor.java:289) + at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$testInstancesProvider$4(ClassBasedTestDescriptor.java:279) + at java.base/java.util.Optional.orElseGet(Optional.java:364) + at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$testInstancesProvider$5(ClassBasedTestDescriptor.java:278) + at org.junit.jupiter.engine.execution.TestInstancesProvider.getTestInstances(TestInstancesProvider.java:31) + at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$prepare$0(TestMethodTestDescriptor.java:106) + at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) + at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.prepare(TestMethodTestDescriptor.java:105) + at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.prepare(TestMethodTestDescriptor.java:69) + at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$prepare$2(NodeTestTask.java:123) + at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) + at org.junit.platform.engine.support.hierarchical.NodeTestTask.prepare(NodeTestTask.java:123) + at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:90) + at java.base/java.util.ArrayList.forEach(ArrayList.java:1511) + at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41) + at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155) + at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) + at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141) + at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) + at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139) + at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) + at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138) + at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95) + at java.base/java.util.ArrayList.forEach(ArrayList.java:1511) + at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41) + at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155) + at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) + at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141) + at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) + at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139) + at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) + at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138) + at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95) + at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35) + at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57) + at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54) + at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:147) + at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:127) + at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:90) + at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:55) + at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:102) + at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:54) + at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:114) + at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:95) + at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:91) + at org.junit.platform.launcher.core.SessionPerRequestLauncher.execute(SessionPerRequestLauncher.java:60) + at org.eclipse.jdt.internal.junit5.runner.JUnit5TestReference.run(JUnit5TestReference.java:98) + at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:40) + at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:529) + at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:757) + at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:452) + at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:210) +Caused by: org.h2.jdbc.JdbcSQLNonTransientException: Внутренняя ошибка: "org.h2.mvstore.MVStoreException: The file is locked: C:/Users/a3012/OneDrive/Рабочий стол/PIbd-21_Zhirnova_A.E._INTERNET_PROGRAMMING_BACKEND/PIbd-21_Zhirnova_A.E._INTERNET_PROGRAMMING_BACKEND/3 лаба/backend/data.mv.db [2.2.224/7]" +General error: "org.h2.mvstore.MVStoreException: The file is locked: C:/Users/a3012/OneDrive/Рабочий стол/PIbd-21_Zhirnova_A.E._INTERNET_PROGRAMMING_BACKEND/PIbd-21_Zhirnova_A.E._INTERNET_PROGRAMMING_BACKEND/3 лаба/backend/data.mv.db [2.2.224/7]" [50000-224] + at org.h2.message.DbException.getJdbcSQLException(DbException.java:566) + at org.h2.message.DbException.getJdbcSQLException(DbException.java:489) + ... 138 more +Caused by: org.h2.mvstore.MVStoreException: The file is locked: C:/Users/a3012/OneDrive/Рабочий стол/PIbd-21_Zhirnova_A.E._INTERNET_PROGRAMMING_BACKEND/PIbd-21_Zhirnova_A.E._INTERNET_PROGRAMMING_BACKEND/3 лаба/backend/data.mv.db [2.2.224/7] + at org.h2.mvstore.DataUtils.newMVStoreException(DataUtils.java:996) + at org.h2.mvstore.SingleFileStore.lockFileChannel(SingleFileStore.java:143) + at org.h2.mvstore.SingleFileStore.open(SingleFileStore.java:117) + at org.h2.mvstore.SingleFileStore.open(SingleFileStore.java:81) + at org.h2.mvstore.MVStore.(MVStore.java:286) + ... 132 more diff --git a/3 лаба/backend/src/main/java/com/example/backend/BackendApplication.java b/3 лаба/backend/src/main/java/com/example/backend/BackendApplication.java index c646ef2..cd35b15 100644 --- a/3 лаба/backend/src/main/java/com/example/backend/BackendApplication.java +++ b/3 лаба/backend/src/main/java/com/example/backend/BackendApplication.java @@ -11,6 +11,8 @@ import com.example.backend.books.model.BookEntity; import com.example.backend.books.service.BookService; import com.example.backend.genres.model.GenreEntity; import com.example.backend.genres.service.GenreService; +import com.example.backend.authors.model.AuthorEntity; +import com.example.backend.authors.service.AuthorService; // create lab 2 @@ -20,10 +22,12 @@ public class BackendApplication implements CommandLineRunner { private final Logger _logger = LoggerFactory.getLogger(BackendApplication.class); private final GenreService genreService; + private final AuthorService authorService; private final BookService bookService; - public BackendApplication(GenreService genreService, BookService bookService) { + public BackendApplication(GenreService genreService, AuthorService authorService, BookService bookService) { this.genreService = genreService; + this.authorService = authorService; this.bookService = bookService; } @@ -46,13 +50,21 @@ public class BackendApplication implements CommandLineRunner { final var genre3 = genreService.create(new GenreEntity(4, "Научная фантастика")); + final var author1 = authorService.create(new AuthorEntity(1, + "aa")); + final var author2 = authorService.create(new AuthorEntity(2, + "bb")); + final var author3 = authorService.create(new AuthorEntity(4, + "cc")); + + _logger.info("Create default movies values"); - bookService.create(new BookEntity(1, genre3, "dd", "1", 4)); - bookService.create(new BookEntity(1, genre1, "ff", "2", 6)); - bookService.create(new BookEntity(1, genre2, "ffd ", "3", 3)); - bookService.create(new BookEntity(1, genre3, "gggfg", "4", 7)); - bookService.create(new BookEntity(1, genre3, "erer", "5", 8)); + bookService.create(new BookEntity(1, genre3, author2, "dd", "1", 4)); + bookService.create(new BookEntity(1, genre1, author3, "ff", "2", 6)); + bookService.create(new BookEntity(1, genre2, author1, "ffd ", "3", 3)); + bookService.create(new BookEntity(1, genre3, author3, "gggfg", "4", 7)); + bookService.create(new BookEntity(1, genre3, author2, "erer", "5", 8)); } } diff --git a/3 лаба/backend/src/main/java/com/example/backend/authors/api/AuthorController.java b/3 лаба/backend/src/main/java/com/example/backend/authors/api/AuthorController.java new file mode 100644 index 0000000..55d276e --- /dev/null +++ b/3 лаба/backend/src/main/java/com/example/backend/authors/api/AuthorController.java @@ -0,0 +1,69 @@ +package com.example.backend.authors.api; + +import java.util.List; + +import org.modelmapper.ModelMapper; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import com.example.backend.core.configurations.Constants; +import com.example.backend.authors.model.AuthorEntity; +import com.example.backend.authors.service.AuthorService; + +import jakarta.validation.Valid; + +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.PutMapping; + +@RestController +@RequestMapping(Constants.API_URL + "/author") + +public class AuthorController { + + private final AuthorService authorService; + private final ModelMapper modelMapper; + + public AuthorController(AuthorService authorService, ModelMapper modelMapper) { + this.authorService = authorService; + this.modelMapper = modelMapper; + } + + private AuthorDTO toDto(AuthorEntity entity) { + return modelMapper.map(entity, AuthorDTO.class); + } + + private AuthorEntity toEntity(AuthorDTO authorDTO) { + return modelMapper.map(authorDTO, AuthorEntity.class); + } + + @GetMapping() + public List getAll() { + return authorService.getAll().stream().map(this::toDto).toList(); + } + + @GetMapping("/{id}") + public AuthorDTO get(@PathVariable(name = "id") Integer id) { + return toDto(authorService.get(id)); + } + + @PostMapping + public AuthorDTO create(@RequestBody @Valid AuthorDTO authorDTO) { + + return toDto(authorService.create(toEntity(authorDTO))); + } + + @PutMapping("/{id}") + public AuthorDTO update(@PathVariable(name = "id") Integer id, @RequestBody AuthorDTO authorDTO) { + return toDto(authorService.update(id, toEntity(authorDTO))); + } + + @DeleteMapping("/{id}") + public AuthorDTO delete(@PathVariable(name = "id") Integer id) { + return toDto(authorService.delete(id)); + } + +} diff --git a/3 лаба/backend/src/main/java/com/example/backend/authors/api/AuthorDTO.java b/3 лаба/backend/src/main/java/com/example/backend/authors/api/AuthorDTO.java new file mode 100644 index 0000000..0fcd959 --- /dev/null +++ b/3 лаба/backend/src/main/java/com/example/backend/authors/api/AuthorDTO.java @@ -0,0 +1,37 @@ +package com.example.backend.authors.api; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.Size; + +public class AuthorDTO { + + @JsonProperty(access = JsonProperty.Access.READ_ONLY) + private Integer id; + + @NotBlank + @Size(min = 5, max = 50) + private String name; + + + + @JsonProperty(access = JsonProperty.Access.READ_ONLY) + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + +} diff --git a/3 лаба/backend/src/main/java/com/example/backend/authors/model/AuthorEntity.java b/3 лаба/backend/src/main/java/com/example/backend/authors/model/AuthorEntity.java new file mode 100644 index 0000000..2cebb6c --- /dev/null +++ b/3 лаба/backend/src/main/java/com/example/backend/authors/model/AuthorEntity.java @@ -0,0 +1,53 @@ +package com.example.backend.authors.model; + +import java.util.Objects; + +import com.example.backend.core.model.BaseEntity; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Table; + +@Entity +@Table(name = "authors") +public class AuthorEntity extends BaseEntity { + + @Column(nullable = false, unique = true, length = 50) + private String name; + + + public AuthorEntity() { + + } + + public AuthorEntity(Integer id, String name) { + this.name = name; + + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + + @Override + public int hashCode() { + return Objects.hash(id, name); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null || getClass() != obj.getClass()) + return false; + final AuthorEntity other = (AuthorEntity) obj; + return Objects.equals(other.getId(), id) && + Objects.equals(other.getName(), name); + } + +} diff --git a/3 лаба/backend/src/main/java/com/example/backend/authors/repository/AuthorRepository.java b/3 лаба/backend/src/main/java/com/example/backend/authors/repository/AuthorRepository.java new file mode 100644 index 0000000..d06a48e --- /dev/null +++ b/3 лаба/backend/src/main/java/com/example/backend/authors/repository/AuthorRepository.java @@ -0,0 +1,11 @@ +package com.example.backend.authors.repository; + +import java.util.Optional; + +import org.springframework.data.repository.CrudRepository; + +import com.example.backend.authors.model.AuthorEntity; + +public interface AuthorRepository extends CrudRepository { + Optional findByNameIgnoreCase(String name); +} diff --git a/3 лаба/backend/src/main/java/com/example/backend/authors/service/AuthorService.java b/3 лаба/backend/src/main/java/com/example/backend/authors/service/AuthorService.java new file mode 100644 index 0000000..1f66432 --- /dev/null +++ b/3 лаба/backend/src/main/java/com/example/backend/authors/service/AuthorService.java @@ -0,0 +1,63 @@ +package com.example.backend.authors.service; + +import java.util.List; + +import java.util.stream.StreamSupport; + +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import com.example.backend.core.errors.NotFoundException; +import com.example.backend.authors.model.AuthorEntity; +import com.example.backend.authors.repository.AuthorRepository; + +@Service +public class AuthorService { + + private final AuthorRepository repository; + + public AuthorService(AuthorRepository repository) { + this.repository = repository; + } + + private void checkName(String name) { + if (repository.findByNameIgnoreCase(name).isPresent()) { + throw new IllegalArgumentException( + String.format("Type with name %s is already exists", name)); + } + } + + @Transactional(readOnly = true) + public List getAll() { + return StreamSupport.stream(repository.findAll().spliterator(), false).toList(); + } + + @Transactional(readOnly = true) + public AuthorEntity get(Integer id) { + return repository.findById(id).orElseThrow(() -> new NotFoundException(id)); + } + + @Transactional + public AuthorEntity create(AuthorEntity entity) { + if (entity == null) { + throw new IllegalArgumentException("Сущность не найдена"); + } + checkName(entity.getName()); + return repository.save(entity); + } + + @Transactional + public AuthorEntity update(Integer id, AuthorEntity entity) { + final AuthorEntity existsentity = get(id); + existsentity.setName(entity.getName()); + return repository.save(existsentity); + } + + @Transactional + public AuthorEntity delete(Integer id) { + final AuthorEntity existsentity = get(id); + repository.delete(existsentity); + return existsentity; + } + +} diff --git a/3 лаба/backend/src/main/java/com/example/backend/books/api/BookController.java b/3 лаба/backend/src/main/java/com/example/backend/books/api/BookController.java index 23a5765..b49c5e7 100644 --- a/3 лаба/backend/src/main/java/com/example/backend/books/api/BookController.java +++ b/3 лаба/backend/src/main/java/com/example/backend/books/api/BookController.java @@ -10,6 +10,7 @@ import com.example.backend.books.model.BookEntity; import com.example.backend.books.service.BookService; import com.example.backend.core.configurations.Constants; import com.example.backend.genres.service.GenreService; +import com.example.backend.authors.service.AuthorService; import jakarta.validation.Valid; @@ -27,11 +28,13 @@ public class BookController { private final BookService bookService; private final GenreService genreService; + private final AuthorService authorService; private final ModelMapper modelMapper; - public BookController(BookService bookService, GenreService genreService, ModelMapper modelMapper) { + public BookController(BookService bookService, GenreService genreService, AuthorService authorService, ModelMapper modelMapper) { this.modelMapper = modelMapper; this.genreService = genreService; + this.authorService = authorService; this.bookService = bookService; } @@ -42,13 +45,19 @@ public class BookController { private BookEntity toEntity(BookDTO dto) { final BookEntity entity = modelMapper.map(dto, BookEntity.class); entity.setGenre(genreService.get(dto.getGenreId())); + entity.setAuthor(authorService.get(dto.getAuthorId())); return entity; } + + @GetMapping - public List getAll(@RequestParam(name = "genreId", defaultValue = "0") Integer genreId) { - return bookService.getAll(genreId).stream().map(this::toDto).toList(); - } +public List getAll(@RequestParam(name = "genreId", defaultValue = "0") Integer genreId, + @RequestParam(name = "authorId", defaultValue = "0") Integer authorId) { + return bookService.getAll(genreId, authorId).stream().map(this::toDto).toList(); +} + + @GetMapping("/{id}") public BookDTO get(@PathVariable(name = "id") Integer id) { diff --git a/3 лаба/backend/src/main/java/com/example/backend/books/api/BookDTO.java b/3 лаба/backend/src/main/java/com/example/backend/books/api/BookDTO.java index 86da7b1..6a9c1c7 100644 --- a/3 лаба/backend/src/main/java/com/example/backend/books/api/BookDTO.java +++ b/3 лаба/backend/src/main/java/com/example/backend/books/api/BookDTO.java @@ -16,6 +16,10 @@ public class BookDTO { @Min(1) private Integer genreId; + @NotNull + @Min(1) + private Integer authorId; + @NotBlank @Size(min = 2, max = 50) private String name; @@ -46,6 +50,14 @@ public class BookDTO { this.genreId = genreId; } + public Integer getAuthorId() { + return authorId; + } + + public void setAuthorId(Integer authorId) { + this.authorId = authorId; + } + public String getName() { return name; } @@ -54,13 +66,19 @@ public class BookDTO { this.name = name; } - + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } public Integer getCount() { return count; } - public void setDuration(Integer count) { + public void setCount(Integer count) { this.count = count; } diff --git a/3 лаба/backend/src/main/java/com/example/backend/books/model/BookEntity.java b/3 лаба/backend/src/main/java/com/example/backend/books/model/BookEntity.java index 40a9d28..01dd3b2 100644 --- a/3 лаба/backend/src/main/java/com/example/backend/books/model/BookEntity.java +++ b/3 лаба/backend/src/main/java/com/example/backend/books/model/BookEntity.java @@ -4,6 +4,7 @@ import java.util.Objects; import com.example.backend.core.model.BaseEntity; import com.example.backend.genres.model.GenreEntity; +import com.example.backend.authors.model.AuthorEntity; import jakarta.persistence.Column; import jakarta.persistence.Entity; @@ -19,6 +20,10 @@ public class BookEntity extends BaseEntity { @JoinColumn(name = "genreId", nullable = false) private GenreEntity genre; + @ManyToOne + @JoinColumn(name = "authorId", nullable = false) + private AuthorEntity author; + @Column(nullable = false, unique = true, length = 50) private String name; @@ -34,9 +39,10 @@ public class BookEntity extends BaseEntity { super(); } - public BookEntity(Integer id, GenreEntity genre, String name, String description, Integer count) { + public BookEntity(Integer id, GenreEntity genre, AuthorEntity author, String name, String description, Integer count) { this.genre = genre; + this.author = author; this.name = name; this.description = description; this.count = count; @@ -51,6 +57,15 @@ public class BookEntity extends BaseEntity { this.genre = genre; } + public AuthorEntity getAuthor() { + return author; + } + + public void setAuthor(AuthorEntity author) { + this.author = author; + } + + public String getName() { return name; } @@ -79,7 +94,7 @@ public class BookEntity extends BaseEntity { @Override public int hashCode() { - return Objects.hash(id, genre, name, description, count); + return Objects.hash(id, genre, author, name, description, count); } @Override @@ -91,6 +106,7 @@ public class BookEntity extends BaseEntity { final BookEntity other = (BookEntity) obj; return Objects.equals(other.getId(), id) && Objects.equals(other.getGenre(), genre) + && Objects.equals(other.getAuthor(), author) && Objects.equals(other.getName(), name) && Objects.equals(other.getDescription(), description) && Objects.equals(other.getCount(), count); diff --git a/3 лаба/backend/src/main/java/com/example/backend/books/repository/BookRepository.java b/3 лаба/backend/src/main/java/com/example/backend/books/repository/BookRepository.java index eada141..44cf60b 100644 --- a/3 лаба/backend/src/main/java/com/example/backend/books/repository/BookRepository.java +++ b/3 лаба/backend/src/main/java/com/example/backend/books/repository/BookRepository.java @@ -17,6 +17,12 @@ public interface BookRepository extends CrudRepository { List findByGenreId(Integer genreId); + Optional findByAuthorIdAndId(Integer authorId, Integer id); + + List findByAuthorId(Integer authorId); + + List findByGenreIdAndAuthorId(Integer genreId, Integer authorId); + } \ No newline at end of file diff --git a/3 лаба/backend/src/main/java/com/example/backend/books/service/BookService.java b/3 лаба/backend/src/main/java/com/example/backend/books/service/BookService.java index c25724a..fda4bf6 100644 --- a/3 лаба/backend/src/main/java/com/example/backend/books/service/BookService.java +++ b/3 лаба/backend/src/main/java/com/example/backend/books/service/BookService.java @@ -27,13 +27,18 @@ public class BookService { } @Transactional(readOnly = true) - public List getAll(Integer genreId) { - - if (genreId == 0) { + public List getAll(Integer genreId, Integer authorId) { + if (genreId == 0 && authorId == 0) { return StreamSupport.stream(repository.findAll().spliterator(), false).toList(); + } else if (genreId != 0 && authorId == 0) { + return repository.findByGenreId(genreId); + } else if (genreId == 0 && authorId != 0) { + return repository.findByAuthorId(authorId); + } else { + return repository.findByGenreIdAndAuthorId(genreId, authorId); } - return repository.findByGenreId(genreId); } + @Transactional(readOnly = true) public BookEntity get(Integer id) { diff --git a/3 лаба/backend/src/test/java/com/example/backend/AuthorServiceTests.java b/3 лаба/backend/src/test/java/com/example/backend/AuthorServiceTests.java new file mode 100644 index 0000000..cc2f31f --- /dev/null +++ b/3 лаба/backend/src/test/java/com/example/backend/AuthorServiceTests.java @@ -0,0 +1,77 @@ +package com.example.backend; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.dao.DataIntegrityViolationException; + +import com.example.backend.core.errors.NotFoundException; +import com.example.backend.authors.model.AuthorEntity; +import com.example.backend.authors.service.AuthorService; + +@SpringBootTest +class AuthorServiceTests { + @Autowired + private AuthorService authorService; + + private AuthorEntity author; + + @BeforeEach + void createData() { + removeData(); + + author = authorService.create(new AuthorEntity(1, "Drama")); + authorService.create(new AuthorEntity(2, "Comedy")); + + } + + @AfterEach + void removeData() { + authorService.getAll().forEach(item -> authorService.delete(item.getId())); + } + + @Test + void getTest() { + Assertions.assertThrows(NotFoundException.class, () -> authorService.get(0)); + } + + @Test + void createTest() { + Assertions.assertEquals(2, authorService.getAll().size()); + Assertions.assertEquals(author, authorService.get(author.getId())); + } + + @Test + void createNotUniqueTest() { + final AuthorEntity nonUniqueAuthor = new AuthorEntity(1, "Drama"); + Assertions.assertThrows(IllegalArgumentException.class, () -> authorService.create(nonUniqueAuthor)); + } + + @Test + void createNullableTest() { + final AuthorEntity nullableAuthor = new AuthorEntity(1, null); + Assertions.assertThrows(DataIntegrityViolationException.class, () -> authorService.create( + nullableAuthor)); + } + + @Test + void updateTest() { + final String newName = "TEST"; + final String oldName = author.getName(); + final AuthorEntity cat = new AuthorEntity(author.getId(), newName); + final AuthorEntity newEntity = authorService.update(author.getId(), cat); + Assertions.assertEquals(newName, newEntity.getName()); + Assertions.assertNotEquals(oldName, newEntity.getName()); + } + + @Test + void deleteTest() { + authorService.delete(author.getId()); + Assertions.assertEquals(1, authorService.getAll().size()); + + Assertions.assertNotEquals(3, authorService.getAll().size()); + } +} diff --git a/3 лаба/backend/src/test/java/com/example/backend/BookServiceTest.java b/3 лаба/backend/src/test/java/com/example/backend/BookServiceTest.java index 8915787..432c9b0 100644 --- a/3 лаба/backend/src/test/java/com/example/backend/BookServiceTest.java +++ b/3 лаба/backend/src/test/java/com/example/backend/BookServiceTest.java @@ -16,6 +16,9 @@ import com.example.backend.books.service.BookService; import com.example.backend.core.errors.NotFoundException; import com.example.backend.genres.model.GenreEntity; import com.example.backend.genres.service.GenreService; +import com.example.backend.authors.model.AuthorEntity; +import com.example.backend.authors.service.AuthorService; + import com.example.backend.users.model.UserEntity; import com.example.backend.users.service.UserService; @@ -34,8 +37,13 @@ class BookServiceTest { @Autowired private GenreService genreService; + @Autowired + private AuthorService authorService; + private GenreEntity cat; + private AuthorEntity author; + @Autowired private UserService userService; @@ -52,76 +60,69 @@ class BookServiceTest { cat = genreService.create(new GenreEntity(0, "Drama")); + author = authorService.create(new AuthorEntity(0, "Drama")); + user = userService.create(new UserEntity(0, "1", "1", true)); user1 = userService.create(new UserEntity(0, "2", "2", true)); user2 = userService.create(new UserEntity(0, "3", "3", true)); user3 = userService.create(new UserEntity(0, "4", "4", true)); - book = bookService.create(new BookEntity(0, cat, "1", "6", 6)); - book2 = bookService.create(new BookEntity(0, cat, "2", "2", 9)); - - - + book = bookService.create(new BookEntity(0, cat, author, "1", "6", 6)); + book2 = bookService.create(new BookEntity(0, cat, author, "2", "2", 9)); } @AfterEach - void removeData() { - - userService.getAll().forEach(u -> userService.delete(u.getId())); - bookService.getAll(0).forEach(item -> bookService.delete(item.getId())); - genreService.getAll().forEach(item -> genreService.delete(item.getId())); - } +void removeData() { + userService.getAll().forEach(u -> userService.delete(u.getId())); + bookService.getAll(0, 0).forEach(item -> bookService.delete(item.getId())); + genreService.getAll().forEach(item -> genreService.delete(item.getId())); + authorService.getAll().forEach(item -> authorService.delete(item.getId())); +} + + @Test - @Order(1) - void getTest() { - Assertions.assertThrows(NotFoundException.class, () -> bookService.get(10)); - } - - @Test - @Order(2) - void createTest() { - Assertions.assertEquals(2, bookService.getAll(cat.getId()).size()); - Assertions.assertEquals(book, bookService.get(book.getId())); - } - +@Order(1) +void createTest() { + Assertions.assertEquals(2, bookService.getAll(cat.getId(), author.getId()).size()); + Assertions.assertEquals(book, bookService.get(book.getId())); +} +@Test +@Order(2) +void getTest() { + Assertions.assertThrows(NotFoundException.class, () -> bookService.get(10)); +} @Test @Order(3) void createNotUniqueTest() { - final BookEntity nonUniqueGenre = new BookEntity(3, cat, "1", "1", 7); + final BookEntity nonUniqueGenre = new BookEntity(3, cat, author, "1", "1", 7); Assertions.assertThrows(IllegalArgumentException.class, () -> bookService.create(nonUniqueGenre)); } - @Test @Order(4) void createNullableTest() { - final BookEntity nullableGenre = new BookEntity(1, cat, null, "1",9); + final BookEntity nullableGenre = new BookEntity(1, cat, author, null, "1",9); Assertions.assertThrows(DataIntegrityViolationException.class, () -> bookService.create( nullableGenre)); } - @Test @Order(5) void updateTest() { final String newName = "TEST"; final String oldName = book.getName(); - final BookEntity mov = new BookEntity(book.getId(), book.getGenre(), + final BookEntity mov = new BookEntity(book.getId(), book.getGenre(), book.getAuthor(), newName, book.getDescription(), book.getCount()); final BookEntity newEntity = bookService.update(book.getId(), mov); Assertions.assertEquals(newName, newEntity.getName()); Assertions.assertNotEquals(oldName, newEntity.getName()); } - @Test @Order(6) void deleteTest() { bookService.delete(book2.getId()); - Assertions.assertEquals(1, bookService.getAll(cat.getId()).size()); + Assertions.assertEquals(0, bookService.getAll(cat.getId(), cat.getId()).size()); - Assertions.assertNotEquals(3, bookService.getAll(cat.getId()).size()); + Assertions.assertNotEquals(3, bookService.getAll(cat.getId(), author.getId()).size()); } - - - } diff --git a/3 лаба/backend/src/test/java/com/example/backend/FavoriteServiceTests.java b/3 лаба/backend/src/test/java/com/example/backend/FavoriteServiceTests.java index 915ef3c..b92b4c4 100644 --- a/3 лаба/backend/src/test/java/com/example/backend/FavoriteServiceTests.java +++ b/3 лаба/backend/src/test/java/com/example/backend/FavoriteServiceTests.java @@ -17,6 +17,8 @@ import com.example.backend.favorites.model.FavoriteEntity; import com.example.backend.favorites.service.FavoriteService; import com.example.backend.genres.model.GenreEntity; import com.example.backend.genres.service.GenreService; +import com.example.backend.authors.model.AuthorEntity; +import com.example.backend.authors.service.AuthorService; import com.example.backend.users.model.UserEntity; import com.example.backend.users.service.UserService; @@ -31,6 +33,9 @@ public class FavoriteServiceTests { private FavoriteEntity lastFavorite2; private GenreEntity cat1; + private AuthorEntity author1; + private GenreEntity cat2; + private AuthorEntity author2; private BookEntity mov1; private BookEntity mov2; private UserEntity us1; @@ -38,6 +43,9 @@ public class FavoriteServiceTests { @Autowired private GenreService genreService; + @Autowired + private AuthorService authorService; + @Autowired private BookService bookService; @@ -47,25 +55,36 @@ public class FavoriteServiceTests { @BeforeEach void createData() { removeData(); - + cat1 = genreService.create(new GenreEntity(null, "Драма")); - - mov1 = bookService.create(new BookEntity(null, cat1, "gffg", "gffg", 0)); - mov2 = bookService.create(new BookEntity(null, cat1, "lol", - "2",8)); - + author1 = authorService.create(new AuthorEntity(null, "Иванов")); + cat2 = genreService.create(new GenreEntity(null, "Фантастика")); + author2 = authorService.create(new AuthorEntity(null, "Петров")); + + mov1 = bookService.create(new BookEntity(null, cat1, author1, "gffg", "gffg", 0)); + mov2 = bookService.create(new BookEntity(null, cat2, author2, "lol", "2", 8)); + us1 = userService.create(new UserEntity(null, "alyona", "123", true)); - + lastFavorite = favoriteService.create(new FavoriteEntity(null, us1, mov1)); lastFavorite2 = favoriteService.create(new FavoriteEntity(null, us1, mov2)); } + + @AfterEach void removeData() { favoriteService.getAll(0).forEach(fv -> favoriteService.delete(fv.getId())); userService.getAll().forEach(u -> userService.delete(u.getId())); - bookService.getAll(0).forEach(item -> bookService.delete(item.getId())); + bookService.getAll(0, 0).forEach(item -> bookService.delete(item.getId())); genreService.getAll().forEach(item -> genreService.delete(item.getId())); + authorService.getAll().forEach(item -> authorService.delete(item.getId())); + } + + + @Test + void createTest() { + Assertions.assertEquals(2, favoriteService.getAll(us1.getId()).size()); } @Test @@ -73,23 +92,20 @@ public class FavoriteServiceTests { Assertions.assertThrows(NotFoundException.class, () -> favoriteService.get(0)); } - @Test - void createTest() { - Assertions.assertEquals(2, favoriteService.getAll(us1.getId()).size()); - } @Test - void update() { - final FavoriteEntity fav = favoriteService.create(new FavoriteEntity(null, us1, mov2)); +void update() { + final String newBookName = "New Book Name"; + + final FavoriteEntity oldFav = favoriteService.get(lastFavorite.getId()); + oldFav.getBook().setName(newBookName); // Обновляем только название книги + + final FavoriteEntity newFav = favoriteService.update(lastFavorite2.getId(), oldFav); + + Assertions.assertEquals(newBookName, newFav.getBook().getName()); +} - final FavoriteEntity oldFav = favoriteService.get(lastFavorite.getId()); - - final FavoriteEntity newFav = favoriteService.update(lastFavorite2.getId(), fav); - - Assertions.assertNotEquals(oldFav.getBook().getName(), - newFav.getBook().getName()); - - } + @Test @Order(3)