55import android .graphics .BitmapFactory ;
66import android .test .ApplicationTestCase ;
77
8+ import com .google .gson .annotations .SerializedName ;
9+
810import net .servicestack .client .AsyncResult ;
11+ import net .servicestack .client .Flags ;
912import net .servicestack .client .Utils ;
1013
1114import java .net .HttpURLConnection ;
@@ -51,4 +54,31 @@ public void complete() {
5154
5255 assertTrue (signal .await (5 , TimeUnit .SECONDS ));
5356 }
57+
58+ public void test_Can_deserialize_enum_flags (){
59+ EnumTest o = client .getGson ().fromJson ("{\" Flags\" :2}" , EnumTest .class );
60+
61+ assertEquals (o .Flags , EnumFlags .Value2 );
62+
63+ o = client .getGson ().fromJson ("{\" Flags\" :4}" , EnumTest .class );
64+ assertEquals (o .Flags , EnumFlags .Value3 );
65+ }
66+
67+ public static class EnumTest
68+ {
69+ public EnumFlags Flags ;
70+ }
71+
72+ @ Flags ()
73+ public static enum EnumFlags
74+ {
75+ @ SerializedName ("1" ) Value1 (1 ),
76+ @ SerializedName ("2" ) Value2 (2 ),
77+ @ SerializedName ("4" ) Value3 (4 );
78+
79+ private final int value ;
80+ EnumFlags (final int intValue ) { value = intValue ; }
81+ public int getValue () { return value ; }
82+ }
83+
5484}
0 commit comments