Skip to content

Commit

Permalink
Add example for AFTER crud operations option
Browse files Browse the repository at this point in the history
- Add example-test

Closes #454
  • Loading branch information
nickkkccc committed Jan 19, 2024
1 parent 14e051a commit a4bc5af
Showing 1 changed file with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -174,4 +174,38 @@ public void withModeTest() throws ExecutionException, InterruptedException {
crudSelectOpts = client.eval("return crud_select_opts").get();
assertEquals(Mode.WRITE.value(), ((HashMap<?, ?>) crudSelectOpts.get(0)).get("mode"));
}

@Test
public void withAfterTest() {
TarantoolSpaceOperations<TarantoolTuple, TarantoolResult<TarantoolTuple>> profileSpace =
client.space(TEST_SPACE_NAME);

TarantoolResult<TarantoolTuple> emptyResult = profileSpace.select(Conditions.any()).join();
assertEquals(0, emptyResult.size());

TarantoolTuple tuple;
TarantoolTuple insertedTuple;
final int tupleCount = 100;
for (int i = 0; i < tupleCount; i++) {
tuple = tupleFactory.create(i, null, String.valueOf(i), i);
insertedTuple = profileSpace.insert(tuple).join().get(0);
assertEquals(insertedTuple.getObject(0), tuple.getObject(0));
assertEquals(insertedTuple.getObject(2), tuple.getObject(2));
assertEquals(insertedTuple.getObject(3), tuple.getObject(3));
assertEquals(insertedTuple.getObject(4), tuple.getObject(4));
}

TarantoolResult<TarantoolTuple> resultAfterInsert = profileSpace.select(Conditions.any()).join();
assertEquals(tupleCount, resultAfterInsert.size());

final int halfOfTupleCount = tupleCount / 2;
TarantoolTuple afterTuple = tupleFactory.create(halfOfTupleCount,
null,
String.valueOf(halfOfTupleCount),
halfOfTupleCount);

TarantoolResult<TarantoolTuple> resultAfterInsertWithAfterOption =
profileSpace.select(Conditions.after(afterTuple)).join();
assertEquals(halfOfTupleCount - 1, resultAfterInsertWithAfterOption.size());
}
}

0 comments on commit a4bc5af

Please sign in to comment.