@@ -151,7 +151,7 @@ public void testParseSeriesAs_testNonNullAndValidValues() {
151
151
Double now = Long .valueOf (System .currentTimeMillis ()).doubleValue ();
152
152
String uuidAsString = UUID .randomUUID ().toString ();
153
153
154
- // InfluxDB client returns any number as Double.
154
+ // InfluxDB client returns any number as Double. (with JSON response format, but not with msgpack)
155
155
// See https://github.com/influxdata/influxdb-java/issues/153#issuecomment-259681987
156
156
// for more information.
157
157
List <Object > seriesResult = Arrays .asList (now , uuidAsString ,
@@ -201,6 +201,62 @@ Double asDouble(Object obj) {
201
201
return (Double ) obj ;
202
202
}
203
203
204
+ @ Test
205
+ public void testParseSeriesAs_testNonNullAndValidValues_msgpack () {
206
+ // Given...
207
+ mapper .cacheMeasurementClass (MyCustomMeasurement .class );
208
+
209
+ List <String > columnList = Arrays .asList ("time" , "uuid" ,
210
+ "doubleObject" , "longObject" , "integerObject" ,
211
+ "doublePrimitive" , "longPrimitive" , "integerPrimitive" ,
212
+ "booleanObject" , "booleanPrimitive" );
213
+
214
+ // InfluxDB client returns the time representation as Double.
215
+ Double now = Long .valueOf (System .currentTimeMillis ()).doubleValue ();
216
+ String uuidAsString = UUID .randomUUID ().toString ();
217
+
218
+ // InfluxDB client returns any number as Double. (with JSON response format, but not with msgpack)
219
+ // See https://github.com/influxdata/influxdb-java/issues/153#issuecomment-259681987
220
+ // for more information.
221
+ List <Object > seriesResult = Arrays .asList (now , uuidAsString ,
222
+ new Double ("1.01" ), Long .valueOf (2 ), Integer .valueOf (3 ),
223
+ new Double ("1.01" ), Long .valueOf (4 ), Integer .valueOf (5 ),
224
+ Boolean .FALSE , Boolean .TRUE );
225
+
226
+ QueryResult .Series series = new QueryResult .Series ();
227
+ series .setColumns (columnList );
228
+ series .setValues (Arrays .asList (seriesResult ));
229
+
230
+ //When...
231
+ List <MyCustomMeasurement > result = new LinkedList <>();
232
+ mapper .parseSeriesAs (series , MyCustomMeasurement .class , result );
233
+
234
+ //Then...
235
+ MyCustomMeasurement myObject = result .get (0 );
236
+ Assertions .assertEquals (now .longValue (), myObject .time .toEpochMilli (), "field 'time' does not match" );
237
+ Assertions .assertEquals (uuidAsString , myObject .uuid , "field 'uuid' does not match" );
238
+
239
+ Assertions .assertEquals (asDouble (seriesResult .get (2 )), myObject .doubleObject , "field 'doubleObject' does not match" );
240
+ Assertions .assertEquals (Long .valueOf (2 ), myObject .longObject , "field 'longObject' does not match" );
241
+ Assertions .assertEquals (Integer .valueOf (3 ), myObject .integerObject , "field 'integerObject' does not match" );
242
+
243
+ Assertions .assertTrue (
244
+ Double .compare (asDouble (seriesResult .get (5 )).doubleValue (), myObject .doublePrimitive ) == 0 ,
245
+ "field 'doublePrimitive' does not match" );
246
+
247
+ Assertions .assertEquals ( myObject .longPrimitive , 4 , "field 'longPrimitive' does not match" );
248
+ Assertions .assertEquals ( myObject .integerPrimitive , 5 , "field 'integerPrimitive' does not match" );
249
+
250
+ Assertions .assertEquals (
251
+ Boolean .valueOf (String .valueOf (seriesResult .get (8 ))), myObject .booleanObject ,
252
+ "field 'booleanObject' does not match" );
253
+
254
+ Assertions .assertEquals (
255
+ Boolean .valueOf (String .valueOf (seriesResult .get (9 ))).booleanValue (), myObject .booleanPrimitive ,
256
+ "field 'booleanPrimitive' does not match" );
257
+ }
258
+
259
+
204
260
@ Test
205
261
public void testFieldValueModified_DateAsISO8601 () {
206
262
// Given...
@@ -638,4 +694,4 @@ public String toString() {
638
694
+ ", median=" + median + ", min=" + min + ", max=" + max + "]" ;
639
695
}
640
696
}
641
- }
697
+ }
0 commit comments