Skip to content

Commit

Permalink
#sonarlint
Browse files Browse the repository at this point in the history
  • Loading branch information
ja-fra committed Sep 3, 2024
1 parent 54b3c48 commit 64e909f
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@SuppressWarnings("java:S115")
public class SuggestionRequestHandler extends SearchHandler implements SolrCoreAware {

private static final String DEFAULT_END_VALUE = "NOW/DAY";
Expand Down Expand Up @@ -81,6 +82,7 @@ public static LimitType parse(String s, LimitType def) {
private static boolean SUGGESTION_INTERVAL = false;
private static boolean SUGGESTION_INTERVAL_OTHER = false;

@Override
public void inform(SolrCore core) {
super.inform(core);
suggestionService = new SuggestionService(core, this.getInitArgs());
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/redlink/solr/suggestion/result/Facet.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void setCount(int count) {

public boolean equals(Object o) {
try {
return ((Facet) o).name.equals(this.name) && ((Facet) o).value.equals(this.value);
return o!= null && ((Facet) o).name.equals(this.name) && ((Facet) o).value.equals(this.value);
} catch (Exception e) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public SuggestionResult getFacets() {

public boolean equals(Object o) {
try {
return ((Interval) o).start.isEqual(this.start) && ((Interval) o).end.isEqual(this.end);
return o!= null && ((Interval) o).start.isEqual(this.start) && ((Interval) o).end.isEqual(this.end);
} catch (Exception e) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,14 @@ public static SuggestionResult createMultiValueResult(SolrCore core, SolrQueryRe
for (String field : fields) {
Iterator<Map.Entry> iter = ((NamedList) facets.get(field)).iterator();
while (iter.hasNext()) {
Map.Entry<String, NamedList<Object>> entry = iter.next();
Map.Entry<String, Integer> entry = iter.next();
String s = " " + FieldAnalyzerService.analyzeString(core, df, entry.getKey());
//try if it maps to current fields
if (s.toLowerCase().contains(" " + qps[i].toLowerCase())) {
Object o = entry.getValue();
l.addLast(new Facet(field, entry.getKey(), (Integer) o));
Integer count = entry.getValue();
if (count != null) {
l.addLast(new Facet(field, entry.getKey(), count));
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public static void afterClass() throws Exception {
core.close();
}*/

@Test
public void testSpecialChars() {

ModifiableSolrParams params = new ModifiableSolrParams();
Expand Down Expand Up @@ -171,6 +172,7 @@ public void testWithNumbers() {
/**
* Test if parameters are parsed
*/
@Test
public void testParameterParsing() {

ModifiableSolrParams params = new ModifiableSolrParams();
Expand Down Expand Up @@ -203,6 +205,7 @@ public void testParameterParsing() {

}

@Test
public void testEmptyNumberSuggestion() {

ModifiableSolrParams params = new ModifiableSolrParams();
Expand All @@ -221,6 +224,7 @@ public void testEmptyNumberSuggestion() {

}

@Test
public void testWithInvalidField() {

ModifiableSolrParams params = new ModifiableSolrParams();
Expand All @@ -240,6 +244,7 @@ public void testWithInvalidField() {
}

//Test should fail regarding the issue. TODO check schema.xml that is used as basis for the issue
@Test
public void testIdSearch() {

ModifiableSolrParams params = new ModifiableSolrParams();
Expand All @@ -258,6 +263,7 @@ public void testIdSearch() {
}

//Test: The full text suggestions (spellcheck) display values which do not deliver search results
@Test
public void testIdSearchNoSpellcheck() {

ModifiableSolrParams params = new ModifiableSolrParams();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.apache.solr.request.SolrQueryRequest;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;

public class PivotRegexBasedSuggestionTest extends SolrTestCaseJ4 {
Expand Down Expand Up @@ -90,6 +91,7 @@ public static void afterClass() throws Exception {
/**
*
*/
@Test
public void testSuggestionIntervals() {

ModifiableSolrParams params = new ModifiableSolrParams();
Expand Down Expand Up @@ -136,6 +138,7 @@ public void testSuggestionIntervals() {
"//response/lst[@name='suggestions']/lst[@name='suggestion_intervals']/lst[@name='last_year']/lst[@name='suggestion_facets']/lst[@name='dynamic_multi_stored_suggest_string_name']/int[@name='sebastien loeb'][.='2']");
}

@Test
public void testSuggestionIntervalsDateMath() {

ModifiableSolrParams params = new ModifiableSolrParams();
Expand Down Expand Up @@ -176,6 +179,7 @@ public void testSuggestionIntervalsDateMath() {
/**
*
*/
@Test
public void testSuggestionNoIntervals() {

ModifiableSolrParams params = new ModifiableSolrParams();
Expand Down Expand Up @@ -209,6 +213,7 @@ public void testSuggestionNoIntervals() {
"//response/lst[@name='suggestions']/lst[@name='suggestion_facets']/lst[@name='dynamic_multi_stored_suggest_string_name']/int[@name='sebastien vettel'][.='1']");
}

@Test
public void testQueryPlusSeparator() {

ModifiableSolrParams params = new ModifiableSolrParams();
Expand All @@ -226,6 +231,7 @@ public void testQueryPlusSeparator() {

}

@Test
public void testQueryTermLimit() {

ModifiableSolrParams params = new ModifiableSolrParams();
Expand Down

0 comments on commit 64e909f

Please sign in to comment.