DATACMNS-809 - Polishing.
Made as many methods in ClassGeneratingPropertyAccessorFactory static as possible. Some code formatting. Some warning suppressions where needed. Original pull request: #159.
This commit is contained in:
@@ -13,13 +13,14 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.mapping.model;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -35,12 +36,11 @@ import org.springframework.data.mapping.PersistentPropertyAccessor;
|
||||
import org.springframework.data.mapping.context.SampleMappingContext;
|
||||
import org.springframework.data.mapping.context.SamplePersistentProperty;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link ClassGeneratingPropertyAccessorFactory}
|
||||
*
|
||||
* @author Mark Paluch
|
||||
* @author Oliver Gierke
|
||||
* @see DATACMNS-809
|
||||
*/
|
||||
@RunWith(Parameterized.class)
|
||||
@@ -49,9 +49,9 @@ public class ClassGeneratingPropertyAccessorFactoryDatatypeTests {
|
||||
private final ClassGeneratingPropertyAccessorFactory factory = new ClassGeneratingPropertyAccessorFactory();
|
||||
private final SampleMappingContext mappingContext = new SampleMappingContext();
|
||||
|
||||
private Object bean;
|
||||
private String propertyName;
|
||||
private Object value;
|
||||
private final Object bean;
|
||||
private final String propertyName;
|
||||
private final Object value;
|
||||
|
||||
public ClassGeneratingPropertyAccessorFactoryDatatypeTests(Object bean, String propertyName, Object value,
|
||||
String displayName) {
|
||||
@@ -62,10 +62,10 @@ public class ClassGeneratingPropertyAccessorFactoryDatatypeTests {
|
||||
}
|
||||
|
||||
@Parameters(name = "{3}")
|
||||
@SuppressWarnings("unchecked")
|
||||
public static List<Object[]> parameters() throws Exception {
|
||||
|
||||
List<Object[]> parameters = new ArrayList<Object[]>();
|
||||
|
||||
List<Class<?>> types = Arrays.asList(FieldAccess.class, PropertyAccess.class);
|
||||
|
||||
parameters.addAll(parameters(types, "primitiveInteger", Integer.valueOf(1)));
|
||||
@@ -120,7 +120,6 @@ public class ClassGeneratingPropertyAccessorFactoryDatatypeTests {
|
||||
|
||||
/**
|
||||
* @see DATACMNS-809
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void shouldSetAndGetProperty() throws Exception {
|
||||
@@ -243,5 +242,4 @@ public class ClassGeneratingPropertyAccessorFactoryDatatypeTests {
|
||||
String string;
|
||||
String stringArray[];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -49,9 +49,9 @@ public class ClassGeneratingPropertyAccessorFactoryTests {
|
||||
private final ClassGeneratingPropertyAccessorFactory factory = new ClassGeneratingPropertyAccessorFactory();
|
||||
private final SampleMappingContext mappingContext = new SampleMappingContext();
|
||||
|
||||
private Object bean;
|
||||
private String propertyName;
|
||||
private Class<?> expectedConstructorType;
|
||||
private final Object bean;
|
||||
private final String propertyName;
|
||||
private final Class<?> expectedConstructorType;
|
||||
|
||||
public ClassGeneratingPropertyAccessorFactoryTests(Object bean, String propertyName, Class<?> expectedConstructorType,
|
||||
String displayName) {
|
||||
@@ -65,9 +65,9 @@ public class ClassGeneratingPropertyAccessorFactoryTests {
|
||||
public static List<Object[]> parameters() {
|
||||
|
||||
List<Object[]> parameters = new ArrayList<Object[]>();
|
||||
|
||||
List<String> propertyNames = Arrays.asList("privateField", "packageDefaultField", "protectedField", "publicField",
|
||||
"privateProperty", "packageDefaultProperty", "protectedProperty", "publicProperty", "syntheticProperty");
|
||||
|
||||
parameters.addAll(parameters(new InnerPrivateType(), propertyNames, Object.class));
|
||||
parameters.addAll(parameters(new InnerTypeWithPrivateAncesor(), propertyNames, InnerTypeWithPrivateAncesor.class));
|
||||
parameters.addAll(parameters(new InnerPackageDefaultType(), propertyNames, InnerPackageDefaultType.class));
|
||||
@@ -77,8 +77,7 @@ public class ClassGeneratingPropertyAccessorFactoryTests {
|
||||
ClassGeneratingPropertyAccessorPackageDefaultType.class));
|
||||
parameters.addAll(parameters(new ClassGeneratingPropertyAccessorPublicType(), propertyNames,
|
||||
ClassGeneratingPropertyAccessorPublicType.class));
|
||||
parameters.addAll(parameters(new SubtypeOfTypeInOtherPackage(), propertyNames,
|
||||
SubtypeOfTypeInOtherPackage.class));
|
||||
parameters.addAll(parameters(new SubtypeOfTypeInOtherPackage(), propertyNames, SubtypeOfTypeInOtherPackage.class));
|
||||
|
||||
return parameters;
|
||||
}
|
||||
@@ -114,6 +113,7 @@ public class ClassGeneratingPropertyAccessorFactoryTests {
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void accessorShouldDeclareConstructor() throws Exception {
|
||||
|
||||
PersistentPropertyAccessor persistentPropertyAccessor = getPersistentPropertyAccessor(bean);
|
||||
@@ -170,6 +170,7 @@ public class ClassGeneratingPropertyAccessorFactoryTests {
|
||||
/**
|
||||
* @see DATACMNS-809
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
private static class InnerPrivateType {
|
||||
|
||||
private String privateField;
|
||||
@@ -238,6 +239,7 @@ public class ClassGeneratingPropertyAccessorFactoryTests {
|
||||
/**
|
||||
* @see DATACMNS-809
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
static class InnerPackageDefaultType {
|
||||
|
||||
private String privateField;
|
||||
@@ -299,6 +301,7 @@ public class ClassGeneratingPropertyAccessorFactoryTests {
|
||||
/**
|
||||
* @see DATACMNS-809
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
protected static class InnerProtectedType {
|
||||
|
||||
private String privateField;
|
||||
@@ -360,6 +363,7 @@ public class ClassGeneratingPropertyAccessorFactoryTests {
|
||||
/**
|
||||
* @see DATACMNS-809
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public static class InnerPublicType {
|
||||
|
||||
private String privateField;
|
||||
@@ -418,16 +422,15 @@ public class ClassGeneratingPropertyAccessorFactoryTests {
|
||||
}
|
||||
}
|
||||
|
||||
public static class SubtypeOfTypeInOtherPackage extends TypeInOtherPackage{
|
||||
|
||||
}
|
||||
public static class SubtypeOfTypeInOtherPackage extends TypeInOtherPackage {}
|
||||
|
||||
/**
|
||||
* @see DATACMNS-809
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
private static class Dummy {
|
||||
|
||||
private String dummy;
|
||||
public String publicField;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.mapping.model;
|
||||
|
||||
import org.springframework.data.annotation.AccessType;
|
||||
@@ -21,8 +20,10 @@ import org.springframework.data.annotation.AccessType.Type;
|
||||
|
||||
/**
|
||||
* @author Mark Paluch
|
||||
* @author Oliver Gierke
|
||||
* @see DATACMNS-809
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
class ClassGeneratingPropertyAccessorPackageDefaultType {
|
||||
|
||||
private String privateField;
|
||||
@@ -79,5 +80,4 @@ class ClassGeneratingPropertyAccessorPackageDefaultType {
|
||||
public void setSyntheticProperty(String syntheticProperty) {
|
||||
backing = syntheticProperty;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.mapping.model;
|
||||
|
||||
import org.springframework.data.annotation.AccessType;
|
||||
@@ -21,8 +20,10 @@ import org.springframework.data.annotation.AccessType.Type;
|
||||
|
||||
/**
|
||||
* @author Mark Paluch
|
||||
* @author Oliver Gierke
|
||||
* @see DATACMNS-809
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public class ClassGeneratingPropertyAccessorPublicType {
|
||||
|
||||
private String privateField;
|
||||
@@ -83,12 +84,12 @@ public class ClassGeneratingPropertyAccessorPublicType {
|
||||
}
|
||||
|
||||
public Object set(Object e) {
|
||||
|
||||
aa = (Integer) e;
|
||||
bb = (Integer) e;
|
||||
|
||||
return bb;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
}
|
||||
public static void main(String[] args) {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user