2024-03 spring-11-jpql updated

This commit is contained in:
stvort
2024-05-29 10:54:27 +04:00
parent 1246a77cbb
commit 8f0e5d6437
20 changed files with 49 additions and 49 deletions
@@ -17,12 +17,12 @@ import java.util.Optional;
// Поэтому, для упрощения, пока вешаем над классом репозитория
@Transactional
@Repository
public class OtusStudentRepositoryJpa implements OtusStudentRepository {
public class JpaOtusStudentRepository implements OtusStudentRepository {
@PersistenceContext
private final EntityManager em;
public OtusStudentRepositoryJpa(EntityManager em) {
public JpaOtusStudentRepository(EntityManager em) {
this.em = em;
}
@@ -20,8 +20,8 @@ import static org.assertj.core.api.Assertions.assertThat;
@DisplayName("Репозиторий на основе Jpa для работы со студентами ")
@DataJpaTest
@Import(OtusStudentRepositoryJpa.class)
class OtusStudentRepositoryJpaTest {
@Import(JpaOtusStudentRepository.class)
class JpaOtusStudentRepositoryTest {
private static final int EXPECTED_NUMBER_OF_STUDENTS = 10;
private static final long FIRST_STUDENT_ID = 1L;
@@ -35,7 +35,7 @@ class OtusStudentRepositoryJpaTest {
private static final String STUDENT_NAME = "Вася";
@Autowired
private OtusStudentRepositoryJpa repositoryJpa;
private JpaOtusStudentRepository repositoryJpa;
@Autowired
private TestEntityManager em;
@@ -18,12 +18,12 @@ import java.util.Optional;
// Поэтому, для упрощения, пока вешаем над классом репозитория
@Transactional
@Repository
public class OtusStudentRepositoryJpa implements OtusStudentRepository {
public class JpaOtusStudentRepository implements OtusStudentRepository {
@PersistenceContext
private final EntityManager em;
public OtusStudentRepositoryJpa(EntityManager em) {
public JpaOtusStudentRepository(EntityManager em) {
this.em = em;
}
@@ -20,8 +20,8 @@ import static org.assertj.core.api.Assertions.assertThat;
@DisplayName("Репозиторий на основе Jpa для работы со студентами ")
@DataJpaTest
@Import(OtusStudentRepositoryJpa.class)
class OtusStudentRepositoryJpaTest {
@Import(JpaOtusStudentRepository.class)
class JpaOtusStudentRepositoryTest {
private static final int EXPECTED_NUMBER_OF_STUDENTS = 10;
private static final long FIRST_STUDENT_ID = 1L;
@@ -35,7 +35,7 @@ class OtusStudentRepositoryJpaTest {
private static final String STUDENT_NAME = "Вася";
@Autowired
private OtusStudentRepositoryJpa repositoryJpa;
private JpaOtusStudentRepository repositoryJpa;
@Autowired
private TestEntityManager em;
@@ -17,12 +17,12 @@ import java.util.Optional;
// Поэтому, для упрощения, пока вешаем над классом репозитория
@Transactional
@Repository
public class OtusStudentRepositoryJpa implements OtusStudentRepository {
public class JpaOtusStudentRepository implements OtusStudentRepository {
@PersistenceContext
private final EntityManager em;
public OtusStudentRepositoryJpa(EntityManager em) {
public JpaOtusStudentRepository(EntityManager em) {
this.em = em;
}
@@ -20,8 +20,8 @@ import static org.assertj.core.api.Assertions.assertThat;
@DisplayName("Репозиторий на основе Jpa для работы со студентами ")
@DataJpaTest
@Import(OtusStudentRepositoryJpa.class)
class OtusStudentRepositoryJpaTest {
@Import(JpaOtusStudentRepository.class)
class JpaOtusStudentRepositoryTest {
private static final int EXPECTED_NUMBER_OF_STUDENTS = 10;
private static final long FIRST_STUDENT_ID = 1L;
@@ -35,7 +35,7 @@ class OtusStudentRepositoryJpaTest {
private static final String STUDENT_NAME = "Вася";
@Autowired
private OtusStudentRepositoryJpa repositoryJpa;
private JpaOtusStudentRepository repositoryJpa;
@Autowired
private TestEntityManager em;
@@ -18,7 +18,7 @@ import java.util.Optional;
// Поэтому, для упрощения, пока вешаем над классом репозитория
@Transactional
@Repository
public class OtusStudentRepositoryJpa implements OtusStudentRepository {
public class JpaOtusStudentRepository implements OtusStudentRepository {
@PersistenceContext
private EntityManager em;
@@ -20,8 +20,8 @@ import static org.assertj.core.api.Assertions.assertThat;
@DisplayName("Репозиторий на основе Jpa для работы со студентами ")
@DataJpaTest
@Import(OtusStudentRepositoryJpa.class)
class OtusStudentRepositoryJpaTest {
@Import(JpaOtusStudentRepository.class)
class JpaOtusStudentRepositoryTest {
private static final int EXPECTED_NUMBER_OF_STUDENTS = 10;
private static final long FIRST_STUDENT_ID = 1L;
@@ -35,7 +35,7 @@ class OtusStudentRepositoryJpaTest {
private static final String STUDENT_NAME = "Вася";
@Autowired
private OtusStudentRepositoryJpa repositoryJpa;
private JpaOtusStudentRepository repositoryJpa;
@Autowired
private TestEntityManager em;
@@ -21,12 +21,12 @@ import static org.springframework.data.jpa.repository.EntityGraph.EntityGraphTyp
// Поэтому, для упрощения, пока вешаем над классом репозитория
@Transactional
@Repository
public class OtusStudentRepositoryJpa implements OtusStudentRepository {
public class JpaOtusStudentRepository implements OtusStudentRepository {
@PersistenceContext
private final EntityManager em;
public OtusStudentRepositoryJpa(EntityManager em) {
public JpaOtusStudentRepository(EntityManager em) {
this.em = em;
}
@@ -14,8 +14,8 @@ import static org.assertj.core.api.Assertions.assertThat;
@DisplayName("Репозиторий на основе Jpa для работы со студентами ")
@DataJpaTest
@Import(OtusStudentRepositoryJpa.class)
class OtusStudentRepositoryJpaTest {
@Import(JpaOtusStudentRepository.class)
class JpaOtusStudentRepositoryTest {
private static final int EXPECTED_NUMBER_OF_STUDENTS = 10;
private static final long FIRST_STUDENT_ID = 1L;
@@ -23,7 +23,7 @@ class OtusStudentRepositoryJpaTest {
private static final int EXPECTED_QUERIES_COUNT = 21;
@Autowired
private OtusStudentRepositoryJpa repositoryJpa;
private JpaOtusStudentRepository repositoryJpa;
@Autowired
private TestEntityManager em;
@@ -21,12 +21,12 @@ import static org.springframework.data.jpa.repository.EntityGraph.EntityGraphTyp
// Поэтому, для упрощения, пока вешаем над классом репозитория
@Transactional
@Repository
public class OtusStudentRepositoryJpa implements OtusStudentRepository {
public class JpaOtusStudentRepository implements OtusStudentRepository {
@PersistenceContext
private final EntityManager em;
public OtusStudentRepositoryJpa(EntityManager em) {
public JpaOtusStudentRepository(EntityManager em) {
this.em = em;
}
@@ -14,8 +14,8 @@ import static org.assertj.core.api.Assertions.assertThat;
@DisplayName("Репозиторий на основе Jpa для работы со студентами ")
@DataJpaTest
@Import(OtusStudentRepositoryJpa.class)
class OtusStudentRepositoryJpaTest {
@Import(JpaOtusStudentRepository.class)
class JpaOtusStudentRepositoryTest {
private static final int EXPECTED_NUMBER_OF_STUDENTS = 10;
private static final long FIRST_STUDENT_ID = 1L;
@@ -23,7 +23,7 @@ class OtusStudentRepositoryJpaTest {
private static final int EXPECTED_QUERIES_COUNT = 11;
@Autowired
private OtusStudentRepositoryJpa repositoryJpa;
private JpaOtusStudentRepository repositoryJpa;
@Autowired
private TestEntityManager em;
@@ -21,12 +21,12 @@ import static org.springframework.data.jpa.repository.EntityGraph.EntityGraphTyp
// Поэтому, для упрощения, пока вешаем над классом репозитория
@Transactional
@Repository
public class OtusStudentRepositoryJpa implements OtusStudentRepository {
public class JpaOtusStudentRepository implements OtusStudentRepository {
@PersistenceContext
private final EntityManager em;
public OtusStudentRepositoryJpa(EntityManager em) {
public JpaOtusStudentRepository(EntityManager em) {
this.em = em;
}
@@ -14,8 +14,8 @@ import static org.assertj.core.api.Assertions.assertThat;
@DisplayName("Репозиторий на основе Jpa для работы со студентами ")
@DataJpaTest
@Import(OtusStudentRepositoryJpa.class)
class OtusStudentRepositoryJpaTest {
@Import(JpaOtusStudentRepository.class)
class JpaOtusStudentRepositoryTest {
private static final int EXPECTED_NUMBER_OF_STUDENTS = 10;
private static final long FIRST_STUDENT_ID = 1L;
@@ -23,7 +23,7 @@ class OtusStudentRepositoryJpaTest {
private static final int EXPECTED_QUERIES_COUNT = 2;
@Autowired
private OtusStudentRepositoryJpa repositoryJpa;
private JpaOtusStudentRepository repositoryJpa;
@Autowired
private TestEntityManager em;
@@ -21,12 +21,12 @@ import static org.springframework.data.jpa.repository.EntityGraph.EntityGraphTyp
// Поэтому, для упрощения, пока вешаем над классом репозитория
@Transactional
@Repository
public class OtusStudentRepositoryJpa implements OtusStudentRepository {
public class JpaOtusStudentRepository implements OtusStudentRepository {
@PersistenceContext
private final EntityManager em;
public OtusStudentRepositoryJpa(EntityManager em) {
public JpaOtusStudentRepository(EntityManager em) {
this.em = em;
}
@@ -21,8 +21,8 @@ import static org.assertj.core.api.Assertions.assertThat;
@DisplayName("Репозиторий на основе Jpa для работы со студентами ")
@DataJpaTest
@Import(OtusStudentRepositoryJpa.class)
class OtusStudentRepositoryJpaTest {
@Import(JpaOtusStudentRepository.class)
class JpaOtusStudentRepositoryTest {
private static final int EXPECTED_NUMBER_OF_STUDENTS = 10;
private static final long FIRST_STUDENT_ID = 1L;
@@ -30,7 +30,7 @@ class OtusStudentRepositoryJpaTest {
private static final int EXPECTED_QUERIES_COUNT = 3;
@Autowired
private OtusStudentRepositoryJpa repositoryJpa;
private JpaOtusStudentRepository repositoryJpa;
@Autowired
private TestEntityManager em;
@@ -6,12 +6,12 @@ import jakarta.persistence.EntityManager;
import jakarta.persistence.PersistenceContext;
import java.util.List;
public class CategoryRepositoryJpa implements CategoryRepository {
public class JpaCategoryRepository implements CategoryRepository {
@PersistenceContext
private final EntityManager em;
public CategoryRepositoryJpa(EntityManager em) {
public JpaCategoryRepository(EntityManager em) {
this.em = em;
}
@@ -15,12 +15,12 @@ import java.util.List;
import java.util.Optional;
@Repository
public class EmployeeRepositoryJpa implements EmployeeRepository {
public class JpaEmployeeRepository implements EmployeeRepository {
@PersistenceContext
private final EntityManager em;
public EmployeeRepositoryJpa(EntityManager em) {
public JpaEmployeeRepository(EntityManager em) {
this.em = em;
}
@@ -17,12 +17,12 @@ import static org.springframework.util.StringUtils.hasLength;
@DisplayName("Репозиторий для Category должен")
@DataJpaTest
@Import(CategoryRepositoryJpa.class)
@Import(JpaCategoryRepository.class)
@Transactional(propagation = Propagation.NEVER)
class CategoryRepositoryJpaTest {
class JpaCategoryRepositoryTest {
@Autowired
private CategoryRepositoryJpa categoryRepository;
private JpaCategoryRepository categoryRepository;
@DisplayName("возвращать список всех категорий")
@Test
@@ -20,8 +20,8 @@ import static org.assertj.core.api.Assertions.*;
@DisplayName("Репозиторий Employee должен")
@DataJpaTest
@Import(EmployeeRepositoryJpa.class)
class EmployeeRepositoryJpaTest {
@Import(JpaEmployeeRepository.class)
class JpaEmployeeRepositoryTest {
private static final long FIRST_EMPLOYEE_ID = 1L;
private static final long SECOND_EMPLOYEE_ID = 2L;
@@ -51,7 +51,7 @@ class EmployeeRepositoryJpaTest {
private TestEntityManager em;
@Autowired
private EmployeeRepositoryJpa employeeRepository;
private JpaEmployeeRepository employeeRepository;
@DisplayName("возвращать список всех сотрудников")