[Update] rename completableFuture to productDataFuture
This commit is contained in:
parent
3f40e66508
commit
223c0bd32f
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue