diff --git a/src/test/java/io/github/amithkoujalgi/ollama4j/integrationtests/TestRealAPIs.java b/src/test/java/io/github/amithkoujalgi/ollama4j/integrationtests/TestRealAPIs.java index 08fb1d1..5abed5c 100644 --- a/src/test/java/io/github/amithkoujalgi/ollama4j/integrationtests/TestRealAPIs.java +++ b/src/test/java/io/github/amithkoujalgi/ollama4j/integrationtests/TestRealAPIs.java @@ -1,21 +1,15 @@ package io.github.amithkoujalgi.ollama4j.integrationtests; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; + import io.github.amithkoujalgi.ollama4j.core.OllamaAPI; import io.github.amithkoujalgi.ollama4j.core.exceptions.OllamaBaseException; -import io.github.amithkoujalgi.ollama4j.core.models.ModelDetail; -import io.github.amithkoujalgi.ollama4j.core.models.OllamaAsyncResultCallback; -import io.github.amithkoujalgi.ollama4j.core.models.OllamaResult; -import io.github.amithkoujalgi.ollama4j.core.types.OllamaModelType; +import java.io.IOException; +import java.net.ConnectException; +import java.net.URISyntaxException; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.mockito.Mockito; - -import java.io.IOException; -import java.net.URISyntaxException; -import java.util.ArrayList; - -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.mockito.Mockito.*; class TestRealAPIs { @@ -27,10 +21,17 @@ class TestRealAPIs { ollamaAPI = new OllamaAPI(ollamaHost); } + @Test + void testWrongEndpoint() { + OllamaAPI ollamaAPI = new OllamaAPI("http://wrong-host:11434"); + assertThrows(ConnectException.class, ollamaAPI::listModels); + } + @Test void testListModels() { try { assertNotNull(ollamaAPI.listModels()); + ollamaAPI.listModels().forEach(System.out::println); } catch (IOException | OllamaBaseException | InterruptedException | URISyntaxException e) { throw new RuntimeException(e); } diff --git a/src/test/java/io/github/amithkoujalgi/ollama4j/unittests/TestMockedAPIs.java b/src/test/java/io/github/amithkoujalgi/ollama4j/unittests/TestMockedAPIs.java index 7f7ba3a..35496ec 100644 --- a/src/test/java/io/github/amithkoujalgi/ollama4j/unittests/TestMockedAPIs.java +++ b/src/test/java/io/github/amithkoujalgi/ollama4j/unittests/TestMockedAPIs.java @@ -14,9 +14,9 @@ import java.util.ArrayList; import org.junit.jupiter.api.Test; import org.mockito.Mockito; -public class TestMockedAPIs { +class TestMockedAPIs { @Test - public void testMockPullModel() { + void testMockPullModel() { OllamaAPI ollamaAPI = Mockito.mock(OllamaAPI.class); String model = OllamaModelType.LLAMA2; try { @@ -29,7 +29,7 @@ public class TestMockedAPIs { } @Test - public void testListModels() { + void testListModels() { OllamaAPI ollamaAPI = Mockito.mock(OllamaAPI.class); try { when(ollamaAPI.listModels()).thenReturn(new ArrayList<>()); @@ -41,7 +41,7 @@ public class TestMockedAPIs { } @Test - public void testCreateModel() { + void testCreateModel() { OllamaAPI ollamaAPI = Mockito.mock(OllamaAPI.class); String model = OllamaModelType.LLAMA2; String modelFilePath = "/somemodel"; @@ -55,7 +55,7 @@ public class TestMockedAPIs { } @Test - public void testDeleteModel() { + void testDeleteModel() { OllamaAPI ollamaAPI = Mockito.mock(OllamaAPI.class); String model = OllamaModelType.LLAMA2; try { @@ -68,7 +68,7 @@ public class TestMockedAPIs { } @Test - public void testGetModelDetails() { + void testGetModelDetails() { OllamaAPI ollamaAPI = Mockito.mock(OllamaAPI.class); String model = OllamaModelType.LLAMA2; try { @@ -81,7 +81,7 @@ public class TestMockedAPIs { } @Test - public void testGenerateEmbeddings() { + void testGenerateEmbeddings() { OllamaAPI ollamaAPI = Mockito.mock(OllamaAPI.class); String model = OllamaModelType.LLAMA2; String prompt = "some prompt text"; @@ -95,7 +95,7 @@ public class TestMockedAPIs { } @Test - public void testAsk() { + void testAsk() { OllamaAPI ollamaAPI = Mockito.mock(OllamaAPI.class); String model = OllamaModelType.LLAMA2; String prompt = "some prompt text"; @@ -109,7 +109,7 @@ public class TestMockedAPIs { } @Test - public void testAskAsync() { + void testAskAsync() { OllamaAPI ollamaAPI = Mockito.mock(OllamaAPI.class); String model = OllamaModelType.LLAMA2; String prompt = "some prompt text";