@@ -22,7 +22,7 @@ void formatSimple() {
22
22
Token token = Token .of ("[a-zA-Z]+" );
23
23
Template template = Template .of ("Hello ${world}!" ).withToken ("world" , token );
24
24
// when
25
- Map < String , String > values = Map .of ("world" , "LangSec" );
25
+ Values values = Values .of ("world" , "LangSec" );
26
26
String result = template .format (values );
27
27
// then
28
28
assertThat (result ).isEqualTo ("Hello LangSec!" );
@@ -44,7 +44,7 @@ void unparse(String regex, String templateString, String field, String value, St
44
44
Token token = Token .of (regex );
45
45
Template template = Template .of (templateString ).withToken (field , token );
46
46
// when
47
- Map < String , String > values = Map .of (field , value );
47
+ Values values = Values .of (field , value );
48
48
String result = template .unparse (values );
49
49
// then
50
50
assertThat (result ).isEqualTo (expected );
@@ -57,9 +57,9 @@ void parse(String regex, String templateString, String field, String expected, S
57
57
Token token = Token .of (regex );
58
58
Template template = Template .of (templateString ).withToken (field , token );
59
59
// when
60
- Map < String , String > result = template .parse (value );
60
+ Values result = template .parse (value );
61
61
// then
62
- assertThat (result ). containsEntry (field , expected );
62
+ assertThat (result . get (field )). hasValue ( expected );
63
63
}
64
64
65
65
@ Test
@@ -68,7 +68,7 @@ void unparseMultipleFields() {
68
68
Token token = Token .of ("[a-zA-Z]+" );
69
69
Template template = Template .of ("${a}, ${b}!" ).withToken ("a" , token ).withToken ("b" , token );
70
70
// when
71
- Map < String , String > values = Map .of ("a" , "foo" , "b" , "bar" );
71
+ Values values = Values . of ( Map .of ("a" , "foo" , "b" , "bar" ) );
72
72
String result = template .unparse (values );
73
73
// then
74
74
assertThat (result ).isEqualTo ("foo, bar!" );
@@ -80,7 +80,7 @@ void unparseWithEncoding() {
80
80
Token token = Token .of ("'[a-zA-Z]+'" ).withEncoding (Encoding .of (".+" , "'$0'" ));
81
81
Template template = Template .of ("Hello ${world}!" ).withToken ("world" , token );
82
82
// when
83
- Map < String , String > values = Map .of ("world" , "LangSec" );
83
+ Values values = Values .of ("world" , "LangSec" );
84
84
String result = template .unparse (values );
85
85
// then
86
86
assertThat (result ).isEqualTo ("Hello 'LangSec'!" );
@@ -92,9 +92,10 @@ void parseMultipleFields() {
92
92
Token token = Token .of ("[a-zA-Z]+" );
93
93
Template template = Template .of ("${a}, ${b}!" ).withToken ("a" , token ).withToken ("b" , token );
94
94
// when
95
- Map < String , String > result = template .parse ("foo, bar!" );
95
+ Values result = template .parse ("foo, bar!" );
96
96
// then
97
- assertThat (result ).containsEntry ("a" , "foo" ).containsEntry ("b" , "bar" );
97
+ assertThat (result .get ("a" )).hasValue ("foo" );
98
+ assertThat (result .get ("b" )).hasValue ("bar" );
98
99
}
99
100
100
101
@ Test
@@ -103,23 +104,23 @@ void parseWithDecoding() {
103
104
Token token = Token .of ("'[a-zA-Z]+'" ).withDecoding (Decoding .of ("'" , "" ));
104
105
Template template = Template .of ("Hello ${world}!" ).withToken ("world" , token );
105
106
// when
106
- Map < String , String > result = template .parse ("Hello 'LangSec'!" );
107
+ Values result = template .parse ("Hello 'LangSec'!" );
107
108
// then
108
- assertThat (result ). containsEntry ("world" , "LangSec" );
109
+ assertThat (result . get ("world" )). hasValue ( "LangSec" );
109
110
}
110
111
111
112
@ Test
112
113
void unparseWithMissingToken () {
113
114
Template template = Template .of ("${any}" );
114
- Map < String , String > values = Map .of ("any" , "any" );
115
+ Values values = Values .of ("any" , "any" );
115
116
assertThatThrownBy (() -> template .unparse (values )).isExactlyInstanceOf (MissingTokenException .class )
116
117
.hasMessage ("Token for field 'any' is missing" );
117
118
}
118
119
119
120
@ Test
120
121
void unparseWithMissingValue () {
121
122
Template template = Template .of ("${any}" ).withToken ("any" , Token .of ("[a-z]+" ));
122
- Map < String , String > values = Map .of ();
123
+ Values values = Values .of ();
123
124
assertThatThrownBy (() -> template .unparse (values )).isExactlyInstanceOf (MissingValueException .class )
124
125
.hasMessage ("Value for field 'any' is missing" );
125
126
}
0 commit comments