diff --git a/build.gradle b/build.gradle index 8c004ec7..7d9da01f 100644 --- a/build.gradle +++ b/build.gradle @@ -20,11 +20,6 @@ group = 'com.meilisearch.sdk' archivesBaseName = 'meilisearch-java' version = '0.14.7' -java { - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 -} - jacoco { toolVersion = "0.8.8" reportsDirectory = layout.buildDirectory.dir("$projectDir/tmp/coverage") @@ -56,10 +51,10 @@ dependencies { api 'com.squareup.okhttp3:okhttp:4.12.0' // Use JUnit test framework - testImplementation(platform('org.junit:junit-bom:5.11.4')) - testImplementation('org.junit.jupiter:junit-jupiter:5.11.4') + testImplementation(platform('org.junit:junit-bom:5.13.0')) + testImplementation('org.junit.jupiter:junit-jupiter:5.13.0') // https://mvnrepository.com/artifact/org.mockito/mockito-core - testImplementation 'org.mockito:mockito-core:4.9.0' + testImplementation 'org.mockito:mockito-core:4.11.0' testImplementation 'org.hamcrest:hamcrest:3.0' testImplementation 'com.squareup.okio:okio:3.12.0' testImplementation 'com.squareup.okhttp3:okhttp:4.12.0' @@ -92,13 +87,12 @@ task buildJar(type: Jar) { } test { - finalizedBy jacocoTestReport useJUnitPlatform { - excludeTags('integration') + excludeTags 'integration' } - + finalizedBy jacocoTestReport testLogging { - events 'passed', 'skipped', 'failed' + events 'passed', 'skipped', 'failed' } } @@ -114,7 +108,7 @@ jacocoTestReport { task integrationTest(type: Test) { useJUnitPlatform { - includeTags('integration') + includeTags 'integration' } testLogging { events 'passed', 'skipped', 'failed' @@ -123,10 +117,17 @@ task integrationTest(type: Test) { } java { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + withJavadocJar() withSourcesJar() } +tasks.withType(JavaCompile).configureEach { + options.compilerArgs += ['-Xlint:deprecation', '-Xlint:unchecked'] +} + publishing { publications { mavenJava(MavenPublication) { @@ -195,3 +196,11 @@ spotless { googleJavaFormat('1.7').aosp() } } + +testing { + suites { + test { + useJUnitJupiter() + } + } +} diff --git a/docker-compose.yml b/docker-compose.yml index 9a93a135..ee3829e1 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,8 +1,6 @@ -version: "3.8" - services: package: - image: azul/zulu-openjdk:8-latest + image: azul/zulu-openjdk:11-latest tty: true stdin_open: true working_dir: /home/package diff --git a/src/main/java/com/meilisearch/sdk/MultiSearchRequest.java b/src/main/java/com/meilisearch/sdk/MultiSearchRequest.java index f22b4c2b..28fb622f 100644 --- a/src/main/java/com/meilisearch/sdk/MultiSearchRequest.java +++ b/src/main/java/com/meilisearch/sdk/MultiSearchRequest.java @@ -6,7 +6,7 @@ public class MultiSearchRequest { private ArrayList queries; public MultiSearchRequest() { - this.queries = new ArrayList(); + this.queries = new ArrayList(); } /* diff --git a/src/main/java/com/meilisearch/sdk/SettingsHandler.java b/src/main/java/com/meilisearch/sdk/SettingsHandler.java index c70f9f80..ee47d902 100644 --- a/src/main/java/com/meilisearch/sdk/SettingsHandler.java +++ b/src/main/java/com/meilisearch/sdk/SettingsHandler.java @@ -706,6 +706,7 @@ public String[] getSeparatorTokensSettings(String uid) { * Updates the separator tokens settings of the index * * @param uid Index identifier + * @param separatorTokens an array of strings that contains the new separator tokens settings * @return TaskInfo instance * @throws MeilisearchException if an error occurs */ @@ -746,6 +747,7 @@ public String[] getNonSeparatorTokensSettings(String uid) { * Updates the non-separator tokens settings of the index * * @param uid Index identifier + * @param separatorTokens an array of strings that contains the new separator tokens settings * @return TaskInfo instance * @throws MeilisearchException if an error occurs */ diff --git a/src/test/java/com/meilisearch/sdk/json/GsonJsonHandlerTest.java b/src/test/java/com/meilisearch/sdk/json/GsonJsonHandlerTest.java index 4a9ee341..52c46d9d 100644 --- a/src/test/java/com/meilisearch/sdk/json/GsonJsonHandlerTest.java +++ b/src/test/java/com/meilisearch/sdk/json/GsonJsonHandlerTest.java @@ -28,6 +28,7 @@ import java.util.stream.Stream; import lombok.Getter; import org.junit.jupiter.api.Test; +import org.mockito.Mockito; class GsonJsonHandlerTest { @@ -68,16 +69,11 @@ void encodeAnObject() { @Test void encodeThrowsJsonEncodingExceptionWhenGsonThrowsException() { - assertThrows( - JsonEncodingException.class, - () -> - classToTest.encode( - new JsonElement() { - @Override - public JsonElement deepCopy() { - return null; - } - })); + JsonElement mockElement = Mockito.mock(JsonElement.class); + // Optionally mock behavior (if needed): + // Mockito.when(mockElement.deepCopy()).thenReturn(null); + + assertThrows(JsonEncodingException.class, () -> classToTest.encode(mockElement)); } @Test @@ -161,6 +157,7 @@ void deserializeWithParametersEmpty() throws Exception { void deserializeMap() throws Exception { String mapString = "{\"commitSha\":\"b46889b5f0f2f8b91438a08a358ba8f05fc09fc1\",\"commitDate\":\"2019-11-15T09:51:54.278247+00:00\",\"pkgVersion\":\"0.1.1\"}"; + @SuppressWarnings("unchecked") HashMap decode = classToTest.decode(mapString, HashMap.class, String.class, String.class);