Skip to content

Commit 712b168

Browse files
committed
minor fixes & update test
1 parent 6727f84 commit 712b168

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

Parse/src/main/java/com/parse/ParseInstallation.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
public class ParseInstallation extends ParseObject {
3131
private static final String TAG = "com.parse.ParseInstallation";
3232

33+
private static final String KEY_OBJECT_ID = "objectId";
3334
private static final String KEY_INSTALLATION_ID = "installationId";
3435
private static final String KEY_DEVICE_TYPE = "deviceType";
3536
private static final String KEY_APP_NAME = "appName";
@@ -45,7 +46,7 @@ public class ParseInstallation extends ParseObject {
4546
private static final List<String> READ_ONLY_FIELDS = Collections.unmodifiableList(
4647
Arrays.asList(KEY_DEVICE_TYPE, KEY_INSTALLATION_ID, KEY_DEVICE_TOKEN, KEY_PUSH_TYPE,
4748
KEY_TIME_ZONE, KEY_LOCALE, KEY_APP_VERSION, KEY_APP_NAME, KEY_PARSE_VERSION,
48-
KEY_APP_IDENTIFIER));
49+
KEY_APP_IDENTIFIER, KEY_OBJECT_ID));
4950

5051
// TODO(mengyan): Inject into ParseInstallationInstanceController
5152
/* package */ static ParseCurrentInstallationController getCurrentInstallationController() {

Parse/src/test/java/com/parse/ParseInstallationTest.java

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,20 @@ public void testImmutableKeys() {
106106
}
107107
}
108108

109+
@Test (expected = RuntimeException.class)
110+
public void testInstallationObjectIdCannotBeChanged() throws Exception {
111+
boolean hasException = false;
112+
ParseInstallation installation = new ParseInstallation();
113+
try {
114+
installation.put("objectId", "abc");
115+
} catch (IllegalArgumentException e) {
116+
assertTrue(e.getMessage().contains("Cannot modify"));
117+
hasException = true;
118+
}
119+
assertTrue(hasException);
120+
installation.setObjectId("abc");
121+
}
122+
109123
@Test
110124
public void testSaveAsync() throws Exception {
111125
String sessionToken = "sessionToken";
@@ -319,19 +333,7 @@ public void testLocaleIdentifierSpecialCases() throws Exception {
319333
assertEquals("en", installation.getString(KEY_LOCALE_IDENTIFIER));
320334
}
321335

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);
329336

330-
ParseInstallation installation = ParseInstallation.getCurrentInstallation();
331-
assertNotNull(installation);
332-
verify(controller, times(1)).getAsync();
333-
installation.setObjectId(null);
334-
}
335337

336338
// TODO(mengyan): Add testFetchAsync, right now we can not test super methods inside
337339
// testFetchAsync

0 commit comments

Comments
 (0)