diff --git a/src/test/java/com/github/brenoepics/at4j/core/AzureApiImplTest.java b/src/test/java/com/github/brenoepics/at4j/core/AzureApiImplTest.java index 2c397c3..c1aa74a 100644 --- a/src/test/java/com/github/brenoepics/at4j/core/AzureApiImplTest.java +++ b/src/test/java/com/github/brenoepics/at4j/core/AzureApiImplTest.java @@ -1,27 +1,28 @@ package com.github.brenoepics.at4j.core; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.when; - import com.github.brenoepics.at4j.data.Translation; import com.github.brenoepics.at4j.data.request.TranslateParams; import com.github.brenoepics.at4j.data.response.TranslationResponse; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.mockito.Mock; + import java.util.Collections; import java.util.Optional; import java.util.concurrent.CompletableFuture; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.mockito.Mockito; -class AzureApiImplTest { +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.when; + +class AzureApiImplTest { - private AzureApiImpl azureApi; + @Mock + private AzureApiImpl azureApi; private TranslateParams translateParams; @BeforeEach public void setup() { - azureApi = Mockito.mock(AzureApiImpl.class); translateParams = new TranslateParams("Hello", Collections.singleton("pt")).setSourceLanguage("en"); } diff --git a/src/test/java/com/github/brenoepics/at4j/core/ratelimit/RateLimitManagerTest.java b/src/test/java/com/github/brenoepics/at4j/core/ratelimit/RateLimitManagerTest.java index b9c853b..64002a6 100644 --- a/src/test/java/com/github/brenoepics/at4j/core/ratelimit/RateLimitManagerTest.java +++ b/src/test/java/com/github/brenoepics/at4j/core/ratelimit/RateLimitManagerTest.java @@ -10,6 +10,7 @@ import okhttp3.Response; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.function.Executable; import org.mockito.Mock; import org.mockito.MockitoAnnotations; @@ -123,9 +124,15 @@ void handleResponseDoesNotUpdateBucketInformationWhenResponseCodeIs429AndViaHead @Test void handleCurrentRequestThrowsException() throws AzureException, IOException { - when(request.executeBlocking()).thenThrow(new RuntimeException()); + // Arrange + RuntimeException expectedException = new RuntimeException(); + when(request.executeBlocking()).thenThrow(expectedException); - assertThrows(RuntimeException.class, () -> rateLimitManager.handleCurrentRequest(result, request, bucket, System.currentTimeMillis())); + // Act + Executable executable = () -> rateLimitManager.handleCurrentRequest(result, request, bucket, System.currentTimeMillis()); + + // Assert + assertThrows(RuntimeException.class, executable); }