Skip to content

Commit 11e0a03

Browse files
committed
remove Object... varargs overloads in FilterExpressionBuilderTests
Signed-off-by: Andrey Litvitski <[email protected]>
1 parent 161c437 commit 11e0a03

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

spring-ai-vector-store/src/main/java/org/springframework/ai/vectorstore/filter/FilterExpressionBuilder.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
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.
@@ -54,6 +54,7 @@
5454
* syntax.
5555
*
5656
* @author Christian Tzolov
57+
* @author Andrey Litvitski
5758
*/
5859
public class FilterExpressionBuilder {
5960

@@ -89,18 +90,10 @@ public Op or(Op left, Op right) {
8990
return new Op(new Filter.Expression(ExpressionType.OR, left.expression, right.expression));
9091
}
9192

92-
public Op in(String key, Object... values) {
93-
return this.in(key, List.of(values));
94-
}
95-
9693
public Op in(String key, List<Object> values) {
9794
return new Op(new Filter.Expression(ExpressionType.IN, new Key(key), new Value(values)));
9895
}
9996

100-
public Op nin(String key, Object... values) {
101-
return this.nin(key, List.of(values));
102-
}
103-
10497
public Op nin(String key, List<Object> values) {
10598
return new Op(new Filter.Expression(ExpressionType.NIN, new Key(key), new Value(values)));
10699
}

spring-ai-vector-store/src/test/java/org/springframework/ai/vectorstore/filter/FilterExpressionBuilderTests.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
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.
@@ -37,6 +37,7 @@
3737

3838
/**
3939
* @author Christian Tzolov
40+
* @author Andrey Litvitski
4041
*/
4142
public class FilterExpressionBuilderTests {
4243

@@ -60,7 +61,7 @@ public void tesEqAndGte() {
6061
@Test
6162
public void testIn() {
6263
// genre in ["comedy", "documentary", "drama"]
63-
var exp = this.b.in("genre", "comedy", "documentary", "drama").build();
64+
var exp = this.b.in("genre", List.of("comedy", "documentary", "drama")).build();
6465
assertThat(exp)
6566
.isEqualTo(new Expression(IN, new Key("genre"), new Value(List.of("comedy", "documentary", "drama"))));
6667
}
@@ -83,7 +84,7 @@ public void testGroup() {
8384
// (year >= 2020 OR country == "BG") AND city NIN ["Sofia", "Plovdiv"]
8485
var exp = this.b
8586
.and(this.b.group(this.b.or(this.b.gte("year", 2020), this.b.eq("country", "BG"))),
86-
this.b.nin("city", "Sofia", "Plovdiv"))
87+
this.b.nin("city", List.of("Sofia", "Plovdiv")))
8788
.build();
8889

8990
assertThat(exp).isEqualTo(new Expression(AND,
@@ -97,7 +98,7 @@ public void tesIn2() {
9798
// isOpen == true AND year >= 2020 AND country IN ["BG", "NL", "US"]
9899
var exp = this.b
99100
.and(this.b.and(this.b.eq("isOpen", true), this.b.gte("year", 2020)),
100-
this.b.in("country", "BG", "NL", "US"))
101+
this.b.in("country", List.of("BG", "NL", "US")))
101102
.build();
102103

103104
assertThat(exp).isEqualTo(new Expression(AND,
@@ -110,7 +111,7 @@ public void tesIn2() {
110111
public void tesNot() {
111112
// isOpen == true AND year >= 2020 AND country IN ["BG", "NL", "US"]
112113
var exp = this.b.not(this.b.and(this.b.and(this.b.eq("isOpen", true), this.b.gte("year", 2020)),
113-
this.b.in("country", "BG", "NL", "US")))
114+
this.b.in("country", List.of("BG", "NL", "US"))))
114115
.build();
115116

116117
assertThat(exp).isEqualTo(new Expression(NOT,
@@ -121,4 +122,11 @@ public void tesNot() {
121122
null));
122123
}
123124

125+
@Test
126+
public void testInWithStringList() {
127+
Expression exp = b.in("country", List.of("BG", "NL", "US")).build();
128+
129+
assertThat(exp).isEqualTo(new Expression(IN, new Key("country"), new Value(List.of("BG", "NL", "US"))));
130+
}
131+
124132
}

0 commit comments

Comments
 (0)