From 41086595b3da90a01ed978d162a714189546f43d Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Thu, 26 Apr 2018 18:14:44 -0700 Subject: [PATCH] Updating Watch conformance tests (#3202) --- .../com/google/cloud/firestore/Watch.java | 5 +++-- .../cloud/firestore/ConformanceTest.java | 20 +++++++++++++----- .../src/test/resources/test-suite.binproto | Bin 31195 -> 37901 bytes 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Watch.java b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Watch.java index 9ca47be390de..cca1f379b646 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Watch.java +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Watch.java @@ -196,8 +196,9 @@ public synchronized void onNext(ListenResponse listenResponse) { } break; case ADD: - Preconditions.checkState( - WATCH_TARGET_ID == change.getTargetIds(0), "Target ID must be 0xD0"); + if (WATCH_TARGET_ID != change.getTargetIds(0)) { + closeStream(FirestoreException.invalidState("Target ID must be 0x01")); + } break; case REMOVE: Status status = diff --git a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/ConformanceTest.java b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/ConformanceTest.java index 1a5a1be41942..71c37e69cd5e 100644 --- a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/ConformanceTest.java +++ b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/ConformanceTest.java @@ -439,7 +439,7 @@ private void runQueryTest(TestDefinition.QueryTest testCase) { } } - private void runWatchTest(TestDefinition.ListenTest testCase) + private void runWatchTest(final TestDefinition.ListenTest testCase) throws ExecutionException, InterruptedException { final SettableApiFuture testCaseStarted = SettableApiFuture.create(); final SettableApiFuture testCaseFinished = SettableApiFuture.create(); @@ -464,10 +464,20 @@ public ApiStreamObserver answer(InvocationOnMock invocationOnMock public void onEvent( @Nullable QuerySnapshot actualSnapshot, @Nullable FirestoreException error) { try { - Assert.assertFalse(expectedSnapshots.isEmpty()); - Snapshot expectedSnapshot = expectedSnapshots.remove(0); - Assert.assertEquals(convertQuerySnapshot(expectedSnapshot), actualSnapshot); - if (expectedSnapshots.isEmpty()) { + if (actualSnapshot != null) { + Assert.assertNull(error); + Assert.assertFalse(expectedSnapshots.isEmpty()); + Snapshot expectedSnapshot = expectedSnapshots.remove(0); + Assert.assertEquals(convertQuerySnapshot(expectedSnapshot), actualSnapshot); + if (expectedSnapshots.isEmpty()) { + if (!testCase.getIsError()) { + testCaseFinished.set(null); + } + } + } else { // Error case + Assert.assertNotNull(error); + Assert.assertTrue(expectedSnapshots.isEmpty()); + Assert.assertTrue(testCase.getIsError()); testCaseFinished.set(null); } } catch (AssertionError e) { diff --git a/google-cloud-firestore/src/test/resources/test-suite.binproto b/google-cloud-firestore/src/test/resources/test-suite.binproto index 917804995759c729f9c9da155a0ed6903d4fdf09..c3a4962d0cf41125163a5b1ebd0ae28198d7b229 100644 GIT binary patch delta 1885 zcmaJ?PiPcZ80Wniv$M}?lSfH6X`?TKC@~gYb(2`dNOn`*sMR$|E2X5<&fDzZ?#yIn zHoNPg^-w82^z=ZarydKv6oiVG{sBP>rO-oZA)vH}9(ofIZ^rk{%-f8vW-jx1^WOLU ze!uVgeY5ruef2H={wNj|yjT1@le>8ZH{RG@rMQ0!$q=+G7kxJ$jr{k)A#zJ6`|5TO za_1;>ToyQ{7u4L4*;Ur!%yOMQAqzNXGYgeU>D+wz3te1wE15p3=dpq0`q-X4l`%~j z6A#O+UD&{52oarPLnHAyOn<{f9Q00$Pur8U_q-VQE{W03F|+qmZe2ZyAsHW&KPf3F z#EoV>w7oh2{iNC8P8f_c)3UfV&MaQ%A-9<6Sgh$;rd*f5rV?;T{M62hYpoOF!w!}2 z1@UF;ZF0CvLJX|r#AojDp(AQbPk15VHMMI({NWWchsgWGi{ye_Prlg?{I~Wir0W0_ zgwW&#kZ7o<N7wmG6csj2)&)uqP^7I#{BoPOonPJtxGS76nZsD)ODCG2WgQ=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