This commit is contained in:
parent
c9343ea05e
commit
fcde6c4aad
@ -4,8 +4,9 @@
|
|||||||
<option name="autoReloadType" value="SELECTIVE" />
|
<option name="autoReloadType" value="SELECTIVE" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="3a869f59-290a-4ab2-b036-a878ce801bc4" name="Changes" comment="Consider increased number of tasks">
|
<list default="true" id="3a869f59-290a-4ab2-b036-a878ce801bc4" name="Changes" comment="Remove entityManager from TaskService">
|
||||||
<change beforePath="$PROJECT_DIR$/src/main/java/core/services/TaskService.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/core/services/TaskService.java" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/src/test/java/core/tasks/TaskServiceTest.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/test/java/core/tasks/TaskServiceTest.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" />
|
||||||
@ -84,22 +85,7 @@
|
|||||||
<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.TaskServiceTest.deleteTask">
|
<component name="RunManager" selected="JUnit.TaskServiceTest">
|
||||||
<configuration name="TaskRepositoryTest" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
|
|
||||||
<module name="demo" />
|
|
||||||
<extension name="coverage">
|
|
||||||
<pattern>
|
|
||||||
<option name="PATTERN" value="core.tasks.*" />
|
|
||||||
<option name="ENABLED" value="true" />
|
|
||||||
</pattern>
|
|
||||||
</extension>
|
|
||||||
<option name="PACKAGE_NAME" value="core.tasks" />
|
|
||||||
<option name="MAIN_CLASS_NAME" value="core.tasks.TaskRepositoryTest" />
|
|
||||||
<option name="TEST_OBJECT" value="class" />
|
|
||||||
<method v="2">
|
|
||||||
<option name="Make" enabled="true" />
|
|
||||||
</method>
|
|
||||||
</configuration>
|
|
||||||
<configuration name="TaskServiceTest" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
|
<configuration name="TaskServiceTest" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
|
||||||
<module name="demo" />
|
<module name="demo" />
|
||||||
<extension name="coverage">
|
<extension name="coverage">
|
||||||
@ -115,7 +101,7 @@
|
|||||||
<option name="Make" enabled="true" />
|
<option name="Make" enabled="true" />
|
||||||
</method>
|
</method>
|
||||||
</configuration>
|
</configuration>
|
||||||
<configuration name="TaskServiceTest.createTask" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
|
<configuration name="TaskServiceTest.clearTasks" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
|
||||||
<module name="demo" />
|
<module name="demo" />
|
||||||
<extension name="coverage">
|
<extension name="coverage">
|
||||||
<pattern>
|
<pattern>
|
||||||
@ -125,7 +111,7 @@
|
|||||||
</extension>
|
</extension>
|
||||||
<option name="PACKAGE_NAME" value="core.tasks" />
|
<option name="PACKAGE_NAME" value="core.tasks" />
|
||||||
<option name="MAIN_CLASS_NAME" value="core.tasks.TaskServiceTest" />
|
<option name="MAIN_CLASS_NAME" value="core.tasks.TaskServiceTest" />
|
||||||
<option name="METHOD_NAME" value="createTask" />
|
<option name="METHOD_NAME" value="clearTasks" />
|
||||||
<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" />
|
||||||
@ -147,17 +133,34 @@
|
|||||||
<option name="Make" enabled="true" />
|
<option name="Make" enabled="true" />
|
||||||
</method>
|
</method>
|
||||||
</configuration>
|
</configuration>
|
||||||
<configuration name="TaskgroupServiceTest" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
|
<configuration name="TaskServiceTest.finishTask" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
|
||||||
<module name="demo" />
|
<module name="demo" />
|
||||||
<extension name="coverage">
|
<extension name="coverage">
|
||||||
<pattern>
|
<pattern>
|
||||||
<option name="PATTERN" value="core.taskgroups.*" />
|
<option name="PATTERN" value="core.tasks.*" />
|
||||||
<option name="ENABLED" value="true" />
|
<option name="ENABLED" value="true" />
|
||||||
</pattern>
|
</pattern>
|
||||||
</extension>
|
</extension>
|
||||||
<option name="PACKAGE_NAME" value="core.taskgroups" />
|
<option name="PACKAGE_NAME" value="core.tasks" />
|
||||||
<option name="MAIN_CLASS_NAME" value="core.taskgroups.TaskgroupServiceTest" />
|
<option name="MAIN_CLASS_NAME" value="core.tasks.TaskServiceTest" />
|
||||||
<option name="TEST_OBJECT" value="class" />
|
<option name="METHOD_NAME" value="finishTask" />
|
||||||
|
<option name="TEST_OBJECT" value="method" />
|
||||||
|
<method v="2">
|
||||||
|
<option name="Make" enabled="true" />
|
||||||
|
</method>
|
||||||
|
</configuration>
|
||||||
|
<configuration name="TaskServiceTest.loadAllTasks" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
|
||||||
|
<module name="demo" />
|
||||||
|
<extension name="coverage">
|
||||||
|
<pattern>
|
||||||
|
<option name="PATTERN" value="core.tasks.*" />
|
||||||
|
<option name="ENABLED" value="true" />
|
||||||
|
</pattern>
|
||||||
|
</extension>
|
||||||
|
<option name="PACKAGE_NAME" value="core.tasks" />
|
||||||
|
<option name="MAIN_CLASS_NAME" value="core.tasks.TaskServiceTest" />
|
||||||
|
<option name="METHOD_NAME" value="loadAllTasks" />
|
||||||
|
<option name="TEST_OBJECT" value="method" />
|
||||||
<method v="2">
|
<method v="2">
|
||||||
<option name="Make" enabled="true" />
|
<option name="Make" enabled="true" />
|
||||||
</method>
|
</method>
|
||||||
@ -171,11 +174,11 @@
|
|||||||
</configuration>
|
</configuration>
|
||||||
<recent_temporary>
|
<recent_temporary>
|
||||||
<list>
|
<list>
|
||||||
<item itemvalue="JUnit.TaskServiceTest.deleteTask" />
|
|
||||||
<item itemvalue="JUnit.TaskServiceTest" />
|
<item itemvalue="JUnit.TaskServiceTest" />
|
||||||
<item itemvalue="JUnit.TaskRepositoryTest" />
|
<item itemvalue="JUnit.TaskServiceTest.loadAllTasks" />
|
||||||
<item itemvalue="JUnit.TaskgroupServiceTest" />
|
<item itemvalue="JUnit.TaskServiceTest.finishTask" />
|
||||||
<item itemvalue="JUnit.TaskServiceTest.createTask" />
|
<item itemvalue="JUnit.TaskServiceTest.clearTasks" />
|
||||||
|
<item itemvalue="JUnit.TaskServiceTest.deleteTask" />
|
||||||
</list>
|
</list>
|
||||||
</recent_temporary>
|
</recent_temporary>
|
||||||
</component>
|
</component>
|
||||||
@ -471,14 +474,21 @@
|
|||||||
<option name="project" value="LOCAL" />
|
<option name="project" value="LOCAL" />
|
||||||
<updated>1699694552466</updated>
|
<updated>1699694552466</updated>
|
||||||
</task>
|
</task>
|
||||||
<option name="localTasksCounter" value="33" />
|
<task id="LOCAL-00033" summary="Remove entityManager from TaskService">
|
||||||
|
<option name="closed" value="true" />
|
||||||
|
<created>1699695051881</created>
|
||||||
|
<option name="number" value="00033" />
|
||||||
|
<option name="presentableId" value="LOCAL-00033" />
|
||||||
|
<option name="project" value="LOCAL" />
|
||||||
|
<updated>1699695051881</updated>
|
||||||
|
</task>
|
||||||
|
<option name="localTasksCounter" value="34" />
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
<component name="TypeScriptGeneratedFilesManager">
|
<component name="TypeScriptGeneratedFilesManager">
|
||||||
<option name="version" value="3" />
|
<option name="version" value="3" />
|
||||||
</component>
|
</component>
|
||||||
<component name="VcsManagerConfiguration">
|
<component name="VcsManagerConfiguration">
|
||||||
<MESSAGE value="Removed unused TaskgroupShortInfo.java" />
|
|
||||||
<MESSAGE value="Fix Foreign Key Constraint Fail when deleting Taskgroups" />
|
<MESSAGE value="Fix Foreign Key Constraint Fail when deleting Taskgroups" />
|
||||||
<MESSAGE value="Stop and Finish TaskSchedules" />
|
<MESSAGE value="Stop and Finish TaskSchedules" />
|
||||||
<MESSAGE value="Include TaskScheduleStopResponse" />
|
<MESSAGE value="Include TaskScheduleStopResponse" />
|
||||||
@ -503,7 +513,8 @@
|
|||||||
<MESSAGE value="Resolve Merge-Conflict" />
|
<MESSAGE value="Resolve Merge-Conflict" />
|
||||||
<MESSAGE value="Deleting Task test" />
|
<MESSAGE value="Deleting Task test" />
|
||||||
<MESSAGE value="Consider increased number of tasks" />
|
<MESSAGE value="Consider increased number of tasks" />
|
||||||
<option name="LAST_COMMIT_MESSAGE" value="Consider increased number of tasks" />
|
<MESSAGE value="Remove entityManager from TaskService" />
|
||||||
|
<option name="LAST_COMMIT_MESSAGE" value="Remove entityManager from TaskService" />
|
||||||
</component>
|
</component>
|
||||||
<component name="XDebuggerManager">
|
<component name="XDebuggerManager">
|
||||||
<breakpoint-manager>
|
<breakpoint-manager>
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package core.tasks;
|
package core.tasks;
|
||||||
|
|
||||||
import core.api.models.timemanager.tasks.TaskFieldInfo;
|
import core.api.models.timemanager.tasks.TaskFieldInfo;
|
||||||
|
import core.api.models.timemanager.tasks.TaskScope;
|
||||||
import core.entities.timemanager.Task;
|
import core.entities.timemanager.Task;
|
||||||
import core.entities.timemanager.Taskgroup;
|
import core.entities.timemanager.Taskgroup;
|
||||||
import core.repositories.timemanager.TaskRepository;
|
import core.repositories.timemanager.TaskRepository;
|
||||||
@ -17,6 +18,7 @@ import javax.persistence.EntityManager;
|
|||||||
import javax.transaction.Transactional;
|
import javax.transaction.Transactional;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
|
import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
@ -184,8 +186,93 @@ public class TaskServiceTest {
|
|||||||
})
|
})
|
||||||
void deleteTask() {
|
void deleteTask() {
|
||||||
for(long i=1; i<=15; i++) {
|
for(long i=1; i<=15; i++) {
|
||||||
taskRepository.deleteByTaskID(entityManager.find(Task.class, i).getTaskID());
|
taskService.deleteTask(entityManager.find(Task.class, i));
|
||||||
assertThat(entityManager.find(Task.class, i)).isNull();
|
assertThat(entityManager.find(Task.class, i)).isNull();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@SqlGroup({
|
||||||
|
@Sql("classpath:taskgroupRepositoryTestEntries.sql"),
|
||||||
|
@Sql("classpath:taskRepositoryEntries.sql")
|
||||||
|
})
|
||||||
|
void clearTasks() {
|
||||||
|
//Situation 1: Delete from taskgroup with no tasks
|
||||||
|
taskService.clearTasks(entityManager.find(Taskgroup.class, 1L));
|
||||||
|
for(long i=1; i<=15; i++) {
|
||||||
|
assertThat(entityManager.find(Task.class, i)).isNotNull();
|
||||||
|
}
|
||||||
|
//Situation 2: Delete from taskgroup with tasks
|
||||||
|
taskService.clearTasks(entityManager.find(Taskgroup.class, 2L));
|
||||||
|
for(long i=1; i<=15; i++) {
|
||||||
|
assertThat(entityManager.find(Task.class, i)).isNull();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@SqlGroup({
|
||||||
|
@Sql("classpath:taskgroupRepositoryTestEntries.sql"),
|
||||||
|
@Sql("classpath:taskRepositoryEntries.sql")
|
||||||
|
})
|
||||||
|
void finishTask() {
|
||||||
|
taskService.finishTask(entityManager.find(Task.class, 1L));
|
||||||
|
assertTrue(entityManager.find(Task.class, 1L).isFinished());
|
||||||
|
|
||||||
|
taskService.finishTask(entityManager.find(Task.class, 2L));
|
||||||
|
assertTrue(entityManager.find(Task.class, 1L).isFinished());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@SqlGroup({
|
||||||
|
@Sql("classpath:taskgroupRepositoryTestEntries.sql"),
|
||||||
|
@Sql("classpath:taskRepositoryEntries.sql")
|
||||||
|
})
|
||||||
|
void loadAllTasks() {
|
||||||
|
//Situation 1: No tasks existing
|
||||||
|
List<Task> result_1 = taskService.loadAllTasks(username2, TaskScope.UNFINISHED);
|
||||||
|
assertEquals(0, result_1.size());
|
||||||
|
|
||||||
|
//Situation 2: Tasks existing, Unfinished#
|
||||||
|
List<Task> result_2 = taskService.loadAllTasks(username, TaskScope.UNFINISHED);
|
||||||
|
assertEquals(8, result_2.size());
|
||||||
|
assertTrue(result_2.contains(entityManager.find(Task.class, 1L)));
|
||||||
|
assertTrue(result_2.contains(entityManager.find(Task.class, 3L)));
|
||||||
|
assertTrue(result_2.contains(entityManager.find(Task.class, 5L)));
|
||||||
|
assertTrue(result_2.contains(entityManager.find(Task.class, 7L)));
|
||||||
|
assertTrue(result_2.contains(entityManager.find(Task.class, 9L)));
|
||||||
|
assertTrue(result_2.contains(entityManager.find(Task.class, 11L)));
|
||||||
|
assertTrue(result_2.contains(entityManager.find(Task.class, 12L)));
|
||||||
|
|
||||||
|
//Situation 3: Finished tasks
|
||||||
|
List<Task> result_3 = taskService.loadAllTasks(username, TaskScope.FINISHED);
|
||||||
|
assertEquals(7, result_3.size());
|
||||||
|
assertTrue(result_3.contains(entityManager.find(Task.class, 2L)));
|
||||||
|
assertTrue(result_3.contains(entityManager.find(Task.class, 4L)));
|
||||||
|
assertTrue(result_3.contains(entityManager.find(Task.class, 6L)));
|
||||||
|
assertTrue(result_3.contains(entityManager.find(Task.class, 8L)));
|
||||||
|
assertTrue(result_3.contains(entityManager.find(Task.class, 10L)));
|
||||||
|
assertTrue(result_3.contains(entityManager.find(Task.class, 13L)));
|
||||||
|
assertTrue(result_3.contains(entityManager.find(Task.class, 14L)));
|
||||||
|
|
||||||
|
//overdue
|
||||||
|
List<Task> result_4 = taskService.loadAllTasks(username, TaskScope.OVERDUE);
|
||||||
|
assertEquals(2, result_4.size());
|
||||||
|
assertTrue(result_4.contains(entityManager.find(Task.class, 3L)));
|
||||||
|
assertTrue(result_4.contains(entityManager.find(Task.class, 5L)));
|
||||||
|
|
||||||
|
//upcoming
|
||||||
|
List<Task> result_5 = taskService.loadAllTasks(username, TaskScope.UPCOMING);
|
||||||
|
assertEquals(2, result_5.size());
|
||||||
|
assertTrue(result_5.contains(entityManager.find(Task.class, 7L)));
|
||||||
|
assertTrue(result_5.contains(entityManager.find(Task.class, 9L)));
|
||||||
|
//Active
|
||||||
|
List<Task> result_6 = taskService.loadAllTasks(username, TaskScope.ACTIVE);
|
||||||
|
assertEquals(6, result_6.size());
|
||||||
|
assertTrue(result_6.contains(entityManager.find(Task.class, 1L)));
|
||||||
|
assertTrue(result_6.contains(entityManager.find(Task.class, 3L)));
|
||||||
|
assertTrue(result_6.contains(entityManager.find(Task.class, 5L)));
|
||||||
|
assertTrue(result_6.contains(entityManager.find(Task.class, 11L)));
|
||||||
|
assertTrue(result_6.contains(entityManager.find(Task.class, 12L)));
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user