Skip to content

Commit

Permalink
Cleanup (#447)
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperMarcomen authored Sep 2, 2024
1 parent 0cc8710 commit d7560f0
Show file tree
Hide file tree
Showing 11 changed files with 8 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import de.uftos.entities.Grade;
import de.uftos.entities.StudentGroup;
import de.uftos.entities.Tag;
import java.util.List;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
Expand All @@ -15,8 +14,6 @@
public interface GradeRepository extends ListPagingAndSortingRepository<Grade, String>,
ListCrudRepository<Grade, String>, JpaSpecificationExecutor<Grade> {

List<Grade> findByTags(Tag tag);

@Query("SELECT g FROM grades g JOIN g.tags t WHERE t IN :tagIds")
List<Grade> findAllByTags(List<String> tagIds);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package de.uftos.repositories.database;

import de.uftos.entities.Room;
import de.uftos.entities.Tag;
import java.util.List;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
Expand All @@ -14,8 +13,6 @@
public interface RoomRepository extends ListPagingAndSortingRepository<Room, String>,
ListCrudRepository<Room, String>, JpaSpecificationExecutor<Room> {

List<Room> findByTags(Tag tag);

@Query("SELECT r FROM rooms r JOIN r.tags t WHERE t IN :tagIds")
List<Room> findAllByTags(List<String> tagIds);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import de.uftos.entities.Student;
import de.uftos.entities.StudentGroup;
import de.uftos.entities.Subject;
import de.uftos.entities.Tag;
import java.util.List;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
Expand All @@ -20,8 +19,6 @@ public interface StudentGroupRepository

List<StudentGroup> findByStudents(Student student);

List<StudentGroup> findByTags(Tag tag);

@Query("SELECT sg FROM student_groups sg JOIN sg.tags t WHERE t IN :tagIds")
List<StudentGroup> findAllByTags(List<String> tagIds);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package de.uftos.repositories.database;

import de.uftos.entities.Student;
import de.uftos.entities.Tag;
import java.util.List;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
Expand All @@ -15,8 +14,6 @@ public interface StudentRepository
extends ListPagingAndSortingRepository<Student, String>, ListCrudRepository<Student, String>,
JpaSpecificationExecutor<Student> {

List<Student> findByTags(Tag tag);

@Query("SELECT s FROM students s JOIN s.tags t WHERE t IN :tagIds")
List<Student> findAllByTags(List<String> tagIds);
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package de.uftos.repositories.database;

import de.uftos.entities.Subject;
import de.uftos.entities.Tag;
import java.util.List;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
Expand All @@ -13,8 +12,6 @@
public interface SubjectRepository
extends ListCrudRepository<Subject, String>, JpaSpecificationExecutor<Subject> {

List<Subject> findByTags(Tag tag);

@Query("SELECT s FROM subjects s JOIN s.tags t WHERE t IN :tagIds")
List<Subject> findAllByTags(List<String> tagIds);
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package de.uftos.repositories.database;

import de.uftos.entities.Subject;
import de.uftos.entities.Tag;
import de.uftos.entities.Teacher;
import java.util.List;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
Expand All @@ -15,8 +14,6 @@
public interface TeacherRepository extends ListPagingAndSortingRepository<Teacher, String>,
ListCrudRepository<Teacher, String>, JpaSpecificationExecutor<Teacher> {

List<Teacher> findByTags(Tag tag);

@Query("SELECT te FROM teachers te JOIN te.tags t WHERE t IN :tagIds")
List<Teacher> findAllByTags(List<String> tagIds);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package de.uftos.repositories.database;

import de.uftos.entities.Tag;
import de.uftos.entities.Timeslot;
import java.util.List;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
Expand All @@ -14,8 +13,6 @@
public interface TimeslotRepository extends ListPagingAndSortingRepository<Timeslot, String>,
ListCrudRepository<Timeslot, String>, JpaSpecificationExecutor<Timeslot> {

List<Timeslot> findByTags(Tag tag);

@Query("SELECT ti FROM timeslots ti JOIN ti.tags t WHERE t IN :tagIds")
List<Timeslot> findAllByTags(List<String> tagIds);
}
1 change: 0 additions & 1 deletion server/src/main/java/de/uftos/services/TagService.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import de.uftos.repositories.database.TimeslotRepository;
import de.uftos.utils.ConstraintInstanceDeleter;
import de.uftos.utils.SpecificationBuilder;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
Expand Down
4 changes: 2 additions & 2 deletions server/src/test/java/de/uftos/UftosApplicationTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
@Testcontainers
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
@Suite
@SelectPackages({ "de.uftos.e2e" })
@SelectPackages({"de.uftos.e2e"})
class UftosApplicationTests {

static Network network = Network.newNetwork();
static final Network network = Network.newNetwork();

static final GenericContainer<?> postgres = new GenericContainer<>(
DockerImageName.parse("postgres:16.3-alpine3.18"))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package de.uftos.services;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Mockito.when;

import de.uftos.dto.responsedtos.ConstraintInstancesResponseDto;
import de.uftos.entities.ConstraintSignature;
import de.uftos.repositories.database.ConstraintSignatureRepository;
import java.util.Optional;
Expand Down
17 changes: 6 additions & 11 deletions server/src/test/java/de/uftos/services/CurriculumServiceTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,28 +42,23 @@
@MockitoSettings(strictness = Strictness.LENIENT)
public class CurriculumServiceTests {
@Mock
private final Grade testGrade = new Grade("testName", List.of("group5"),
List.of("T2", "T3"));
@Mock
private final Grade newGrade = new Grade("newGradeName", List.of("group5"),
List.of("T2", "T3"));
@Mock
private GradeRepository gradeRepository;

@Mock
private CurriculumRepository curriculumRepository;

@Mock
private ServerRepository serverRepository;

@Mock
private Grade testGrade = new Grade("testName", List.of("group5"),
List.of("T2", "T3"));

@Mock
private Grade newGrade = new Grade("newGradeName", List.of("group5"),
List.of("T2", "T3"));
/*
the grades need to be mocked to return a studentGroup with a non-null
student list, when getStudentGroups() is called.
Otherwise a null pointer exception is thrown when making a
response dto from the curricula with these grades.
*/

@InjectMocks
private CurriculumService curriculumService;

Expand Down

0 comments on commit d7560f0

Please sign in to comment.