Skip to content

Commit 0f4d2fe

Browse files
authored
Using the encoder on state is too broad. (#18)
Related to issue: #14 Currently only the conditions and class name are encoded: https://github.com/ParsePlatform/ParseLiveQuery-iOS-OSX/blob/master/Sources/ParseLiveQuery/Internal/QueryEncoder.swift fix test
1 parent ea2892f commit 0f4d2fe

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

ParseLiveQuery/src/main/java/com/parse/SubscribeClientOperation.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,14 @@
2222
jsonObject.put("requestId", requestId);
2323
jsonObject.put("sessionToken", sessionToken);
2424

25-
JSONObject queryJsonObject = state.toJSON(PointerEncoder.get());
25+
JSONObject queryJsonObject = new JSONObject();
26+
queryJsonObject.put("className", state.className());
27+
28+
// TODO: add support for fields
29+
// https://github.com/ParsePlatform/parse-server/issues/3671
30+
31+
PointerEncoder pointerEncoder = PointerEncoder.get();
32+
queryJsonObject.put("where", pointerEncoder.encode(state.constraints()));
2633

2734
jsonObject.put("query", queryJsonObject);
2835

ParseLiveQuery/src/test/java/com/parse/TestParseLiveQueryClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public void testUnsubscribeWhenSubscribedToCallback() throws Exception {
117117
@Test
118118
public void testErrorWhileSubscribing() throws Exception {
119119
ParseQuery.State state = mock(ParseQuery.State.class);
120-
when(state.toJSON(any(ParseEncoder.class))).thenThrow(new RuntimeException("forced error"));
120+
when(state.constraints()).thenThrow(new RuntimeException("forced error"));
121121

122122
ParseQuery.State.Builder builder = mock(ParseQuery.State.Builder.class);
123123
when(builder.build()).thenReturn(state);

0 commit comments

Comments
 (0)