DATALDAP-157 - Migrate tests to JUnit 5.

This commit is contained in:
Mark Paluch
2020-05-07 11:38:32 +02:00
parent 2561ce9285
commit 71ee9011e9
11 changed files with 123 additions and 127 deletions

View File

@@ -17,26 +17,24 @@ package org.springframework.data.ldap.config;
import static org.assertj.core.api.Assertions.*;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
/**
* Unit test for {@link LdapNamespaceHandler}.
*
* @author Mark Paluch
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
public class LdapNamespaceHandlerTests {
@SpringJUnitConfig
class LdapNamespaceHandlerTests {
@Autowired private ApplicationContext context;
@Test // DATALDAP-1
public void shouldCreateRepository() {
void shouldCreateRepository() {
assertThat(context.getBean(DummyLdapRepository.class)).isNotNull();
}
}

View File

@@ -17,7 +17,7 @@ package org.springframework.data.ldap.core.mapping;
import static org.assertj.core.api.Assertions.*;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.ldap.odm.annotations.Id;
/**
@@ -25,10 +25,10 @@ import org.springframework.ldap.odm.annotations.Id;
*
* @author Mark Paluch
*/
public class LdapMappingContextUnitTests {
class LdapMappingContextUnitTests {
@Test // DATALDAP-60
public void shouldCreatePersistentEntities() {
void shouldCreatePersistentEntities() {
LdapMappingContext context = new LdapMappingContext();

View File

@@ -17,7 +17,7 @@ package org.springframework.data.ldap.core.mapping;
import static org.assertj.core.api.Assertions.*;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.ldap.odm.annotations.Id;
/**
@@ -25,10 +25,10 @@ import org.springframework.ldap.odm.annotations.Id;
*
* @author Mark Paluch
*/
public class LdapPersistentPropertyUnitTests {
class LdapPersistentPropertyUnitTests {
@Test // DATALDAP-60
public void shouldConsiderOdmIdAsIdentifier() {
void shouldConsiderOdmIdAsIdentifier() {
LdapMappingContext context = new LdapMappingContext();
BasicLdapPersistentEntity<?> entity = context.getRequiredPersistentEntity(Person.class);

View File

@@ -16,7 +16,7 @@
package org.springframework.data.ldap.repository;
import static org.assertj.core.api.Assertions.*;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.*;
import static org.mockito.Mockito.*;
import java.util.Arrays;
@@ -26,12 +26,12 @@ import java.util.Optional;
import javax.naming.Name;
import javax.naming.ldap.LdapName;
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.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoSettings;
import org.springframework.data.domain.Persistable;
import org.springframework.data.ldap.repository.support.SimpleLdapRepository;
import org.springframework.ldap.NameNotFoundException;
@@ -49,21 +49,21 @@ import org.springframework.ldap.support.LdapUtils;
* @author Mark Paluch
* @author Jens Schauder
*/
@RunWith(MockitoJUnitRunner.class)
public class SimpleLdapRepositoryTests {
@MockitoSettings
class SimpleLdapRepositoryTests {
@Mock LdapOperations ldapOperationsMock;
@Mock ObjectDirectoryMapper odmMock;
SimpleLdapRepository<Object> tested;
private SimpleLdapRepository<Object> tested;
@Before
public void prepareTestedInstance() {
@BeforeEach
void prepareTestedInstance() {
tested = new SimpleLdapRepository<>(ldapOperationsMock, odmMock, Object.class);
}
@Test
public void testCount() {
void testCount() {
Filter filterMock = mock(Filter.class);
when(odmMock.filterFor(Object.class, null)).thenReturn(filterMock);
@@ -79,7 +79,7 @@ public class SimpleLdapRepositoryTests {
}
@Test
public void testSaveNonPersistableWithIdSet() {
void testSaveNonPersistableWithIdSet() {
Object expectedEntity = new Object();
@@ -91,7 +91,7 @@ public class SimpleLdapRepositoryTests {
}
@Test
public void testSaveNonPersistableWithIdChanged() {
void testSaveNonPersistableWithIdChanged() {
Object expectedEntity = new Object();
LdapName expectedName = LdapUtils.newLdapName("ou=newlocation");
@@ -104,7 +104,7 @@ public class SimpleLdapRepositoryTests {
}
@Test
public void testSaveNonPersistableWithNoIdCalculatedId() {
void testSaveNonPersistableWithNoIdCalculatedId() {
Object expectedEntity = new Object();
LdapName expectedName = LdapUtils.emptyLdapName();
@@ -117,7 +117,7 @@ public class SimpleLdapRepositoryTests {
}
@Test
public void testSavePersistableNewWithDeclaredId() {
void testSavePersistableNewWithDeclaredId() {
Persistable expectedEntity = mock(Persistable.class);
@@ -130,7 +130,7 @@ public class SimpleLdapRepositoryTests {
}
@Test
public void testSavePersistableNewWithCalculatedId() {
void testSavePersistableNewWithCalculatedId() {
Persistable expectedEntity = mock(Persistable.class);
LdapName expectedName = LdapUtils.emptyLdapName();
@@ -144,7 +144,7 @@ public class SimpleLdapRepositoryTests {
}
@Test
public void testSavePersistableNotNew() {
void testSavePersistableNotNew() {
Persistable expectedEntity = mock(Persistable.class);
@@ -157,7 +157,7 @@ public class SimpleLdapRepositoryTests {
}
@Test
public void testFindOneWithName() {
void testFindOneWithName() {
LdapName expectedName = LdapUtils.emptyLdapName();
Object expectedResult = new Object();
@@ -170,7 +170,7 @@ public class SimpleLdapRepositoryTests {
}
@Test // DATALDAP-21
public void verifyThatNameNotFoundInFindOneWithNameReturnsEmptyOptional() {
void verifyThatNameNotFoundInFindOneWithNameReturnsEmptyOptional() {
LdapName expectedName = LdapUtils.emptyLdapName();
@@ -182,7 +182,7 @@ public class SimpleLdapRepositoryTests {
}
@Test // DATALDAP-21
public void verifyThatNoResultFoundInFindOneWithNameReturnsEmptyOptional() {
void verifyThatNoResultFoundInFindOneWithNameReturnsEmptyOptional() {
LdapName expectedName = LdapUtils.emptyLdapName();
@@ -194,7 +194,7 @@ public class SimpleLdapRepositoryTests {
}
@Test
public void testFindAll() {
void testFindAll() {
Name expectedName1 = LdapUtils.newLdapName("ou=aa");
Name expectedName2 = LdapUtils.newLdapName("ou=bb");
@@ -215,7 +215,7 @@ public class SimpleLdapRepositoryTests {
}
@Test
public void testFindAllWhereOneEntryIsNotFound() {
void testFindAllWhereOneEntryIsNotFound() {
Name expectedName1 = LdapUtils.newLdapName("ou=aa");
Name expectedName2 = LdapUtils.newLdapName("ou=bb");
@@ -232,5 +232,4 @@ public class SimpleLdapRepositoryTests {
assertThat(iterator.hasNext()).isFalse();
}
}

View File

@@ -23,9 +23,10 @@ import java.util.Collections;
import javax.enterprise.inject.se.SeContainer;
import javax.enterprise.inject.se.SeContainerInitializer;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.springframework.data.ldap.config.DummyEntity;
import org.springframework.ldap.core.LdapTemplate;
@@ -34,12 +35,12 @@ import org.springframework.ldap.core.LdapTemplate;
*
* @author Mark Paluch
*/
public class CdiExtensionIntegrationTests {
class CdiExtensionIntegrationTests {
static SeContainer container;
private static SeContainer container;
@BeforeClass
public static void setUp() {
@BeforeAll
static void setUp() {
container = SeContainerInitializer.newInstance() //
.disableDiscovery() //
@@ -47,13 +48,13 @@ public class CdiExtensionIntegrationTests {
.initialize();
}
@AfterClass
public static void tearDown() {
@AfterAll
static void tearDown() {
container.close();
}
@Test // DATALDAP-5
public void bootstrapsRepositoryCorrectly() {
void bootstrapsRepositoryCorrectly() {
RepositoryClient client = container.select(RepositoryClient.class).get();
LdapTemplate ldapTemplateMock = client.getLdapTemplate();
@@ -71,7 +72,7 @@ public class CdiExtensionIntegrationTests {
}
@Test // DATALDAP-5
public void returnOneFromCustomImpl() {
void returnOneFromCustomImpl() {
RepositoryClient repositoryConsumer = container.select(RepositoryClient.class).get();
assertThat(repositoryConsumer.getSampleRepository().returnOne()).isEqualTo(1);

View File

@@ -17,29 +17,27 @@ package org.springframework.data.ldap.repository.config;
import static org.assertj.core.api.Assertions.*;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;
import org.springframework.data.ldap.config.DummyLdapRepository;
import org.springframework.data.ldap.repository.config.AnnotationConfigTests.Config;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
/**
* @author Mattias Hellborg Arthursson
* @author Mark Paluch
*/
@RunWith(SpringRunner.class)
@ContextConfiguration(classes = Config.class)
public class AnnotationConfigTests {
@SpringJUnitConfig(classes = Config.class)
class AnnotationConfigTests {
@Autowired ApplicationContext context;
@Test
public void testAnnotationConfig() {
void testAnnotationConfig() {
DummyLdapRepository repository = context.getBean(DummyLdapRepository.class);
assertThat(repository).isNotNull();

View File

@@ -17,8 +17,8 @@ package org.springframework.data.ldap.repository.config;
import static org.assertj.core.api.Assertions.*;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Configuration;
@@ -29,22 +29,20 @@ import org.springframework.data.ldap.repository.support.SimpleLdapRepository;
import org.springframework.data.repository.NoRepositoryBean;
import org.springframework.ldap.core.LdapOperations;
import org.springframework.ldap.odm.core.ObjectDirectoryMapper;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
/**
* Unit tests for {@link EnableLdapRepositories#repositoryBaseClass()}.
*
* @author Mark Paluch
*/
@RunWith(SpringRunner.class)
@ContextConfiguration(classes = CustomRepositoryBaseClassTests.Config.class)
public class CustomRepositoryBaseClassTests {
@SpringJUnitConfig(classes = CustomRepositoryBaseClassTests.Config.class)
class CustomRepositoryBaseClassTests {
@Autowired ApplicationContext applicationContext;
@Test // DATALDAP-2
public void shouldImplementCustomizedRepository() {
void shouldImplementCustomizedRepository() {
CustomizedDummyRepository repository = applicationContext.getBean(CustomizedDummyRepository.class);
assertThat(repository.returnOne()).isEqualTo(1);

View File

@@ -19,7 +19,7 @@ import static org.junit.Assert.*;
import java.util.Collection;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.core.env.Environment;
@@ -39,32 +39,32 @@ import org.springframework.ldap.odm.annotations.Entry;
*
* @author Mark Paluch
*/
public class LdapRepositoryConfigurationExtensionUnitTests {
class LdapRepositoryConfigurationExtensionUnitTests {
StandardAnnotationMetadata metadata = new StandardAnnotationMetadata(Config.class, true);
ResourceLoader loader = new PathMatchingResourcePatternResolver();
Environment environment = new StandardEnvironment();
BeanDefinitionRegistry registry = new DefaultListableBeanFactory();
private StandardAnnotationMetadata metadata = new StandardAnnotationMetadata(Config.class, true);
private ResourceLoader loader = new PathMatchingResourcePatternResolver();
private Environment environment = new StandardEnvironment();
private BeanDefinitionRegistry registry = new DefaultListableBeanFactory();
RepositoryConfigurationSource configurationSource = new AnnotationRepositoryConfigurationSource(metadata,
private RepositoryConfigurationSource configurationSource = new AnnotationRepositoryConfigurationSource(metadata,
EnableLdapRepositories.class, loader, environment, registry);
@Test // DATALDAP-60
public void isStrictMatchIfDomainTypeIsAnnotatedWithEntry() {
void isStrictMatchIfDomainTypeIsAnnotatedWithEntry() {
LdapRepositoryConfigurationExtension extension = new LdapRepositoryConfigurationExtension();
assertHasRepo(SampleRepository.class, extension.getRepositoryConfigurations(configurationSource, loader, true));
}
@Test // DATALDAP-60
public void isStrictMatchIfRepositoryExtendsStoreSpecificBase() {
void isStrictMatchIfRepositoryExtendsStoreSpecificBase() {
LdapRepositoryConfigurationExtension extension = new LdapRepositoryConfigurationExtension();
assertHasRepo(StoreRepository.class, extension.getRepositoryConfigurations(configurationSource, loader, true));
}
@Test // DATALDAP-60
public void isNotStrictMatchIfDomainTypeIsNotAnnotatedWithEntry() {
void isNotStrictMatchIfDomainTypeIsNotAnnotatedWithEntry() {
LdapRepositoryConfigurationExtension extension = new LdapRepositoryConfigurationExtension();
assertDoesNotHaveRepo(UnannotatedRepository.class,
@@ -95,7 +95,7 @@ public class LdapRepositoryConfigurationExtensionUnitTests {
}
@EnableLdapRepositories(considerNestedRepositories = true)
static class Config {}
private static class Config {}
@Entry(objectClasses = "person")
static class Sample {}

View File

@@ -19,7 +19,8 @@ import static org.assertj.core.api.Assertions.*;
import java.lang.reflect.Method;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.ldap.repository.support.BaseUnitTestPerson;
import org.springframework.data.ldap.repository.support.UnitTestPerson;
@@ -29,15 +30,16 @@ import org.springframework.data.repository.core.support.DefaultRepositoryMetadat
import org.springframework.ldap.core.LdapTemplate;
import org.springframework.ldap.query.LdapQuery;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
/**
* @author Mattias Hellborg Arthursson
* @author Eddu Melendez
* @author Mark Paluch
*/
@SpringJUnitConfig
@ContextConfiguration
public class PartTreeLdapRepositoryQueryTests extends AbstractJUnit4SpringContextTests {
class PartTreeLdapRepositoryQueryTests {
@Autowired private LdapTemplate ldapTemplate;
@@ -47,13 +49,13 @@ public class PartTreeLdapRepositoryQueryTests extends AbstractJUnit4SpringContex
private ProjectionFactory factory = new SpelAwareProxyProjectionFactory();
@Test
public void testFindByFullName() throws NoSuchMethodException {
void testFindByFullName() throws NoSuchMethodException {
assertFilterForMethod(targetClass.getMethod("findByFullName", String.class), "(cn=John Doe)", "John Doe");
}
// LDAP-314
@Test
public void testFindByFullNameWithBase() throws NoSuchMethodException {
void testFindByFullNameWithBase() throws NoSuchMethodException {
entityClass = BaseUnitTestPerson.class;
targetClass = BaseTestPersonRepository.class;
@@ -64,63 +66,63 @@ public class PartTreeLdapRepositoryQueryTests extends AbstractJUnit4SpringContex
}
@Test
public void testFindByFullNameLike() throws NoSuchMethodException {
void testFindByFullNameLike() throws NoSuchMethodException {
assertFilterForMethod(targetClass.getMethod("findByFullNameLike", String.class), "(cn=*John*)", "*John*");
}
@Test
public void testFindByFullNameStartsWith() throws NoSuchMethodException {
void testFindByFullNameStartsWith() throws NoSuchMethodException {
assertFilterForMethod(targetClass.getMethod("findByFullNameStartsWith", String.class), "(cn=John*)", "John");
}
@Test
public void testFindByFullNameEndsWith() throws NoSuchMethodException {
void testFindByFullNameEndsWith() throws NoSuchMethodException {
assertFilterForMethod(targetClass.getMethod("findByFullNameEndsWith", String.class), "(cn=*John)", "John");
}
@Test
public void testFindByFullNameContains() throws NoSuchMethodException {
void testFindByFullNameContains() throws NoSuchMethodException {
assertFilterForMethod(targetClass.getMethod("findByFullNameContains", String.class), "(cn=*John*)", "John");
}
@Test
public void testFindByFullNameGreaterThanEqual() throws NoSuchMethodException {
void testFindByFullNameGreaterThanEqual() throws NoSuchMethodException {
assertFilterForMethod(targetClass.getMethod("findByFullNameGreaterThanEqual", String.class), "(cn>=John)", "John");
}
@Test
public void testFindByFullNameLessThanEqual() throws NoSuchMethodException {
void testFindByFullNameLessThanEqual() throws NoSuchMethodException {
assertFilterForMethod(targetClass.getMethod("findByFullNameLessThanEqual", String.class), "(cn<=John)", "John");
}
@Test
public void testFindByFullNameIsNotNull() throws NoSuchMethodException {
void testFindByFullNameIsNotNull() throws NoSuchMethodException {
assertFilterForMethod(targetClass.getMethod("findByFullNameIsNotNull"), "(cn=*)");
}
@Test
public void testFindByFullNameIsNull() throws NoSuchMethodException {
void testFindByFullNameIsNull() throws NoSuchMethodException {
assertFilterForMethod(targetClass.getMethod("findByFullNameIsNull"), "(!(cn=*))");
}
@Test
public void testFindByFullNameNot() throws NoSuchMethodException {
void testFindByFullNameNot() throws NoSuchMethodException {
assertFilterForMethod(targetClass.getMethod("findByFullNameNot", String.class), "(!(cn=John Doe))", "John Doe");
}
@Test
public void testFindByFullNameNotLike() throws NoSuchMethodException {
void testFindByFullNameNotLike() throws NoSuchMethodException {
assertFilterForMethod(targetClass.getMethod("findByFullNameNotLike", String.class), "(!(cn=*John*))", "*John*");
}
@Test
public void testFindByFullNameAndLastName() throws NoSuchMethodException {
void testFindByFullNameAndLastName() throws NoSuchMethodException {
assertFilterForMethod(targetClass.getMethod("findByFullNameAndLastName", String.class, String.class),
"(&(cn=John Doe)(sn=Doe))", "John Doe", "Doe");
}
@Test
public void testFindByFullNameAndLastNameNot() throws NoSuchMethodException {
void testFindByFullNameAndLastNameNot() throws NoSuchMethodException {
assertFilterForMethod(targetClass.getMethod("findByFullNameAndLastNameNot", String.class, String.class),
"(&(cn=John Doe)(!(sn=Doe)))", "John Doe", "Doe");
}

View File

@@ -17,7 +17,7 @@ package org.springframework.data.ldap.repository.support;
import static org.assertj.core.api.Assertions.*;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.ldap.filter.Filter;
import org.springframework.ldap.odm.core.ObjectDirectoryMapper;
import org.springframework.ldap.odm.core.impl.DefaultObjectDirectoryMapper;
@@ -28,110 +28,110 @@ import com.querydsl.core.types.Expression;
* @author Mattias Hellborg Arthursson
* @author Eddu Melendez
*/
public class QuerydslFilterGeneratorTests {
class QuerydslFilterGeneratorTests {
private ObjectDirectoryMapper odm = new DefaultObjectDirectoryMapper();
private LdapSerializer tested = new LdapSerializer(odm, UnitTestPerson.class);
private QPerson person = QPerson.person;
@Test
public void testEqualsFilter() {
void testEqualsFilter() {
Expression<?> expression = person.fullName.eq("John Doe");
Filter result = tested.handle(expression);
assertThat(result.toString()).isEqualTo("(cn=John Doe)");
assertThat(result).hasToString("(cn=John Doe)");
}
@Test
public void testAndFilter() {
void testAndFilter() {
Expression<?> expression = person.fullName.eq("John Doe").and(person.lastName.eq("Doe"));
Filter result = tested.handle(expression);
assertThat(result.toString()).isEqualTo("(&(cn=John Doe)(sn=Doe))");
assertThat(result).hasToString("(&(cn=John Doe)(sn=Doe))");
}
@Test
public void testOrFilter() {
void testOrFilter() {
Expression<?> expression = person.fullName.eq("John Doe").or(person.lastName.eq("Doe"));
Filter result = tested.handle(expression);
assertThat(result.toString()).isEqualTo("(|(cn=John Doe)(sn=Doe))");
assertThat(result).hasToString("(|(cn=John Doe)(sn=Doe))");
}
@Test
public void testOr() {
void testOr() {
Expression<?> expression = person.fullName.eq("John Doe")
.and(person.lastName.eq("Doe").or(person.lastName.eq("Die")));
Filter result = tested.handle(expression);
assertThat(result.toString()).isEqualTo("(&(cn=John Doe)(|(sn=Doe)(sn=Die)))");
assertThat(result).hasToString("(&(cn=John Doe)(|(sn=Doe)(sn=Die)))");
}
@Test
public void testNot() {
void testNot() {
Expression<?> expression = person.fullName.eq("John Doe").not();
Filter result = tested.handle(expression);
assertThat(result.toString()).isEqualTo("(!(cn=John Doe))");
assertThat(result).hasToString("(!(cn=John Doe))");
}
@Test
public void testIsLike() {
void testIsLike() {
Expression<?> expression = person.fullName.like("kalle*");
Filter result = tested.handle(expression);
assertThat(result.toString()).isEqualTo("(cn=kalle*)");
assertThat(result).hasToString("(cn=kalle*)");
}
@Test
public void testStartsWith() {
void testStartsWith() {
Expression<?> expression = person.fullName.startsWith("kalle");
Filter result = tested.handle(expression);
assertThat(result.toString()).isEqualTo("(cn=kalle*)");
assertThat(result).hasToString("(cn=kalle*)");
}
@Test
public void testEndsWith() {
void testEndsWith() {
Expression<?> expression = person.fullName.endsWith("kalle");
Filter result = tested.handle(expression);
assertThat(result.toString()).isEqualTo("(cn=*kalle)");
assertThat(result).hasToString("(cn=*kalle)");
}
@Test
public void testContains() {
void testContains() {
Expression<?> expression = person.fullName.contains("kalle");
Filter result = tested.handle(expression);
assertThat(result.toString()).isEqualTo("(cn=*kalle*)");
assertThat(result).hasToString("(cn=*kalle*)");
}
@Test
public void testNotNull() {
void testNotNull() {
Expression<?> expression = person.fullName.isNotNull();
Filter result = tested.handle(expression);
assertThat(result.toString()).isEqualTo("(cn=*)");
assertThat(result).hasToString("(cn=*)");
}
@Test
public void testNull() {
void testNull() {
Expression<?> expression = person.fullName.isNull();
Filter result = tested.handle(expression);
assertThat(result.toString()).isEqualTo("(!(cn=*))");
assertThat(result).hasToString("(!(cn=*))");
}
}

View File

@@ -18,11 +18,11 @@ package org.springframework.data.ldap.repository.support;
import static org.assertj.core.api.Assertions.*;
import static org.mockito.Mockito.*;
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.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoSettings;
import org.springframework.ldap.core.LdapOperations;
import org.springframework.ldap.filter.AbsoluteTrueFilter;
import org.springframework.ldap.filter.EqualsFilter;
@@ -34,18 +34,18 @@ import org.springframework.ldap.query.LdapQuery;
*
* @author Mark Paluch
*/
@RunWith(MockitoJUnitRunner.class)
public class QuerydslLdapQueryUnitTests {
@MockitoSettings
class QuerydslLdapQueryUnitTests {
@Mock LdapOperations ldapOperations;
@Before
public void before() {
@BeforeEach
void before() {
when(ldapOperations.getObjectDirectoryMapper()).thenReturn(new DefaultObjectDirectoryMapper());
}
@Test // DATALDAP-65
public void shouldCreateFilter() {
void shouldCreateFilter() {
QuerydslLdapQuery<UnitTestPerson> query = new QuerydslLdapQuery<>(ldapOperations, UnitTestPerson.class);
@@ -55,7 +55,7 @@ public class QuerydslLdapQueryUnitTests {
}
@Test // DATALDAP-65
public void shouldCreateEmptyFilter() {
void shouldCreateEmptyFilter() {
QuerydslLdapQuery<UnitTestPerson> query = new QuerydslLdapQuery<>(ldapOperations, UnitTestPerson.class);
@@ -65,7 +65,7 @@ public class QuerydslLdapQueryUnitTests {
}
@Test // DATALDAP-65
public void shouldCreateEmptyFilterFromWhereNull() {
void shouldCreateEmptyFilterFromWhereNull() {
QuerydslLdapQuery<UnitTestPerson> query = new QuerydslLdapQuery<>(ldapOperations, QPerson.person);