@@ -156,6 +156,7 @@ public void constructNullArrayValue() {
156
156
public void constructByte () {
157
157
assertAll (
158
158
() -> assertEquals (byteValue ((byte ) 1 ), tupleValue ("{\" byteV\" :1}" ).get ("byteV" )),
159
+ () -> assertEquals (byteValue ((byte ) 1 ), tupleValue ("{\" byteV\" :\" 1\" }" ).get ("byteV" )),
159
160
() -> assertEquals (byteValue ((byte ) 1 ), constructFromObject ("byteV" , 1 )),
160
161
() -> assertEquals (byteValue ((byte ) 1 ), constructFromObject ("byteV" , "1.0" )));
161
162
}
@@ -164,6 +165,7 @@ public void constructByte() {
164
165
public void constructShort () {
165
166
assertAll (
166
167
() -> assertEquals (shortValue ((short ) 1 ), tupleValue ("{\" shortV\" :1}" ).get ("shortV" )),
168
+ () -> assertEquals (shortValue ((short ) 1 ), tupleValue ("{\" shortV\" :\" 1\" }" ).get ("shortV" )),
167
169
() -> assertEquals (shortValue ((short ) 1 ), constructFromObject ("shortV" , 1 )),
168
170
() -> assertEquals (shortValue ((short ) 1 ), constructFromObject ("shortV" , "1.0" )));
169
171
}
@@ -172,19 +174,16 @@ public void constructShort() {
172
174
public void constructInteger () {
173
175
assertAll (
174
176
() -> assertEquals (integerValue (1 ), tupleValue ("{\" intV\" :1}" ).get ("intV" )),
177
+ () -> assertEquals (integerValue (1 ), tupleValue ("{\" intV\" :\" 1\" }" ).get ("intV" )),
175
178
() -> assertEquals (integerValue (1 ), constructFromObject ("intV" , 1 )),
176
179
() -> assertEquals (integerValue (1 ), constructFromObject ("intV" , "1.0" )));
177
180
}
178
181
179
- @ Test
180
- public void constructIntegerValueInStringValue () {
181
- assertEquals (integerValue (1 ), constructFromObject ("intV" , "1" ));
182
- }
183
-
184
182
@ Test
185
183
public void constructLong () {
186
184
assertAll (
187
185
() -> assertEquals (longValue (1L ), tupleValue ("{\" longV\" :1}" ).get ("longV" )),
186
+ () -> assertEquals (longValue (1L ), tupleValue ("{\" longV\" :\" 1\" }" ).get ("longV" )),
188
187
() -> assertEquals (longValue (1L ), constructFromObject ("longV" , 1L )),
189
188
() -> assertEquals (longValue (1L ), constructFromObject ("longV" , "1.0" )));
190
189
}
@@ -193,13 +192,15 @@ public void constructLong() {
193
192
public void constructFloat () {
194
193
assertAll (
195
194
() -> assertEquals (floatValue (1f ), tupleValue ("{\" floatV\" :1.0}" ).get ("floatV" )),
195
+ () -> assertEquals (floatValue (1f ), tupleValue ("{\" floatV\" :\" 1.0\" }" ).get ("floatV" )),
196
196
() -> assertEquals (floatValue (1f ), constructFromObject ("floatV" , 1f )));
197
197
}
198
198
199
199
@ Test
200
200
public void constructDouble () {
201
201
assertAll (
202
202
() -> assertEquals (doubleValue (1d ), tupleValue ("{\" doubleV\" :1.0}" ).get ("doubleV" )),
203
+ () -> assertEquals (doubleValue (1d ), tupleValue ("{\" doubleV\" :\" 1.0\" }" ).get ("doubleV" )),
203
204
() -> assertEquals (doubleValue (1d ), constructFromObject ("doubleV" , 1d )));
204
205
}
205
206
@@ -215,6 +216,7 @@ public void constructString() {
215
216
public void constructBoolean () {
216
217
assertAll (
217
218
() -> assertEquals (booleanValue (true ), tupleValue ("{\" boolV\" :true}" ).get ("boolV" )),
219
+ () -> assertEquals (booleanValue (true ), tupleValue ("{\" boolV\" :\" true\" }" ).get ("boolV" )),
218
220
() -> assertEquals (booleanValue (true ), constructFromObject ("boolV" , true )),
219
221
() -> assertEquals (booleanValue (true ), constructFromObject ("boolV" , "true" )),
220
222
() -> assertEquals (booleanValue (true ), constructFromObject ("boolV" , 1 )),
@@ -755,6 +757,27 @@ public void constructGeoPointFromUnsupportedFormatShouldThrowException() {
755
757
assertEquals ("lat must be a number" , exception .getMessage ());
756
758
}
757
759
760
+ @ Test
761
+ public void constructNumberFromUnsupportedFormatShouldThrowException () {
762
+ OpenSearchParseException exception =
763
+ assertThrows (
764
+ OpenSearchParseException .class , () -> tupleValue ("{\" intV\" : false}" ).get ("intV" ));
765
+ assertEquals ("node must be a number" , exception .getMessage ());
766
+
767
+ exception =
768
+ assertThrows (
769
+ OpenSearchParseException .class , () -> tupleValue ("{\" longV\" : false}" ).get ("intV" ));
770
+ assertEquals ("node must be a number" , exception .getMessage ());
771
+ }
772
+
773
+ @ Test
774
+ public void constructBooleanFromUnsupportedFormatShouldThrowException () {
775
+ OpenSearchParseException exception =
776
+ assertThrows (
777
+ OpenSearchParseException .class , () -> tupleValue ("{\" boolV\" : 1}" ).get ("boolV" ));
778
+ assertEquals ("node must be a boolean" , exception .getMessage ());
779
+ }
780
+
758
781
@ Test
759
782
public void constructBinary () {
760
783
assertEquals (
@@ -769,6 +792,7 @@ public void constructBinary() {
769
792
@ Test
770
793
public void constructFromOpenSearchArrayReturnFirstElement () {
771
794
assertEquals (integerValue (1 ), tupleValue ("{\" intV\" :[1, 2, 3]}" ).get ("intV" ));
795
+ assertEquals (integerValue (1 ), tupleValue ("{\" intV\" :[\" 1\" , 2, 3]}" ).get ("intV" ));
772
796
assertEquals (
773
797
new ExprTupleValue (
774
798
new LinkedHashMap <String , ExprValue >() {
0 commit comments