11package cn .jpush .api .push .model .notification ;
22
3+ import static org .hamcrest .CoreMatchers .is ;
4+ import static org .junit .Assert .assertEquals ;
5+ import static org .junit .Assert .assertThat ;
6+
37import org .junit .Assert ;
48import org .junit .Test ;
59
10+ import com .google .gson .JsonElement ;
611import com .google .gson .JsonObject ;
712import com .google .gson .JsonPrimitive ;
813
@@ -14,7 +19,7 @@ public void testEmpty() {
1419 JsonObject json = new JsonObject ();
1520 json .add ("sound" , new JsonPrimitive ("" ));
1621 json .add ("badge" , new JsonPrimitive ("+1" ));
17- Assert . assertEquals ("" , json , ios .toJSON ());
22+ assertEquals ("" , json , ios .toJSON ());
1823 }
1924
2025 @ Test
@@ -24,7 +29,7 @@ public void testQuickAlert() {
2429 json .add ("alert" , new JsonPrimitive ("aaa" ));
2530 json .add ("sound" , new JsonPrimitive ("" ));
2631 json .add ("badge" , new JsonPrimitive ("+1" ));
27- Assert . assertEquals ("" , json , ios .toJSON ());
32+ assertEquals ("" , json , ios .toJSON ());
2833 }
2934
3035 @ Test
@@ -33,7 +38,7 @@ public void testBadge_0() {
3338 JsonObject json = new JsonObject ();
3439 json .add ("badge" , new JsonPrimitive ("0" ));
3540 json .add ("sound" , new JsonPrimitive ("" ));
36- Assert . assertEquals ("" , json , ios .toJSON ());
41+ assertEquals ("" , json , ios .toJSON ());
3742 }
3843
3944 @ Test
@@ -42,7 +47,7 @@ public void testBadge_2() {
4247 JsonObject json = new JsonObject ();
4348 json .add ("badge" , new JsonPrimitive ("2" ));
4449 json .add ("sound" , new JsonPrimitive ("" ));
45- Assert . assertEquals ("" , json , ios .toJSON ());
50+ assertEquals ("" , json , ios .toJSON ());
4651 }
4752
4853 @ Test
@@ -51,7 +56,7 @@ public void testBadge_auto() {
5156 JsonObject json = new JsonObject ();
5257 json .add ("badge" , new JsonPrimitive ("+1" ));
5358 json .add ("sound" , new JsonPrimitive ("" ));
54- Assert . assertEquals ("" , json , ios .toJSON ());
59+ assertEquals ("" , json , ios .toJSON ());
5560 }
5661
5762 @ Test
@@ -60,7 +65,7 @@ public void testBadge_plus_2() {
6065 JsonObject json = new JsonObject ();
6166 json .add ("badge" , new JsonPrimitive ("+2" ));
6267 json .add ("sound" , new JsonPrimitive ("" ));
63- Assert . assertEquals ("" , json , ios .toJSON ());
68+ assertEquals ("" , json , ios .toJSON ());
6469 }
6570
6671 @ Test
@@ -69,7 +74,7 @@ public void testBadge_plus_0() {
6974 JsonObject json = new JsonObject ();
7075 json .add ("badge" , new JsonPrimitive ("+0" ));
7176 json .add ("sound" , new JsonPrimitive ("" ));
72- Assert . assertEquals ("" , json , ios .toJSON ());
77+ assertEquals ("" , json , ios .toJSON ());
7378 }
7479
7580 @ Test
@@ -78,7 +83,7 @@ public void testBadge_minus_2() {
7883 JsonObject json = new JsonObject ();
7984 json .add ("badge" , new JsonPrimitive ("-2" ));
8085 json .add ("sound" , new JsonPrimitive ("" ));
81- Assert . assertEquals ("" , json , ios .toJSON ());
86+ assertEquals ("" , json , ios .toJSON ());
8287 }
8388
8489 @ Test
@@ -100,7 +105,7 @@ public void testSoundDisabled() {
100105 JsonObject json = new JsonObject ();
101106 json .add ("alert" , new JsonPrimitive ("alert" ));
102107 json .add ("badge" , new JsonPrimitive ("+1" ));
103- Assert . assertEquals ("" , json , ios .toJSON ());
108+ assertEquals ("" , json , ios .toJSON ());
104109 }
105110
106111 @ Test
@@ -112,7 +117,7 @@ public void testBadgeDisabled() {
112117 JsonObject json = new JsonObject ();
113118 json .add ("alert" , new JsonPrimitive ("alert" ));
114119 json .add ("sound" , new JsonPrimitive ("" ));
115- Assert . assertEquals ("" , json , ios .toJSON ());
120+ assertEquals ("" , json , ios .toJSON ());
116121 }
117122
118123
@@ -128,10 +133,21 @@ public void testExtra() {
128133 json .add ("extras" , extra );
129134 json .add ("sound" , new JsonPrimitive ("" ));
130135 json .add ("badge" , new JsonPrimitive ("+1" ));
131- Assert . assertEquals ("" , json , ios .toJSON ());
136+ assertEquals ("" , json , ios .toJSON ());
132137 }
133138
134-
139+ @ Test
140+ public void testCategory () {
141+ IosNotification ios = IosNotification .newBuilder ()
142+ .setCategory ("java" ).build ();
143+
144+ JsonObject json = new JsonObject ();
145+ json .add ("category" , new JsonPrimitive ("java" ));
146+ json .add ("sound" , new JsonPrimitive ("" ));
147+ json .add ("badge" , new JsonPrimitive ("+1" ));
148+
149+ assertThat (ios .toJSON (), is ((JsonElement ) json ));
150+ }
135151}
136152
137153
0 commit comments