Skip to content

Commit ee641a8

Browse files
committed
Using the encoder on state is too broad.
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 948563c commit ee641a8

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

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

+8-1
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

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public void testUnsubscribeWhenSubscribedToCallback() throws Exception {
116116
@Test
117117
public void testErrorWhileSubscribing() throws Exception {
118118
ParseQuery.State state = mock(ParseQuery.State.class);
119-
when(state.toJSON(any(ParseEncoder.class))).thenThrow(new RuntimeException("forced error"));
119+
when(state.constraints()).thenThrow(new RuntimeException("forced error"));
120120

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

0 commit comments

Comments
 (0)