QueryTaskClientHelper { private static void assertNotNull(Object value, String propertyName) { if (value == null) { throw new IllegalArgumentException("'" + propertyName + "' is required"); } } private  QueryTaskClientHelper(Class<T> type); static QueryTaskClientHelper<T> create(Class<T> type); QueryTaskClientHelper<T> setDocumentLink(String documentSelfLink); QueryTaskClientHelper<T> setUpdatedDocumentSince(long documentSinceUpdateTimeMicros,
            String documentSelfLink); QueryTaskClientHelper<T> setUpdatedSince(long documentSinceUpdateTimeMicros); QueryTaskClientHelper<T> sendWith(ServiceHost serviceHost); QueryTaskClientHelper<T> sendWith(Service service); QueryTaskClientHelper<T> setQueryTask(QueryTask queryTask); QueryTaskClientHelper<T> setBaseUri(URI baseUri); QueryTaskClientHelper<T> setFactoryPath(String factoryPath); QueryTaskClientHelper<T> setResultHandler(ResultHandler<T> resultHandler); static long getDefaultQueryExpiration(); QueryElementResult<T> result(Object json, long count); static QueryElementResult<S> resultLink(
            String selfLink, long count); static QueryElementResult<S> countResult(
            long count); static QueryElementResult<S> noResult(); static final long QUERY_RETRIEVAL_RETRY_INTERVAL_MICROS; static final long DEFAULT_EXPIRATION_TIME_IN_MICROS; static final Integer DEFAULT_QUERY_RESULT_LIMIT; }
@Test public void testQueryUpdatedSince() throws Throwable { long startTime = Utils.getNowMicrosUtc(); MinimalTestServiceState minimalTestState = new MinimalTestServiceState(); minimalTestState.id = this.idValue1; minimalTestState = doPost(minimalTestState); MinimalTestServiceState minimalTestState1 = new MinimalTestServiceState(); minimalTestState1.id = this.idValue1; minimalTestState1 = doPost(minimalTestState1); this.minimalTestStates = queryUpdatedSince(startTime); int countAfterMinState1 = 2; assertEquals(countAfterMinState1, this.minimalTestStates.size()); long timeAfterMinState1 = Utils.getNowMicrosUtc(); minimalTestState = new MinimalTestServiceState(); minimalTestState.id = this.idValue2; doPost(minimalTestState); MinimalTestServiceState minimalTestState2 = new MinimalTestServiceState(); minimalTestState2.id = this.idValue2; minimalTestState2 = doPost(minimalTestState2); this.minimalTestStates = queryUpdatedSince(startTime); int countAfterMinState2 = 2; assertEquals(countAfterMinState1 + countAfterMinState2, this.minimalTestStates.size()); long timeAfterMinState2 = Utils.getNowMicrosUtc(); this.minimalTestStates = queryUpdatedSince(timeAfterMinState1); assertEquals(countAfterMinState2, this.minimalTestStates.size()); boolean match = false; for (MinimalTestServiceState state : this.minimalTestStates) { if (minimalTestState2.documentSelfLink.equals(state.documentSelfLink)) { assertNotNull(minimalTestState2.id); match = true; } } assertTrue(match); this.minimalTestStates = queryUpdatedSince(timeAfterMinState2); assertEquals(0, this.minimalTestStates.size()); long timeBeforeDeletion = Utils.getNowMicrosUtc(); delete(minimalTestState1); this.minimalTestStates = queryUpdatedSince(startTime); assertEquals(countAfterMinState1 + countAfterMinState2, this.minimalTestStates.size()); boolean deleted = false; for (MinimalTestServiceState state : this.minimalTestStates) { if (minimalTestState1.documentSelfLink.equals(state.documentSelfLink)) { assertTrue(ServiceDocument.isDeleted(state)); deleted = true; } } assertTrue(deleted); delete(minimalTestState2); this.minimalTestStates = queryUpdatedSince(timeBeforeDeletion); assertEquals(countAfterMinState1 + countAfterMinState2 - 2, this.minimalTestStates.size()); for (MinimalTestServiceState state : this.minimalTestStates) { assertTrue(ServiceDocument.isDeleted(state)); } this.minimalTestStates = queryUpdatedSince(Utils.getNowMicrosUtc()); assertEquals(0, this.minimalTestStates.size()); }