DATACMNS-1718 - Migrate tests to JUnit 5.
This commit is contained in:
@@ -17,7 +17,8 @@ package org.springframework.data.querydsl;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.data.domain.AbstractPageRequest;
|
||||
import org.springframework.data.domain.AbstractPageRequestUnitTests;
|
||||
|
||||
@@ -25,6 +26,7 @@ import org.springframework.data.domain.AbstractPageRequestUnitTests;
|
||||
* @author Thomas Darimont
|
||||
*/
|
||||
public class QPageRequestUnitTests extends AbstractPageRequestUnitTests {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.domain.AbstractPageRequestUnitTests#newPageRequest(int, int)
|
||||
@@ -35,7 +37,7 @@ public class QPageRequestUnitTests extends AbstractPageRequestUnitTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void constructsQPageRequestWithOrderSpecifiers() {
|
||||
void constructsQPageRequestWithOrderSpecifiers() {
|
||||
|
||||
QUser user = QUser.user;
|
||||
QPageRequest pageRequest = QPageRequest.of(0, 10, user.firstname.asc());
|
||||
@@ -44,7 +46,7 @@ public class QPageRequestUnitTests extends AbstractPageRequestUnitTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void constructsQPageRequestWithQSort() {
|
||||
void constructsQPageRequestWithQSort() {
|
||||
|
||||
QUser user = QUser.user;
|
||||
QPageRequest pageRequest = QPageRequest.of(0, 10, QSort.by(user.firstname.asc()));
|
||||
@@ -53,7 +55,7 @@ public class QPageRequestUnitTests extends AbstractPageRequestUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-1581
|
||||
public void rejectsNullSort() {
|
||||
void rejectsNullSort() {
|
||||
|
||||
assertThatExceptionOfType(IllegalArgumentException.class) //
|
||||
.isThrownBy(() -> QPageRequest.of(0, 10, (QSort) null));
|
||||
|
||||
@@ -22,7 +22,7 @@ import static org.springframework.data.querydsl.QQSortUnitTests_WrapperToWrapWra
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.domain.Sort.Direction;
|
||||
@@ -40,15 +40,15 @@ import com.querydsl.core.types.dsl.StringPath;
|
||||
* @author Oliver Gierke
|
||||
* @author Christoph Strobl
|
||||
*/
|
||||
public class QSortUnitTests {
|
||||
class QSortUnitTests {
|
||||
|
||||
@Test // DATACMNS-402
|
||||
public void shouldThrowIfNullIsGiven() {
|
||||
void shouldThrowIfNullIsGiven() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new QSort((List<OrderSpecifier<?>>) null));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-402
|
||||
public void sortBySingleProperty() {
|
||||
void sortBySingleProperty() {
|
||||
|
||||
QUser user = QUser.user;
|
||||
QSort qsort = new QSort(user.firstname.asc());
|
||||
@@ -59,7 +59,7 @@ public class QSortUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-402
|
||||
public void sortByMultiplyProperties() {
|
||||
void sortByMultiplyProperties() {
|
||||
|
||||
QUser user = QUser.user;
|
||||
QSort qsort = new QSort(user.firstname.asc(), user.lastname.desc());
|
||||
@@ -72,7 +72,7 @@ public class QSortUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-402
|
||||
public void sortByMultiplyPropertiesWithAnd() {
|
||||
void sortByMultiplyPropertiesWithAnd() {
|
||||
|
||||
QUser user = QUser.user;
|
||||
QSort qsort = new QSort(user.firstname.asc()).and(new QSort(user.lastname.desc()));
|
||||
@@ -85,7 +85,7 @@ public class QSortUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-402
|
||||
public void sortByMultiplyPropertiesWithAndAndVarArgs() {
|
||||
void sortByMultiplyPropertiesWithAndAndVarArgs() {
|
||||
|
||||
QUser user = QUser.user;
|
||||
QSort qsort = new QSort(user.firstname.asc()).and(user.lastname.desc());
|
||||
@@ -98,7 +98,7 @@ public class QSortUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-402
|
||||
public void ensureInteroperabilityWithSort() {
|
||||
void ensureInteroperabilityWithSort() {
|
||||
|
||||
QUser user = QUser.user;
|
||||
QSort qsort = new QSort(user.firstname.asc(), user.lastname.desc());
|
||||
@@ -110,7 +110,7 @@ public class QSortUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-402
|
||||
public void concatenatesPlainSortCorrectly() {
|
||||
void concatenatesPlainSortCorrectly() {
|
||||
|
||||
QUser user = QUser.user;
|
||||
QSort sort = new QSort(user.firstname.asc());
|
||||
@@ -121,7 +121,7 @@ public class QSortUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-566
|
||||
public void shouldSupportSortByOperatorExpressions() {
|
||||
void shouldSupportSortByOperatorExpressions() {
|
||||
|
||||
QUser user = QUser.user;
|
||||
QSort sort = new QSort(user.dateOfBirth.yearMonth().asc());
|
||||
@@ -133,7 +133,7 @@ public class QSortUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-621
|
||||
public void shouldCreateSortForNestedPathCorrectly() {
|
||||
void shouldCreateSortForNestedPathCorrectly() {
|
||||
|
||||
QSort sort = new QSort(userWrapper.user.firstname.asc());
|
||||
|
||||
@@ -141,7 +141,7 @@ public class QSortUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-621
|
||||
public void shouldCreateSortForDeepNestedPathCorrectly() {
|
||||
void shouldCreateSortForDeepNestedPathCorrectly() {
|
||||
|
||||
QSort sort = new QSort(wrapperForUserWrapper.wrapper.user.firstname.asc());
|
||||
|
||||
@@ -149,7 +149,7 @@ public class QSortUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-621
|
||||
public void shouldCreateSortForReallyDeepNestedPathCorrectly() {
|
||||
void shouldCreateSortForReallyDeepNestedPathCorrectly() {
|
||||
|
||||
QSort sort = new QSort(wrapperToWrapWrapperForUserWrapper.wrapperForUserWrapper.wrapper.user.firstname.asc());
|
||||
|
||||
@@ -157,7 +157,7 @@ public class QSortUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-755
|
||||
public void handlesPlainStringPathsCorrectly() {
|
||||
void handlesPlainStringPathsCorrectly() {
|
||||
|
||||
StringPath path = new PathBuilderFactory().create(User.class).getString("firstname");
|
||||
|
||||
|
||||
@@ -19,11 +19,12 @@ import static org.mockito.Mockito.*;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.repository.support.RepositoryInvoker;
|
||||
@@ -36,8 +37,8 @@ import com.querydsl.core.types.Predicate;
|
||||
* @author Oliver Gierke
|
||||
* @soundtrack Emilie Nicolas - Grown Up
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class QuerydslRepositoryInvokerAdapterUnitTests {
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class QuerydslRepositoryInvokerAdapterUnitTests {
|
||||
|
||||
@Mock RepositoryInvoker delegate;
|
||||
@Mock QuerydslPredicateExecutor<Object> executor;
|
||||
@@ -45,13 +46,13 @@ public class QuerydslRepositoryInvokerAdapterUnitTests {
|
||||
|
||||
QuerydslRepositoryInvokerAdapter adapter;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
this.adapter = new QuerydslRepositoryInvokerAdapter(delegate, executor, predicate);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-669
|
||||
public void forwardsFindAllToExecutorWithPredicate() {
|
||||
void forwardsFindAllToExecutorWithPredicate() {
|
||||
|
||||
Sort sort = Sort.by("firstname");
|
||||
adapter.invokeFindAll(sort);
|
||||
@@ -61,7 +62,7 @@ public class QuerydslRepositoryInvokerAdapterUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-669
|
||||
public void forwardsFindAllWithPageableToExecutorWithPredicate() {
|
||||
void forwardsFindAllWithPageableToExecutorWithPredicate() {
|
||||
|
||||
PageRequest pageable = PageRequest.of(0, 10);
|
||||
adapter.invokeFindAll(pageable);
|
||||
@@ -72,7 +73,7 @@ public class QuerydslRepositoryInvokerAdapterUnitTests {
|
||||
|
||||
@Test // DATACMNS-669
|
||||
@SuppressWarnings("unchecked")
|
||||
public void forwardsMethodsToDelegate() {
|
||||
void forwardsMethodsToDelegate() {
|
||||
|
||||
adapter.hasDeleteMethod();
|
||||
verify(delegate, times(1)).hasDeleteMethod();
|
||||
|
||||
@@ -18,22 +18,22 @@ package org.springframework.data.querydsl;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.springframework.data.querydsl.QuerydslUtils.*;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link QuerydslUtils}.
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
public class QuerydslUtilsUnitTests {
|
||||
class QuerydslUtilsUnitTests {
|
||||
|
||||
@Test // DATACMNS-883
|
||||
public void rendersDotPathForPathTraversalContainingAnyExpression() {
|
||||
void rendersDotPathForPathTraversalContainingAnyExpression() {
|
||||
assertThat(QuerydslUtils.toDotPath(QUser.user.addresses.any().street)).isEqualTo("addresses.street");
|
||||
}
|
||||
|
||||
@Test // DATACMNS-941
|
||||
public void skipsIntermediateDelegates() {
|
||||
void skipsIntermediateDelegates() {
|
||||
|
||||
assertThat(toDotPath(QUser.user.as(QSpecialUser.class).as(QSpecialUser.class).specialProperty))
|
||||
.isEqualTo("specialProperty");
|
||||
|
||||
@@ -17,7 +17,7 @@ package org.springframework.data.querydsl;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import com.querydsl.core.annotations.QueryEntity;
|
||||
|
||||
@@ -27,28 +27,28 @@ import com.querydsl.core.annotations.QueryEntity;
|
||||
* @author Oliver Gierke
|
||||
* @author Jens Schauder
|
||||
*/
|
||||
public class SimpleEntityPathResolverUnitTests {
|
||||
class SimpleEntityPathResolverUnitTests {
|
||||
|
||||
EntityPathResolver resolver = SimpleEntityPathResolver.INSTANCE;
|
||||
|
||||
@Test
|
||||
public void createsRepositoryFromDomainClassCorrectly() throws Exception {
|
||||
void createsRepositoryFromDomainClassCorrectly() throws Exception {
|
||||
assertThat(resolver.createPath(User.class)).isInstanceOf(QUser.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void resolvesEntityPathForInnerClassCorrectly() throws Exception {
|
||||
void resolvesEntityPathForInnerClassCorrectly() throws Exception {
|
||||
assertThat(resolver.createPath(NamedUser.class)).isInstanceOf(QSimpleEntityPathResolverUnitTests_NamedUser.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rejectsClassWithoutQueryClassConfrmingToTheNamingScheme() {
|
||||
void rejectsClassWithoutQueryClassConfrmingToTheNamingScheme() {
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> resolver.createPath(QSimpleEntityPathResolverUnitTests_Sample.class));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-1235
|
||||
public void handlesPackageSuffixCorrectly() {
|
||||
void handlesPackageSuffixCorrectly() {
|
||||
assertThat(new SimpleEntityPathResolver(".suffix").createPath(User.class))
|
||||
.isInstanceOf(org.springframework.data.querydsl.suffix.QUser.class);
|
||||
}
|
||||
|
||||
@@ -21,8 +21,8 @@ import static org.mockito.Mockito.*;
|
||||
import java.util.Collections;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
|
||||
import org.springframework.data.querydsl.QUser;
|
||||
import org.springframework.data.querydsl.SimpleEntityPathResolver;
|
||||
@@ -42,20 +42,20 @@ import com.querydsl.core.types.Predicate;
|
||||
* @author Oliver Gierke
|
||||
* @soundtrack Miles Davis - All Blues (Kind of Blue)
|
||||
*/
|
||||
public class QuerydslBindingsFactoryUnitTests {
|
||||
class QuerydslBindingsFactoryUnitTests {
|
||||
|
||||
static final TypeInformation<?> USER_TYPE = ClassTypeInformation.from(User.class);
|
||||
|
||||
QuerydslBindingsFactory factory;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
this.factory = new QuerydslBindingsFactory(SimpleEntityPathResolver.INSTANCE);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-669
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public void createBindingsShouldHonorQuerydslBinderCustomizerHookWhenPresent() {
|
||||
void createBindingsShouldHonorQuerydslBinderCustomizerHookWhenPresent() {
|
||||
|
||||
Repositories repositories = mock(Repositories.class);
|
||||
|
||||
@@ -77,7 +77,7 @@ public class QuerydslBindingsFactoryUnitTests {
|
||||
|
||||
@Test // DATACMNS-669
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public void shouldReuseExistingQuerydslBinderCustomizer() {
|
||||
void shouldReuseExistingQuerydslBinderCustomizer() {
|
||||
|
||||
AutowireCapableBeanFactory beanFactory = mock(AutowireCapableBeanFactory.class);
|
||||
when(beanFactory.getBean(SpecificBinding.class)).thenReturn(new SpecificBinding());
|
||||
@@ -96,7 +96,7 @@ public class QuerydslBindingsFactoryUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-669
|
||||
public void rejectsPredicateResolutionIfDomainTypeCantBeAutoDetected() {
|
||||
void rejectsPredicateResolutionIfDomainTypeCantBeAutoDetected() {
|
||||
|
||||
assertThatExceptionOfType(IllegalStateException.class)//
|
||||
.isThrownBy(() -> factory.createBindingsFor(ClassTypeInformation.from(ModelAndView.class)))//
|
||||
@@ -116,7 +116,7 @@ public class QuerydslBindingsFactoryUnitTests {
|
||||
}
|
||||
}
|
||||
|
||||
public static class SampleRepo implements QuerydslBinderCustomizer<QUser> {
|
||||
static class SampleRepo implements QuerydslBinderCustomizer<QUser> {
|
||||
|
||||
@Override
|
||||
public void customize(QuerydslBindings bindings, QUser user) {
|
||||
|
||||
@@ -19,8 +19,8 @@ import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.core.convert.support.DefaultConversionService;
|
||||
import org.springframework.data.querydsl.QSpecialUser;
|
||||
@@ -39,27 +39,27 @@ import com.querydsl.core.types.dsl.StringPath;
|
||||
* @author Oliver Gierke
|
||||
* @author Christoph Strobl
|
||||
*/
|
||||
public class QuerydslBindingsUnitTests {
|
||||
class QuerydslBindingsUnitTests {
|
||||
|
||||
QuerydslPredicateBuilder builder;
|
||||
QuerydslBindings bindings;
|
||||
|
||||
static final SingleValueBinding<StringPath, String> CONTAINS_BINDING = (path, value) -> path.contains(value);
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
|
||||
this.builder = new QuerydslPredicateBuilder(new DefaultConversionService(), SimpleEntityPathResolver.INSTANCE);
|
||||
this.bindings = new QuerydslBindings();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-669
|
||||
public void rejectsNullPath() {
|
||||
void rejectsNullPath() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> bindings.getBindingForPath(null));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-669
|
||||
public void returnsEmptyOptionalIfNoBindingRegisteredForPath() {
|
||||
void returnsEmptyOptionalIfNoBindingRegisteredForPath() {
|
||||
|
||||
PathInformation path = PropertyPathInformation.of("lastname", User.class);
|
||||
|
||||
@@ -67,7 +67,7 @@ public class QuerydslBindingsUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-669
|
||||
public void returnsRegisteredBindingForSimplePath() {
|
||||
void returnsRegisteredBindingForSimplePath() {
|
||||
|
||||
bindings.bind(QUser.user.firstname).first(CONTAINS_BINDING);
|
||||
|
||||
@@ -77,7 +77,7 @@ public class QuerydslBindingsUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-669
|
||||
public void getBindingForPathShouldReturnSpeficicBindingForNestedElementsWhenAvailable() {
|
||||
void getBindingForPathShouldReturnSpeficicBindingForNestedElementsWhenAvailable() {
|
||||
|
||||
bindings.bind(QUser.user.address.street).first(CONTAINS_BINDING);
|
||||
|
||||
@@ -87,7 +87,7 @@ public class QuerydslBindingsUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-669
|
||||
public void getBindingForPathShouldReturnSpeficicBindingForTypes() {
|
||||
void getBindingForPathShouldReturnSpeficicBindingForTypes() {
|
||||
|
||||
bindings.bind(String.class).first(CONTAINS_BINDING);
|
||||
|
||||
@@ -96,7 +96,7 @@ public class QuerydslBindingsUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-669
|
||||
public void propertyNotExplicitlyIncludedAndWithoutTypeBindingIsNotAvailable() {
|
||||
void propertyNotExplicitlyIncludedAndWithoutTypeBindingIsNotAvailable() {
|
||||
|
||||
bindings.bind(String.class).first(CONTAINS_BINDING);
|
||||
|
||||
@@ -106,7 +106,7 @@ public class QuerydslBindingsUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-669
|
||||
public void pathIsAvailableIfTypeBasedBindingWasRegistered() {
|
||||
void pathIsAvailableIfTypeBasedBindingWasRegistered() {
|
||||
|
||||
bindings.bind(String.class).first(CONTAINS_BINDING);
|
||||
|
||||
@@ -114,7 +114,7 @@ public class QuerydslBindingsUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-669
|
||||
public void explicitlyIncludedPathIsAvailable() {
|
||||
void explicitlyIncludedPathIsAvailable() {
|
||||
|
||||
bindings.including(QUser.user.inceptionYear);
|
||||
|
||||
@@ -122,7 +122,7 @@ public class QuerydslBindingsUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-669
|
||||
public void notExplicitlyIncludedPathIsNotAvailable() {
|
||||
void notExplicitlyIncludedPathIsNotAvailable() {
|
||||
|
||||
bindings.including(QUser.user.inceptionYear);
|
||||
|
||||
@@ -130,7 +130,7 @@ public class QuerydslBindingsUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-669
|
||||
public void excludedPathIsNotAvailable() {
|
||||
void excludedPathIsNotAvailable() {
|
||||
|
||||
bindings.excluding(QUser.user.inceptionYear);
|
||||
|
||||
@@ -138,7 +138,7 @@ public class QuerydslBindingsUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-669
|
||||
public void pathIsAvailableIfNotExplicitlyExcluded() {
|
||||
void pathIsAvailableIfNotExplicitlyExcluded() {
|
||||
|
||||
bindings.excluding(QUser.user.inceptionYear);
|
||||
|
||||
@@ -146,7 +146,7 @@ public class QuerydslBindingsUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-669
|
||||
public void pathIsAvailableIfItsBothBlackAndWhitelisted() {
|
||||
void pathIsAvailableIfItsBothBlackAndWhitelisted() {
|
||||
|
||||
bindings.excluding(QUser.user.firstname);
|
||||
bindings.including(QUser.user.firstname);
|
||||
@@ -155,7 +155,7 @@ public class QuerydslBindingsUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-669
|
||||
public void nestedPathIsNotAvailableIfAParanetPathWasExcluded() {
|
||||
void nestedPathIsNotAvailableIfAParanetPathWasExcluded() {
|
||||
|
||||
bindings.excluding(QUser.user.address);
|
||||
|
||||
@@ -163,7 +163,7 @@ public class QuerydslBindingsUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-669
|
||||
public void pathIsAvailableIfConcretePathIsAvailableButParentExcluded() {
|
||||
void pathIsAvailableIfConcretePathIsAvailableButParentExcluded() {
|
||||
|
||||
bindings.excluding(QUser.user.address);
|
||||
bindings.including(QUser.user.address.city);
|
||||
@@ -172,7 +172,7 @@ public class QuerydslBindingsUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-669
|
||||
public void isPathAvailableShouldReturnFalseWhenPartialPathContainedInExcludingAndConcretePathToDifferentPropertyIsIncluded() {
|
||||
void isPathAvailableShouldReturnFalseWhenPartialPathContainedInExcludingAndConcretePathToDifferentPropertyIsIncluded() {
|
||||
|
||||
bindings.excluding(QUser.user.address);
|
||||
bindings.including(QUser.user.address.city);
|
||||
@@ -181,7 +181,7 @@ public class QuerydslBindingsUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-669
|
||||
public void whitelistsPropertiesCorrectly() {
|
||||
void whitelistsPropertiesCorrectly() {
|
||||
|
||||
bindings.including(QUser.user.firstname, QUser.user.address.street);
|
||||
|
||||
@@ -192,17 +192,17 @@ public class QuerydslBindingsUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-787
|
||||
public void rejectsNullAlias() {
|
||||
void rejectsNullAlias() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> bindings.bind(QUser.user.address).as(null));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-787
|
||||
public void rejectsEmptyAlias() {
|
||||
void rejectsEmptyAlias() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> bindings.bind(QUser.user.address).as(""));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-787
|
||||
public void aliasesBinding() {
|
||||
void aliasesBinding() {
|
||||
|
||||
bindings.bind(QUser.user.address.city).as("city").first(CONTAINS_BINDING);
|
||||
|
||||
@@ -216,7 +216,7 @@ public class QuerydslBindingsUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-787
|
||||
public void explicitlyIncludesOriginalBindingDespiteAlias() {
|
||||
void explicitlyIncludesOriginalBindingDespiteAlias() {
|
||||
|
||||
bindings.including(QUser.user.address.city);
|
||||
bindings.bind(QUser.user.address.city).as("city").first(CONTAINS_BINDING);
|
||||
@@ -235,7 +235,7 @@ public class QuerydslBindingsUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-787
|
||||
public void registedAliasWithNullBinding() {
|
||||
void registedAliasWithNullBinding() {
|
||||
|
||||
bindings.bind(QUser.user.address.city).as("city").withDefaultBinding();
|
||||
|
||||
@@ -246,7 +246,7 @@ public class QuerydslBindingsUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-941
|
||||
public void registersBindingForPropertyOfSubtype() {
|
||||
void registersBindingForPropertyOfSubtype() {
|
||||
|
||||
bindings.bind(QUser.user.as(QSpecialUser.class).specialProperty).first(ContainsBinding.INSTANCE);
|
||||
|
||||
|
||||
@@ -21,8 +21,8 @@ import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.data.querydsl.QUser;
|
||||
|
||||
import com.querydsl.core.types.Predicate;
|
||||
@@ -32,17 +32,17 @@ import com.querydsl.core.types.Predicate;
|
||||
* @author Oliver Gierke
|
||||
* @author Colin Gao
|
||||
*/
|
||||
public class QuerydslDefaultBindingUnitTests {
|
||||
class QuerydslDefaultBindingUnitTests {
|
||||
|
||||
QuerydslDefaultBinding binding;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
binding = new QuerydslDefaultBinding();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-669
|
||||
public void shouldCreatePredicateCorrectlyWhenPropertyIsInRoot() {
|
||||
void shouldCreatePredicateCorrectlyWhenPropertyIsInRoot() {
|
||||
|
||||
Optional<Predicate> predicate = binding.bind(QUser.user.firstname, Collections.singleton("tam"));
|
||||
|
||||
@@ -50,7 +50,7 @@ public class QuerydslDefaultBindingUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-669
|
||||
public void shouldCreatePredicateCorrectlyWhenPropertyIsInNestedElement() {
|
||||
void shouldCreatePredicateCorrectlyWhenPropertyIsInNestedElement() {
|
||||
|
||||
Optional<Predicate> predicate = binding.bind(QUser.user.address.city, Collections.singleton("two rivers"));
|
||||
|
||||
@@ -59,7 +59,7 @@ public class QuerydslDefaultBindingUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-669
|
||||
public void shouldCreatePredicateWithContainingWhenPropertyIsCollectionLikeAndValueIsObject() {
|
||||
void shouldCreatePredicateWithContainingWhenPropertyIsCollectionLikeAndValueIsObject() {
|
||||
|
||||
Optional<Predicate> predicate = binding.bind(QUser.user.nickNames, Collections.singleton("dragon reborn"));
|
||||
|
||||
@@ -67,7 +67,7 @@ public class QuerydslDefaultBindingUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-669
|
||||
public void shouldCreatePredicateWithInWhenPropertyIsAnObjectAndValueIsACollection() {
|
||||
void shouldCreatePredicateWithInWhenPropertyIsAnObjectAndValueIsACollection() {
|
||||
|
||||
Optional<Predicate> predicate = binding.bind(QUser.user.firstname, Arrays.asList("dragon reborn", "shadowkiller"));
|
||||
|
||||
@@ -75,12 +75,12 @@ public class QuerydslDefaultBindingUnitTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testname() {
|
||||
void testname() {
|
||||
assertThat(binding.bind(QUser.user.lastname, Collections.emptySet())).isNotPresent();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-1578
|
||||
public void shouldCreatePredicateWithIsNullWhenPropertyIsANestedObjectAndValueIsNull() {
|
||||
void shouldCreatePredicateWithIsNullWhenPropertyIsANestedObjectAndValueIsNull() {
|
||||
|
||||
Optional<Predicate> predicate = binding.bind(QUser.user.address.city, Collections.singleton(null));
|
||||
|
||||
|
||||
@@ -25,8 +25,8 @@ import java.util.List;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.format.DateTimeFormat;
|
||||
import org.joda.time.format.DateTimeFormatter;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.data.querydsl.QSpecialUser;
|
||||
import org.springframework.data.querydsl.QUser;
|
||||
import org.springframework.data.querydsl.QUserWrapper;
|
||||
@@ -50,7 +50,7 @@ import com.querydsl.core.types.Predicate;
|
||||
* @author Oliver Gierke
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
public class QuerydslPredicateBuilderUnitTests {
|
||||
class QuerydslPredicateBuilderUnitTests {
|
||||
|
||||
static final ClassTypeInformation<User> USER_TYPE = ClassTypeInformation.from(User.class);
|
||||
static final QuerydslBindings DEFAULT_BINDINGS = new QuerydslBindings();
|
||||
@@ -58,31 +58,31 @@ public class QuerydslPredicateBuilderUnitTests {
|
||||
QuerydslPredicateBuilder builder;
|
||||
MultiValueMap<String, String> values;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
this.builder = new QuerydslPredicateBuilder(new DefaultFormattingConversionService(),
|
||||
SimpleEntityPathResolver.INSTANCE);
|
||||
this.values = new LinkedMultiValueMap<>();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-669
|
||||
public void rejectsNullConversionService() {
|
||||
void rejectsNullConversionService() {
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> new QuerydslPredicateBuilder(null, SimpleEntityPathResolver.INSTANCE));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-669
|
||||
public void getPredicateShouldThrowErrorWhenBindingContextIsNull() {
|
||||
void getPredicateShouldThrowErrorWhenBindingContextIsNull() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> builder.getPredicate(null, values, null));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-669, DATACMNS-1168
|
||||
public void getPredicateShouldReturnNullWhenPropertiesAreEmpty() {
|
||||
void getPredicateShouldReturnNullWhenPropertiesAreEmpty() {
|
||||
assertThat(builder.getPredicate(ClassTypeInformation.OBJECT, values, DEFAULT_BINDINGS)).isNull();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-669
|
||||
public void resolveArgumentShouldCreateSingleStringParameterPredicateCorrectly() throws Exception {
|
||||
void resolveArgumentShouldCreateSingleStringParameterPredicateCorrectly() throws Exception {
|
||||
|
||||
assumeThat(Version.javaVersion().toString())
|
||||
.as("QueryDSL isn't Java 11 ready https://github.com/querydsl/querydsl/issues/2151").startsWith("1.8");
|
||||
@@ -99,7 +99,7 @@ public class QuerydslPredicateBuilderUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-669
|
||||
public void resolveArgumentShouldCreateNestedStringParameterPredicateCorrectly() throws Exception {
|
||||
void resolveArgumentShouldCreateNestedStringParameterPredicateCorrectly() throws Exception {
|
||||
|
||||
assumeThat(Version.javaVersion().toString())
|
||||
.as("QueryDSL isn't Java 11 ready https://github.com/querydsl/querydsl/issues/2151").startsWith("1.8");
|
||||
@@ -116,7 +116,7 @@ public class QuerydslPredicateBuilderUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-669
|
||||
public void ignoresNonDomainTypeProperties() {
|
||||
void ignoresNonDomainTypeProperties() {
|
||||
|
||||
values.add("firstname", "rand");
|
||||
values.add("lastname".toUpperCase(), "al'thor");
|
||||
@@ -127,7 +127,7 @@ public class QuerydslPredicateBuilderUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-669
|
||||
public void forwardsNullForEmptyParameterToSingleValueBinder() {
|
||||
void forwardsNullForEmptyParameterToSingleValueBinder() {
|
||||
|
||||
values.add("lastname", null);
|
||||
|
||||
@@ -139,7 +139,7 @@ public class QuerydslPredicateBuilderUnitTests {
|
||||
|
||||
@Test // DATACMNS-734
|
||||
@SuppressWarnings("unchecked")
|
||||
public void resolvesCommaSeparatedArgumentToArrayCorrectly() {
|
||||
void resolvesCommaSeparatedArgumentToArrayCorrectly() {
|
||||
|
||||
values.add("address.lonLat", "40.740337,-73.995146");
|
||||
|
||||
@@ -152,7 +152,7 @@ public class QuerydslPredicateBuilderUnitTests {
|
||||
|
||||
@Test // DATACMNS-734
|
||||
@SuppressWarnings("unchecked")
|
||||
public void leavesCommaSeparatedArgumentUntouchedWhenTargetIsNotAnArray() {
|
||||
void leavesCommaSeparatedArgumentUntouchedWhenTargetIsNotAnArray() {
|
||||
|
||||
values.add("address.city", "rivers,two");
|
||||
|
||||
@@ -164,7 +164,7 @@ public class QuerydslPredicateBuilderUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-734
|
||||
public void bindsDateCorrectly() throws ParseException {
|
||||
void bindsDateCorrectly() throws ParseException {
|
||||
|
||||
DateTimeFormatter format = DateTimeFormat.forPattern("yyyy-MM-dd");
|
||||
String date = format.print(new DateTime());
|
||||
@@ -177,7 +177,7 @@ public class QuerydslPredicateBuilderUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-883
|
||||
public void automaticallyInsertsAnyStepInCollectionReference() {
|
||||
void automaticallyInsertsAnyStepInCollectionReference() {
|
||||
|
||||
values.add("addresses.street", "VALUE");
|
||||
|
||||
@@ -187,7 +187,7 @@ public class QuerydslPredicateBuilderUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-941
|
||||
public void buildsPredicateForBindingUsingDowncast() {
|
||||
void buildsPredicateForBindingUsingDowncast() {
|
||||
|
||||
values.add("specialProperty", "VALUE");
|
||||
|
||||
@@ -200,7 +200,7 @@ public class QuerydslPredicateBuilderUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-941
|
||||
public void buildsPredicateForBindingUsingNestedDowncast() {
|
||||
void buildsPredicateForBindingUsingNestedDowncast() {
|
||||
|
||||
values.add("user.specialProperty", "VALUE");
|
||||
|
||||
@@ -215,7 +215,7 @@ public class QuerydslPredicateBuilderUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-1443
|
||||
public void doesNotDropValuesContainingABlank() {
|
||||
void doesNotDropValuesContainingABlank() {
|
||||
|
||||
values.add("firstname", " ");
|
||||
|
||||
@@ -224,7 +224,7 @@ public class QuerydslPredicateBuilderUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-1443
|
||||
public void dropsValuesContainingAnEmptyString() {
|
||||
void dropsValuesContainingAnEmptyString() {
|
||||
|
||||
values.add("firstname", "");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user