Skip to content

Commit c03a5ca

Browse files
alxkmilayaperumalg
authored andcommitted
test: add null parameter validation tests
Co-authored-by: Oleksandr Klymenko <alexanderklmn@gmail.com> Signed-off-by: Oleksandr Klymenko <alexanderklmn@gmail.com>
1 parent 2a916db commit c03a5ca

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

models/spring-ai-azure-openai/src/test/java/org/springframework/ai/azure/openai/aot/AzureOpenAiRuntimeHintsTests.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import org.springframework.aot.hint.TypeReference;
3232

3333
import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
34+
import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy;
3435
import static org.springframework.aot.hint.predicate.RuntimeHintsPredicates.reflection;
3536
import static org.springframework.aot.hint.predicate.RuntimeHintsPredicates.resource;
3637

@@ -209,4 +210,11 @@ void verifyEnumTypesInAzurePackageAreRegistered() {
209210
assertThat(hasEnumTypes).as("Azure OpenAI enum types should be registered").isTrue();
210211
}
211212

213+
@Test
214+
void registerHintsWithNullRuntimeHints() {
215+
// Should throw when RuntimeHints is null
216+
assertThatThrownBy(() -> this.azureOpenAiRuntimeHints.registerHints(null, null))
217+
.isInstanceOf(NullPointerException.class);
218+
}
219+
212220
}

models/spring-ai-transformers/src/test/java/org/springframework/ai/transformers/ResourceCacheServiceTests.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.springframework.core.io.DefaultResourceLoader;
2828

2929
import static org.assertj.core.api.Assertions.assertThat;
30+
import static org.assertj.core.api.Assertions.assertThatThrownBy;
3031

3132
/**
3233
* @author Christian Tzolov
@@ -109,4 +110,12 @@ public void cacheHttpResources() throws IOException {
109110
assertThat(Files.list(Files.list(this.tempDir.toPath()).iterator().next()).count()).isEqualTo(1);
110111
}
111112

113+
@Test
114+
public void shouldHandleNullUri() {
115+
var cache = new ResourceCacheService(this.tempDir);
116+
117+
assertThatThrownBy(() -> cache.getCachedResource((String) null)).isInstanceOf(IllegalArgumentException.class)
118+
.hasMessageContaining("Location must not be null");
119+
}
120+
112121
}

0 commit comments

Comments
 (0)