Вроде живет :D

This commit is contained in:
Allllen4a 2024-05-11 16:39:25 +04:00
parent aeda331958
commit 763feff798
16 changed files with 926 additions and 74 deletions

Binary file not shown.

View File

@ -0,0 +1,459 @@
2024-05-11 16:11:04.962597+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.<init>(MVStore.java:291)
at org.h2.mvstore.MVStore$Builder.open(MVStore.java:2035)
at org.h2.mvstore.db.Store.<init>(Store.java:133)
at org.h2.engine.Database.<init>(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.<init>(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.<init>(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.<init>(Database.java:45)
at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.getDatabase(InFlightMetadataCollectorImpl.java:223)
at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.<init>(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.<init>(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.<init>(MVStore.java:291)
at org.h2.mvstore.MVStore$Builder.open(MVStore.java:2035)
at org.h2.mvstore.db.Store.<init>(Store.java:133)
at org.h2.engine.Database.<init>(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.<init>(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.<init>(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.<init>(Database.java:45)
at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.getDatabase(InFlightMetadataCollectorImpl.java:223)
at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.<init>(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.<init>(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.<init>(MVStore.java:291)
at org.h2.mvstore.MVStore$Builder.open(MVStore.java:2035)
at org.h2.mvstore.db.Store.<init>(Store.java:133)
at org.h2.engine.Database.<init>(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.<init>(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.<init>(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.<init>(Database.java:45)
at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.getDatabase(InFlightMetadataCollectorImpl.java:223)
at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.<init>(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.<init>(MVStore.java:286)
... 132 more

View File

@ -11,6 +11,8 @@ import com.example.backend.books.model.BookEntity;
import com.example.backend.books.service.BookService; import com.example.backend.books.service.BookService;
import com.example.backend.genres.model.GenreEntity; import com.example.backend.genres.model.GenreEntity;
import com.example.backend.genres.service.GenreService; import com.example.backend.genres.service.GenreService;
import com.example.backend.authors.model.AuthorEntity;
import com.example.backend.authors.service.AuthorService;
// create lab 2 // create lab 2
@ -20,10 +22,12 @@ public class BackendApplication implements CommandLineRunner {
private final Logger _logger = LoggerFactory.getLogger(BackendApplication.class); private final Logger _logger = LoggerFactory.getLogger(BackendApplication.class);
private final GenreService genreService; private final GenreService genreService;
private final AuthorService authorService;
private final BookService bookService; private final BookService bookService;
public BackendApplication(GenreService genreService, BookService bookService) { public BackendApplication(GenreService genreService, AuthorService authorService, BookService bookService) {
this.genreService = genreService; this.genreService = genreService;
this.authorService = authorService;
this.bookService = bookService; this.bookService = bookService;
} }
@ -46,13 +50,21 @@ public class BackendApplication implements CommandLineRunner {
final var genre3 = genreService.create(new GenreEntity(4, 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"); _logger.info("Create default movies values");
bookService.create(new BookEntity(1, genre3, "dd", "1", 4)); bookService.create(new BookEntity(1, genre3, author2, "dd", "1", 4));
bookService.create(new BookEntity(1, genre1, "ff", "2", 6)); bookService.create(new BookEntity(1, genre1, author3, "ff", "2", 6));
bookService.create(new BookEntity(1, genre2, "ffd ", "3", 3)); bookService.create(new BookEntity(1, genre2, author1, "ffd ", "3", 3));
bookService.create(new BookEntity(1, genre3, "gggfg", "4", 7)); bookService.create(new BookEntity(1, genre3, author3, "gggfg", "4", 7));
bookService.create(new BookEntity(1, genre3, "erer", "5", 8)); bookService.create(new BookEntity(1, genre3, author2, "erer", "5", 8));
} }
} }

View File

@ -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<AuthorDTO> 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));
}
}

View File

@ -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;
}
}

View File

@ -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);
}
}

View File

@ -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<AuthorEntity, Integer> {
Optional<AuthorEntity> findByNameIgnoreCase(String name);
}

View File

@ -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<AuthorEntity> 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;
}
}

View File

@ -10,6 +10,7 @@ import com.example.backend.books.model.BookEntity;
import com.example.backend.books.service.BookService; import com.example.backend.books.service.BookService;
import com.example.backend.core.configurations.Constants; import com.example.backend.core.configurations.Constants;
import com.example.backend.genres.service.GenreService; import com.example.backend.genres.service.GenreService;
import com.example.backend.authors.service.AuthorService;
import jakarta.validation.Valid; import jakarta.validation.Valid;
@ -27,11 +28,13 @@ public class BookController {
private final BookService bookService; private final BookService bookService;
private final GenreService genreService; private final GenreService genreService;
private final AuthorService authorService;
private final ModelMapper modelMapper; 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.modelMapper = modelMapper;
this.genreService = genreService; this.genreService = genreService;
this.authorService = authorService;
this.bookService = bookService; this.bookService = bookService;
} }
@ -42,14 +45,20 @@ public class BookController {
private BookEntity toEntity(BookDTO dto) { private BookEntity toEntity(BookDTO dto) {
final BookEntity entity = modelMapper.map(dto, BookEntity.class); final BookEntity entity = modelMapper.map(dto, BookEntity.class);
entity.setGenre(genreService.get(dto.getGenreId())); entity.setGenre(genreService.get(dto.getGenreId()));
entity.setAuthor(authorService.get(dto.getAuthorId()));
return entity; return entity;
} }
@GetMapping @GetMapping
public List<BookDTO> getAll(@RequestParam(name = "genreId", defaultValue = "0") Integer genreId) { public List<BookDTO> getAll(@RequestParam(name = "genreId", defaultValue = "0") Integer genreId,
return bookService.getAll(genreId).stream().map(this::toDto).toList(); @RequestParam(name = "authorId", defaultValue = "0") Integer authorId) {
return bookService.getAll(genreId, authorId).stream().map(this::toDto).toList();
} }
@GetMapping("/{id}") @GetMapping("/{id}")
public BookDTO get(@PathVariable(name = "id") Integer id) { public BookDTO get(@PathVariable(name = "id") Integer id) {
return toDto(bookService.get(id)); return toDto(bookService.get(id));

View File

@ -16,6 +16,10 @@ public class BookDTO {
@Min(1) @Min(1)
private Integer genreId; private Integer genreId;
@NotNull
@Min(1)
private Integer authorId;
@NotBlank @NotBlank
@Size(min = 2, max = 50) @Size(min = 2, max = 50)
private String name; private String name;
@ -46,6 +50,14 @@ public class BookDTO {
this.genreId = genreId; this.genreId = genreId;
} }
public Integer getAuthorId() {
return authorId;
}
public void setAuthorId(Integer authorId) {
this.authorId = authorId;
}
public String getName() { public String getName() {
return name; return name;
} }
@ -54,13 +66,19 @@ public class BookDTO {
this.name = name; this.name = name;
} }
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Integer getCount() { public Integer getCount() {
return count; return count;
} }
public void setDuration(Integer count) { public void setCount(Integer count) {
this.count = count; this.count = count;
} }

View File

@ -4,6 +4,7 @@ import java.util.Objects;
import com.example.backend.core.model.BaseEntity; import com.example.backend.core.model.BaseEntity;
import com.example.backend.genres.model.GenreEntity; import com.example.backend.genres.model.GenreEntity;
import com.example.backend.authors.model.AuthorEntity;
import jakarta.persistence.Column; import jakarta.persistence.Column;
import jakarta.persistence.Entity; import jakarta.persistence.Entity;
@ -19,6 +20,10 @@ public class BookEntity extends BaseEntity {
@JoinColumn(name = "genreId", nullable = false) @JoinColumn(name = "genreId", nullable = false)
private GenreEntity genre; private GenreEntity genre;
@ManyToOne
@JoinColumn(name = "authorId", nullable = false)
private AuthorEntity author;
@Column(nullable = false, unique = true, length = 50) @Column(nullable = false, unique = true, length = 50)
private String name; private String name;
@ -34,9 +39,10 @@ public class BookEntity extends BaseEntity {
super(); 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.genre = genre;
this.author = author;
this.name = name; this.name = name;
this.description = description; this.description = description;
this.count = count; this.count = count;
@ -51,6 +57,15 @@ public class BookEntity extends BaseEntity {
this.genre = genre; this.genre = genre;
} }
public AuthorEntity getAuthor() {
return author;
}
public void setAuthor(AuthorEntity author) {
this.author = author;
}
public String getName() { public String getName() {
return name; return name;
} }
@ -79,7 +94,7 @@ public class BookEntity extends BaseEntity {
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(id, genre, name, description, count); return Objects.hash(id, genre, author, name, description, count);
} }
@Override @Override
@ -91,6 +106,7 @@ public class BookEntity extends BaseEntity {
final BookEntity other = (BookEntity) obj; final BookEntity other = (BookEntity) obj;
return Objects.equals(other.getId(), id) return Objects.equals(other.getId(), id)
&& Objects.equals(other.getGenre(), genre) && Objects.equals(other.getGenre(), genre)
&& Objects.equals(other.getAuthor(), author)
&& Objects.equals(other.getName(), name) && Objects.equals(other.getName(), name)
&& Objects.equals(other.getDescription(), description) && Objects.equals(other.getDescription(), description)
&& Objects.equals(other.getCount(), count); && Objects.equals(other.getCount(), count);

View File

@ -17,6 +17,12 @@ public interface BookRepository extends CrudRepository<BookEntity, Integer> {
List<BookEntity> findByGenreId(Integer genreId); List<BookEntity> findByGenreId(Integer genreId);
Optional<BookEntity> findByAuthorIdAndId(Integer authorId, Integer id);
List<BookEntity> findByAuthorId(Integer authorId);
List<BookEntity> findByGenreIdAndAuthorId(Integer genreId, Integer authorId);
} }

View File

@ -27,13 +27,18 @@ public class BookService {
} }
@Transactional(readOnly = true) @Transactional(readOnly = true)
public List<BookEntity> getAll(Integer genreId) { public List<BookEntity> getAll(Integer genreId, Integer authorId) {
if (genreId == 0 && authorId == 0) {
if (genreId == 0) {
return StreamSupport.stream(repository.findAll().spliterator(), false).toList(); return StreamSupport.stream(repository.findAll().spliterator(), false).toList();
} } else if (genreId != 0 && authorId == 0) {
return repository.findByGenreId(genreId); return repository.findByGenreId(genreId);
} else if (genreId == 0 && authorId != 0) {
return repository.findByAuthorId(authorId);
} else {
return repository.findByGenreIdAndAuthorId(genreId, authorId);
} }
}
@Transactional(readOnly = true) @Transactional(readOnly = true)
public BookEntity get(Integer id) { public BookEntity get(Integer id) {

View File

@ -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());
}
}

View File

@ -16,6 +16,9 @@ import com.example.backend.books.service.BookService;
import com.example.backend.core.errors.NotFoundException; import com.example.backend.core.errors.NotFoundException;
import com.example.backend.genres.model.GenreEntity; import com.example.backend.genres.model.GenreEntity;
import com.example.backend.genres.service.GenreService; 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.model.UserEntity;
import com.example.backend.users.service.UserService; import com.example.backend.users.service.UserService;
@ -34,8 +37,13 @@ class BookServiceTest {
@Autowired @Autowired
private GenreService genreService; private GenreService genreService;
@Autowired
private AuthorService authorService;
private GenreEntity cat; private GenreEntity cat;
private AuthorEntity author;
@Autowired @Autowired
private UserService userService; private UserService userService;
@ -52,76 +60,69 @@ class BookServiceTest {
cat = genreService.create(new GenreEntity(0, "Drama")); cat = genreService.create(new GenreEntity(0, "Drama"));
author = authorService.create(new AuthorEntity(0, "Drama"));
user = userService.create(new UserEntity(0, "1", "1", true)); user = userService.create(new UserEntity(0, "1", "1", true));
user1 = userService.create(new UserEntity(0, "2", "2", true)); user1 = userService.create(new UserEntity(0, "2", "2", true));
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", "6", 6)); book = bookService.create(new BookEntity(0, cat, author, "1", "6", 6));
book2 = bookService.create(new BookEntity(0, cat, "2", "2", 9)); book2 = bookService.create(new BookEntity(0, cat, author, "2", "2", 9));
} }
@AfterEach @AfterEach
void removeData() { void removeData() {
userService.getAll().forEach(u -> userService.delete(u.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())); genreService.getAll().forEach(item -> genreService.delete(item.getId()));
authorService.getAll().forEach(item -> authorService.delete(item.getId()));
} }
@Test @Test
@Order(1) @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() { void getTest() {
Assertions.assertThrows(NotFoundException.class, () -> bookService.get(10)); 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()));
}
@Test @Test
@Order(3) @Order(3)
void createNotUniqueTest() { 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)); 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",9); final BookEntity nullableGenre = new BookEntity(1, cat, author, null, "1",9);
Assertions.assertThrows(DataIntegrityViolationException.class, () -> bookService.create( Assertions.assertThrows(DataIntegrityViolationException.class, () -> bookService.create(
nullableGenre)); nullableGenre));
} }
@Test @Test
@Order(5) @Order(5)
void updateTest() { void updateTest() {
final String newName = "TEST"; final String newName = "TEST";
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(), book.getAuthor(),
newName, book.getDescription(), newName, book.getDescription(),
book.getCount()); 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());
} }
@Test @Test
@Order(6) @Order(6)
void deleteTest() { void deleteTest() {
bookService.delete(book2.getId()); 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());
} }
} }

View File

@ -17,6 +17,8 @@ import com.example.backend.favorites.model.FavoriteEntity;
import com.example.backend.favorites.service.FavoriteService; import com.example.backend.favorites.service.FavoriteService;
import com.example.backend.genres.model.GenreEntity; import com.example.backend.genres.model.GenreEntity;
import com.example.backend.genres.service.GenreService; 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.model.UserEntity;
import com.example.backend.users.service.UserService; import com.example.backend.users.service.UserService;
@ -31,6 +33,9 @@ public class FavoriteServiceTests {
private FavoriteEntity lastFavorite2; private FavoriteEntity lastFavorite2;
private GenreEntity cat1; private GenreEntity cat1;
private AuthorEntity author1;
private GenreEntity cat2;
private AuthorEntity author2;
private BookEntity mov1; private BookEntity mov1;
private BookEntity mov2; private BookEntity mov2;
private UserEntity us1; private UserEntity us1;
@ -38,6 +43,9 @@ public class FavoriteServiceTests {
@Autowired @Autowired
private GenreService genreService; private GenreService genreService;
@Autowired
private AuthorService authorService;
@Autowired @Autowired
private BookService bookService; private BookService bookService;
@ -49,10 +57,12 @@ public class FavoriteServiceTests {
removeData(); removeData();
cat1 = genreService.create(new GenreEntity(null, "Драма")); cat1 = genreService.create(new GenreEntity(null, "Драма"));
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, "gffg", "gffg", 0)); mov1 = bookService.create(new BookEntity(null, cat1, author1, "gffg", "gffg", 0));
mov2 = bookService.create(new BookEntity(null, cat1, "lol", mov2 = bookService.create(new BookEntity(null, cat2, author2, "lol", "2", 8));
"2",8));
us1 = userService.create(new UserEntity(null, "alyona", "123", true)); us1 = userService.create(new UserEntity(null, "alyona", "123", true));
@ -60,37 +70,43 @@ public class FavoriteServiceTests {
lastFavorite2 = favoriteService.create(new FavoriteEntity(null, us1, mov2)); lastFavorite2 = favoriteService.create(new FavoriteEntity(null, us1, mov2));
} }
@AfterEach @AfterEach
void removeData() { void removeData() {
favoriteService.getAll(0).forEach(fv -> favoriteService.delete(fv.getId())); favoriteService.getAll(0).forEach(fv -> favoriteService.delete(fv.getId()));
userService.getAll().forEach(u -> userService.delete(u.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())); genreService.getAll().forEach(item -> genreService.delete(item.getId()));
authorService.getAll().forEach(item -> authorService.delete(item.getId()));
} }
@Test
void getTest() {
Assertions.assertThrows(NotFoundException.class, () -> favoriteService.get(0));
}
@Test @Test
void createTest() { void createTest() {
Assertions.assertEquals(2, favoriteService.getAll(us1.getId()).size()); Assertions.assertEquals(2, favoriteService.getAll(us1.getId()).size());
} }
@Test
void getTest() {
Assertions.assertThrows(NotFoundException.class, () -> favoriteService.get(0));
}
@Test @Test
void update() { void update() {
final FavoriteEntity fav = favoriteService.create(new FavoriteEntity(null, us1, mov2)); final String newBookName = "New Book Name";
final FavoriteEntity oldFav = favoriteService.get(lastFavorite.getId()); final FavoriteEntity oldFav = favoriteService.get(lastFavorite.getId());
oldFav.getBook().setName(newBookName); // Обновляем только название книги
final FavoriteEntity newFav = favoriteService.update(lastFavorite2.getId(), fav); final FavoriteEntity newFav = favoriteService.update(lastFavorite2.getId(), oldFav);
Assertions.assertNotEquals(oldFav.getBook().getName(),
newFav.getBook().getName());
Assertions.assertEquals(newBookName, newFav.getBook().getName());
} }
@Test @Test
@Order(3) @Order(3)
void delete() { void delete() {