Skip to content

Commit

Permalink
add example of using the values handler and change method signature
Browse files Browse the repository at this point in the history
  • Loading branch information
mdavis95 committed Jan 3, 2023
1 parent 5796cc0 commit fa2d5c0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,9 @@ public Values withFields(Collection<String> fields) {
}


public void setValueHandler(Function<String, String> valueHandler) {
public Values valueHandler(Function<String, String> valueHandler) {
this.valueHandler = valueHandler;
return this;
}

public String asString() {
Expand Down
9 changes: 9 additions & 0 deletions zulia-client/src/test/java/io/zulia/client/HelperTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import java.util.function.Function;

public class HelperTest {

@Test
Expand All @@ -29,6 +31,13 @@ public void valuesTest() {
}


{
Function<String, String> quoteAndTrim = s -> Values.VALUE_QUOTER.apply(s).trim();
String query = Values.all().valueHandler(quoteAndTrim).of(" slow cat ", " Pink Shirt ").asString();
Assertions.assertEquals("(\"slow cat\" AND \"Pink Shirt\")", query);
}


{
String query = Values.any().of("a", "b").withFields("title", "abstract").asString();
Assertions.assertEquals("title,abstract:(a OR b)", query);
Expand Down

0 comments on commit fa2d5c0

Please sign in to comment.