Make the Test Transactional
All checks were successful
Java CI with Maven / build (push) Successful in 45s

This commit is contained in:
Sebastian Böckelmann 2023-11-11 09:59:43 +01:00
parent 542e04659b
commit 0c1f94c6a7
2 changed files with 11 additions and 13 deletions

View File

@ -6,10 +6,6 @@
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="3a869f59-290a-4ab2-b036-a878ce801bc4" name="Changes" comment="Use @Sql instead of persit()"> <list default="true" id="3a869f59-290a-4ab2-b036-a878ce801bc4" name="Changes" comment="Use @Sql instead of persit()">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/core/api/models/timemanager/taskgroup/TaskgroupFieldInfo.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/core/api/models/timemanager/taskgroup/TaskgroupFieldInfo.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/core/entities/timemanager/Taskgroup.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/core/entities/timemanager/Taskgroup.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/core/services/TaskgroupService.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/core/services/TaskgroupService.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/test/java/core/taskgroups/TaskgroupServiceTest.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/test/java/core/taskgroups/TaskgroupServiceTest.java" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -28,7 +24,7 @@
<component name="Git.Settings"> <component name="Git.Settings">
<option name="RECENT_BRANCH_BY_REPOSITORY"> <option name="RECENT_BRANCH_BY_REPOSITORY">
<map> <map>
<entry key="$PROJECT_DIR$/.." value="master" /> <entry key="$PROJECT_DIR$/.." value="test-failing" />
</map> </map>
</option> </option>
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/.." /> <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/.." />
@ -88,8 +84,8 @@
<recent name="$PROJECT_DIR$/src/test/java/core/taskgroups" /> <recent name="$PROJECT_DIR$/src/test/java/core/taskgroups" />
</key> </key>
</component> </component>
<component name="RunManager" selected="JUnit.TaskgroupServiceTest.deleteTaskgroupByUser"> <component name="RunManager" selected="JUnit.TaskgroupServiceTest">
<configuration name="TaskgroupServiceTest.addTaskgroup" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true"> <configuration name="TaskgroupServiceTest" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
<module name="demo" /> <module name="demo" />
<extension name="coverage"> <extension name="coverage">
<pattern> <pattern>
@ -99,8 +95,7 @@
</extension> </extension>
<option name="PACKAGE_NAME" value="core.taskgroups" /> <option name="PACKAGE_NAME" value="core.taskgroups" />
<option name="MAIN_CLASS_NAME" value="core.taskgroups.TaskgroupServiceTest" /> <option name="MAIN_CLASS_NAME" value="core.taskgroups.TaskgroupServiceTest" />
<option name="METHOD_NAME" value="addTaskgroup" /> <option name="TEST_OBJECT" value="class" />
<option name="TEST_OBJECT" value="method" />
<method v="2"> <method v="2">
<option name="Make" enabled="true" /> <option name="Make" enabled="true" />
</method> </method>
@ -137,7 +132,7 @@
<option name="Make" enabled="true" /> <option name="Make" enabled="true" />
</method> </method>
</configuration> </configuration>
<configuration name="TaskgroupServiceTest.editTaskgroup" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true"> <configuration name="TaskgroupServiceTest.getTaskgroupByIDAndUsername" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
<module name="demo" /> <module name="demo" />
<extension name="coverage"> <extension name="coverage">
<pattern> <pattern>
@ -147,7 +142,7 @@
</extension> </extension>
<option name="PACKAGE_NAME" value="core.taskgroups" /> <option name="PACKAGE_NAME" value="core.taskgroups" />
<option name="MAIN_CLASS_NAME" value="core.taskgroups.TaskgroupServiceTest" /> <option name="MAIN_CLASS_NAME" value="core.taskgroups.TaskgroupServiceTest" />
<option name="METHOD_NAME" value="editTaskgroup" /> <option name="METHOD_NAME" value="getTaskgroupByIDAndUsername" />
<option name="TEST_OBJECT" value="method" /> <option name="TEST_OBJECT" value="method" />
<method v="2"> <method v="2">
<option name="Make" enabled="true" /> <option name="Make" enabled="true" />
@ -178,11 +173,11 @@
</configuration> </configuration>
<recent_temporary> <recent_temporary>
<list> <list>
<item itemvalue="JUnit.TaskgroupServiceTest" />
<item itemvalue="JUnit.TaskgroupServiceTest.getTaskgroupByIDAndUsername" />
<item itemvalue="JUnit.TaskgroupServiceTest.deleteTaskgroupByUser" /> <item itemvalue="JUnit.TaskgroupServiceTest.deleteTaskgroupByUser" />
<item itemvalue="JUnit.TaskgroupServiceTest.getTopTaskgroupsByUser" /> <item itemvalue="JUnit.TaskgroupServiceTest.getTopTaskgroupsByUser" />
<item itemvalue="JUnit.TaskgroupServiceTest.deleteTaskgroup" /> <item itemvalue="JUnit.TaskgroupServiceTest.deleteTaskgroup" />
<item itemvalue="JUnit.TaskgroupServiceTest.editTaskgroup" />
<item itemvalue="JUnit.TaskgroupServiceTest.addTaskgroup" />
</list> </list>
</recent_temporary> </recent_temporary>
</component> </component>

View File

@ -25,8 +25,10 @@ import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.jdbc.Sql; import org.springframework.test.context.jdbc.Sql;
import org.springframework.test.context.jdbc.SqlGroup; import org.springframework.test.context.jdbc.SqlGroup;
import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.context.junit4.SpringRunner;
import javax.persistence.EntityManager; import javax.persistence.EntityManager;
import javax.transaction.Transactional;
import java.util.List; import java.util.List;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
import java.util.Optional; import java.util.Optional;
@ -35,6 +37,7 @@ import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
import static org.junit.jupiter.api.Assertions.*; import static org.junit.jupiter.api.Assertions.*;
@SpringBootTest @SpringBootTest
@Transactional
public class TaskgroupServiceTest { public class TaskgroupServiceTest {
@Autowired @Autowired