Skip to content

Remove Object... varargs overloads in FilterExpressionBuilderTests #3489

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023-2024 the original author or authors.
* Copyright 2023-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -54,6 +54,7 @@
* syntax.
*
* @author Christian Tzolov
* @author Andrey Litvitski
*/
public class FilterExpressionBuilder {

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

public Op in(String key, Object... values) {
return this.in(key, List.of(values));
}

public Op in(String key, List<Object> values) {
return new Op(new Filter.Expression(ExpressionType.IN, new Key(key), new Value(values)));
}

public Op nin(String key, Object... values) {
return this.nin(key, List.of(values));
}

public Op nin(String key, List<Object> values) {
return new Op(new Filter.Expression(ExpressionType.NIN, new Key(key), new Value(values)));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023-2024 the original author or authors.
* Copyright 2023-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -37,6 +37,7 @@

/**
* @author Christian Tzolov
* @author Andrey Litvitski
*/
public class FilterExpressionBuilderTests {

Expand All @@ -60,7 +61,7 @@ public void tesEqAndGte() {
@Test
public void testIn() {
// genre in ["comedy", "documentary", "drama"]
var exp = this.b.in("genre", "comedy", "documentary", "drama").build();
var exp = this.b.in("genre", List.of("comedy", "documentary", "drama")).build();
assertThat(exp)
.isEqualTo(new Expression(IN, new Key("genre"), new Value(List.of("comedy", "documentary", "drama"))));
}
Expand All @@ -83,7 +84,7 @@ public void testGroup() {
// (year >= 2020 OR country == "BG") AND city NIN ["Sofia", "Plovdiv"]
var exp = this.b
.and(this.b.group(this.b.or(this.b.gte("year", 2020), this.b.eq("country", "BG"))),
this.b.nin("city", "Sofia", "Plovdiv"))
this.b.nin("city", List.of("Sofia", "Plovdiv")))
.build();

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

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

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

@Test
public void testInWithStringList() {
Expression exp = b.in("country", List.of("BG", "NL", "US")).build();

assertThat(exp).isEqualTo(new Expression(IN, new Key("country"), new Value(List.of("BG", "NL", "US"))));
}

}