DATACMNS-829 - Fixed handling of Map null values in ProxyProjectionFactory.
We now eagerly return null values in attempts to project Map values.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2015 the original author or authors.
|
||||
* Copyright 2014-2016 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.
|
||||
@@ -20,6 +20,7 @@ import static org.junit.Assert.*;
|
||||
|
||||
import java.beans.PropertyDescriptor;
|
||||
import java.lang.reflect.Proxy;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -159,7 +160,7 @@ public class ProxyProjectionFactoryUnitTests {
|
||||
ProjectionInformation projectionInformation = factory.getProjectionInformation(CustomerExcerpt.class);
|
||||
List<PropertyDescriptor> result = projectionInformation.getInputProperties();
|
||||
|
||||
assertThat(result, hasSize(5));
|
||||
assertThat(result, hasSize(6));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -247,6 +248,22 @@ public class ProxyProjectionFactoryUnitTests {
|
||||
assertThat(information.isClosed(), is(true));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATACMNS-829
|
||||
*/
|
||||
@Test
|
||||
public void projectsMapOfStringToObjectCorrectly() {
|
||||
|
||||
Customer customer = new Customer();
|
||||
customer.data = Collections.singletonMap("key", null);
|
||||
|
||||
Map<String, Object> data = factory.createProjection(CustomerExcerpt.class, customer).getData();
|
||||
|
||||
assertThat(data, is(notNullValue()));
|
||||
assertThat(data.containsKey("key"), is(true));
|
||||
assertThat(data.get("key"), is(nullValue()));
|
||||
}
|
||||
|
||||
static class Customer {
|
||||
|
||||
public Long id;
|
||||
@@ -254,6 +271,7 @@ public class ProxyProjectionFactoryUnitTests {
|
||||
public Address address;
|
||||
public byte[] picture;
|
||||
public Address[] shippingAddresses;
|
||||
public Map<String, Object> data;
|
||||
}
|
||||
|
||||
static class Address {
|
||||
@@ -272,6 +290,8 @@ public class ProxyProjectionFactoryUnitTests {
|
||||
AddressExcerpt[] getShippingAddresses();
|
||||
|
||||
byte[] getPicture();
|
||||
|
||||
Map<String, Object> getData();
|
||||
}
|
||||
|
||||
interface AddressExcerpt {
|
||||
|
||||
Reference in New Issue
Block a user