diff --git a/.github/workflows/maven-publish.yml b/.github/workflows/maven-publish.yml index fe79e8c..91e2b78 100644 --- a/.github/workflows/maven-publish.yml +++ b/.github/workflows/maven-publish.yml @@ -31,7 +31,7 @@ jobs: settings-path: ${{ github.workspace }} # location for the settings.xml file - name: Build with Maven - run: mvn -U -B clean package --file pom.xml + run: mvn -U -B clean verify package --file pom.xml - name: Set up Apache Maven Central (Overwrite settings.xml) uses: actions/setup-java@v3 diff --git a/pom.xml b/pom.xml index 27dc6ed..103fc59 100644 --- a/pom.xml +++ b/pom.xml @@ -41,7 +41,7 @@ org.sonatype.plugins nexus-staging-maven-plugin - 1.6.7 + 1.6.8 true ossrh @@ -111,6 +111,20 @@ httpclient5 5.2.1 + + org.junit.jupiter + junit-jupiter + RELEASE + test + + + org.mockito + mockito-core + 4.1.0 + test + + + diff --git a/src/main/java/io/github/amithkoujalgi/ollama4j/Main.java b/src/main/java/io/github/amithkoujalgi/ollama4j/Main.java deleted file mode 100644 index ee5997b..0000000 --- a/src/main/java/io/github/amithkoujalgi/ollama4j/Main.java +++ /dev/null @@ -1,13 +0,0 @@ -package io.github.amithkoujalgi.ollama4j; - -public class Main { - public static void main(String[] args) throws Exception { - String host = "http://localhost:11434/"; - OllamaAPI ollamaAPI = new OllamaAPI(host); - ollamaAPI.pullModel(OllamaModel.LLAMA2); - String response = ollamaAPI.runSync(OllamaModel.LLAMA2, "Who are you?"); - System.out.println(response); - } -} - - diff --git a/src/test/java/io/github/amithkoujalgi/ollama4j/TestMockedAPIs.java b/src/test/java/io/github/amithkoujalgi/ollama4j/TestMockedAPIs.java new file mode 100644 index 0000000..22880f2 --- /dev/null +++ b/src/test/java/io/github/amithkoujalgi/ollama4j/TestMockedAPIs.java @@ -0,0 +1,24 @@ +package io.github.amithkoujalgi.ollama4j; + +import org.apache.hc.core5.http.ParseException; +import org.junit.jupiter.api.Test; +import org.mockito.Mockito; + +import java.io.IOException; + +import static org.mockito.Mockito.*; + +public class TestMockedAPIs { + @Test + public void testMockPullModel() { + OllamaAPI ollamaAPI = Mockito.mock(OllamaAPI.class); + OllamaModel model = OllamaModel.LLAMA2; + try { + doNothing().when(ollamaAPI).pullModel(model); + ollamaAPI.pullModel(model); + verify(ollamaAPI, times(1)).pullModel(model); + } catch (IOException | ParseException | OllamaBaseException e) { + throw new RuntimeException(e); + } + } +}