From ad6fb5595834d416e5bcd042a9369305b3f970f6 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Tue, 4 Aug 2015 14:48:38 +0200 Subject: [PATCH] Add relaxed names for enum test Add an extra test that demonstrate the use of relaxed binding for Enum when it is used as a map key. See gh-2465 --- .../boot/bind/RelaxedDataBinderTests.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/spring-boot/src/test/java/org/springframework/boot/bind/RelaxedDataBinderTests.java b/spring-boot/src/test/java/org/springframework/boot/bind/RelaxedDataBinderTests.java index 4852ebbcf3..310d2eef4b 100644 --- a/spring-boot/src/test/java/org/springframework/boot/bind/RelaxedDataBinderTests.java +++ b/spring-boot/src/test/java/org/springframework/boot/bind/RelaxedDataBinderTests.java @@ -334,6 +334,15 @@ public class RelaxedDataBinderTests { assertEquals("123", target.getNested().get(Bingo.THAT)); } + @Test + public void testBindNestedMapOfEnumRelaxedNames() throws Exception { + this.conversionService = new DefaultConversionService(); + TargetWithNestedMapOfEnum target = new TargetWithNestedMapOfEnum(); + bind(target, "nested.the-other: bar\n" + "nested.that_other: 123"); + assertEquals("bar", target.getNested().get(Bingo.THE_OTHER)); + assertEquals("123", target.getNested().get(Bingo.THAT_OTHER)); + } + @Test public void testBindNestedMapBracketReferenced() throws Exception { TargetWithNestedMap target = new TargetWithNestedMap(); @@ -969,7 +978,7 @@ public class RelaxedDataBinderTests { } enum Bingo { - THIS, or, THAT, THE_OTHER + THIS, or, THAT, THE_OTHER, THAT_OTHER } public static class ValidatedTarget {