11/*
2- * Copyright 2023-2024 the original author or authors.
2+ * Copyright 2023-2025 the original author or authors.
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
2020import java .time .Instant ;
2121import java .util .List ;
2222
23+ import io .micrometer .observation .ObservationRegistry ;
2324import org .junit .jupiter .api .Test ;
2425import org .junit .jupiter .api .extension .ExtendWith ;
2526import org .mockito .Mock ;
2627import org .mockito .junit .jupiter .MockitoExtension ;
2728
2829import org .springframework .ai .chat .metadata .ChatResponseMetadata ;
2930import org .springframework .ai .chat .metadata .DefaultUsage ;
31+ import org .springframework .ai .chat .model .ChatModel ;
3032import org .springframework .ai .chat .model .ChatResponse ;
33+ import org .springframework .ai .model .tool .ToolCallingManager ;
3134import org .springframework .ai .ollama .api .OllamaApi ;
3235import org .springframework .ai .ollama .api .OllamaModel ;
3336import org .springframework .ai .ollama .api .OllamaOptions ;
37+ import org .springframework .ai .ollama .management .ModelManagementOptions ;
3438
3539import static org .assertj .core .api .Assertions .assertThat ;
3640import static org .junit .jupiter .api .Assertions .assertEquals ;
4044 * @author Jihoon Kim
4145 * @author Christian Tzolov
4246 * @author Alexandros Pappas
47+ * @author Thomas Vitale
4348 * @since 1.0.0
4449 */
4550@ ExtendWith (MockitoExtension .class )
46- public class OllamaChatModelTests {
51+ class OllamaChatModelTests {
4752
4853 @ Mock
4954 OllamaApi ollamaApi ;
5055
5156 @ Test
52- public void buildOllamaChatModel () {
57+ void buildOllamaChatModelWithDeprecatedConstructor () {
58+ ChatModel chatModel = new OllamaChatModel (this .ollamaApi ,
59+ OllamaOptions .builder ().model (OllamaModel .MISTRAL ).build (), null , null , ObservationRegistry .NOOP ,
60+ ModelManagementOptions .builder ().build ());
61+ assertThat (chatModel ).isNotNull ();
62+ }
63+
64+ @ Test
65+ void buildOllamaChatModelWithConstructor () {
66+ ChatModel chatModel = new OllamaChatModel (this .ollamaApi ,
67+ OllamaOptions .builder ().model (OllamaModel .MISTRAL ).build (), ToolCallingManager .builder ().build (),
68+ ObservationRegistry .NOOP , ModelManagementOptions .builder ().build ());
69+ assertThat (chatModel ).isNotNull ();
70+ }
71+
72+ @ Test
73+ void buildOllamaChatModelWithBuilder () {
74+ ChatModel chatModel = OllamaChatModel .builder ().ollamaApi (ollamaApi ).build ();
75+ assertThat (chatModel ).isNotNull ();
76+ }
77+
78+ @ Test
79+ void buildOllamaChatModel () {
5380 Exception exception = assertThrows (IllegalArgumentException .class ,
5481 () -> OllamaChatModel .builder ()
5582 .ollamaApi (this .ollamaApi )
@@ -60,7 +87,7 @@ public void buildOllamaChatModel() {
6087 }
6188
6289 @ Test
63- public void buildChatResponseMetadata () {
90+ void buildChatResponseMetadata () {
6491
6592 Long evalDuration = 1000L ;
6693 Integer evalCount = 101 ;
@@ -83,7 +110,7 @@ public void buildChatResponseMetadata() {
83110 }
84111
85112 @ Test
86- public void buildChatResponseMetadataAggregationWithNonEmptyMetadata () {
113+ void buildChatResponseMetadataAggregationWithNonEmptyMetadata () {
87114
88115 Long evalDuration = 1000L ;
89116 Integer evalCount = 101 ;
0 commit comments