|
49 | 49 |
|
50 | 50 | /** |
51 | 51 | * @author Filip Hrisafov |
| 52 | + * @author Oleksandr Klymenko |
52 | 53 | */ |
53 | 54 | public class AnthropicApiBuilderTests { |
54 | 55 |
|
@@ -132,6 +133,80 @@ void testInvalidResponseErrorHandler() { |
132 | 133 | .hasMessageContaining("responseErrorHandler cannot be null"); |
133 | 134 | } |
134 | 135 |
|
| 136 | + @Test |
| 137 | + void testApiKeyStringOverload() { |
| 138 | + AnthropicApi api = AnthropicApi.builder().apiKey("test-string-key").build(); |
| 139 | + |
| 140 | + assertThat(api).isNotNull(); |
| 141 | + } |
| 142 | + |
| 143 | + @Test |
| 144 | + void testInvalidAnthropicVersion() { |
| 145 | + assertThatThrownBy(() -> AnthropicApi.builder().apiKey(TEST_API_KEY).anthropicVersion(null).build()) |
| 146 | + .isInstanceOf(IllegalArgumentException.class) |
| 147 | + .hasMessageContaining("anthropicVersion cannot be null"); |
| 148 | + } |
| 149 | + |
| 150 | + @Test |
| 151 | + void testInvalidAnthropicBetaFeatures() { |
| 152 | + assertThatThrownBy(() -> AnthropicApi.builder().apiKey(TEST_API_KEY).anthropicBetaFeatures(null).build()) |
| 153 | + .isInstanceOf(IllegalArgumentException.class) |
| 154 | + .hasMessageContaining("anthropicBetaFeatures cannot be null"); |
| 155 | + } |
| 156 | + |
| 157 | + @Test |
| 158 | + void testDefaultValues() { |
| 159 | + AnthropicApi api = AnthropicApi.builder().apiKey(TEST_API_KEY).build(); |
| 160 | + |
| 161 | + assertThat(api).isNotNull(); |
| 162 | + } |
| 163 | + |
| 164 | + @Test |
| 165 | + void testBuilderIndependence() { |
| 166 | + AnthropicApi.Builder builder1 = AnthropicApi.builder().apiKey("key1").baseUrl("https://api1.example.com"); |
| 167 | + |
| 168 | + AnthropicApi.Builder builder2 = AnthropicApi.builder().apiKey("key2").baseUrl("https://api2.example.com"); |
| 169 | + |
| 170 | + AnthropicApi api1 = builder1.build(); |
| 171 | + AnthropicApi api2 = builder2.build(); |
| 172 | + |
| 173 | + assertThat(api1).isNotNull(); |
| 174 | + assertThat(api2).isNotNull(); |
| 175 | + } |
| 176 | + |
| 177 | + @Test |
| 178 | + void testCustomAnthropicVersionAndBetaFeatures() { |
| 179 | + AnthropicApi api = AnthropicApi.builder() |
| 180 | + .apiKey(TEST_API_KEY) |
| 181 | + .anthropicVersion("version") |
| 182 | + .anthropicBetaFeatures("custom-beta-feature") |
| 183 | + .build(); |
| 184 | + |
| 185 | + assertThat(api).isNotNull(); |
| 186 | + } |
| 187 | + |
| 188 | + @Test |
| 189 | + void testApiKeyStringNullValidation() { |
| 190 | + assertThatThrownBy(() -> AnthropicApi.builder().apiKey((String) null).build()) |
| 191 | + .isInstanceOf(IllegalArgumentException.class) |
| 192 | + .hasMessageContaining("simpleApiKey cannot be null"); |
| 193 | + } |
| 194 | + |
| 195 | + @Test |
| 196 | + void testChainedBuilderMethods() { |
| 197 | + AnthropicApi api = AnthropicApi.builder() |
| 198 | + .baseUrl(TEST_BASE_URL) |
| 199 | + .completionsPath(TEST_COMPLETIONS_PATH) |
| 200 | + .apiKey(TEST_API_KEY) |
| 201 | + .anthropicBetaFeatures("feature1,feature2") |
| 202 | + .restClientBuilder(RestClient.builder()) |
| 203 | + .webClientBuilder(WebClient.builder()) |
| 204 | + .responseErrorHandler(mock(ResponseErrorHandler.class)) |
| 205 | + .build(); |
| 206 | + |
| 207 | + assertThat(api).isNotNull(); |
| 208 | + } |
| 209 | + |
135 | 210 | @Nested |
136 | 211 | class MockRequests { |
137 | 212 |
|
|
0 commit comments