File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -94,6 +94,11 @@ public String getInstallationId() {
94
94
return getString (KEY_INSTALLATION_ID );
95
95
}
96
96
97
+ @ Override
98
+ public void setObjectId (String newObjectId ) {
99
+ throw new RuntimeException ("Installation's objectId cannot be changed" );
100
+ }
101
+
97
102
@ Override
98
103
/* package */ boolean needsDefaultACL () {
99
104
return false ;
@@ -149,7 +154,7 @@ public Task<Void> then(Task<Void> task) throws Exception {
149
154
&& task .getError () instanceof ParseException
150
155
&& ((ParseException ) task .getError ()).getCode () == ParseException .OBJECT_NOT_FOUND ) {
151
156
synchronized (mutex ) {
152
- setObjectId ( null );
157
+ setState ( new State . Builder ( getState ()). objectId ( null ). build () );
153
158
markAllFieldsDirty ();
154
159
return ParseInstallation .super .saveAsync (sessionToken , toAwait );
155
160
}
Original file line number Diff line number Diff line change @@ -319,7 +319,19 @@ public void testLocaleIdentifierSpecialCases() throws Exception {
319
319
assertEquals ("en" , installation .getString (KEY_LOCALE_IDENTIFIER ));
320
320
}
321
321
322
+ @ Test (expected = RuntimeException .class )
323
+ public void testSetObjectId () throws Exception {
324
+ ParseCurrentInstallationController controller =
325
+ mock (ParseCurrentInstallationController .class );
326
+ ParseInstallation currentInstallation = new ParseInstallation ();
327
+ when (controller .getAsync ()).thenReturn (Task .forResult (currentInstallation ));
328
+ ParseCorePlugins .getInstance ().registerCurrentInstallationController (controller );
322
329
330
+ ParseInstallation installation = ParseInstallation .getCurrentInstallation ();
331
+ assertNotNull (installation );
332
+ verify (controller , times (1 )).getAsync ();
333
+ installation .setObjectId (null );
334
+ }
323
335
324
336
// TODO(mengyan): Add testFetchAsync, right now we can not test super methods inside
325
337
// testFetchAsync
You can’t perform that action at this time.
0 commit comments