Skip to content

Commit 1e081c8

Browse files
committed
minor fixes & update test
1 parent bcc1134 commit 1e081c8

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
@@ -110,6 +110,20 @@ public void testImmutableKeys() {
110110
}
111111
}
112112

113+
@Test (expected = RuntimeException.class)
114+
public void testInstallationObjectIdCannotBeChanged() throws Exception {
115+
boolean hasException = false;
116+
ParseInstallation installation = new ParseInstallation();
117+
try {
118+
installation.put("objectId", "abc");
119+
} catch (IllegalArgumentException e) {
120+
assertTrue(e.getMessage().contains("Cannot modify"));
121+
hasException = true;
122+
}
123+
assertTrue(hasException);
124+
installation.setObjectId("abc");
125+
}
126+
113127
@Test
114128
public void testSaveAsync() throws Exception {
115129
String sessionToken = "sessionToken";
@@ -323,19 +337,7 @@ public void testLocaleIdentifierSpecialCases() throws Exception {
323337
assertEquals("en", installation.getString(KEY_LOCALE_IDENTIFIER));
324338
}
325339

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

334-
ParseInstallation installation = ParseInstallation.getCurrentInstallation();
335-
assertNotNull(installation);
336-
verify(controller, times(1)).getAsync();
337-
installation.setObjectId(null);
338-
}
339341

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

0 commit comments

Comments
 (0)