Skip to content

Commit

Permalink
Fix the failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
vim345 committed Mar 22, 2024
1 parent e9099ae commit 5dd576a
Showing 1 changed file with 26 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import static org.junit.Assert.assertEquals;

import com.google.protobuf.Value;
import com.yelp.nrtsearch.server.config.LuceneServerConfiguration;
import com.yelp.nrtsearch.server.grpc.*;
import com.yelp.nrtsearch.server.luceneserver.ServerTestCase;
Expand Down Expand Up @@ -179,7 +180,7 @@ protected List<String> getIndices() {
}

protected FieldDefRequest getIndexDef(String name) throws IOException {
return getFieldsFromResourceFile("/facet/runtime_field_script.json");
return getFieldsFromResourceFile("/script/runtime_field_script.json");
}

protected void initIndex(String name) throws Exception {
Expand Down Expand Up @@ -311,26 +312,41 @@ public void RuntimeScriptForList() {
.setName("runtime_field")
.build();

List<List<String>> expectedValues = new ArrayList<>();
List<List<Value.Builder>> expectedValues = new ArrayList<>();
for (int id = 0; id < TOP_HITS; ++id) {
List nums = new ArrayList();
nums.add("1");
nums.add("2");
expectedValues.add(nums);
List<Value.Builder> nums = new ArrayList();
nums.add(Value.newBuilder().setStringValue("1"));
nums.add(Value.newBuilder().setStringValue("2"));
List<Value.Builder> values = Collections.unmodifiableList(nums);
expectedValues.add(values);
}
SearchResponse response = doQuery(runtimeField);
assertEquals(TOP_HITS, response.getHitsCount());
for (int id = 0; id < TOP_HITS; ++id) {
assertEquals(
String respOne =
response
.getHits(id)
.getFieldsMap()
.get("runtime_field")
.getFieldValueList()
.get(0)
.getRepeatedFieldValues()
.getTextValuesList(),
expectedValues.get(id));
.getListValue()
.getValuesList()
.get(0)
.getStringValue();
String respTwo =
response
.getHits(id)
.getFieldsMap()
.get("runtime_field")
.getFieldValueList()
.get(0)
.getListValue()
.getValuesList()
.get(1)
.getStringValue();
assertEquals(respOne, expectedValues.get(id).get(0).getStringValue());
assertEquals(respTwo, expectedValues.get(id).get(1).getStringValue());
}
}

Expand Down

0 comments on commit 5dd576a

Please sign in to comment.