|
14 | 14 | * limitations under the License. |
15 | 15 | */ |
16 | 16 |
|
17 | | -package org.springframework.ai.openai.api; |
| 17 | +package org.springframework.ai.openai.image.api; |
18 | 18 |
|
19 | 19 | import org.junit.jupiter.api.Test; |
20 | 20 | import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; |
21 | 21 | import org.junit.jupiter.params.ParameterizedTest; |
22 | 22 | import org.junit.jupiter.params.provider.EnumSource; |
23 | 23 |
|
24 | 24 | import org.springframework.ai.model.SimpleApiKey; |
| 25 | +import org.springframework.ai.openai.api.OpenAiImageApi; |
25 | 26 | import org.springframework.ai.openai.api.OpenAiImageApi.ImageModel; |
26 | 27 | import org.springframework.ai.openai.api.OpenAiImageApi.OpenAiImageRequest; |
27 | 28 | import org.springframework.ai.openai.api.OpenAiImageApi.OpenAiImageResponse; |
@@ -161,4 +162,68 @@ void createMultipleImagesWithDallE2() { |
161 | 162 | assertThat(response.getBody().data().get(1).url()).isNotEmpty(); |
162 | 163 | } |
163 | 164 |
|
| 165 | + // Comprehensive model-specific tests with all parameters |
| 166 | + |
| 167 | + @Test |
| 168 | + void gptImage1WithAllParameters() { |
| 169 | + // Test GPT-Image-1 with all supported parameters |
| 170 | + OpenAiImageRequest request = new OpenAiImageRequest("A red apple floating in space", |
| 171 | + ImageModel.GPT_IMAGE_1.getValue(), 1, "high", "b64_json", "1024x1024", null, "test-user", "transparent", |
| 172 | + "auto", 85, "png", null, false); |
| 173 | + |
| 174 | + ResponseEntity<OpenAiImageResponse> response = this.openAiImageApi.createImage(request); |
| 175 | + |
| 176 | + assertThat(response).isNotNull(); |
| 177 | + assertThat(response.getBody()).isNotNull(); |
| 178 | + assertThat(response.getBody().data()).hasSize(1); |
| 179 | + assertThat(response.getBody().data().get(0).b64Json()).isNotEmpty(); |
| 180 | + } |
| 181 | + |
| 182 | + @Test |
| 183 | + void gptImage1MiniWithAllParameters() { |
| 184 | + // Test GPT-Image-1-Mini with all supported parameters |
| 185 | + OpenAiImageRequest request = new OpenAiImageRequest("A sunset over the ocean", |
| 186 | + ImageModel.GPT_IMAGE_1_MINI.getValue(), 1, "medium", "b64_json", "1024x1024", null, "test-user", |
| 187 | + "opaque", "low", 70, "jpeg", null, false); |
| 188 | + |
| 189 | + ResponseEntity<OpenAiImageResponse> response = this.openAiImageApi.createImage(request); |
| 190 | + |
| 191 | + assertThat(response).isNotNull(); |
| 192 | + assertThat(response.getBody()).isNotNull(); |
| 193 | + assertThat(response.getBody().data()).hasSize(1); |
| 194 | + assertThat(response.getBody().data().get(0).b64Json()).isNotEmpty(); |
| 195 | + } |
| 196 | + |
| 197 | + @Test |
| 198 | + void dallE3WithAllParameters() { |
| 199 | + // Test DALL-E 3 with all supported parameters |
| 200 | + OpenAiImageRequest request = new OpenAiImageRequest("A hyper-realistic portrait of a wise old wizard", |
| 201 | + ImageModel.DALL_E_3.getValue(), 1, "hd", "url", "1024x1024", "vivid", "test-user", null, null, null, |
| 202 | + null, null, null); |
| 203 | + |
| 204 | + ResponseEntity<OpenAiImageResponse> response = this.openAiImageApi.createImage(request); |
| 205 | + |
| 206 | + assertThat(response).isNotNull(); |
| 207 | + assertThat(response.getBody()).isNotNull(); |
| 208 | + assertThat(response.getBody().data()).hasSize(1); |
| 209 | + assertThat(response.getBody().data().get(0).url()).isNotEmpty(); |
| 210 | + assertThat(response.getBody().data().get(0).revisedPrompt()).isNotEmpty(); |
| 211 | + } |
| 212 | + |
| 213 | + @Test |
| 214 | + void dallE2WithAllParameters() { |
| 215 | + // Test DALL-E 2 with all supported parameters |
| 216 | + OpenAiImageRequest request = new OpenAiImageRequest("A simple geometric pattern", |
| 217 | + ImageModel.DALL_E_2.getValue(), 2, null, "b64_json", "512x512", null, "test-user", null, null, null, |
| 218 | + null, null, null); |
| 219 | + |
| 220 | + ResponseEntity<OpenAiImageResponse> response = this.openAiImageApi.createImage(request); |
| 221 | + |
| 222 | + assertThat(response).isNotNull(); |
| 223 | + assertThat(response.getBody()).isNotNull(); |
| 224 | + assertThat(response.getBody().data()).hasSize(2); |
| 225 | + assertThat(response.getBody().data().get(0).b64Json()).isNotEmpty(); |
| 226 | + assertThat(response.getBody().data().get(1).b64Json()).isNotEmpty(); |
| 227 | + } |
| 228 | + |
164 | 229 | } |
0 commit comments