@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());
}