File tree 2 files changed +18
-1
lines changed
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 @@ -323,7 +323,19 @@ public void testLocaleIdentifierSpecialCases() throws Exception {
323
323
assertEquals ("en" , installation .getString (KEY_LOCALE_IDENTIFIER ));
324
324
}
325
325
326
+ @ Test (expected = RuntimeException .class )
327
+ public void testSetObjectId () throws Exception {
328
+ ParseCurrentInstallationController controller =
329
+ mock (ParseCurrentInstallationController .class );
330
+ ParseInstallation currentInstallation = new ParseInstallation ();
331
+ when (controller .getAsync ()).thenReturn (Task .forResult (currentInstallation ));
332
+ ParseCorePlugins .getInstance ().registerCurrentInstallationController (controller );
326
333
334
+ ParseInstallation installation = ParseInstallation .getCurrentInstallation ();
335
+ assertNotNull (installation );
336
+ verify (controller , times (1 )).getAsync ();
337
+ installation .setObjectId (null );
338
+ }
327
339
328
340
// TODO(mengyan): Add testFetchAsync, right now we can not test super methods inside
329
341
// testFetchAsync
You can’t perform that action at this time.
0 commit comments