diff --git a/pom.xml b/pom.xml index 9643e3c..80c2a14 100644 --- a/pom.xml +++ b/pom.xml @@ -110,12 +110,6 @@ guava 33.0.0-jre - - junit - junit - 4.13.2 - test - org.junit.jupiter junit-jupiter @@ -194,20 +188,6 @@ - - - maven-source-plugin - 3.3.0 - - - attach-source - compile - - jar-no-fork - - - - org.apache.maven.plugins @@ -222,12 +202,12 @@ - - - --pinentry-mode - loopback - - + + + --pinentry-mode + loopback + + org.sonatype.central diff --git a/src/test/java/io/github/brenoepics/at4j/AT4JTest.java b/src/test/java/io/github/brenoepics/at4j/AT4JTest.java index f212828..5516c54 100644 --- a/src/test/java/io/github/brenoepics/at4j/AT4JTest.java +++ b/src/test/java/io/github/brenoepics/at4j/AT4JTest.java @@ -1,15 +1,16 @@ package io.github.brenoepics.at4j; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import org.junit.jupiter.api.Test; import java.lang.reflect.Field; -import org.junit.Test; -public class AT4JTest { +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +class AT4JTest { @Test - public void testVersionFields() throws NoSuchFieldException, IllegalAccessException { + void testVersionFields() throws NoSuchFieldException, IllegalAccessException { Field versionField = AT4J.class.getDeclaredField("VERSION"); versionField.setAccessible(true); String version = (String) versionField.get(null); @@ -27,7 +28,7 @@ public void testVersionFields() throws NoSuchFieldException, IllegalAccessExcept } @Test - public void testAzureTranslatorApiVersion() { + void testAzureTranslatorApiVersion() { assertEquals("3.0", AT4J.AZURE_TRANSLATOR_API_VERSION); } } diff --git a/src/test/java/io/github/brenoepics/at4j/AzureApiTest.java b/src/test/java/io/github/brenoepics/at4j/AzureApiTest.java index 1c22d13..be964a6 100644 --- a/src/test/java/io/github/brenoepics/at4j/AzureApiTest.java +++ b/src/test/java/io/github/brenoepics/at4j/AzureApiTest.java @@ -1,7 +1,5 @@ package io.github.brenoepics.at4j; -import static org.junit.Assert.*; - import io.github.brenoepics.at4j.azure.BaseURL; import io.github.brenoepics.at4j.azure.lang.Language; import io.github.brenoepics.at4j.data.request.AvailableLanguagesParams; @@ -14,24 +12,26 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionException; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; + -public class AzureApiTest { +class AzureApiTest { @Test - public void BuildNullKey() { +void BuildNullKey() { AzureApiBuilder builder = new AzureApiBuilder(); - assertThrows("Subscription key cannot be null", NullPointerException.class, builder::build); + assertThrows(NullPointerException.class, builder::build, "Subscription key cannot be null"); } @Test - public void buildApi() { +void buildApi() { AzureApi api = new AzureApiBuilder().setKey("test").region("test").build(); assertNotNull(api); api.disconnect(); } @Test - public void getLanguages() { +void getLanguages() { AzureApi api = new AzureApiBuilder().baseURL(BaseURL.GLOBAL).setKey("test").region("test").build(); @@ -43,7 +43,7 @@ public void getLanguages() { } @Test - public void getLanguagesEmptyKey() { +void getLanguagesEmptyKey() { AzureApi api = new AzureApiBuilder().baseURL(BaseURL.GLOBAL).setKey("").region("test").build(); CompletableFuture>> languages = @@ -53,7 +53,7 @@ public void getLanguagesEmptyKey() { } @Test - public void getLanguagesEmptySourceLanguage() { +void getLanguagesEmptySourceLanguage() { AzureApi api = new AzureApiBuilder().baseURL(BaseURL.GLOBAL).setKey("test").region("test").build(); @@ -64,7 +64,7 @@ public void getLanguagesEmptySourceLanguage() { } @Test - public void translateEmptyKey() { +void translateEmptyKey() { AzureApi api = new AzureApiBuilder().baseURL(BaseURL.GLOBAL).setKey("").region("test").build(); TranslateParams params = new TranslateParams("test", List.of("pt")).setSourceLanguage("en"); @@ -74,7 +74,7 @@ public void translateEmptyKey() { } @Test - public void translateEmptyText() { +void translateEmptyText() { AzureApi api = new AzureApiBuilder().baseURL(BaseURL.GLOBAL).setKey("test").build(); TranslateParams params = new TranslateParams("", List.of("pt")).setSourceLanguage("en"); @@ -85,7 +85,7 @@ public void translateEmptyText() { } @Test - public void translateEmptySourceLanguage() { +void translateEmptySourceLanguage() { AzureApi api = new AzureApiBuilder().baseURL(BaseURL.GLOBAL).setKey("test").build(); TranslateParams params = new TranslateParams("", List.of("pt")).setTargetLanguages("pt"); diff --git a/src/test/java/io/github/brenoepics/at4j/core/AzureApiImplTest.java b/src/test/java/io/github/brenoepics/at4j/core/AzureApiImplTest.java index 80c5c89..86eb82e 100644 --- a/src/test/java/io/github/brenoepics/at4j/core/AzureApiImplTest.java +++ b/src/test/java/io/github/brenoepics/at4j/core/AzureApiImplTest.java @@ -34,7 +34,7 @@ void returnsEmptyOnInvalidInput() { .whenComplete( (response, throwable) -> { if (throwable != null) { - assertTrue(throwable instanceof AzureException); + assertInstanceOf(AzureException.class, throwable); assertEquals("Text is required", throwable.getMessage()); } }); diff --git a/src/test/java/io/github/brenoepics/at4j/util/logging/PrivacyProtectionLoggerTest.java b/src/test/java/io/github/brenoepics/at4j/util/logging/PrivacyProtectionLoggerTest.java deleted file mode 100644 index 6d41418..0000000 --- a/src/test/java/io/github/brenoepics/at4j/util/logging/PrivacyProtectionLoggerTest.java +++ /dev/null @@ -1,43 +0,0 @@ -package io.github.brenoepics.at4j.util.logging; - -import org.apache.logging.log4j.Level; -import org.apache.logging.log4j.Marker; -import org.apache.logging.log4j.message.SimpleMessage; -import org.apache.logging.log4j.spi.AbstractLogger; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.mockito.Mockito; - -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -class PrivacyProtectionLoggerTest { - private AbstractLogger delegate; - private PrivacyProtectionLogger privacyProtectionLogger; - - @BeforeEach - public void setup() { - delegate = Mockito.mock(AbstractLogger.class); - privacyProtectionLogger = new PrivacyProtectionLogger(delegate); - } - - @Test - void shouldLogMessageWithPrivateDataReplaced() { - Marker marker = Mockito.mock(Marker.class); - String privateData = "privateData"; - String message = "This is a test message with " + privateData; - Exception throwable = new NullPointerException(""); - PrivacyProtectionLogger.addPrivateData(privateData); - privacyProtectionLogger.logMessage( - null, Level.INFO, marker, new SimpleMessage(message), throwable); - verify(delegate).log(Level.INFO, marker, "This is a test message with **********", throwable); - } - - @Test - void shouldDelegateIsEnabledCalls() { - Marker marker = Mockito.mock(Marker.class); - when(delegate.isEnabled(Level.INFO, marker)).thenReturn(true); - assertTrue(privacyProtectionLogger.isEnabled(Level.INFO, marker, "message")); - } -}