[Update] rename completableFuture to productDataFuture

This commit is contained in:
@hangga 2023-10-17 18:45:08 +07:00
parent 3f40e66508
commit 223c0bd32f
1 changed files with 9 additions and 9 deletions

View File

@ -160,23 +160,23 @@ class CompletableFutureTimeoutUnitTest {
@Test @Test
void whenorTimeout_thenGetThrow() { void whenorTimeout_thenGetThrow() {
CompletableFuture<String> completableFuture = fetchProductData(); CompletableFuture<String> productDataFuture = fetchProductData();
completableFuture.orTimeout(DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS); productDataFuture.orTimeout(DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS);
assertThrows(ExecutionException.class, completableFuture::get); assertThrows(ExecutionException.class, productDataFuture::get);
} }
@Test @Test
void whencompleteOnTimeout_thenReturnValue() throws ExecutionException, InterruptedException { void whencompleteOnTimeout_thenReturnValue() throws ExecutionException, InterruptedException {
CompletableFuture<String> completableFuture = fetchProductData(); CompletableFuture<String> productDataFuture = fetchProductData();
completableFuture.completeOnTimeout(DEFAULT_PRODUCT, DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS); productDataFuture.completeOnTimeout(DEFAULT_PRODUCT, DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS);
assertEquals(DEFAULT_PRODUCT, completableFuture.get()); assertEquals(DEFAULT_PRODUCT, productDataFuture.get());
} }
@Test @Test
void whencompleteExceptionally_thenGetThrow() { void whencompleteExceptionally_thenGetThrow() {
CompletableFuture<String> completableFuture = fetchProductData(); CompletableFuture<String> productDataFuture = fetchProductData();
executorService.schedule(() -> completableFuture executorService.schedule(() -> productDataFuture
.completeExceptionally(new TimeoutException("Timeout occurred")), DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS); .completeExceptionally(new TimeoutException("Timeout occurred")), DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS);
assertThrows(ExecutionException.class, completableFuture::get); assertThrows(ExecutionException.class, productDataFuture::get);
} }
} }