diff options
Diffstat (limited to 'container-search/src')
11 files changed, 119 insertions, 87 deletions
diff --git a/container-search/src/main/java/com/yahoo/prelude/query/WeightedSetItem.java b/container-search/src/main/java/com/yahoo/prelude/query/WeightedSetItem.java index 131d4fcc9da..b87de5f019a 100644 --- a/container-search/src/main/java/com/yahoo/prelude/query/WeightedSetItem.java +++ b/container-search/src/main/java/com/yahoo/prelude/query/WeightedSetItem.java @@ -49,6 +49,7 @@ public class WeightedSetItem extends SimpleTaggableItem { * Add weighted token. * If token is already in the set, the maximum weight is kept. * NOTE: The weight must be 1 or more; negative values (and zero) are not allowed. + * * @return weight of added token (might be old value, if kept) */ public Integer addToken(String token, int weight) { diff --git a/container-search/src/main/java/com/yahoo/prelude/query/WordAlternativesItem.java b/container-search/src/main/java/com/yahoo/prelude/query/WordAlternativesItem.java index 652e1ca60b8..1157d2763e0 100644 --- a/container-search/src/main/java/com/yahoo/prelude/query/WordAlternativesItem.java +++ b/container-search/src/main/java/com/yahoo/prelude/query/WordAlternativesItem.java @@ -15,7 +15,7 @@ import com.yahoo.compress.IntegerCompressor; * A set words with differing exactness scores to be used for literal boost * ranking. * - * @author <a href="mailto:steinar@yahoo-inc.com">Steinar Knutsen</a> + * @author Steinar Knutsen */ public class WordAlternativesItem extends TermItem { @@ -23,6 +23,7 @@ public class WordAlternativesItem extends TermItem { private int maxIndex; public static final class Alternative { + public final String word; public final double exactness; @@ -38,6 +39,7 @@ public class WordAlternativesItem extends TermItem { builder.append("Alternative [word=").append(word).append(", exactness=").append(exactness).append("]"); return builder.toString(); } + } public WordAlternativesItem(String indexName, boolean isFromQuery, Substring origin, Collection<Alternative> terms) { @@ -51,7 +53,7 @@ public class WordAlternativesItem extends TermItem { } private static ImmutableList<Alternative> uniqueAlternatives(Collection<Alternative> terms) { - List<Alternative> uniqueTerms = new ArrayList<Alternative>(terms.size()); + List<Alternative> uniqueTerms = new ArrayList<>(terms.size()); for (Alternative term : terms) { int i = Collections.binarySearch(uniqueTerms, term, (t0, t1) -> t0.word.compareTo(t1.word)); if (i >= 0) { @@ -104,7 +106,7 @@ public class WordAlternativesItem extends TermItem { @Override public void setValue(String value) { - throw new UnsupportedOperationException("semantics for setting to a string would be brittle, use setAlternatives()"); + throw new UnsupportedOperationException("Semantics for setting to a string would be brittle, use setAlternatives()"); } @Override @@ -180,4 +182,5 @@ public class WordAlternativesItem extends TermItem { newTerms.add(new Alternative(term, exactness)); setAlternatives(newTerms); } + } diff --git a/container-search/src/main/java/com/yahoo/search/Query.java b/container-search/src/main/java/com/yahoo/search/Query.java index 2e106dc62f4..bf0920a2aa5 100644 --- a/container-search/src/main/java/com/yahoo/search/Query.java +++ b/container-search/src/main/java/com/yahoo/search/Query.java @@ -187,6 +187,7 @@ public class Query extends com.yahoo.processing.Request implements Cloneable { public static final CompoundName OFFSET = new CompoundName("offset"); public static final CompoundName HITS = new CompoundName("hits"); + public static final CompoundName QUERY_PROFILE = new CompoundName("queryProfile"); public static final CompoundName SEARCH_CHAIN = new CompoundName("searchChain"); public static final CompoundName TRACE_LEVEL = new CompoundName("traceLevel"); public static final CompoundName NO_CACHE = new CompoundName("noCache"); @@ -202,6 +203,7 @@ public class Query extends com.yahoo.processing.Request implements Cloneable { argumentType.addField(new FieldDescription(OFFSET.toString(), "integer", "offset start")); argumentType.addField(new FieldDescription(HITS.toString(), "integer", "hits count")); // TODO: Should this be added to com.yahoo.search.query.properties.QueryProperties? If not, why not? + argumentType.addField(new FieldDescription(QUERY_PROFILE.toString(), "string")); argumentType.addField(new FieldDescription(SEARCH_CHAIN.toString(), "string")); argumentType.addField(new FieldDescription(TRACE_LEVEL.toString(), "integer", "tracelevel")); argumentType.addField(new FieldDescription(NO_CACHE.toString(), "boolean", "nocache")); @@ -409,10 +411,10 @@ public class Query extends com.yahoo.processing.Request implements Cloneable { } } } else { - Object value=originalProperties.get(fullName,context); - if (value!=null) { + Object value = originalProperties.get(fullName,context); + if (value != null) { try { - properties().set(fullName,value,context); + properties().set(fullName, value, context); } catch (IllegalArgumentException e) { throw new QueryException("Invalid request parameter", e); } @@ -425,7 +427,6 @@ public class Query extends com.yahoo.processing.Request implements Cloneable { private void setPropertiesFromRequestMap(Map<String, String> requestMap, Properties properties) { for (Map.Entry<String, String> entry : requestMap.entrySet()) { try { - if (entry.getKey().equals("queryProfile")) continue; properties.set(entry.getKey(), entry.getValue(), requestMap); } catch (IllegalArgumentException e) { @@ -444,12 +445,12 @@ public class Query extends com.yahoo.processing.Request implements Cloneable { */ private void traceProperties() { if (traceLevel == 0) return; - CompiledQueryProfile profile=null; - QueryProfileProperties profileProperties=properties().getInstance(QueryProfileProperties.class); - if (profileProperties!=null) - profile=profileProperties.getQueryProfile(); + CompiledQueryProfile profile = null; + QueryProfileProperties profileProperties = properties().getInstance(QueryProfileProperties.class); + if (profileProperties != null) + profile = profileProperties.getQueryProfile(); - if (profile==null) + if (profile == null) trace("No query profile is used", false, 1); else trace("Using " + profile.toString(), false, 1); @@ -464,7 +465,7 @@ public class Query extends com.yahoo.processing.Request implements Cloneable { b.append(requestProperty.getKey()); b.append("="); - b.append(String.valueOf(resolvedValue)); // (may be null) + b.append(resolvedValue); // (may be null) b.append(" ("); if (profile != null && ! profile.isOverridable(new CompoundName(requestProperty.getKey()), requestProperties())) @@ -474,8 +475,8 @@ public class Query extends com.yahoo.processing.Request implements Cloneable { b.append(")\n"); mentioned.add(requestProperty.getKey()); } - if (profile!=null) { - appendQueryProfileProperties(profile,mentioned,b); + if (profile != null) { + appendQueryProfileProperties(profile, mentioned, b); } trace(b.toString(),false,4); } @@ -485,7 +486,7 @@ public class Query extends com.yahoo.processing.Request implements Cloneable { } private void appendQueryProfileProperties(CompiledQueryProfile profile,Set<String> mentioned,StringBuilder b) { - for (Map.Entry<String,Object> property : profile.listValues("",requestProperties()).entrySet()) { + for (Map.Entry<String,Object> property : profile.listValues("", requestProperties()).entrySet()) { if ( ! mentioned.contains(property.getKey())) b.append(property.getKey() + "=" + property.getValue() + " (value from query profile)<br/>\n"); } diff --git a/container-search/src/main/java/com/yahoo/search/query/Model.java b/container-search/src/main/java/com/yahoo/search/query/Model.java index 4baa651fa01..fd52618ad85 100644 --- a/container-search/src/main/java/com/yahoo/search/query/Model.java +++ b/container-search/src/main/java/com/yahoo/search/query/Model.java @@ -7,7 +7,6 @@ import com.yahoo.language.LocaleFactory; import com.yahoo.prelude.query.CompositeItem; import com.yahoo.prelude.query.Item; import com.yahoo.prelude.query.TaggableItem; -import com.yahoo.prelude.query.textualrepresentation.TextualQueryRepresentation; import com.yahoo.processing.request.CompoundName; import com.yahoo.search.Query; import com.yahoo.search.query.parser.Parsable; @@ -18,7 +17,13 @@ import com.yahoo.search.query.profile.types.FieldDescription; import com.yahoo.search.query.profile.types.QueryProfileType; import com.yahoo.search.searchchain.Execution; -import java.util.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Locale; +import java.util.Set; import static com.yahoo.text.Lowercase.toLowerCase; @@ -169,9 +174,9 @@ public class Model implements Cloneable { public void setLanguage(Language language) { this.language = language; } /** - * <p>Explicitly sets the language to be used during parsing. The argument is first normalized by replacing + * Explicitly sets the language to be used during parsing. The argument is first normalized by replacing * underscores with hyphens (to support locale strings being used as RFC 5646 language tags), and then forwarded to - * {@link #setLocale(String)} so that the Locale information of the tag is preserved.</p> + * {@link #setLocale(String)} so that the Locale information of the tag is preserved. * * @param language The language string to parse. * @see #getLanguage() @@ -182,9 +187,9 @@ public class Model implements Cloneable { } /** - * <p>Returns the explicitly set parsing locale of this query model, or null if none.</p> + * Returns the explicitly set parsing locale of this query model, or null if none. * - * @return The locale of this. + * @return the locale of this * @see #setLocale(Locale) */ public Locale getLocale() { @@ -195,7 +200,7 @@ public class Model implements Cloneable { * <p>Explicitly sets the locale to be used during parsing. This method also calls {@link #setLanguage(Language)} * with the corresponding {@link Language} instance.</p> * - * @param locale The locale to set. + * @param locale the locale to set * @see #getLocale() * @see #setLanguage(Language) */ @@ -205,10 +210,10 @@ public class Model implements Cloneable { } /** - * <p>Explicitly sets the locale to be used during parsing. This creates a Locale instance from the given language - * tag, and passes that to {@link #setLocale(Locale)}.</p> + * Explicitly sets the locale to be used during parsing. This creates a Locale instance from the given language + * tag, and passes that to {@link #setLocale(Locale)}. * - * @param languageTag The language tag to parse. + * @param languageTag the language tag to parse * @see #setLocale(Locale) */ public void setLocale(String languageTag) { diff --git a/container-search/src/main/java/com/yahoo/search/query/profile/SubstituteString.java b/container-search/src/main/java/com/yahoo/search/query/profile/SubstituteString.java index 36b38ad8d03..3252f0f4662 100644 --- a/container-search/src/main/java/com/yahoo/search/query/profile/SubstituteString.java +++ b/container-search/src/main/java/com/yahoo/search/query/profile/SubstituteString.java @@ -27,23 +27,23 @@ public class SubstituteString { * Returns a new SubstituteString if the given string contains substitutions, null otherwise. */ public static SubstituteString create(String value) { - int lastEnd=0; - int start=value.indexOf("%{"); - if (start<0) return null; // Shortcut - List<Component> components=new ArrayList<>(); - while (start>=0) { - int end=value.indexOf("}",start+2); - if (end<0) + int lastEnd = 0; + int start = value.indexOf("%{"); + if (start < 0) return null; // Shortcut + List<Component> components = new ArrayList<>(); + while (start >= 0) { + int end = value.indexOf("}", start + 2); + if (end < 0) throw new IllegalArgumentException("Unterminated value substitution '" + value.substring(start) + "'"); - String propertyName=value.substring(start+2,end); - if (propertyName.indexOf("%{")>=0) + String propertyName = value.substring(start+2,end); + if (propertyName.indexOf("%{") >= 0) throw new IllegalArgumentException("Unterminated value substitution '" + value.substring(start) + "'"); - components.add(new StringComponent(value.substring(lastEnd,start))); + components.add(new StringComponent(value.substring(lastEnd, start))); components.add(new PropertyComponent(propertyName)); - lastEnd=end+1; - start=value.indexOf("%{",lastEnd); + lastEnd = end+1; + start = value.indexOf("%{", lastEnd); } - components.add(new StringComponent(value.substring(lastEnd,value.length()))); + components.add(new StringComponent(value.substring(lastEnd))); return new SubstituteString(components, value); } @@ -83,7 +83,7 @@ public class SubstituteString { private abstract static class Component { - protected abstract String getValue(Map<String,String> context,Properties substitution); + protected abstract String getValue(Map<String, String> context, Properties substitution); } @@ -92,11 +92,11 @@ public class SubstituteString { private final String value; public StringComponent(String value) { - this.value=value; + this.value = value; } @Override - public String getValue(Map<String,String> context,Properties substitution) { + public String getValue(Map<String, String> context, Properties substitution) { return value; } @@ -112,13 +112,13 @@ public class SubstituteString { private final String propertyName; public PropertyComponent(String propertyName) { - this.propertyName=propertyName; + this.propertyName = propertyName; } @Override - public String getValue(Map<String,String> context,Properties substitution) { - Object value=substitution.get(propertyName,context,substitution); - if (value==null) return ""; + public String getValue(Map<String,String> context, Properties substitution) { + Object value = substitution.get(propertyName, context, substitution); + if (value == null) return ""; return String.valueOf(value); } diff --git a/container-search/src/main/java/com/yahoo/search/query/properties/QueryProperties.java b/container-search/src/main/java/com/yahoo/search/query/properties/QueryProperties.java index 55855624691..60427aeb0af 100644 --- a/container-search/src/main/java/com/yahoo/search/query/properties/QueryProperties.java +++ b/container-search/src/main/java/com/yahoo/search/query/properties/QueryProperties.java @@ -3,9 +3,12 @@ package com.yahoo.search.query.properties; import com.yahoo.processing.request.CompoundName; import com.yahoo.search.Query; -import com.yahoo.search.grouping.GroupingRequest; -import com.yahoo.search.grouping.vespa.GroupingExecutor; -import com.yahoo.search.query.*; + +import com.yahoo.search.query.Model; +import com.yahoo.search.query.Presentation; +import com.yahoo.search.query.Properties; +import com.yahoo.search.query.Ranking; +import com.yahoo.search.query.Select; import com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry; import com.yahoo.search.query.profile.types.FieldDescription; import com.yahoo.search.query.profile.types.QueryProfileType; @@ -15,11 +18,8 @@ import com.yahoo.search.query.ranking.Matching; import com.yahoo.search.query.ranking.SoftTimeout; import com.yahoo.tensor.Tensor; -import java.util.List; import java.util.Map; - - /** * Maps between the query model and text properties. * This can be done simpler by using reflection but the performance penalty was not worth it, diff --git a/container-search/src/test/java/com/yahoo/prelude/semantics/test/PhraseMatchTestCase.java b/container-search/src/test/java/com/yahoo/prelude/semantics/test/PhraseMatchTestCase.java index 41f67ed16fc..5cee88de849 100644 --- a/container-search/src/test/java/com/yahoo/prelude/semantics/test/PhraseMatchTestCase.java +++ b/container-search/src/test/java/com/yahoo/prelude/semantics/test/PhraseMatchTestCase.java @@ -22,4 +22,9 @@ public class PhraseMatchTestCase extends RuleBaseAbstractTestCase { assertSemantics("AND retailer:digital retailer:camera","keyword:digital keyword:camera"); } + @Test + public void testMatchingPhrase() { + assertSemantics("OR (AND iphone 7) i7", "iphone 7"); + } + } diff --git a/container-search/src/test/java/com/yahoo/prelude/semantics/test/rulebases/phrasematch.sr b/container-search/src/test/java/com/yahoo/prelude/semantics/test/rulebases/phrasematch.sr index f985c693284..70351ba8ba1 100644 --- a/container-search/src/test/java/com/yahoo/prelude/semantics/test/rulebases/phrasematch.sr +++ b/container-search/src/test/java/com/yahoo/prelude/semantics/test/rulebases/phrasematch.sr @@ -3,3 +3,5 @@ [ret] :- keyword:[B]; retailer:"[...]" -> retailer:[...]; + +iphone 7 +> ?i7;
\ No newline at end of file diff --git a/container-search/src/test/java/com/yahoo/search/query/profile/config/test/QueryProfileIntegrationTestCase.java b/container-search/src/test/java/com/yahoo/search/query/profile/config/test/QueryProfileIntegrationTestCase.java index 67fb5da10a0..67d22fba4a3 100644 --- a/container-search/src/test/java/com/yahoo/search/query/profile/config/test/QueryProfileIntegrationTestCase.java +++ b/container-search/src/test/java/com/yahoo/search/query/profile/config/test/QueryProfileIntegrationTestCase.java @@ -80,7 +80,7 @@ public class QueryProfileIntegrationTestCase { System.setProperty("config.id", configId); Container container = new Container(); HandlersConfigurerTestWrapper configurer = new HandlersConfigurerTestWrapper(container, configId); - SearchHandler searchHandler = (SearchHandler) configurer.getRequestHandlerRegistry().getComponent(SearchHandler.class.getName()); + SearchHandler searchHandler = (SearchHandler)configurer.getRequestHandlerRegistry().getComponent(SearchHandler.class.getName()); // Should get "default" query profile containing the "test" search chain containing the "test" searcher HttpRequest request = HttpRequest.createTestRequest("search", Method.GET); diff --git a/container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileSubstitutionTestCase.java b/container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileSubstitutionTestCase.java index 7ff120ddc70..9a0063e7f07 100644 --- a/container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileSubstitutionTestCase.java +++ b/container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileSubstitutionTestCase.java @@ -19,7 +19,7 @@ public class QueryProfileSubstitutionTestCase { @Test public void testSingleSubstitution() { - QueryProfile p=new QueryProfile("test"); + QueryProfile p = new QueryProfile("test"); p.set("message","Hello %{world}!", null); p.set("world", "world", null); assertEquals("Hello world!",p.compile(null).get("message")); @@ -27,7 +27,7 @@ public class QueryProfileSubstitutionTestCase { QueryProfile p2=new QueryProfile("test2"); p2.addInherited(p); p2.set("world", "universe", null); - assertEquals("Hello universe!",p2.compile(null).get("message")); + assertEquals("Hello universe!", p2.compile(null).get("message")); } @Test @@ -39,16 +39,16 @@ public class QueryProfileSubstitutionTestCase { p.set("exclamation","?", null); assertEquals("Hola local group?",p.compile(null).get("message")); - QueryProfile p2=new QueryProfile("test2"); + QueryProfile p2 = new QueryProfile("test2"); p2.addInherited(p); p2.set("entity","milky way", null); - assertEquals("Hola milky way?",p2.compile(null).get("message")); + assertEquals("Hola milky way?", p2.compile(null).get("message")); } @Test public void testUnclosedSubstitution1() { try { - QueryProfile p=new QueryProfile("test"); + QueryProfile p = new QueryProfile("test"); p.set("message1","%{greeting} %{entity}%{exclamation", null); fail("Should have produced an exception"); } @@ -61,7 +61,7 @@ public class QueryProfileSubstitutionTestCase { @Test public void testUnclosedSubstitution2() { try { - QueryProfile p=new QueryProfile("test"); + QueryProfile p = new QueryProfile("test"); p.set("message1","%{greeting} %{entity%{exclamation}", null); fail("Should have produced an exception"); } @@ -73,26 +73,26 @@ public class QueryProfileSubstitutionTestCase { @Test public void testNullSubstitution() { - QueryProfile p=new QueryProfile("test"); + QueryProfile p = new QueryProfile("test"); p.set("message","%{greeting} %{entity}%{exclamation}", null); p.set("greeting","Hola", null); assertEquals("Hola ", p.compile(null).get("message")); - QueryProfile p2=new QueryProfile("test2"); + QueryProfile p2 = new QueryProfile("test2"); p2.addInherited(p); p2.set("greeting","Hola", null); p2.set("exclamation", "?", null); - assertEquals("Hola ?",p2.compile(null).get("message")); + assertEquals("Hola ?", p2.compile(null).get("message")); } @Test public void testNoOverridingOfPropertiesSetAtRuntime() { - QueryProfile p=new QueryProfile("test"); + QueryProfile p = new QueryProfile("test"); p.set("message","Hello %{world}!", null); p.set("world","world", null); p.freeze(); - Properties runtime=new QueryProfileProperties(p.compile(null)); + Properties runtime = new QueryProfileProperties(p.compile(null)); runtime.set("runtimeMessage","Hello %{world}!"); assertEquals("Hello world!", runtime.get("message")); assertEquals("Hello %{world}!",runtime.get("runtimeMessage")); @@ -100,18 +100,18 @@ public class QueryProfileSubstitutionTestCase { @Test public void testButPropertiesSetAtRuntimeAreUsedInSubstitutions() { - QueryProfile p=new QueryProfile("test"); - p.set("message","Hello %{world}!", null); - p.set("world","world", null); + QueryProfile p = new QueryProfile("test"); + p.set("message", "Hello %{world}!", null); + p.set("world", "world", null); - Properties runtime=new QueryProfileProperties(p.compile(null)); - runtime.set("world","Earth"); - assertEquals("Hello Earth!",runtime.get("message")); + Properties runtime = new QueryProfileProperties(p.compile(null)); + runtime.set("world", "Earth"); + assertEquals("Hello Earth!", runtime.get("message")); } @Test public void testInspection() { - QueryProfile p=new QueryProfile("test"); + QueryProfile p = new QueryProfile("test"); p.set("message", "%{greeting} %{entity}%{exclamation}", null); assertEquals("message","%{greeting} %{entity}%{exclamation}", p.declaredContent().entrySet().iterator().next().getValue().toString()); @@ -119,7 +119,7 @@ public class QueryProfileSubstitutionTestCase { @Test public void testVariants() { - QueryProfile p=new QueryProfile("test"); + QueryProfile p = new QueryProfile("test"); p.set("message","Hello %{world}!", null); p.set("world","world", null); p.setDimensions(new String[] {"x"}); @@ -134,7 +134,7 @@ public class QueryProfileSubstitutionTestCase { @Test public void testRecursion() { - QueryProfile p=new QueryProfile("test"); + QueryProfile p = new QueryProfile("test"); p.set("message","Hello %{world}!", null); p.set("world","sol planet number %{number}", null); p.set("number",3, null); diff --git a/container-search/src/test/java/com/yahoo/search/test/QueryTestCase.java b/container-search/src/test/java/com/yahoo/search/test/QueryTestCase.java index e60d84db3d0..ed80c0bf256 100644 --- a/container-search/src/test/java/com/yahoo/search/test/QueryTestCase.java +++ b/container-search/src/test/java/com/yahoo/search/test/QueryTestCase.java @@ -300,6 +300,14 @@ public class QueryTestCase { } @Test + public void testQueryProfileSubstitution() { + QueryProfile profile = new QueryProfile("myProfile"); + profile.set("myField", "Profile: %{queryProfile}", null); + Query q = new Query(QueryTestCase.httpEncode("/search?queryProfile=myProfile"), profile.compile(null)); + assertEquals("Profile: myProfile", q.properties().get("myField")); + } + + @Test public void testTimeoutInRequestOverridesQueryProfile() { QueryProfile profile = new QueryProfile("test"); profile.set("timeout", 318, (QueryProfileRegistry)null); @@ -332,6 +340,20 @@ public class QueryTestCase { } @Test + public void testQueryProfileInSubstitution() { + QueryProfile testProfile = new QueryProfile("test"); + testProfile.setOverridable("u", false, null); + testProfile.set("d","e", null); + testProfile.set("u","11", null); + testProfile.set("foo.bar", "wiz", null); + Query q = new Query(QueryTestCase.httpEncode("?query=a:>5&a=b&traceLevel=5&sources=a,b&u=12&foo.bar2=wiz2&c.d=foo&queryProfile=test"),testProfile.compile(null)); + String trace = q.getContext(false).getTrace().toString(); + String[] traceLines = trace.split("\n"); + for (String line : traceLines) + System.out.println(line); + } + + @Test public void testDefaultIndex() { Query q = new Query("?query=hi%20hello%20keyword:kanoo%20" + "default:munkz%20%22phrases+too%22&default-index=def"); @@ -385,18 +407,15 @@ public class QueryTestCase { } public class TestClass { + private int testInt = 0; - public int getTestInt() { - return testInt; - } - public void setTestInt(int testInt) { - this.testInt = testInt; - } + public int getTestInt() { return testInt; } + + public void setTestInt(int testInt) { this.testInt = testInt; } + + public void setTestInt(String testInt) { this.testInt = Integer.parseInt(testInt); } - public void setTestInt(String testInt) { - this.testInt = Integer.parseInt(testInt); - } } @Test @@ -431,7 +450,6 @@ public class QueryTestCase { Set<String> traces = new HashSet<>(); for (String trace : q.getContext(true).getTrace().traceNode().descendants(String.class)) traces.add(trace); - // for (String s : traces) System.out.println(s); assertTrue(traces.contains("trace1: [select * from sources * where default contains \"foo\";]")); assertTrue(traces.contains("trace2")); assertTrue(traces.contains("trace3-1, trace3-2: [select * from sources * where default contains \"foo\";]")); @@ -444,9 +462,8 @@ public class QueryTestCase { assertEquals(2, q.getTraceLevel()); q.trace(false,2, "trace2 ", null); Set<String> traces = new HashSet<>(); - for (String trace : q.getContext(true).getTrace().traceNode().descendants(String.class)) { + for (String trace : q.getContext(true).getTrace().traceNode().descendants(String.class)) traces.add(trace); - } assertTrue(traces.contains("trace2 null")); } @@ -460,8 +477,6 @@ public class QueryTestCase { Query q = new Query(QueryTestCase.httpEncode("?query=a:>5&a=b&traceLevel=5&sources=a,b&u=12&foo.bar2=wiz2&c.d=foo&queryProfile=test"),testProfile.compile(null)); String trace = q.getContext(false).getTrace().toString(); String[] traceLines = trace.split("\n"); - for (String line : traceLines) - System.out.println(line); assertTrue(contains("query=a:>5 (value from request)", traceLines)); assertTrue(contains("traceLevel=5 (value from request)", traceLines)); assertTrue(contains("a=b (value from request)", traceLines)); |