4
4
import com .fasterxml .jackson .databind .ObjectMapper ;
5
5
import com .fasterxml .jackson .dataformat .yaml .YAMLFactory ;
6
6
import com .fasterxml .jackson .dataformat .yaml .YAMLMapper ;
7
- import com .google .common .collect .ImmutableMap ;
8
7
import org .junit .Test ;
9
8
10
9
import java .io .IOException ;
@@ -63,10 +62,10 @@ private void run(JsonNode spec) {
63
62
int success = 0 ;
64
63
int whitespace = 0 ;
65
64
Map <String , Object > functionMap = new HashMap <String , Object >() {{
66
- put ("Interpolation" , mapWithConstantLambda ("world" ));
67
- put ("Interpolation - Expansion" , mapWithConstantLambda ("{{planet}}" ));
68
- put ("Interpolation - Alternate Delimiters" , mapWithConstantLambda ("|planet| => {{planet}}" ));
69
- put ("Interpolation - Multiple Calls" ,ImmutableMap . of ("lambda" , new Function <String , String >() {
65
+ put ("Interpolation" , singletonMapWithConstantLambda ("world" ));
66
+ put ("Interpolation - Expansion" , singletonMapWithConstantLambda ("{{planet}}" ));
67
+ put ("Interpolation - Alternate Delimiters" , singletonMapWithConstantLambda ("|planet| => {{planet}}" ));
68
+ put ("Interpolation - Multiple Calls" ,singletonMap ("lambda" , new Function <String , String >() {
70
69
71
70
int calls = 0 ;
72
71
@@ -75,20 +74,20 @@ public String apply(String input) {
75
74
return String .valueOf (++calls );
76
75
}
77
76
}));
78
- put ("Escaping" , mapWithConstantLambda (">" ));
79
- put ("Section" , ImmutableMap . of (
77
+ put ("Escaping" , singletonMapWithConstantLambda (">" ));
78
+ put ("Section" , singletonMap (
80
79
"lambda" ,
81
80
(TemplateFunction ) (input ) -> input .equals ("{{x}}" ) ? "yes" : "no" ));
82
- put ("Section - Expansion" , ImmutableMap . of (
81
+ put ("Section - Expansion" , singletonMap (
83
82
"lambda" ,
84
83
(TemplateFunction ) (input ) -> input + "{{planet}}" + input ));
85
- put ("Section - Alternate Delimiters" , ImmutableMap . of (
84
+ put ("Section - Alternate Delimiters" , singletonMap (
86
85
"lambda" ,
87
86
(TemplateFunction ) (input ) -> input + "{{planet}} => |planet|" + input ));
88
- put ("Section - Multiple Calls" , ImmutableMap . of (
87
+ put ("Section - Multiple Calls" , singletonMap (
89
88
"lambda" ,
90
89
(TemplateFunction ) (input ) -> "__" + input + "__" ));
91
- put ("Inverted Section" , mapWithConstantLambda (false ));
90
+ put ("Inverted Section" , singletonMapWithConstantLambda (false ));
92
91
}};
93
92
for (final JsonNode test : spec .get ("tests" )) {
94
93
boolean failed = false ;
@@ -155,7 +154,15 @@ private JsonNode getSpec(String spec) throws IOException {
155
154
"/spec/specs/" + spec ))).readValueAsTree ();
156
155
}
157
156
158
- private static Map <String , Function <String , Object >> mapWithConstantLambda (Object value ) {
159
- return ImmutableMap .of ("lambda" , (input ) -> value );
157
+ private static Map <String , Function <String , Object >> singletonMapWithConstantLambda (Object value ) {
158
+ return new HashMap <String , Function <String , Object >>() {{
159
+ put ("lambda" , (input ) -> value );
160
+ }};
161
+ }
162
+
163
+ private static Map <String , Object > singletonMap (String key , Object value ) {
164
+ return new HashMap <String , Object >() {{
165
+ put (key , value );
166
+ }};
160
167
}
161
168
}
0 commit comments