@@ -83,6 +83,7 @@ public void testBuildRESTSendPushCommandWithChannelSet() throws Exception {
8383
8484 // Verify command
8585 JSONObject jsonParameters = pushCommand .jsonParameters ;
86+ assertFalse (jsonParameters .has (ParseRESTPushCommand .KEY_PUSH_TIME ));
8687 assertFalse (jsonParameters .has (ParseRESTPushCommand .KEY_EXPIRATION_TIME ));
8788 assertFalse (jsonParameters .has (ParseRESTPushCommand .KEY_EXPIRATION_INTERVAL ));
8889 // Verify device type and query
@@ -113,6 +114,7 @@ public void testBuildRESTSendPushCommandWithExpirationTime() throws Exception {
113114
114115 // Verify command
115116 JSONObject jsonParameters = pushCommand .jsonParameters ;
117+ assertFalse (jsonParameters .has (ParseRESTPushCommand .KEY_PUSH_TIME ));
116118 assertFalse (jsonParameters .has (ParseRESTPushCommand .KEY_EXPIRATION_INTERVAL ));
117119 assertFalse (jsonParameters .has (ParseRESTPushCommand .KEY_CHANNELS ));
118120 // Verify device type and query
@@ -123,6 +125,36 @@ public void testBuildRESTSendPushCommandWithExpirationTime() throws Exception {
123125 assertEquals (1400000000 , jsonParameters .getLong (ParseRESTPushCommand .KEY_EXPIRATION_TIME ));
124126 }
125127
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+
126158 @ Test
127159 public void testBuildRESTSendPushCommandWithExpirationTimeInterval () throws Exception {
128160 ParseHttpClient restClient = mock (ParseHttpClient .class );
@@ -141,6 +173,7 @@ public void testBuildRESTSendPushCommandWithExpirationTimeInterval() throws Exce
141173
142174 // Verify command
143175 JSONObject jsonParameters = pushCommand .jsonParameters ;
176+ assertFalse (jsonParameters .has (ParseRESTPushCommand .KEY_PUSH_TIME ));
144177 assertFalse (jsonParameters .has (ParseRESTPushCommand .KEY_EXPIRATION_TIME ));
145178 assertFalse (jsonParameters .has (ParseRESTPushCommand .KEY_CHANNELS ));
146179 // Verify device type and query
@@ -172,6 +205,7 @@ public void testBuildRESTSendPushCommandWithQuery() throws Exception {
172205
173206 // Verify command
174207 JSONObject jsonParameters = pushCommand .jsonParameters ;
208+ assertFalse (jsonParameters .has (ParseRESTPushCommand .KEY_PUSH_TIME ));
175209 assertFalse (jsonParameters .has (ParseRESTPushCommand .KEY_EXPIRATION_TIME ));
176210 assertFalse (jsonParameters .has (ParseRESTPushCommand .KEY_EXPIRATION_INTERVAL ));
177211 assertFalse (jsonParameters .getJSONObject (ParseRESTPushCommand .KEY_WHERE )
@@ -206,6 +240,7 @@ public void testBuildRESTSendPushCommandWithPushToAndroid() throws Exception {
206240
207241 // Verify command
208242 JSONObject jsonParameters = pushCommand .jsonParameters ;
243+ assertFalse (jsonParameters .has (ParseRESTPushCommand .KEY_PUSH_TIME ));
209244 assertFalse (jsonParameters .has (ParseRESTPushCommand .KEY_EXPIRATION_TIME ));
210245 assertFalse (jsonParameters .has (ParseRESTPushCommand .KEY_EXPIRATION_INTERVAL ));
211246 assertFalse (jsonParameters .has (ParseRESTPushCommand .KEY_CHANNELS ));
@@ -235,6 +270,7 @@ public void testBuildRESTSendPushCommandWithPushToIOS() throws Exception {
235270
236271 // Verify command
237272 JSONObject jsonParameters = pushCommand .jsonParameters ;
273+ assertFalse (jsonParameters .has (ParseRESTPushCommand .KEY_PUSH_TIME ));
238274 assertFalse (jsonParameters .has (ParseRESTPushCommand .KEY_EXPIRATION_TIME ));
239275 assertFalse (jsonParameters .has (ParseRESTPushCommand .KEY_EXPIRATION_INTERVAL ));
240276 assertFalse (jsonParameters .has (ParseRESTPushCommand .KEY_CHANNELS ));
@@ -265,6 +301,7 @@ public void testBuildRESTSendPushCommandWithPushToIOSAndAndroid() throws Excepti
265301
266302 // Verify command
267303 JSONObject jsonParameters = pushCommand .jsonParameters ;
304+ assertFalse (jsonParameters .has (ParseRESTPushCommand .KEY_PUSH_TIME ));
268305 assertFalse (jsonParameters .has (ParseRESTPushCommand .KEY_EXPIRATION_TIME ));
269306 assertFalse (jsonParameters .has (ParseRESTPushCommand .KEY_EXPIRATION_INTERVAL ));
270307 assertFalse (jsonParameters .has (ParseRESTPushCommand .KEY_CHANNELS ));
0 commit comments