QueryTaskClientHelper { public QueryTaskClientHelper<T> setUpdatedSince(long documentSinceUpdateTimeMicros) { long nowMicrosUtc = Utils.getNowMicrosUtc(); if (nowMicrosUtc < documentSinceUpdateTimeMicros) { throw new IllegalArgumentException( "'documentSinceUpdateTimeMicros' must be in the past."); } Query query = Builder.create().addKindFieldClause(this.type) .addClause(createUpdatedSinceTimeRange(documentSinceUpdateTimeMicros)).build(); QueryTask q = QueryTask.Builder.createDirectTask() .addOption(QueryOption.EXPAND_CONTENT) .addOption(QueryOption.INCLUDE_DELETED) .setResultLimit(DEFAULT_QUERY_RESULT_LIMIT) .setQuery(query).build(); setQueryTask(q); return this; } 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 testQueryUpdatedDocumentSince() throws Throwable { long futureDate = Utils.getNowMicrosUtc() + TimeUnit.DAYS.toMicros(1); try { this.queryHelper.setUpdatedSince(futureDate); fail("IllegalArgumentException expected when date in future."); } catch (IllegalArgumentException e) { } long startTime = Utils.getNowMicrosUtc(); this.minimalTestStates = queryDocumentUpdatedSince(startTime, "testLink"); assertEquals(0, this.minimalTestStates.size()); MinimalTestServiceState minimalTestState = new MinimalTestServiceState(); minimalTestState.id = this.idValue1; minimalTestState = doPost(minimalTestState); long timeAfterPost = Utils.getNowMicrosUtc(); this.minimalTestStates = queryDocumentUpdatedSince(startTime, "testLink"); assertEquals(0, this.minimalTestStates.size()); this.minimalTestStates = queryDocumentUpdatedSince(timeAfterPost, minimalTestState.documentSelfLink); assertEquals(0, this.minimalTestStates.size()); this.minimalTestStates = queryDocumentUpdatedSince(startTime, minimalTestState.documentSelfLink); assertEquals(1, this.minimalTestStates.size()); minimalTestState.id = this.idValue2; minimalTestState = doPatch(minimalTestState); assertEquals(this.idValue2, minimalTestState.id); long timeAfterPatch = Utils.getNowMicrosUtc(); this.minimalTestStates = queryDocumentUpdatedSince(timeAfterPost, minimalTestState.documentSelfLink); assertEquals(1, this.minimalTestStates.size()); assertEquals(this.idValue2, this.minimalTestStates.get(0).id); this.minimalTestStates = queryDocumentUpdatedSince(timeAfterPatch, minimalTestState.documentSelfLink); assertEquals(0, this.minimalTestStates.size()); delete(minimalTestState); long timeAfterDelete = Utils.getNowMicrosUtc(); this.minimalTestStates = queryDocumentUpdatedSince(timeAfterPatch, minimalTestState.documentSelfLink); assertEquals(1, this.minimalTestStates.size()); assertTrue(ServiceDocument.isDeleted(this.minimalTestStates.get(0))); this.minimalTestStates = queryDocumentUpdatedSince(timeAfterDelete, minimalTestState.documentSelfLink); assertEquals(0, this.minimalTestStates.size()); }