ibessonov commented on code in PR #1807:
URL: https://github.com/apache/ignite-3/pull/1807#discussion_r1144424579
##########
modules/core/src/test/java/org/apache/ignite/internal/causality/VersionedValueTest.java:
##########
@@ -260,189 +198,47 @@ public void testAutocompleteFuture() throws
OutdatedTokenException {
}
/**
- * Checks that the update method work as expected when the previous value
is known.
- *
- * @throws Exception If failed.
- */
- @Test
- public void testUpdate() throws Exception {
- VersionedValue<Integer> longVersionedValue = new
VersionedValue<>(REGISTER);
-
- longVersionedValue.update(0, (integer, throwable) ->
CompletableFuture.completedFuture(TEST_VALUE));
-
- REGISTER.moveRevision(0L).join();
-
- CompletableFuture<Integer> fut = longVersionedValue.get(1);
-
- assertFalse(fut.isDone());
-
- int incrementCount = 10;
-
- for (int i = 0; i < incrementCount; i++) {
- longVersionedValue.update(1, (previous, e) ->
completedFuture(++previous));
-
- assertFalse(fut.isDone());
- }
-
- REGISTER.moveRevision(1L).join();
-
- assertTrue(fut.isDone());
-
- assertEquals(TEST_VALUE + incrementCount, fut.get());
-
- assertThrows(AssertionError.class, () -> longVersionedValue.update(1L,
(i, t) -> completedFuture(null)));
- }
-
- /**
- * Checks that the update method work as expected when there is no history
to calculate previous value.
- *
- * @throws Exception If failed.
- */
- @Test
- public void testUpdatePredefined() throws Exception {
- VersionedValue<Integer> longVersionedValue = new
VersionedValue<>(REGISTER);
-
- CompletableFuture<Integer> fut = longVersionedValue.get(0);
-
- assertFalse(fut.isDone());
-
- longVersionedValue.update(0, (previous, e) -> {
- assertNull(previous);
-
- return completedFuture(TEST_VALUE);
- });
-
- assertFalse(fut.isDone());
-
- REGISTER.moveRevision(0L).join();
-
- assertTrue(fut.isDone());
-
- assertEquals(TEST_VALUE, fut.get());
- }
-
- /**
- * Test asynchronous update closure.
- */
- @Test
- public void testAsyncUpdate() {
- VersionedValue<Integer> vv = new VersionedValue<>(REGISTER);
-
- CompletableFuture<Integer> fut = new CompletableFuture<>();
-
- vv.update(0L, (v, e) -> fut);
-
- CompletableFuture<Integer> vvFut = vv.get(0L);
-
- CompletableFuture<?> revFut = REGISTER.moveRevision(0L);
-
- assertFalse(fut.isDone());
- assertFalse(vvFut.isDone());
- assertFalse(revFut.isDone());
-
- fut.complete(1);
-
- revFut.join();
-
- assertTrue(vvFut.isDone());
- }
-
- /**
- * Test the case when exception happens in updater.
- */
- @Test
- public void testExceptionOnUpdate() {
- VersionedValue<Integer> vv = new VersionedValue<>(REGISTER, () -> 0);
-
- final int count = 4;
- final int successfulCompletionsCount = count / 2;
-
- AtomicInteger actualSuccessfulCompletionsCount = new AtomicInteger();
-
- final String exceptionMsg = "test msg";
-
- for (int i = 0; i < count; i++) {
- vv.update(0L, (v, e) -> {
- if (e != null) {
- return failedFuture(e);
- }
-
- if (v == successfulCompletionsCount) {
- throw new IgniteInternalException(exceptionMsg);
- }
-
- actualSuccessfulCompletionsCount.incrementAndGet();
-
- return completedFuture(++v);
- });
- }
-
- AtomicReference<Throwable> exceptionRef = new AtomicReference<>();
-
- vv.whenComplete((t, v, e) -> exceptionRef.set(e));
-
- vv.complete(0L);
-
- assertThrowsWithCause(() -> vv.get(0L).join(),
IgniteInternalException.class);
-
- assertThat(exceptionRef.get().getMessage(),
containsString(exceptionMsg));
- }
-
- /**
- * Test with multiple versioned values and asynchronous completion.
+ * Test {@link VersionedValue#whenComplete}.
*/
@Test
- public void testAsyncMultiVv() {
- final String registryName = "Registry";
- final String assignmentName = "Assignment";
- final String tableName = "T1_";
-
- VersionedValue<Map<UUID, String>> tablesVv = new VersionedValue<>(f ->
{}, HashMap::new);
- VersionedValue<Map<UUID, String>> schemasVv = new
VersionedValue<>(REGISTER, HashMap::new);
- VersionedValue<Map<UUID, String>> assignmentsVv = new
VersionedValue<>(REGISTER, HashMap::new);
+ public void testWhenComplete() {
Review Comment:
Ok, I thought there was an abstract class
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]