1717import static org .hamcrest .core .IsIterableContaining .hasItems ;
1818
1919import java .math .BigDecimal ;
20+ import java .util .ArrayList ;
2021import java .util .HashMap ;
2122import java .util .List ;
2223import java .util .Map ;
@@ -129,30 +130,29 @@ public void assertGetConfigAsEnumWrongValue() {
129130 assertThat (configClass .enumField , is (ConfigClass .MyEnum .UNKNOWN ));
130131 }
131132
132- /**
133- * TODO check why this is wanted
134- *
135- * @Test
136- * public void assertConfigAllowsNullValues() {
137- * Configuration configuration = new Configuration();
138- * configuration.put("stringField", null);
139- * configuration.put("anotherField", null);
140- *
141- * // ensure conversions are null-tolerant and don't throw exceptions
142- * Map<String, @Nullable Object> props = configuration.getProperties();
143- * Set<String> keys = configuration.keySet();
144- * List<Object> values = new ArrayList<>(configuration.values());
145- *
146- * // ensure copies, not views
147- * configuration.put("stringField", "someValue");
148- * configuration.put("additionalField", "");
149- * assertThat(props.get("stringField"), is(nullValue()));
150- * assertThat(values.getFirst(), is(nullValue()));
151- * assertThat(values.get(1), is(nullValue()));
152- * assertThat(values.size(), is(2));
153- * assertThat(keys.size(), is(2));
154- * }
155- */
133+ @ Test
134+ public void assertConfigAllowsNullValues () {
135+ Configuration configuration = new Configuration ();
136+ configuration .put ("stringField" , null );
137+ configuration .put ("anotherField" , null );
138+
139+ // ensure conversions are null-tolerant and don't throw exceptions
140+ Map <String , Object > props = configuration .getProperties ();
141+ Set <String > keys = configuration .keySet ();
142+ List <Object > values = new ArrayList <>(configuration .values ());
143+
144+ // ensure copies, not views
145+ configuration .put ("stringField" , "someValue" );
146+ configuration .put ("additionalField" , "" );
147+ // ATTENTION, breaking change: the following assertions are no longer valid
148+ // assertThat(props.get("stringField"), is(nullValue()));
149+ // assertThat(values.getFirst(), is(nullValue()));
150+ // assertThat(values.get(1), is(nullValue()));
151+ // assertThat(values.size(), is(2));
152+ // assertThat(keys.size(), is(2));
153+ assertThat (values .size (), is (0 ));
154+ assertThat (keys .size (), is (0 ));
155+ }
156156
157157 @ Test
158158 public void assertPropertiesCanBeRemoved () {
@@ -176,20 +176,6 @@ public void assertPropertiesCanBeRemoved() {
176176 assertThat (configuration .get ("intField" ), is (nullValue ()));
177177 }
178178
179- /**
180- * TODO check why this is wanted
181- *
182- * @Test
183- * public void assertToStringHandlesNullValuesGracefully() {
184- * Map<String, Object> properties = new HashMap<>();
185- * properties.put("stringField", null);
186- *
187- * Configuration configuration = new Configuration(properties);
188- * String res = configuration.toString();
189- * assertThat(res.contains("type=?"), is(true));
190- * }
191- */
192-
193179 @ Test
194180 public void assertNormalizationInSetProperties () {
195181 Map <String , Object > properties = new HashMap <>();
0 commit comments