DATAKV-197 - Introduce usage of nullable annotations for API validation.

Annotate all packages with Spring Frameworks @NonNullApi and @NonNullFields. Add Spring's @Nullable to methods, parameters and fields that take or produce null values. Adapted using code to make sure the IDE can evaluate the null flow properly. Fix Javadoc in places where an invalid null handling policy was advertised. Strengthened null requirements for types that expose null-instances.

Original Pull Request: #28
This commit is contained in:
Mark Paluch
2017-09-22 16:53:31 +02:00
committed by Christoph Strobl
parent f1935f73b7
commit 83057f1288
44 changed files with 330 additions and 130 deletions

View File

@@ -30,14 +30,10 @@ import org.junit.Test;
/**
* @author Christoph Strobl
* @author Mark Paluch
*/
public class IterableConverterUnitTests {
@Test // DATAKV-101
public void toListShouldReturnEmptyListWhenSourceIsNull() {
assertThat(toList(null), notNullValue());
}
@Test // DATAKV-101
public void toListShouldReturnEmptyListWhenSourceEmpty() {
assertThat(toList(Collections.emptySet()), empty());

View File

@@ -39,6 +39,7 @@ import com.querydsl.core.types.dsl.PathBuilder;
* @author Christoph Strobl
* @author Thomas Darimont
* @author Oliver Gierke
* @author Mark Paluch
*/
public class KeyValueQuerydslUtilsUnitTests {
@@ -57,9 +58,9 @@ public class KeyValueQuerydslUtilsUnitTests {
toOrderSpecifier(Sort.by("firstname"), null);
}
@Test // DATACMNS-525
public void toOrderSpecifierReturnsEmptyArrayWhenSortIsNull() {
assertThat(toOrderSpecifier(null, builder), arrayWithSize(0));
@Test // DATACMNS-525, DATAKV-197
public void toOrderSpecifierReturnsEmptyArrayWhenSortIsUnsorted() {
assertThat(toOrderSpecifier(Sort.unsorted(), builder), arrayWithSize(0));
}
@Test // DATACMNS-525

View File

@@ -45,6 +45,7 @@ import com.google.common.collect.Lists;
* @author Christoph Strobl
* @author Oliver Gierke
* @author Thomas Darimont
* @author Mark Paluch
*/
public class QuerydslKeyValueRepositoryUnitTests extends AbstractRepositoryUnitTests<QPersonRepository> {
@@ -76,8 +77,7 @@ public class QuerydslKeyValueRepositoryUnitTests extends AbstractRepositoryUnitT
assertThat(page1.getContent(), hasSize(1));
assertThat(page1.hasNext(), is(true));
Page<Person> page2 = repository.findAll(QPerson.person.age.eq(CERSEI.getAge()),
page1.nextPageable());
Page<Person> page2 = repository.findAll(QPerson.person.age.eq(CERSEI.getAge()), page1.nextPageable());
assertThat(page2.getTotalElements(), is(2L));
assertThat(page2.getContent(), hasSize(1));
@@ -127,12 +127,17 @@ public class QuerydslKeyValueRepositoryUnitTests extends AbstractRepositoryUnitT
assertThat(result, contains(TYRION, JAIME, CERSEI));
}
@Test // DATAKV-90
public void findAllShouldIgnoreNullOrderSpecifier() {
@Test(expected = IllegalArgumentException.class) // DATAKV-90, DATAKV-197
public void findAllShouldRequireSort() {
repository.findAll((QSort) null);
}
@Test // DATAKV-90, DATAKV-197
public void findAllShouldAllowUnsortedFindAll() {
repository.saveAll(LENNISTERS);
Iterable<Person> result = repository.findAll((QSort) null);
Iterable<Person> result = repository.findAll(Sort.unsorted());
assertThat(result, containsInAnyOrder(TYRION, JAIME, CERSEI));
}