@Test
public void testSetLimitsFrom() {

    final ExecuteProperties base = ExecuteProperties.newBuilder()
            .setIsolationLevel(IsolationLevel.SNAPSHOT) // not the default
            .setReturnedRowLimit(ROW_LIMIT)
            .setTimeLimit(TIME_LIMIT)
            .setScannedRecordsLimit(RECORD_SCAN_LIMIT)
            .build();
    final ExecuteProperties merge1 = base.setLimitsFrom(ExecuteProperties.newBuilder()
            .setReturnedRowLimit(ROW_LIMIT + 1)
            .build());
    assertEquals(ROW_LIMIT + 1, merge1.getReturnedRowLimit());
    assertEquals(TIME_LIMIT, merge1.getTimeLimit());
    assertEquals(base.getState(), merge1.getState());
    final ExecuteProperties merge2 = base.setLimitsFrom(ExecuteProperties.newBuilder()
            .setTimeLimit(TIME_LIMIT + 1)
            .build());
    assertEquals(ROW_LIMIT, merge2.getReturnedRowLimit());
    assertEquals(TIME_LIMIT + 1, merge2.getTimeLimit());
    assertEquals(base.getState(), merge2.getState());
    final ExecuteProperties merge3 = base.setLimitsFrom(ExecuteProperties.newBuilder()
            .setScannedRecordsLimit(RECORD_SCAN_LIMIT + 1)
            .build());
    assertEquals(ROW_LIMIT, merge3.getReturnedRowLimit());
    assertEquals(TIME_LIMIT, merge3.getTimeLimit());
    assertNotEquals(base.getState(), merge3.getState());
    for (int i = 0; i < RECORD_SCAN_LIMIT + 1; i++) {
        // verify that the record scan limit really is RECORD_SCAN_LIMIT + 1
        assertTrue(merge3.getState().getRecordScanLimiter().tryRecordScan());
    }
    // verify that the record scan limit really is RECORD_SCAN_LIMIT + 1
    assertFalse(merge3.getState().getRecordScanLimiter().tryRecordScan());
}