committed by
Greg L. Turnquist
parent
864c7c454d
commit
c510e28fa9
@@ -47,6 +47,7 @@ import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
* @author Jens Schauder
|
||||
* @author Krzysztof Krason
|
||||
*/
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration(classes = Config.class)
|
||||
@@ -192,7 +193,6 @@ class RepositoryIntegrationTests {
|
||||
|
||||
assertThat(revisions).hasSize(2);
|
||||
assertThat(revisions.getLatestRevision().getEntity()) //
|
||||
.isNotNull() //
|
||||
.extracting(c -> c.name, c -> c.code) //
|
||||
.containsExactly(null, null);
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
package org.springframework.data.jpa.convert.threeten;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.junit.Assume.*;
|
||||
import static org.assertj.core.api.Assumptions.*;
|
||||
import static org.springframework.data.jpa.support.EntityManagerTestUtils.*;
|
||||
|
||||
import java.time.Instant;
|
||||
@@ -51,7 +51,7 @@ public class Jsr310JpaConvertersIntegrationTests extends AbstractAttributeConver
|
||||
@Test // DATAJPA-650, DATAJPA-1631
|
||||
void usesJsr310JpaConverters() {
|
||||
|
||||
assumeTrue(currentEntityManagerIsAJpa21EntityManager(em));
|
||||
assumeThat(currentEntityManagerIsAJpa21EntityManager(em)).isTrue();
|
||||
|
||||
DateTimeSample sample = new DateTimeSample();
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@ package org.springframework.data.jpa.domain.support;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -42,6 +41,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
* @author Jens Schauder
|
||||
* @author Krzysztof Krason
|
||||
*/
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration("classpath:auditing/auditing-entity-listener.xml")
|
||||
@@ -58,14 +58,14 @@ public class AuditingEntityListenerTests {
|
||||
|
||||
private static void assertDatesSet(Auditable<?, ?, LocalDateTime> auditable) {
|
||||
|
||||
assertThat(auditable.getCreatedDate().isPresent()).isTrue();
|
||||
assertThat(auditable.getLastModifiedDate().isPresent()).isTrue();
|
||||
assertThat(auditable.getCreatedDate()).isPresent();
|
||||
assertThat(auditable.getLastModifiedDate()).isPresent();
|
||||
}
|
||||
|
||||
private static void assertUserIsAuditor(AuditableUser user, Auditable<AuditableUser, ?, LocalDateTime> auditable) {
|
||||
|
||||
assertThat(auditable.getCreatedBy()).isEqualTo(Optional.of(user));
|
||||
assertThat(auditable.getLastModifiedBy()).isEqualTo(Optional.of(user));
|
||||
assertThat(auditable.getCreatedBy()).contains(user);
|
||||
assertThat(auditable.getLastModifiedBy()).contains(user);
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
|
||||
@@ -45,6 +45,7 @@ import org.springframework.transaction.support.TransactionTemplate;
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
* @author Jens Schauder
|
||||
* @author Krzysztof Krason
|
||||
*/
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration
|
||||
@@ -75,7 +76,7 @@ public class PersistenceProviderIntegrationTests {
|
||||
ProxyIdAccessor accessor = PersistenceProvider.fromEntityManager(em);
|
||||
|
||||
assertThat(accessor.shouldUseAccessorFor(product)).isTrue();
|
||||
assertThat(accessor.getIdentifierFrom(product).toString()).isEqualTo((Object) product.getId().toString());
|
||||
assertThat(accessor.getIdentifierFrom(product)).hasToString(product.getId().toString());
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ import org.springframework.test.context.ContextConfiguration;
|
||||
* @author Jens Schauder
|
||||
* @author Moritz Becker
|
||||
* @author Andrey Kovalev
|
||||
* @author Krzysztof Krason
|
||||
*/
|
||||
@ContextConfiguration(value = "classpath:eclipselink.xml")
|
||||
@Disabled("hsqldb seems to hang on this test class without leaving a surefire report")
|
||||
@@ -66,8 +67,7 @@ class EclipseLinkNamespaceUserRepositoryTests extends NamespaceUserRepositoryTes
|
||||
|
||||
Query query = em.createNativeQuery("select 1 from User where firstname=? and lastname=?");
|
||||
assertThat(query.getParameters()).describedAs(
|
||||
"Due to a bug eclipse has size 0; If this is no longer the case the special code path triggered in NamedOrIndexedQueryParameterSetter.registerExcessParameters can be removed")
|
||||
.hasSize(0);
|
||||
"Due to a bug eclipse has size 0; If this is no longer the case the special code path triggered in NamedOrIndexedQueryParameterSetter.registerExcessParameters can be removed").isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package org.springframework.data.jpa.repository;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.assertj.core.api.Assumptions.*;
|
||||
import static org.springframework.data.jpa.support.EntityManagerTestUtils.*;
|
||||
|
||||
import jakarta.persistence.EntityManager;
|
||||
@@ -29,7 +30,6 @@ import jakarta.persistence.criteria.Root;
|
||||
import java.util.List;
|
||||
|
||||
import org.assertj.core.api.SoftAssertions;
|
||||
import org.junit.Assume;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -55,6 +55,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
* @author Jocelyn Ntakpe
|
||||
* @author Christoph Strobl
|
||||
* @author Jens Schauder
|
||||
* @author Krzysztof Krason
|
||||
*/
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration("classpath:config/namespace-autoconfig-context.xml")
|
||||
@@ -96,14 +97,14 @@ public class EntityGraphRepositoryMethodsIntegrationTests {
|
||||
@Test // DATAJPA-612
|
||||
void shouldRespectConfiguredJpaEntityGraph() {
|
||||
|
||||
Assume.assumeTrue(currentEntityManagerIsAJpa21EntityManager(em));
|
||||
assumeThat(currentEntityManagerIsAJpa21EntityManager(em)).isTrue();
|
||||
|
||||
em.flush();
|
||||
em.clear();
|
||||
|
||||
List<User> result = repository.findAll();
|
||||
|
||||
assertThat(result.size()).isEqualTo(3);
|
||||
assertThat(result).hasSize(3);
|
||||
assertThat(util.isLoaded(result.get(0), "roles")).isTrue();
|
||||
assertThat(result.get(0)).isEqualTo(tom);
|
||||
}
|
||||
@@ -111,7 +112,7 @@ public class EntityGraphRepositoryMethodsIntegrationTests {
|
||||
@Test // DATAJPA-689
|
||||
void shouldRespectConfiguredJpaEntityGraphInFindOne() {
|
||||
|
||||
Assume.assumeTrue(currentEntityManagerIsAJpa21EntityManager(em));
|
||||
assumeThat(currentEntityManagerIsAJpa21EntityManager(em)).isTrue();
|
||||
|
||||
em.flush();
|
||||
em.clear();
|
||||
@@ -127,7 +128,7 @@ public class EntityGraphRepositoryMethodsIntegrationTests {
|
||||
@Test // DATAJPA-696
|
||||
void shouldRespectInferFetchGraphFromMethodName() {
|
||||
|
||||
Assume.assumeTrue(currentEntityManagerIsAJpa21EntityManager(em));
|
||||
assumeThat(currentEntityManagerIsAJpa21EntityManager(em)).isTrue();
|
||||
|
||||
em.flush();
|
||||
em.clear();
|
||||
@@ -143,7 +144,7 @@ public class EntityGraphRepositoryMethodsIntegrationTests {
|
||||
@Test // DATAJPA-696
|
||||
void shouldRespectDynamicFetchGraphForGetOneWithAttributeNamesById() {
|
||||
|
||||
Assume.assumeTrue(currentEntityManagerIsAJpa21EntityManager(em));
|
||||
assumeThat(currentEntityManagerIsAJpa21EntityManager(em)).isTrue();
|
||||
|
||||
em.flush();
|
||||
em.clear();
|
||||
@@ -169,7 +170,7 @@ public class EntityGraphRepositoryMethodsIntegrationTests {
|
||||
@Test // DATAJPA-790, DATAJPA-1087
|
||||
void shouldRespectConfiguredJpaEntityGraphWithPaginationAndQueryDslPredicates() {
|
||||
|
||||
Assume.assumeTrue(currentEntityManagerIsAJpa21EntityManager(em));
|
||||
assumeThat(currentEntityManagerIsAJpa21EntityManager(em)).isTrue();
|
||||
|
||||
em.flush();
|
||||
em.clear();
|
||||
@@ -177,7 +178,7 @@ public class EntityGraphRepositoryMethodsIntegrationTests {
|
||||
Page<User> page = repository.findAll(QUser.user.firstname.isNotNull(), PageRequest.of(0, 100));
|
||||
List<User> result = page.getContent();
|
||||
|
||||
assertThat(result.size()).isEqualTo(3);
|
||||
assertThat(result).hasSize(3);
|
||||
assertThat(util.isLoaded(result.get(0), "roles")).isTrue();
|
||||
assertThat(result.get(0)).isEqualTo(tom);
|
||||
}
|
||||
@@ -185,7 +186,7 @@ public class EntityGraphRepositoryMethodsIntegrationTests {
|
||||
@Test // DATAJPA-1207
|
||||
void shouldRespectConfiguredJpaEntityGraphWithPaginationAndSpecification() {
|
||||
|
||||
Assume.assumeTrue(currentEntityManagerIsAJpa21EntityManager(em));
|
||||
assumeThat(currentEntityManagerIsAJpa21EntityManager(em)).isTrue();
|
||||
|
||||
em.flush();
|
||||
em.clear();
|
||||
@@ -197,7 +198,7 @@ public class EntityGraphRepositoryMethodsIntegrationTests {
|
||||
|
||||
List<User> result = page.getContent();
|
||||
|
||||
assertThat(result.size()).isEqualTo(3);
|
||||
assertThat(result).hasSize(3);
|
||||
assertThat(util.isLoaded(result.get(0), "roles")).isTrue();
|
||||
assertThat(result.get(0)).isEqualTo(tom);
|
||||
}
|
||||
@@ -205,7 +206,7 @@ public class EntityGraphRepositoryMethodsIntegrationTests {
|
||||
@Test // DATAJPA-1041
|
||||
void shouldRespectNamedEntitySubGraph() {
|
||||
|
||||
Assume.assumeTrue(currentEntityManagerIsAJpa21EntityManager(em));
|
||||
assumeThat(currentEntityManagerIsAJpa21EntityManager(em)).isTrue();
|
||||
|
||||
em.flush();
|
||||
em.clear();
|
||||
@@ -230,7 +231,7 @@ public class EntityGraphRepositoryMethodsIntegrationTests {
|
||||
@Test // DATAJPA-1041
|
||||
void shouldRespectMultipleSubGraphForSameAttributeWithDynamicFetchGraph() {
|
||||
|
||||
Assume.assumeTrue(currentEntityManagerIsAJpa21EntityManager(em));
|
||||
assumeThat(currentEntityManagerIsAJpa21EntityManager(em)).isTrue();
|
||||
|
||||
em.flush();
|
||||
em.clear();
|
||||
@@ -256,7 +257,7 @@ public class EntityGraphRepositoryMethodsIntegrationTests {
|
||||
@Disabled // likely broken due to the fixes made for HHH-15391
|
||||
void shouldCreateDynamicGraphWithMultipleLevelsOfSubgraphs() {
|
||||
|
||||
Assume.assumeTrue(currentEntityManagerIsAJpa21EntityManager(em));
|
||||
assumeThat(currentEntityManagerIsAJpa21EntityManager(em)).isTrue();
|
||||
em.flush();
|
||||
em.clear();
|
||||
|
||||
|
||||
@@ -46,6 +46,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
*
|
||||
* @author Thomas Darimont
|
||||
* @author Jens Schauder
|
||||
* @author Krzysztof Krason
|
||||
*/
|
||||
@Transactional
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@@ -66,8 +67,8 @@ public class MappedTypeRepositoryIntegrationTests {
|
||||
List<ConcreteType1> concretes1 = concreteRepository1.findAllByAttribute1("foo");
|
||||
List<ConcreteType2> concretes2 = concreteRepository2.findAllByAttribute1("foo");
|
||||
|
||||
assertThat(concretes1.size()).isEqualTo(1);
|
||||
assertThat(concretes2.size()).isEqualTo(1);
|
||||
assertThat(concretes1).hasSize(1);
|
||||
assertThat(concretes2).hasSize(1);
|
||||
}
|
||||
|
||||
@Test // DATAJPA-424
|
||||
@@ -79,7 +80,7 @@ public class MappedTypeRepositoryIntegrationTests {
|
||||
Page<ConcreteType2> page = concreteRepository2.findByAttribute1Custom("foo",
|
||||
PageRequest.of(0, 10, Sort.Direction.DESC, "attribute1"));
|
||||
|
||||
assertThat(page.getNumberOfElements()).isEqualTo(1);
|
||||
assertThat(page.getNumberOfElements()).isOne();
|
||||
}
|
||||
|
||||
@Test // DATAJPA-1535
|
||||
|
||||
@@ -40,6 +40,7 @@ import org.springframework.test.context.ContextConfiguration;
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
* @author Jens Schauder
|
||||
* @author Krzysztof Krason
|
||||
*/
|
||||
@ContextConfiguration("classpath:openjpa.xml")
|
||||
class OpenJpaNamespaceUserRepositoryTests extends NamespaceUserRepositoryTests {
|
||||
@@ -78,7 +79,7 @@ class OpenJpaNamespaceUserRepositoryTests extends NamespaceUserRepositoryTests {
|
||||
query.setParameter(parameter, Arrays.asList(1, 2));
|
||||
|
||||
List<User> resultList = query.getResultList();
|
||||
assertThat(resultList.size()).isEqualTo(2);
|
||||
assertThat(resultList).hasSize(2);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -44,6 +44,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* @author Jens Schauder
|
||||
* @author Krzysztof Krason
|
||||
*/
|
||||
@Transactional
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@@ -76,11 +77,11 @@ public class ParentRepositoryIntegrationTests {
|
||||
|
||||
List<Parent> content = page.getContent();
|
||||
|
||||
assertThat(content.size()).isEqualTo(3);
|
||||
assertThat(content).hasSize(3);
|
||||
assertThat(page.getSize()).isEqualTo(5);
|
||||
assertThat(page.getNumber()).isEqualTo(0);
|
||||
assertThat(page.getNumber()).isZero();
|
||||
assertThat(page.getTotalElements()).isEqualTo(3L);
|
||||
assertThat(page.getTotalPages()).isEqualTo(1);
|
||||
assertThat(page.getTotalPages()).isOne();
|
||||
}
|
||||
|
||||
@Test // DATAJPA-287
|
||||
@@ -99,13 +100,13 @@ public class ParentRepositoryIntegrationTests {
|
||||
|
||||
// according to the initial setup there should be
|
||||
// 3 parents which children collection is not empty
|
||||
assertThat(content.size()).isEqualTo(3);
|
||||
assertThat(content).hasSize(3);
|
||||
assertThat(page.getSize()).isEqualTo(5);
|
||||
assertThat(page.getNumber()).isEqualTo(0);
|
||||
assertThat(page.getNumber()).isZero();
|
||||
|
||||
// we get here wrong total elements number since
|
||||
// count query doesn't take into account the distinct marker of query
|
||||
assertThat(page.getTotalElements()).isEqualTo(3L);
|
||||
assertThat(page.getTotalPages()).isEqualTo(1);
|
||||
assertThat(page.getTotalPages()).isOne();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
/**
|
||||
* @author Thomas Darimont
|
||||
* @author Jens Schauder
|
||||
* @author Krzysztof Krason
|
||||
*/
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration(classes = SampleConfig.class)
|
||||
@@ -62,7 +63,7 @@ public class RedeclaringRepositoryMethodsTests {
|
||||
|
||||
Page<User> page = repository.findAll(PageRequest.of(0, 2));
|
||||
|
||||
assertThat(page.getNumberOfElements()).isEqualTo(1);
|
||||
assertThat(page.getNumberOfElements()).isOne();
|
||||
assertThat(page.getContent().get(0).getFirstname()).isEqualTo("Oliver");
|
||||
}
|
||||
|
||||
@@ -74,6 +75,6 @@ public class RedeclaringRepositoryMethodsTests {
|
||||
|
||||
List<User> result = repository.findAll();
|
||||
|
||||
assertThat(result.isEmpty()).isTrue();
|
||||
assertThat(result).isEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,6 +50,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
* @author Mark Paluch
|
||||
* @author Jens Schauder
|
||||
* @author Ernst-Jan van der Laan
|
||||
* @author Krzysztof Krason
|
||||
*/
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration(classes = SampleConfig.class)
|
||||
@@ -127,7 +128,7 @@ public class RepositoryWithCompositeKeyTests {
|
||||
Page<IdClassExampleEmployee> page = employeeRepositoryWithIdClass.findAll(PageRequest.of(0, 1));
|
||||
|
||||
assertThat(page).isNotNull();
|
||||
assertThat(page.getTotalElements()).isEqualTo(1L);
|
||||
assertThat(page.getTotalElements()).isOne();
|
||||
}
|
||||
|
||||
@Test // DATAJPA-2414
|
||||
|
||||
@@ -44,6 +44,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
*
|
||||
* @author Mark Paluch
|
||||
* @author Jens Schauder
|
||||
* @author Krzysztof Krason
|
||||
*/
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration(classes = RepositoryWithIdClassKeyTests.TestConfig.class)
|
||||
@@ -72,7 +73,7 @@ public class RepositoryWithIdClassKeyTests {
|
||||
.findById(new ItemSiteId(new ItemId(item.getId(), item.getManufacturerId()), site.getId()));
|
||||
|
||||
assertThat(loaded).isNotNull();
|
||||
assertThat(loaded.isPresent()).isTrue();
|
||||
assertThat(loaded).isPresent();
|
||||
}
|
||||
|
||||
@Configuration
|
||||
|
||||
@@ -17,8 +17,6 @@ package org.springframework.data.jpa.repository;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
|
||||
@@ -36,6 +34,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
* @author Oliver Gierke
|
||||
* @author Thomas Darimont
|
||||
* @author Jens Schauder
|
||||
* @author Krzysztof Krason
|
||||
*/
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration(locations = { "classpath:application-context.xml" })
|
||||
@@ -63,7 +62,7 @@ public class RoleRepositoryIntegrationTests {
|
||||
ReflectionTestUtils.setField(reference, "name", "USER");
|
||||
repository.save(reference);
|
||||
|
||||
assertThat(repository.findById(result.getId())).isEqualTo(Optional.of(reference));
|
||||
assertThat(repository.findById(result.getId())).contains(reference);
|
||||
}
|
||||
|
||||
@Test // DATAJPA-509
|
||||
@@ -72,7 +71,7 @@ public class RoleRepositoryIntegrationTests {
|
||||
Role reference = new Role("ADMIN");
|
||||
repository.save(reference);
|
||||
|
||||
assertThat(repository.count()).isEqualTo(1L);
|
||||
assertThat(repository.count()).isOne();
|
||||
}
|
||||
|
||||
@Test // DATAJPA-509
|
||||
@@ -90,6 +89,6 @@ public class RoleRepositoryIntegrationTests {
|
||||
Role reference = new Role("ADMIN");
|
||||
reference = repository.save(reference);
|
||||
|
||||
assertThat(repository.countByName(reference.getName())).isEqualTo(1L);
|
||||
assertThat(repository.countByName(reference.getName())).isOne();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@ package org.springframework.data.jpa.repository;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -32,6 +31,7 @@ import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
/**
|
||||
* @author Jens Schauder
|
||||
* @author Krzysztof Krason
|
||||
*/
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration("classpath:config/namespace-application-context.xml")
|
||||
@@ -46,9 +46,9 @@ public class SPR8954Tests {
|
||||
Map<String, RepositoryFactoryInformation> repoFactories = context
|
||||
.getBeansOfType(RepositoryFactoryInformation.class);
|
||||
|
||||
assertThat(repoFactories.size()).isGreaterThan(0);
|
||||
assertThat(repoFactories).isNotEmpty();
|
||||
assertThat(repoFactories.keySet()).contains("&userRepository");
|
||||
assertThat(repoFactories.get("&userRepository")).isInstanceOf(JpaRepositoryFactoryBean.class);
|
||||
assertThat(Arrays.asList(context.getBeanNamesForType(UserRepository.class))).contains("userRepository");
|
||||
assertThat(context.getBeanNamesForType(UserRepository.class)).contains("userRepository");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
/**
|
||||
* @author Oliver Gierke
|
||||
* @author Jens Schauder
|
||||
* @author Krzysztof Krason
|
||||
*/
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration({ "classpath:application-context.xml"
|
||||
@@ -71,7 +72,7 @@ class SimpleJpaParameterBindingTests {
|
||||
query.setParameter(parameter, new String[] { "Dave", "Carter" });
|
||||
|
||||
List<User> result = query.getResultList();
|
||||
assertThat(result.isEmpty()).isFalse();
|
||||
assertThat(result).isNotEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -94,7 +95,7 @@ class SimpleJpaParameterBindingTests {
|
||||
query.setParameter(parameter, Arrays.asList("Dave"));
|
||||
|
||||
List<User> result = query.getResultList();
|
||||
assertThat(result.isEmpty()).isFalse();
|
||||
assertThat(result).isNotEmpty();
|
||||
assertThat(result.get(0)).isEqualTo(user);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
package org.springframework.data.jpa.repository;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.junit.Assume.*;
|
||||
import static org.assertj.core.api.Assumptions.*;
|
||||
import static org.springframework.data.jpa.support.EntityManagerTestUtils.*;
|
||||
|
||||
import java.util.List;
|
||||
@@ -47,6 +47,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
* @author Oliver Gierke
|
||||
* @author Jens Schauder
|
||||
* @author Gabriel Basilio
|
||||
* @author Krzysztof Krason
|
||||
* @see scripts/schema-stored-procedures.sql for procedure definitions.
|
||||
*/
|
||||
@Transactional
|
||||
@@ -61,7 +62,7 @@ public class StoredProcedureIntegrationTests {
|
||||
|
||||
@BeforeEach
|
||||
void setup() {
|
||||
assumeTrue(currentEntityManagerIsAJpa21EntityManager(em));
|
||||
assumeThat(currentEntityManagerIsAJpa21EntityManager(em)).isTrue();
|
||||
}
|
||||
|
||||
@Test // DATAJPA-652
|
||||
@@ -86,7 +87,7 @@ public class StoredProcedureIntegrationTests {
|
||||
List<Dummy> dummies = repository.adHocProcedureWith1InputAnd1OutputParameterWithResultSet("FOO");
|
||||
|
||||
assertThat(dummies).isNotNull();
|
||||
assertThat(dummies.size()).isEqualTo(3);
|
||||
assertThat(dummies).hasSize(3);
|
||||
}
|
||||
|
||||
@Test // DATAJPA-652
|
||||
@@ -96,7 +97,7 @@ public class StoredProcedureIntegrationTests {
|
||||
List<Dummy> dummies = repository.adHocProcedureWith1InputAnd1OutputParameterWithResultSetWithUpdate("FOO");
|
||||
|
||||
assertThat(dummies).isNotNull();
|
||||
assertThat(dummies.size()).isEqualTo(3);
|
||||
assertThat(dummies).hasSize(3);
|
||||
}
|
||||
|
||||
@Test // DATAJPA-652
|
||||
@@ -126,7 +127,7 @@ public class StoredProcedureIntegrationTests {
|
||||
List<Dummy> dummies = repository.procedureWith1InputAnd1OutputParameterWithResultSet("FOO");
|
||||
|
||||
assertThat(dummies).isNotNull();
|
||||
assertThat(dummies.size()).isEqualTo(3);
|
||||
assertThat(dummies).hasSize(3);
|
||||
}
|
||||
|
||||
@Test // DATAJPA-652
|
||||
@@ -136,7 +137,7 @@ public class StoredProcedureIntegrationTests {
|
||||
List<Dummy> dummies = repository.procedureWith1InputAnd1OutputParameterWithResultSetWithUpdate("FOO");
|
||||
|
||||
assertThat(dummies).isNotNull();
|
||||
assertThat(dummies.size()).isEqualTo(3);
|
||||
assertThat(dummies).hasSize(3);
|
||||
}
|
||||
|
||||
@Test // DATAJPA-652
|
||||
|
||||
@@ -49,6 +49,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
* Integration test for executing finders, thus testing various query lookup strategies.
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
* @author Krzysztof Krason
|
||||
* @see QueryLookupStrategy
|
||||
*/
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@@ -128,7 +129,7 @@ public class UserRepositoryFinderTests {
|
||||
|
||||
Page<User> page = userRepository.findByLastname(PageRequest.of(0, 1), "Matthews");
|
||||
|
||||
assertThat(page.getNumberOfElements()).isEqualTo(1);
|
||||
assertThat(page.getNumberOfElements()).isOne();
|
||||
assertThat(page.getTotalElements()).isEqualTo(2L);
|
||||
assertThat(page.getTotalPages()).isEqualTo(2);
|
||||
}
|
||||
@@ -145,7 +146,7 @@ public class UserRepositoryFinderTests {
|
||||
|
||||
Page<User> page = userRepository.findByFirstnameIn(PageRequest.of(0, 1), "Dave", "Oliver August");
|
||||
|
||||
assertThat(page.getNumberOfElements()).isEqualTo(1);
|
||||
assertThat(page.getNumberOfElements()).isOne();
|
||||
assertThat(page.getTotalElements()).isEqualTo(2L);
|
||||
assertThat(page.getTotalPages()).isEqualTo(2);
|
||||
}
|
||||
@@ -214,7 +215,7 @@ public class UserRepositoryFinderTests {
|
||||
|
||||
assertThat(slice).containsExactlyInAnyOrder(dave, oliver);
|
||||
assertThat(slice.getNumberOfElements()).isEqualTo(2);
|
||||
assertThat(slice.hasNext()).isEqualTo(false);
|
||||
assertThat(slice.hasNext()).isFalse();
|
||||
}
|
||||
|
||||
@Test // DATAJPA-830
|
||||
|
||||
@@ -84,6 +84,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
* @author Daniel Shuy
|
||||
* @author Simon Paradies
|
||||
* @author Geoffrey Deremetz
|
||||
* @author Krzysztof Krason
|
||||
*/
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration("classpath:application-context.xml")
|
||||
@@ -297,7 +298,7 @@ public class UserRepositoryTests {
|
||||
repository.renameAllUsersTo("newLastname");
|
||||
|
||||
long expected = repository.count();
|
||||
assertThat(repository.findByLastname("newLastname").size()).isEqualTo(Long.valueOf(expected).intValue());
|
||||
assertThat(repository.findByLastname("newLastname")).hasSize(Long.valueOf(expected).intValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -446,7 +447,7 @@ public class UserRepositoryTests {
|
||||
void testExecutionOfProjectingMethod() {
|
||||
|
||||
flushTestUsers();
|
||||
assertThat(repository.countWithFirstname("Oliver")).isEqualTo(1L);
|
||||
assertThat(repository.countWithFirstname("Oliver")).isOne();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -512,7 +513,7 @@ public class UserRepositoryTests {
|
||||
Specification<User> spec1 = userHasFirstname("Oliver").or(userHasLastname("Arrasz"));
|
||||
|
||||
Page<User> users1 = repository.findAll(spec1, PageRequest.of(0, 1));
|
||||
assertThat(users1.getSize()).isEqualTo(1);
|
||||
assertThat(users1.getSize()).isOne();
|
||||
assertThat(users1.hasPrevious()).isFalse();
|
||||
assertThat(users1.getTotalElements()).isEqualTo(2L);
|
||||
|
||||
@@ -521,7 +522,7 @@ public class UserRepositoryTests {
|
||||
userHasLastname("Arrasz"));
|
||||
|
||||
Page<User> users2 = repository.findAll(spec2, PageRequest.of(0, 1));
|
||||
assertThat(users2.getSize()).isEqualTo(1);
|
||||
assertThat(users2.getSize()).isOne();
|
||||
assertThat(users2.hasPrevious()).isFalse();
|
||||
assertThat(users2.getTotalElements()).isEqualTo(2L);
|
||||
|
||||
@@ -702,7 +703,7 @@ public class UserRepositoryTests {
|
||||
flushTestUsers();
|
||||
|
||||
Page<String> result = repository.findByLastnameGrouped(PageRequest.of(0, 10));
|
||||
assertThat(result.getTotalPages()).isEqualTo(1);
|
||||
assertThat(result.getTotalPages()).isOne();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -811,7 +812,7 @@ public class UserRepositoryTests {
|
||||
assertThat(repository.findByFirstname("Oliver", null)).containsOnly(firstUser);
|
||||
|
||||
Page<User> page = repository.findByFirstnameIn(Pageable.unpaged(), "Oliver");
|
||||
assertThat(page.getNumberOfElements()).isEqualTo(1);
|
||||
assertThat(page.getNumberOfElements()).isOne();
|
||||
assertThat(page.getContent()).contains(firstUser);
|
||||
|
||||
page = repository.findAll(Pageable.unpaged());
|
||||
@@ -826,7 +827,7 @@ public class UserRepositoryTests {
|
||||
|
||||
List<Integer> result = repository.findOnesByNativeQuery();
|
||||
|
||||
assertThat(result.size()).isEqualTo(4);
|
||||
assertThat(result).hasSize(4);
|
||||
assertThat(result).contains(1);
|
||||
}
|
||||
|
||||
@@ -895,7 +896,7 @@ public class UserRepositoryTests {
|
||||
|
||||
Page<User> all = repository.findAll(PageRequest.of(0, 10, Sort.by("manager.id")));
|
||||
|
||||
assertThat(all.getContent().isEmpty()).isFalse();
|
||||
assertThat(all.getContent()).isNotEmpty();
|
||||
}
|
||||
|
||||
@Test // DATAJPA-252
|
||||
@@ -920,7 +921,7 @@ public class UserRepositoryTests {
|
||||
}
|
||||
}, PageRequest.of(0, 20, Sort.by("manager.lastname")));
|
||||
|
||||
assertThat(page.getNumberOfElements()).isEqualTo(1);
|
||||
assertThat(page.getNumberOfElements()).isOne();
|
||||
assertThat(page).containsOnly(firstUser);
|
||||
}
|
||||
|
||||
@@ -968,7 +969,7 @@ public class UserRepositoryTests {
|
||||
|
||||
flushTestUsers();
|
||||
|
||||
assertThat(repository.countByLastname("Matthews")).isEqualTo(1L);
|
||||
assertThat(repository.countByLastname("Matthews")).isOne();
|
||||
}
|
||||
|
||||
@Test // DATAJPA-231
|
||||
@@ -976,7 +977,7 @@ public class UserRepositoryTests {
|
||||
|
||||
flushTestUsers();
|
||||
|
||||
assertThat(repository.countUsersByFirstname("Dave")).isEqualTo(1);
|
||||
assertThat(repository.countUsersByFirstname("Dave")).isOne();
|
||||
}
|
||||
|
||||
@Test // DATAJPA-231
|
||||
@@ -984,8 +985,8 @@ public class UserRepositoryTests {
|
||||
|
||||
flushTestUsers();
|
||||
|
||||
assertThat(repository.existsByLastname("Matthews")).isEqualTo(true);
|
||||
assertThat(repository.existsByLastname("Hans Peter")).isEqualTo(false);
|
||||
assertThat(repository.existsByLastname("Matthews")).isTrue();
|
||||
assertThat(repository.existsByLastname("Hans Peter")).isFalse();
|
||||
}
|
||||
|
||||
@Test // DATAJPA-332, DATAJPA-1168
|
||||
@@ -1049,8 +1050,8 @@ public class UserRepositoryTests {
|
||||
fourthUser.getId());
|
||||
|
||||
long expectedCount = repository.count();
|
||||
assertThat(repository.findByActiveFalse().size()).isEqualTo((int) expectedCount);
|
||||
assertThat(repository.findByActiveTrue().size()).isEqualTo(0);
|
||||
assertThat(repository.findByActiveFalse()).hasSize((int) expectedCount);
|
||||
assertThat(repository.findByActiveTrue()).isEmpty();
|
||||
}
|
||||
|
||||
@Test // DATAJPA-405
|
||||
@@ -1269,7 +1270,7 @@ public class UserRepositoryTests {
|
||||
flushTestUsers();
|
||||
|
||||
repository.deleteByLastname(firstUser.getLastname());
|
||||
assertThat(repository.countByLastname(firstUser.getLastname())).isEqualTo(0L);
|
||||
assertThat(repository.countByLastname(firstUser.getLastname())).isZero();
|
||||
}
|
||||
|
||||
@Test // DATAJPA-460
|
||||
@@ -1277,7 +1278,7 @@ public class UserRepositoryTests {
|
||||
|
||||
flushTestUsers();
|
||||
|
||||
assertThat(repository.removeByLastname(firstUser.getLastname())).isEqualTo(1L);
|
||||
assertThat(repository.removeByLastname(firstUser.getLastname())).isOne();
|
||||
}
|
||||
|
||||
@Test // DATAJPA-460
|
||||
@@ -1285,7 +1286,7 @@ public class UserRepositoryTests {
|
||||
|
||||
flushTestUsers();
|
||||
|
||||
assertThat(repository.removeByLastname("bubu")).isEqualTo(0L);
|
||||
assertThat(repository.removeByLastname("bubu")).isZero();
|
||||
}
|
||||
|
||||
@Test // DATAJPA-460
|
||||
@@ -1310,7 +1311,7 @@ public class UserRepositoryTests {
|
||||
|
||||
byte[] result = repository.findBinaryDataByIdNative(firstUser.getId());
|
||||
|
||||
assertThat(result.length).isEqualTo(data.length);
|
||||
assertThat(result).hasSameSizeAs(data);
|
||||
assertThat(result).isEqualTo(data);
|
||||
}
|
||||
|
||||
@@ -1325,7 +1326,7 @@ public class UserRepositoryTests {
|
||||
byte[] result = repository.findBinaryDataByIdNative(firstUser.getId());
|
||||
|
||||
assertThat(result).isEqualTo(data);
|
||||
assertThat(result.length).isEqualTo(data.length);
|
||||
assertThat(result).hasSameSizeAs(data);
|
||||
}
|
||||
|
||||
@Test // DATAJPA-456
|
||||
@@ -1337,7 +1338,7 @@ public class UserRepositoryTests {
|
||||
|
||||
Page<User> result = repository.findAllByFirstnameLike("", PageRequest.of(0, 10));
|
||||
|
||||
assertThat(result.getContent().size()).isEqualTo(3);
|
||||
assertThat(result.getContent()).hasSize(3);
|
||||
}
|
||||
|
||||
@Test // DATAJPA-456
|
||||
@@ -1347,7 +1348,7 @@ public class UserRepositoryTests {
|
||||
|
||||
Page<User> result = repository.findByNamedQueryAndCountProjection("Gierke", PageRequest.of(0, 10));
|
||||
|
||||
assertThat(result.getContent().size()).isEqualTo(1);
|
||||
assertThat(result.getContent()).hasSize(1);
|
||||
}
|
||||
|
||||
@Test // DATAJPA-551
|
||||
@@ -1484,7 +1485,7 @@ public class UserRepositoryTests {
|
||||
assertThat(firstPage.getTotalElements()).isEqualTo(4L);
|
||||
|
||||
Page<User> secondPage = repository.findAll(PageRequest.of(10, 10));
|
||||
assertThat(secondPage.getContent()).hasSize(0);
|
||||
assertThat(secondPage.getContent()).isEmpty();
|
||||
assertThat(secondPage.getTotalElements()).isEqualTo(4L);
|
||||
}
|
||||
|
||||
@@ -1495,8 +1496,8 @@ public class UserRepositoryTests {
|
||||
|
||||
Optional<User> result = repository.findOptionalByEmailAddress("gierke@synyx.de");
|
||||
|
||||
assertThat(result.isPresent()).isEqualTo(true);
|
||||
assertThat(result.get()).isEqualTo(firstUser);
|
||||
assertThat(result).isPresent();
|
||||
assertThat(result).contains(firstUser);
|
||||
}
|
||||
|
||||
@Test // DATAJPA-564
|
||||
@@ -1686,7 +1687,7 @@ public class UserRepositoryTests {
|
||||
flushTestUsers();
|
||||
|
||||
List<User> users = repository.findByAttributesIn(new HashSet<>());
|
||||
assertThat(users).hasSize(0);
|
||||
assertThat(users).isEmpty();
|
||||
}
|
||||
|
||||
@Test // DATAJPA-606
|
||||
@@ -1695,7 +1696,7 @@ public class UserRepositoryTests {
|
||||
flushTestUsers();
|
||||
|
||||
List<User> users = repository.findByAgeIn(Collections.emptyList());
|
||||
assertThat(users).hasSize(0);
|
||||
assertThat(users).isEmpty();
|
||||
}
|
||||
|
||||
@Test // GH-2013
|
||||
@@ -1707,7 +1708,7 @@ public class UserRepositoryTests {
|
||||
|
||||
assertThat(userPage).hasSize(2);
|
||||
assertThat(userPage.getTotalElements()).isEqualTo(2);
|
||||
assertThat(userPage.getTotalPages()).isEqualTo(1);
|
||||
assertThat(userPage.getTotalPages()).isOne();
|
||||
assertThat(userPage.getContent()).containsExactlyInAnyOrder(firstUser, secondUser);
|
||||
}
|
||||
|
||||
@@ -1720,7 +1721,7 @@ public class UserRepositoryTests {
|
||||
|
||||
assertThat(userPage).hasSize(2);
|
||||
assertThat(userPage.getTotalElements()).isEqualTo(2);
|
||||
assertThat(userPage.getTotalPages()).isEqualTo(1);
|
||||
assertThat(userPage.getTotalPages()).isOne();
|
||||
assertThat(userPage.getContent()).containsExactlyInAnyOrder(firstUser, secondUser);
|
||||
}
|
||||
|
||||
@@ -1730,7 +1731,7 @@ public class UserRepositoryTests {
|
||||
flushTestUsers();
|
||||
|
||||
List<User> users = repository.queryByAgeIn(new Integer[0]);
|
||||
assertThat(users).hasSize(0);
|
||||
assertThat(users).isEmpty();
|
||||
}
|
||||
|
||||
@Test // DATAJPA-606
|
||||
@@ -2022,7 +2023,7 @@ public class UserRepositoryTests {
|
||||
Page<User> users = repository.findAll(example, PageRequest.of(0, 10, Sort.by(DESC, "age")));
|
||||
|
||||
assertThat(users.getSize()).isEqualTo(10);
|
||||
assertThat(users.hasNext()).isEqualTo(true);
|
||||
assertThat(users.hasNext()).isTrue();
|
||||
assertThat(users.getTotalElements()).isEqualTo(100L);
|
||||
}
|
||||
|
||||
@@ -2513,7 +2514,7 @@ public class UserRepositoryTests {
|
||||
Example<User> example = Example.of(prototype, matching().withIgnorePaths("createdAt"));
|
||||
long count = repository.count(example);
|
||||
|
||||
assertThat(count).isEqualTo(1L);
|
||||
assertThat(count).isOne();
|
||||
}
|
||||
|
||||
@Test // DATAJPA-218
|
||||
@@ -2527,7 +2528,7 @@ public class UserRepositoryTests {
|
||||
Example<User> example = Example.of(prototype, matching().withIgnorePaths("createdAt"));
|
||||
boolean exists = repository.exists(example);
|
||||
|
||||
assertThat(exists).isEqualTo(true);
|
||||
assertThat(exists).isTrue();
|
||||
}
|
||||
|
||||
@Test // GH-2368
|
||||
@@ -2541,7 +2542,7 @@ public class UserRepositoryTests {
|
||||
Example<User> example = Example.of(prototype, matching().withIgnorePaths("createdAt"));
|
||||
boolean exists = repository.exists(example);
|
||||
|
||||
assertThat(exists).isEqualTo(false);
|
||||
assertThat(exists).isFalse();
|
||||
}
|
||||
|
||||
@Test // DATAJPA-905
|
||||
@@ -2552,7 +2553,7 @@ public class UserRepositoryTests {
|
||||
Page<User> result = repository.findAll(userHasLastnameLikeWithSort("e"), PageRequest.of(0, 1));
|
||||
|
||||
assertThat(result.getTotalElements()).isEqualTo(2L);
|
||||
assertThat(result.getNumberOfElements()).isEqualTo(1);
|
||||
assertThat(result.getNumberOfElements()).isOne();
|
||||
assertThat(result.getContent().get(0)).isEqualTo(thirdUser);
|
||||
}
|
||||
|
||||
@@ -2679,7 +2680,7 @@ public class UserRepositoryTests {
|
||||
.containsExactly("Dave", "Joachim", "kevin");
|
||||
|
||||
assertThat(secondPage.getTotalElements()).isEqualTo(4L);
|
||||
assertThat(secondPage.getNumberOfElements()).isEqualTo(1);
|
||||
assertThat(secondPage.getNumberOfElements()).isOne();
|
||||
assertThat(secondPage.getContent()) //
|
||||
.extracting(User::getFirstname) //
|
||||
.containsExactly("Oliver");
|
||||
@@ -2704,7 +2705,7 @@ public class UserRepositoryTests {
|
||||
.containsExactly("Dave", "Joachim", "kevin");
|
||||
|
||||
assertThat(secondPage.getTotalElements()).isEqualTo(4L);
|
||||
assertThat(secondPage.getNumberOfElements()).isEqualTo(1);
|
||||
assertThat(secondPage.getNumberOfElements()).isOne();
|
||||
assertThat(secondPage.getContent()) //
|
||||
.containsExactly("Oliver");
|
||||
|
||||
@@ -2981,8 +2982,6 @@ public class UserRepositoryTests {
|
||||
|
||||
List<User> all = repository.findAll();
|
||||
assertThat(all) //
|
||||
.isNotNull() //
|
||||
.isNotEmpty() //
|
||||
.hasSize(5) //
|
||||
.map(User::getLastname) //
|
||||
.contains("Gierke", "Arrasz", "Matthews", "raymond", "K");
|
||||
@@ -2996,8 +2995,6 @@ public class UserRepositoryTests {
|
||||
|
||||
List<User> all = repository.findAll();
|
||||
assertThat(all) //
|
||||
.isNotNull() //
|
||||
.isNotEmpty() //
|
||||
.hasSize(5) //
|
||||
.map(User::getLastname) //
|
||||
.contains("Gierke", "Arrasz", "Matthews", "raymond", testLastName);
|
||||
@@ -3009,7 +3006,6 @@ public class UserRepositoryTests {
|
||||
flushTestUsers();
|
||||
|
||||
assertThat(repository.findById(firstUser.getId())) //
|
||||
.isPresent() //
|
||||
.map(User::getAge).contains(28);
|
||||
|
||||
// when
|
||||
@@ -3017,7 +3013,6 @@ public class UserRepositoryTests {
|
||||
|
||||
// then
|
||||
assertThat(repository.findById(firstUser.getId())) //
|
||||
.isPresent() //
|
||||
.map(User::getAge).contains(30);
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ import org.apache.commons.logging.LogFactory;
|
||||
* @author Oliver Gierke
|
||||
* @author Mark Paluch
|
||||
* @author Jens Schauder
|
||||
* @author Krzysztof Krason
|
||||
*/
|
||||
class CdiExtensionIntegrationTests {
|
||||
|
||||
@@ -83,7 +84,7 @@ class CdiExtensionIntegrationTests {
|
||||
void returnOneFromCustomImpl() {
|
||||
|
||||
RepositoryConsumer repositoryConsumer = container.select(RepositoryConsumer.class).get();
|
||||
assertThat(repositoryConsumer.returnOne()).isEqualTo(1);
|
||||
assertThat(repositoryConsumer.returnOne()).isOne();
|
||||
}
|
||||
|
||||
@Test // DATAJPA-584, DATAJPA-1180
|
||||
@@ -97,6 +98,6 @@ class CdiExtensionIntegrationTests {
|
||||
void useQualifiedFragmentUserRepo() {
|
||||
|
||||
RepositoryConsumer repositoryConsumer = container.select(RepositoryConsumer.class).get();
|
||||
assertThat(repositoryConsumer.returnOneUserDB()).isEqualTo(1);
|
||||
assertThat(repositoryConsumer.returnOneUserDB()).isOne();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ import org.springframework.test.util.ReflectionTestUtils;
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
* @author Jens Schauder
|
||||
* @author Krzysztof Krason
|
||||
*/
|
||||
class JpaRepositoryExtensionUnitTests {
|
||||
|
||||
@@ -48,7 +49,7 @@ class JpaRepositoryExtensionUnitTests {
|
||||
|
||||
Map<Set<Annotation>, Bean<EntityManager>> entityManagers = (Map<Set<Annotation>, Bean<EntityManager>>) ReflectionTestUtils
|
||||
.getField(extension, "entityManagers");
|
||||
assertThat(entityManagers.size()).isEqualTo(1);
|
||||
assertThat(entityManagers).hasSize(1);
|
||||
assertThat(entityManagers.values()).contains(em);
|
||||
}
|
||||
|
||||
|
||||
@@ -54,6 +54,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
* @author Thomas Darimont
|
||||
* @author Oliver Gierke
|
||||
* @author Jens Schauder
|
||||
* @author Krzysztof Krason
|
||||
*/
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@Transactional
|
||||
@@ -123,8 +124,8 @@ public abstract class AbstractAuditingViaJavaConfigRepositoriesTests {
|
||||
for (AuditableUser user : users) {
|
||||
|
||||
assertThat(user.getFirstname()).isEqualTo(user.getFirstname().toUpperCase());
|
||||
assertThat(user.getLastModifiedBy()).isEqualTo(Optional.of(thomas));
|
||||
assertThat(user.getLastModifiedDate()).isEqualTo(Optional.of(now));
|
||||
assertThat(user.getLastModifiedBy()).contains(thomas);
|
||||
assertThat(user.getLastModifiedDate()).contains(now);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ import org.springframework.core.io.ClassPathResource;
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
* @author Jens Schauder
|
||||
* @author Krzysztof Krason
|
||||
*/
|
||||
class JpaRepositoryConfigDefinitionParserTests {
|
||||
|
||||
@@ -44,6 +45,6 @@ class JpaRepositoryConfigDefinitionParserTests {
|
||||
|
||||
PropertyValue transactionManager = definition.getPropertyValues().getPropertyValue("transactionManager");
|
||||
assertThat(transactionManager).isNotNull();
|
||||
assertThat(transactionManager.getValue().toString()).isEqualTo("transactionManager-2");
|
||||
assertThat(transactionManager.getValue()).hasToString("transactionManager-2");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.jpa.repository.query;
|
||||
|
||||
import static org.assertj.core.api.Assumptions.*;
|
||||
import static org.mockito.ArgumentMatchers.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
import static org.springframework.data.jpa.support.EntityManagerTestUtils.*;
|
||||
@@ -29,7 +30,6 @@ import jakarta.persistence.Query;
|
||||
import jakarta.persistence.QueryHint;
|
||||
import jakarta.persistence.TypedQuery;
|
||||
|
||||
import org.junit.Assume;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
@@ -53,6 +53,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
* @author Oliver Gierke
|
||||
* @author Thomas Darimont
|
||||
* @author Mark Paluch
|
||||
* @author Krzysztof Krason
|
||||
*/
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration("classpath:infrastructure.xml")
|
||||
@@ -118,7 +119,7 @@ public class AbstractJpaQueryTests {
|
||||
@Transactional
|
||||
void shouldAddEntityGraphHintForFetch() throws Exception {
|
||||
|
||||
Assume.assumeTrue(currentEntityManagerIsAJpa21EntityManager(em));
|
||||
assumeThat(currentEntityManagerIsAJpa21EntityManager(em)).isTrue();
|
||||
|
||||
JpaQueryMethod queryMethod = getMethod("findAll");
|
||||
|
||||
@@ -134,7 +135,7 @@ public class AbstractJpaQueryTests {
|
||||
@Transactional
|
||||
void shouldAddEntityGraphHintForLoad() throws Exception {
|
||||
|
||||
Assume.assumeTrue(currentEntityManagerIsAJpa21EntityManager(em));
|
||||
assumeThat(currentEntityManagerIsAJpa21EntityManager(em)).isTrue();
|
||||
|
||||
JpaQueryMethod queryMethod = getMethod("getById", Integer.class);
|
||||
|
||||
@@ -190,7 +191,7 @@ public class AbstractJpaQueryTests {
|
||||
|
||||
@Override
|
||||
protected TypedQuery<Long> doCreateCountQuery(JpaParametersParameterAccessor accessor) {
|
||||
return (TypedQuery<Long>) countQuery;
|
||||
return countQuery;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package org.springframework.data.jpa.repository.query;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.assertj.core.api.Assumptions.*;
|
||||
import static org.junit.Assume.*;
|
||||
import static org.springframework.data.jpa.support.EntityManagerTestUtils.*;
|
||||
|
||||
@@ -32,6 +33,7 @@ import jakarta.persistence.Subgraph;
|
||||
|
||||
import org.assertj.core.api.AbstractAssert;
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.assertj.core.api.Assumptions;
|
||||
import org.assertj.core.api.SoftAssertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
@@ -50,6 +52,7 @@ import org.springframework.util.ObjectUtils;
|
||||
* @author Christoph Strobl
|
||||
* @author Mark Paluch
|
||||
* @author Jens Schauder
|
||||
* @author Krzysztof Krason
|
||||
*/
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration("classpath:application-context.xml")
|
||||
@@ -61,7 +64,7 @@ public class Jpa21UtilsTests {
|
||||
@Test // DATAJPA-1041, DATAJPA-1075
|
||||
void shouldCreateGraphWithoutSubGraphCorrectly() {
|
||||
|
||||
assumeTrue(currentEntityManagerIsAJpa21EntityManager(em));
|
||||
assumeThat(currentEntityManagerIsAJpa21EntityManager(em)).isTrue();
|
||||
|
||||
EntityGraph<User> graph = em.createEntityGraph(User.class);
|
||||
Jpa21Utils.configureFetchGraphFrom(
|
||||
@@ -77,7 +80,7 @@ public class Jpa21UtilsTests {
|
||||
@Test // DATAJPA-1041, DATAJPA-1075
|
||||
void shouldCreateGraphWithMultipleSubGraphCorrectly() {
|
||||
|
||||
assumeTrue(currentEntityManagerIsAJpa21EntityManager(em));
|
||||
assumeThat(currentEntityManagerIsAJpa21EntityManager(em)).isTrue();
|
||||
|
||||
EntityGraph<User> graph = em.createEntityGraph(User.class);
|
||||
Jpa21Utils.configureFetchGraphFrom(new JpaEntityGraph("name", EntityGraphType.FETCH,
|
||||
@@ -94,7 +97,7 @@ public class Jpa21UtilsTests {
|
||||
@Test // DATAJPA-1041, DATAJPA-1075
|
||||
void shouldCreateGraphWithDeepSubGraphCorrectly() {
|
||||
|
||||
assumeTrue(currentEntityManagerIsAJpa21EntityManager(em));
|
||||
assumeThat(currentEntityManagerIsAJpa21EntityManager(em)).isTrue();
|
||||
|
||||
EntityGraph<User> graph = em.createEntityGraph(User.class);
|
||||
Jpa21Utils.configureFetchGraphFrom(new JpaEntityGraph("name", EntityGraphType.FETCH,
|
||||
@@ -116,7 +119,7 @@ public class Jpa21UtilsTests {
|
||||
@Test // DATAJPA-1041, DATAJPA-1075
|
||||
void shouldIgnoreIntermedeateSubGraphNodesThatAreNotNeeded() {
|
||||
|
||||
assumeTrue(currentEntityManagerIsAJpa21EntityManager(em));
|
||||
assumeThat(currentEntityManagerIsAJpa21EntityManager(em)).isTrue();
|
||||
|
||||
EntityGraph<User> graph = em.createEntityGraph(User.class);
|
||||
Jpa21Utils.configureFetchGraphFrom(new JpaEntityGraph("name", EntityGraphType.FETCH, new String[] { "roles",
|
||||
@@ -138,7 +141,7 @@ public class Jpa21UtilsTests {
|
||||
@Test // DATAJPA-1041, DATAJPA-1075
|
||||
void orderOfSubGraphsShouldNotMatter() {
|
||||
|
||||
assumeTrue(currentEntityManagerIsAJpa21EntityManager(em));
|
||||
assumeThat(currentEntityManagerIsAJpa21EntityManager(em)).isTrue();
|
||||
|
||||
EntityGraph<User> graph = em.createEntityGraph(User.class);
|
||||
Jpa21Utils.configureFetchGraphFrom(new JpaEntityGraph("name", EntityGraphType.FETCH, new String[] {
|
||||
@@ -159,7 +162,7 @@ public class Jpa21UtilsTests {
|
||||
@Test // DATAJPA-1041, DATAJPA-1075
|
||||
void errorsOnUnknownProperties() {
|
||||
|
||||
assumeTrue(currentEntityManagerIsAJpa21EntityManager(em));
|
||||
assumeThat(currentEntityManagerIsAJpa21EntityManager(em)).isTrue();
|
||||
|
||||
assertThatExceptionOfType(Exception.class).isThrownBy(() -> Jpa21Utils.configureFetchGraphFrom(
|
||||
new JpaEntityGraph("name", EntityGraphType.FETCH, new String[] { "¯\\_(ツ)_/¯" }),
|
||||
@@ -256,7 +259,6 @@ public class Jpa21UtilsTests {
|
||||
Assertions.assertThat(attributeNode.getSubgraphs()) //
|
||||
.describedAs(
|
||||
String.format("Leaf properties %s could not be found; The node does not have any subgraphs", nodes)) //
|
||||
.isNotNull() //
|
||||
.isNotEmpty();
|
||||
|
||||
Subgraph<?> graph = attributeNode.getSubgraphs().values().iterator().next();
|
||||
@@ -292,7 +294,6 @@ public class Jpa21UtilsTests {
|
||||
Assertions.assertThat(attributeNode.getSubgraphs()) //
|
||||
.describedAs(
|
||||
String.format("Subgraphs %s could not be found; The node does not have any subgraphs", subgraphs)) //
|
||||
.isNotNull() //
|
||||
.isNotEmpty();
|
||||
|
||||
Subgraph<?> graph = attributeNode.getSubgraphs().values().iterator().next();
|
||||
@@ -313,7 +314,7 @@ public class Jpa21UtilsTests {
|
||||
attributeNode.getAttributeName());
|
||||
|
||||
softly.assertThat(node.getSubgraphs()) //
|
||||
.describedAs(notSubGraph).isNotNull() //
|
||||
.describedAs(notSubGraph) //
|
||||
.isNotEmpty();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -46,6 +46,7 @@ import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
* Unit tests for repository with {@link Query} and {@link QueryRewrite}.
|
||||
*
|
||||
* @author Greg Turnquist
|
||||
* @author Krzysztof Krason
|
||||
*/
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration
|
||||
@@ -156,7 +157,7 @@ public class JpaQueryRewriteIntegrationTests {
|
||||
|
||||
assertThat(repository.count()).isEqualTo(3);
|
||||
assertThat(repository.countDistinctByLastname("Baggins")).isEqualTo(2);
|
||||
assertThat(repository.countDistinctByLastname("Gamgee")).isEqualTo(1);
|
||||
assertThat(repository.countDistinctByLastname("Gamgee")).isOne();
|
||||
}
|
||||
|
||||
public interface UserRepositoryWithRewriter
|
||||
|
||||
@@ -55,6 +55,7 @@ import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
* @author Mark Paluch
|
||||
* @author Michael Cramer
|
||||
* @author Jens Schauder
|
||||
* @author Krzysztof Krason
|
||||
*/
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration("classpath:infrastructure.xml")
|
||||
@@ -120,7 +121,7 @@ public class PartTreeJpaQueryIntegrationTests {
|
||||
|
||||
Query query = jpaQuery.createQuery(getAccessor(queryMethod, new Object[] { "Matthews" }));
|
||||
|
||||
assertThat(query.getMaxResults()).isEqualTo(1);
|
||||
assertThat(query.getMaxResults()).isOne();
|
||||
}
|
||||
|
||||
@Test // DATAJPA-920
|
||||
|
||||
@@ -37,6 +37,7 @@ import org.springframework.data.jpa.domain.JpaSort;
|
||||
*
|
||||
* @author Diego Krupitza
|
||||
* @author Geoffrey Deremetz
|
||||
* @author Krzysztof Krason
|
||||
*/
|
||||
class QueryEnhancerUnitTests {
|
||||
|
||||
@@ -678,8 +679,7 @@ class QueryEnhancerUnitTests {
|
||||
Set<String> nonNativeJoinAliases = getEnhancer(nonNativeQuery).getJoinAliases();
|
||||
|
||||
assertThat(nonNativeJoinAliases).containsAll(nativeJoinAliases);
|
||||
assertThat(nativeJoinAliases) //
|
||||
.hasSize(aliases.size()) //
|
||||
assertThat(nativeJoinAliases).hasSameSizeAs(aliases) //
|
||||
.containsAll(aliases);
|
||||
|
||||
}
|
||||
|
||||
@@ -66,6 +66,7 @@ import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
* @author Jens Schauder
|
||||
* @author Patrice Blanchardie
|
||||
* @author Diego Krupitza
|
||||
* @author Krzysztof Krason
|
||||
*/
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration("classpath:infrastructure.xml")
|
||||
@@ -222,7 +223,7 @@ public class QueryUtilsIntegrationTests {
|
||||
|
||||
QueryUtils.toExpressionRecursively(root, PropertyPath.from("manager", User.class));
|
||||
|
||||
assertThat(getNonInnerJoins(root)).hasSize(0);
|
||||
assertThat(getNonInnerJoins(root)).isEmpty();
|
||||
}
|
||||
|
||||
@Test // DATAJPA-401
|
||||
|
||||
@@ -64,6 +64,7 @@ import org.springframework.expression.spel.standard.SpelExpressionParser;
|
||||
* @author Tom Hombergs
|
||||
* @author Mark Paluch
|
||||
* @author Greg Turnquist
|
||||
* @author Krzysztof Krason
|
||||
*/
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
@MockitoSettings(strictness = Strictness.LENIENT)
|
||||
@@ -147,7 +148,7 @@ class SimpleJpaQueryUnitTests {
|
||||
queryMethod.getAnnotatedQuery(), null, QueryRewriter.IdentityQueryRewriter.INSTANCE,
|
||||
EVALUATION_CONTEXT_PROVIDER);
|
||||
|
||||
assertThat(jpaQuery instanceof NativeJpaQuery).isTrue();
|
||||
assertThat(jpaQuery).isInstanceOf(NativeJpaQuery.class);
|
||||
|
||||
when(em.createNativeQuery(anyString(), eq(User.class))).thenReturn(query);
|
||||
when(metadata.getReturnedDomainClass(method)).thenReturn((Class) User.class);
|
||||
@@ -190,14 +191,14 @@ class SimpleJpaQueryUnitTests {
|
||||
void createsASimpleJpaQueryFromAnnotation() throws Exception {
|
||||
|
||||
RepositoryQuery query = createJpaQuery(SampleRepository.class.getMethod("findByAnnotatedQuery"));
|
||||
assertThat(query instanceof SimpleJpaQuery).isTrue();
|
||||
assertThat(query).isInstanceOf(SimpleJpaQuery.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
void createsANativeJpaQueryFromAnnotation() throws Exception {
|
||||
|
||||
RepositoryQuery query = createJpaQuery(SampleRepository.class.getMethod("findNativeByLastname", String.class));
|
||||
assertThat(query instanceof NativeJpaQuery).isTrue();
|
||||
assertThat(query).isInstanceOf(NativeJpaQuery.class);
|
||||
}
|
||||
|
||||
@Test // DATAJPA-757
|
||||
|
||||
@@ -502,7 +502,7 @@ class StringQueryUnitTests {
|
||||
|
||||
softly.assertThat(query.getQueryString()).isEqualTo(queryString);
|
||||
softly.assertThat(query.hasParameterBindings()).isFalse();
|
||||
softly.assertThat(query.getParameterBindings()).hasSize(0);
|
||||
softly.assertThat(query.getParameterBindings()).isEmpty();
|
||||
|
||||
softly.assertAll();
|
||||
}
|
||||
|
||||
@@ -33,8 +33,9 @@ import org.springframework.core.io.ClassPathResource;
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
* @author Jens Schauder
|
||||
* @author Krzysztof Krason
|
||||
*/
|
||||
class EntityManagerFactoryRefUnitTests {
|
||||
public class EntityManagerFactoryRefUnitTests {
|
||||
|
||||
@Test
|
||||
@Disabled
|
||||
@@ -46,7 +47,7 @@ class EntityManagerFactoryRefUnitTests {
|
||||
|
||||
BeanDefinition bean = factory.getBeanDefinition("userRepository");
|
||||
Object value = getPropertyValue(bean, "entityManager");
|
||||
assertThat(value instanceof RuntimeBeanNameReference).isTrue();
|
||||
assertThat(value).isInstanceOf(RuntimeBeanNameReference.class);
|
||||
BeanDefinition emCreator = (BeanDefinition) value;
|
||||
|
||||
BeanReference reference = getConstructorBeanReference(emCreator, 0);
|
||||
@@ -61,7 +62,7 @@ class EntityManagerFactoryRefUnitTests {
|
||||
private BeanReference getConstructorBeanReference(BeanDefinition definition, int index) {
|
||||
|
||||
Object value = definition.getConstructorArgumentValues().getIndexedArgumentValues().get(index).getValue();
|
||||
assertThat(value instanceof BeanReference).isTrue();
|
||||
assertThat(value).isInstanceOf(BeanReference.class);
|
||||
return (BeanReference) value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@ import org.springframework.data.repository.core.EntityInformation;
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
* @author Jens Schauder
|
||||
* @author Krzysztof Krason
|
||||
*/
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
@MockitoSettings(strictness = Strictness.LENIENT)
|
||||
@@ -79,7 +80,7 @@ class JpaPersistableEntityInformationUnitTests {
|
||||
|
||||
foo.id = 1L;
|
||||
assertThat(entityInformation.isNew(foo)).isTrue();
|
||||
assertThat(entityInformation.getId(foo)).isEqualTo(1L);
|
||||
assertThat(entityInformation.getId(foo)).isOne();
|
||||
}
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
|
||||
@@ -52,6 +52,7 @@ import org.springframework.util.ClassUtils;
|
||||
* @author Oliver Gierke
|
||||
* @author Thomas Darimont
|
||||
* @author Jens Schauder
|
||||
* @author Krzysztof Krason
|
||||
*/
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
@MockitoSettings(strictness = Strictness.LENIENT)
|
||||
@@ -87,8 +88,6 @@ public class JpaRepositoryFactoryUnitTests {
|
||||
|
||||
/**
|
||||
* Assert that the instance created for the standard configuration is a valid {@code UserRepository}.
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
void setsUpBasicInstanceCorrectly() {
|
||||
@@ -118,7 +117,7 @@ public class JpaRepositoryFactoryUnitTests {
|
||||
try {
|
||||
factory.getRepository(SampleRepository.class);
|
||||
} catch (IllegalArgumentException e) {
|
||||
assertThat(e.getMessage().contains(SampleRepository.class.getName())).isTrue();
|
||||
assertThat(e.getMessage()).contains(SampleRepository.class.getName());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@ import jakarta.persistence.PersistenceContext;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
@@ -46,6 +45,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
* @author Thomas Darimont
|
||||
* @author Jens Schauder
|
||||
* @author Greg Turnquist
|
||||
* @author Krzysztof Krason
|
||||
*/
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration({ "classpath:infrastructure.xml" })
|
||||
@@ -70,12 +70,12 @@ class JpaRepositoryTests {
|
||||
SampleEntity entity = new SampleEntity("foo", "bar");
|
||||
repository.saveAndFlush(entity);
|
||||
assertThat(repository.existsById(new SampleEntityPK("foo", "bar"))).isTrue();
|
||||
assertThat(repository.count()).isEqualTo(1L);
|
||||
assertThat(repository.findById(new SampleEntityPK("foo", "bar"))).isEqualTo(Optional.of(entity));
|
||||
assertThat(repository.count()).isOne();
|
||||
assertThat(repository.findById(new SampleEntityPK("foo", "bar"))).contains(entity);
|
||||
|
||||
repository.deleteAll(Arrays.asList(entity));
|
||||
repository.flush();
|
||||
assertThat(repository.count()).isEqualTo(0L);
|
||||
assertThat(repository.count()).isZero();
|
||||
}
|
||||
|
||||
@Test // DATAJPA-50
|
||||
@@ -89,7 +89,7 @@ class JpaRepositoryTests {
|
||||
|
||||
PersistableWithIdClassPK id = new PersistableWithIdClassPK(entity.getFirst(), entity.getSecond());
|
||||
|
||||
assertThat(idClassRepository.findById(id)).isEqualTo(Optional.of(entity));
|
||||
assertThat(idClassRepository.findById(id)).contains(entity);
|
||||
}
|
||||
|
||||
@Test // DATAJPA-266
|
||||
|
||||
@@ -64,6 +64,7 @@ import com.querydsl.core.types.dsl.PathBuilderFactory;
|
||||
* @author Christoph Strobl
|
||||
* @author Malte Mauelshagen
|
||||
* @author Greg Turnquist
|
||||
* @author Krzysztof Krason
|
||||
*/
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration({ "classpath:infrastructure.xml" })
|
||||
@@ -269,9 +270,9 @@ class QuerydslJpaPredicateExecutorUnitTests {
|
||||
@Test // DATAJPA-665
|
||||
void shouldSupportExistsWithPredicate() {
|
||||
|
||||
assertThat(predicateExecutor.exists(user.firstname.eq("Dave"))).isEqualTo(true);
|
||||
assertThat(predicateExecutor.exists(user.firstname.eq("Unknown"))).isEqualTo(false);
|
||||
assertThat(predicateExecutor.exists((Predicate) null)).isEqualTo(true);
|
||||
assertThat(predicateExecutor.exists(user.firstname.eq("Dave"))).isTrue();
|
||||
assertThat(predicateExecutor.exists(user.firstname.eq("Unknown"))).isFalse();
|
||||
assertThat(predicateExecutor.exists((Predicate) null)).isTrue();
|
||||
}
|
||||
|
||||
@Test // DATAJPA-679
|
||||
@@ -307,7 +308,7 @@ class QuerydslJpaPredicateExecutorUnitTests {
|
||||
assertThat(firstPage.getTotalElements()).isEqualTo(3L);
|
||||
|
||||
Page<User> secondPage = predicateExecutor.findAll(user.dateOfBirth.isNull(), PageRequest.of(10, 10));
|
||||
assertThat(secondPage.getContent()).hasSize(0);
|
||||
assertThat(secondPage.getContent()).isEmpty();
|
||||
assertThat(secondPage.getTotalElements()).isEqualTo(3L);
|
||||
}
|
||||
|
||||
|
||||
@@ -58,6 +58,7 @@ import com.querydsl.core.types.dsl.PathBuilderFactory;
|
||||
* @author Christoph Strobl
|
||||
* @author Malte Mauelshagen
|
||||
* @author Greg Turnquist
|
||||
* @author Krzysztof Krason
|
||||
*/
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration({ "classpath:infrastructure.xml" })
|
||||
@@ -271,9 +272,9 @@ class QuerydslJpaRepositoryTests {
|
||||
@Test // DATAJPA-665
|
||||
void shouldSupportExistsWithPredicate() {
|
||||
|
||||
assertThat(repository.exists(user.firstname.eq("Dave"))).isEqualTo(true);
|
||||
assertThat(repository.exists(user.firstname.eq("Unknown"))).isEqualTo(false);
|
||||
assertThat(repository.exists((Predicate) null)).isEqualTo(true);
|
||||
assertThat(repository.exists(user.firstname.eq("Dave"))).isTrue();
|
||||
assertThat(repository.exists(user.firstname.eq("Unknown"))).isFalse();
|
||||
assertThat(repository.exists((Predicate) null)).isTrue();
|
||||
}
|
||||
|
||||
@Test // DATAJPA-679
|
||||
@@ -309,7 +310,7 @@ class QuerydslJpaRepositoryTests {
|
||||
assertThat(firstPage.getTotalElements()).isEqualTo(3L);
|
||||
|
||||
Page<User> secondPage = repository.findAll(user.dateOfBirth.isNull(), PageRequest.of(10, 10));
|
||||
assertThat(secondPage.getContent()).hasSize(0);
|
||||
assertThat(secondPage.getContent()).isEmpty();
|
||||
assertThat(secondPage.getTotalElements()).isEqualTo(3L);
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
* @author Oliver Gierke
|
||||
* @author Thomas Darimont
|
||||
* @author Jens Schauder
|
||||
* @author Krzysztof Krason
|
||||
*/
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration({ "classpath:infrastructure.xml" })
|
||||
@@ -70,11 +71,11 @@ public class QuerydslRepositorySupportTests {
|
||||
void readsUsersCorrectly() {
|
||||
|
||||
List<User> result = repository.findUsersByLastname("Matthews");
|
||||
assertThat(result.size()).isEqualTo(1);
|
||||
assertThat(result).hasSize(1);
|
||||
assertThat(result.get(0)).isEqualTo(dave);
|
||||
|
||||
result = repository.findUsersByLastname("Beauford");
|
||||
assertThat(result.size()).isEqualTo(1);
|
||||
assertThat(result).hasSize(1);
|
||||
assertThat(result.get(0)).isEqualTo(carter);
|
||||
}
|
||||
|
||||
@@ -85,13 +86,13 @@ public class QuerydslRepositorySupportTests {
|
||||
assertThat(updates).isEqualTo(2L);
|
||||
|
||||
List<User> result = repository.findUsersByLastname("Matthews");
|
||||
assertThat(result.size()).isEqualTo(0);
|
||||
assertThat(result).isEmpty();
|
||||
|
||||
result = repository.findUsersByLastname("Beauford");
|
||||
assertThat(result.size()).isEqualTo(0);
|
||||
assertThat(result).isEmpty();
|
||||
|
||||
result = repository.findUsersByLastname("Foo");
|
||||
assertThat(result.size()).isEqualTo(2);
|
||||
assertThat(result).hasSize(2);
|
||||
assertThat(result).contains(dave, carter);
|
||||
}
|
||||
|
||||
@@ -99,13 +100,13 @@ public class QuerydslRepositorySupportTests {
|
||||
void deletesAllWithLastnameCorrectly() {
|
||||
|
||||
long updates = repository.deleteAllWithLastname("Matthews");
|
||||
assertThat(updates).isEqualTo(1L);
|
||||
assertThat(updates).isOne();
|
||||
|
||||
List<User> result = repository.findUsersByLastname("Matthews");
|
||||
assertThat(result.size()).isEqualTo(0);
|
||||
assertThat(result).isEmpty();
|
||||
|
||||
result = repository.findUsersByLastname("Beauford");
|
||||
assertThat(result.size()).isEqualTo(1);
|
||||
assertThat(result).hasSize(1);
|
||||
assertThat(result.get(0)).isEqualTo(carter);
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ import org.springframework.transaction.TransactionStatus;
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
* @author Jens Schauder
|
||||
* @author Krzysztof Krason
|
||||
*/
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration({ "classpath:config/namespace-autoconfig-context.xml", "classpath:tx-manager.xml" })
|
||||
@@ -61,21 +62,21 @@ public class TransactionalRepositoryTests {
|
||||
void simpleManipulatingOperation() {
|
||||
|
||||
repository.saveAndFlush(new User("foo", "bar", "foo@bar.de"));
|
||||
assertThat(transactionManager.getTransactionRequests()).isEqualTo(1);
|
||||
assertThat(transactionManager.getTransactionRequests()).isOne();
|
||||
}
|
||||
|
||||
@Test
|
||||
void unannotatedFinder() {
|
||||
|
||||
repository.findByEmailAddress("foo@bar.de");
|
||||
assertThat(transactionManager.getTransactionRequests()).isEqualTo(0);
|
||||
assertThat(transactionManager.getTransactionRequests()).isZero();
|
||||
}
|
||||
|
||||
@Test
|
||||
void invokeTransactionalFinder() {
|
||||
|
||||
repository.findByAnnotatedQuery("foo@bar.de");
|
||||
assertThat(transactionManager.getTransactionRequests()).isEqualTo(1);
|
||||
assertThat(transactionManager.getTransactionRequests()).isOne();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -40,6 +40,7 @@ import org.springframework.orm.jpa.persistenceunit.MutablePersistenceUnitInfo;
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
* @author Jens Schauder
|
||||
* @author Krzysztof Krason
|
||||
*/
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
@MockitoSettings(strictness = Strictness.LENIENT)
|
||||
@@ -64,15 +65,15 @@ class MergingPersistenceUnitManagerUnitTests {
|
||||
void mergesManagedClassesCorrectly() {
|
||||
|
||||
MergingPersistenceUnitManager manager = new MergingPersistenceUnitManager();
|
||||
manager.setPersistenceXmlLocations(new String[] { "classpath:org/springframework/data/jpa/support/persistence.xml",
|
||||
"classpath:org/springframework/data/jpa/support/persistence2.xml" });
|
||||
manager.setPersistenceXmlLocations("classpath:org/springframework/data/jpa/support/persistence.xml",
|
||||
"classpath:org/springframework/data/jpa/support/persistence2.xml");
|
||||
manager.preparePersistenceUnitInfos();
|
||||
|
||||
PersistenceUnitInfo info = manager.obtainPersistenceUnitInfo("pu");
|
||||
assertThat(info.getManagedClassNames().size()).isEqualTo(2);
|
||||
assertThat(info.getManagedClassNames()).hasSize(2);
|
||||
assertThat(info.getManagedClassNames()).contains(User.class.getName(), Role.class.getName());
|
||||
|
||||
assertThat(info.getMappingFileNames().size()).isEqualTo(2);
|
||||
assertThat(info.getMappingFileNames()).hasSize(2);
|
||||
assertThat(info.getMappingFileNames()).contains("foo.xml", "bar.xml");
|
||||
}
|
||||
|
||||
@@ -87,7 +88,7 @@ class MergingPersistenceUnitManagerUnitTests {
|
||||
MergingPersistenceUnitManager manager = new MergingPersistenceUnitManager();
|
||||
manager.postProcessPersistenceUnitInfo(newInfo, oldInfo);
|
||||
|
||||
assertThat(newInfo.getJarFileUrls().size()).isEqualTo(1);
|
||||
assertThat(newInfo.getJarFileUrls()).hasSize(1);
|
||||
assertThat(newInfo.getJarFileUrls()).contains(oldInfo.getPersistenceUnitRootUrl());
|
||||
}
|
||||
|
||||
@@ -101,7 +102,7 @@ class MergingPersistenceUnitManagerUnitTests {
|
||||
MergingPersistenceUnitManager manager = new MergingPersistenceUnitManager();
|
||||
manager.postProcessPersistenceUnitInfo(newInfo, oldInfo);
|
||||
|
||||
assertThat(newInfo.getJarFileUrls().isEmpty()).isTrue();
|
||||
assertThat(newInfo.getJarFileUrls()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -116,7 +117,7 @@ class MergingPersistenceUnitManagerUnitTests {
|
||||
MergingPersistenceUnitManager manager = new MergingPersistenceUnitManager();
|
||||
manager.postProcessPersistenceUnitInfo(newInfo, oldInfo);
|
||||
|
||||
assertThat(newInfo.getJarFileUrls().size()).isEqualTo(1);
|
||||
assertThat(newInfo.getJarFileUrls()).hasSize(1);
|
||||
assertThat(newInfo.getJarFileUrls()).contains(oldInfo.getPersistenceUnitRootUrl());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ import org.springframework.data.repository.config.RepositoryConfigurationSource;
|
||||
* Integration tests for {@link JpaMetamodelCacheCleanup}.
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
* @author Krzysztof Krason
|
||||
*/
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
@MockitoSettings(strictness = Strictness.LENIENT)
|
||||
@@ -71,7 +72,7 @@ class JpaMetamodelCacheCleanupIntegrationTests {
|
||||
|
||||
String[] cleanupBeanNames = beanFactory.getBeanNamesForType(JpaMetamodelCacheCleanup.class);
|
||||
|
||||
assertThat(cleanupBeanNames.length).isEqualTo(1);
|
||||
assertThat(cleanupBeanNames).hasSize(1);
|
||||
assertThat(beanFactory.getBeanDefinition(cleanupBeanNames[0]).isLazyInit()).isFalse();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user