@@ -83,6 +83,7 @@ public void testBuildRESTSendPushCommandWithChannelSet() throws Exception {
83
83
84
84
// Verify command
85
85
JSONObject jsonParameters = pushCommand .jsonParameters ;
86
+ assertFalse (jsonParameters .has (ParseRESTPushCommand .KEY_PUSH_TIME ));
86
87
assertFalse (jsonParameters .has (ParseRESTPushCommand .KEY_EXPIRATION_TIME ));
87
88
assertFalse (jsonParameters .has (ParseRESTPushCommand .KEY_EXPIRATION_INTERVAL ));
88
89
// Verify device type and query
@@ -113,6 +114,7 @@ public void testBuildRESTSendPushCommandWithExpirationTime() throws Exception {
113
114
114
115
// Verify command
115
116
JSONObject jsonParameters = pushCommand .jsonParameters ;
117
+ assertFalse (jsonParameters .has (ParseRESTPushCommand .KEY_PUSH_TIME ));
116
118
assertFalse (jsonParameters .has (ParseRESTPushCommand .KEY_EXPIRATION_INTERVAL ));
117
119
assertFalse (jsonParameters .has (ParseRESTPushCommand .KEY_CHANNELS ));
118
120
// Verify device type and query
@@ -123,6 +125,36 @@ public void testBuildRESTSendPushCommandWithExpirationTime() throws Exception {
123
125
assertEquals (1400000000 , jsonParameters .getLong (ParseRESTPushCommand .KEY_EXPIRATION_TIME ));
124
126
}
125
127
128
+ @ Test
129
+ public void testBuildRESTSendPushCommandWithPushTime () throws Exception {
130
+ ParseHttpClient restClient = mock (ParseHttpClient .class );
131
+ ParsePushController controller = new ParsePushController (restClient );
132
+
133
+ // Build PushState
134
+ JSONObject data = new JSONObject ();
135
+ data .put (ParsePush .KEY_DATA_MESSAGE , "hello world" );
136
+ long pushTime = System .currentTimeMillis () / 1000 + 1000 ;
137
+ ParsePush .State state = new ParsePush .State .Builder ()
138
+ .data (data )
139
+ .pushTime (pushTime )
140
+ .build ();
141
+
142
+ // Build command
143
+ ParseRESTCommand pushCommand = controller .buildRESTSendPushCommand (state , "sessionToken" );
144
+
145
+ // Verify command
146
+ JSONObject jsonParameters = pushCommand .jsonParameters ;
147
+ assertFalse (jsonParameters .has (ParseRESTPushCommand .KEY_EXPIRATION_TIME ));
148
+ assertFalse (jsonParameters .has (ParseRESTPushCommand .KEY_EXPIRATION_INTERVAL ));
149
+ assertFalse (jsonParameters .has (ParseRESTPushCommand .KEY_CHANNELS ));
150
+ // Verify device type and query
151
+ assertEquals ("{}" , jsonParameters .get (ParseRESTPushCommand .KEY_WHERE ).toString ());
152
+ assertEquals ("hello world" ,
153
+ jsonParameters .getJSONObject (ParseRESTPushCommand .KEY_DATA )
154
+ .getString (ParsePush .KEY_DATA_MESSAGE ));
155
+ assertEquals (pushTime , jsonParameters .getLong (ParseRESTPushCommand .KEY_PUSH_TIME ));
156
+ }
157
+
126
158
@ Test
127
159
public void testBuildRESTSendPushCommandWithExpirationTimeInterval () throws Exception {
128
160
ParseHttpClient restClient = mock (ParseHttpClient .class );
@@ -141,6 +173,7 @@ public void testBuildRESTSendPushCommandWithExpirationTimeInterval() throws Exce
141
173
142
174
// Verify command
143
175
JSONObject jsonParameters = pushCommand .jsonParameters ;
176
+ assertFalse (jsonParameters .has (ParseRESTPushCommand .KEY_PUSH_TIME ));
144
177
assertFalse (jsonParameters .has (ParseRESTPushCommand .KEY_EXPIRATION_TIME ));
145
178
assertFalse (jsonParameters .has (ParseRESTPushCommand .KEY_CHANNELS ));
146
179
// Verify device type and query
@@ -172,6 +205,7 @@ public void testBuildRESTSendPushCommandWithQuery() throws Exception {
172
205
173
206
// Verify command
174
207
JSONObject jsonParameters = pushCommand .jsonParameters ;
208
+ assertFalse (jsonParameters .has (ParseRESTPushCommand .KEY_PUSH_TIME ));
175
209
assertFalse (jsonParameters .has (ParseRESTPushCommand .KEY_EXPIRATION_TIME ));
176
210
assertFalse (jsonParameters .has (ParseRESTPushCommand .KEY_EXPIRATION_INTERVAL ));
177
211
assertFalse (jsonParameters .getJSONObject (ParseRESTPushCommand .KEY_WHERE )
@@ -206,6 +240,7 @@ public void testBuildRESTSendPushCommandWithPushToAndroid() throws Exception {
206
240
207
241
// Verify command
208
242
JSONObject jsonParameters = pushCommand .jsonParameters ;
243
+ assertFalse (jsonParameters .has (ParseRESTPushCommand .KEY_PUSH_TIME ));
209
244
assertFalse (jsonParameters .has (ParseRESTPushCommand .KEY_EXPIRATION_TIME ));
210
245
assertFalse (jsonParameters .has (ParseRESTPushCommand .KEY_EXPIRATION_INTERVAL ));
211
246
assertFalse (jsonParameters .has (ParseRESTPushCommand .KEY_CHANNELS ));
@@ -235,6 +270,7 @@ public void testBuildRESTSendPushCommandWithPushToIOS() throws Exception {
235
270
236
271
// Verify command
237
272
JSONObject jsonParameters = pushCommand .jsonParameters ;
273
+ assertFalse (jsonParameters .has (ParseRESTPushCommand .KEY_PUSH_TIME ));
238
274
assertFalse (jsonParameters .has (ParseRESTPushCommand .KEY_EXPIRATION_TIME ));
239
275
assertFalse (jsonParameters .has (ParseRESTPushCommand .KEY_EXPIRATION_INTERVAL ));
240
276
assertFalse (jsonParameters .has (ParseRESTPushCommand .KEY_CHANNELS ));
@@ -265,6 +301,7 @@ public void testBuildRESTSendPushCommandWithPushToIOSAndAndroid() throws Excepti
265
301
266
302
// Verify command
267
303
JSONObject jsonParameters = pushCommand .jsonParameters ;
304
+ assertFalse (jsonParameters .has (ParseRESTPushCommand .KEY_PUSH_TIME ));
268
305
assertFalse (jsonParameters .has (ParseRESTPushCommand .KEY_EXPIRATION_TIME ));
269
306
assertFalse (jsonParameters .has (ParseRESTPushCommand .KEY_EXPIRATION_INTERVAL ));
270
307
assertFalse (jsonParameters .has (ParseRESTPushCommand .KEY_CHANNELS ));
0 commit comments