DATACMNS-387 - Improvements in null handling in PartTree area.
We're now rejecting invalid constructor arguments handed to ClassTypeInformation, Part, PartTree and PropertyPath. Beyond that we skip the creation of a Part for an empty path segment, so that you don't end up with an invalid Part instance for a findAllByOrderByFooAsc.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2011-2012 the original author or authors.
|
||||
* Copyright 2011-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,6 +17,7 @@ package org.springframework.data.mapping;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.springframework.data.mapping.PropertyPath.*;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
@@ -319,6 +320,38 @@ public class PropertyPathUnitTests {
|
||||
PropertyPath.from("userNameBar", Bar.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATACMNS-387
|
||||
*/
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void rejectsNullSource() {
|
||||
from(null, Foo.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATACMNS-387
|
||||
*/
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void rejectsEmptySource() {
|
||||
from("", Foo.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATACMNS-387
|
||||
*/
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void rejectsNullClass() {
|
||||
from("foo", (Class<?>) null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATACMNS-387
|
||||
*/
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void rejectsNullTypeInformation() {
|
||||
from("foo", (TypeInformation<?>) null);
|
||||
}
|
||||
|
||||
private class Foo {
|
||||
|
||||
String userName;
|
||||
|
||||
Reference in New Issue
Block a user