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() {
9494 return getString (KEY_INSTALLATION_ID );
9595 }
9696
97+ @ Override
98+ public void setObjectId (String newObjectId ) {
99+ throw new RuntimeException ("Installation's objectId cannot be changed" );
100+ }
101+
97102 @ Override
98103 /* package */ boolean needsDefaultACL () {
99104 return false ;
@@ -149,7 +154,7 @@ public Task<Void> then(Task<Void> task) throws Exception {
149154 && task .getError () instanceof ParseException
150155 && ((ParseException ) task .getError ()).getCode () == ParseException .OBJECT_NOT_FOUND ) {
151156 synchronized (mutex ) {
152- setObjectId ( null );
157+ setState ( new State . Builder ( getState ()). objectId ( null ). build () );
153158 markAllFieldsDirty ();
154159 return ParseInstallation .super .saveAsync (sessionToken , toAwait );
155160 }
Original file line number Diff line number Diff line change @@ -323,7 +323,19 @@ public void testLocaleIdentifierSpecialCases() throws Exception {
323323 assertEquals ("en" , installation .getString (KEY_LOCALE_IDENTIFIER ));
324324 }
325325
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 );
326333
334+ ParseInstallation installation = ParseInstallation .getCurrentInstallation ();
335+ assertNotNull (installation );
336+ verify (controller , times (1 )).getAsync ();
337+ installation .setObjectId (null );
338+ }
327339
328340 // TODO(mengyan): Add testFetchAsync, right now we can not test super methods inside
329341 // testFetchAsync
You can’t perform that action at this time.
0 commit comments