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:
Oliver Gierke
2016-03-14 15:46:40 +01:00
parent f8ea9fb8ab
commit a8db5e3d23
2 changed files with 24 additions and 4 deletions

View File

@@ -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 {