Skip to content

Conversation

@mmiguerodriguez
Copy link
Collaborator

No description provided.

@mmiguerodriguez mmiguerodriguez marked this pull request as ready for review October 28, 2025 21:52
Copy link
Collaborator

@jgaleotti jgaleotti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add test cases for the classes OpenSearchHeuristicsCalculator, ParameterExtractor and OpenSearchQueryHelper

import org.evomaster.client.java.controller.opensearch.selectors.MatchSelector;
import org.evomaster.client.java.controller.opensearch.selectors.QuerySelector;

public class OpenSearchQueryParser {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need tests for OpenSearchQueryParser to check that the JSON is correctly parsed into its corresponding OpenSearch operation.

/**
* Utility class to extract common parameters and reduce code duplication in selectors.
*/
public class ParameterExtractor {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add test cases for this class

/**
* Extracts the case_insensitive parameter from a term query object.
*/
public static Boolean extractCaseInsensitive(Object query, String structure) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add test cases for this class

@mmiguerodriguez mmiguerodriguez marked this pull request as draft October 29, 2025 18:36
@mmiguerodriguez mmiguerodriguez marked this pull request as ready for review October 29, 2025 18:36
@jgaleotti jgaleotti requested a review from arcuri82 November 14, 2025 13:56
Copy link
Collaborator

@arcuri82 arcuri82 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry for late check, but was on vacation most of last week


if (operation instanceof MatchOperation) {
return calculateDistanceForMatch((MatchOperation) operation, doc);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't these be a chain of if/else, with a final having a warn log if no match was present? (eg to see if we miss any case).

// Not enough matches - distance based on how many more matches needed
int shortfall = minimumRequired - matchCount;
// Return a distance that reflects both the shortfall and the quality of non-matching terms
return shortfall * 10.0 + (totalDistance / expectedTerms.size());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if expectedTerms.size() is 0?


try {
// Create pattern with case insensitive flag if needed
java.util.regex.Pattern pattern;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are the regex in OpenSearch having the same syntax of Java regex? clarify here in some comments, with possible some links

Copy link
Collaborator Author

@mmiguerodriguez mmiguerodriguez Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OpenSearch uses Lucene regular expression syntax, which is similar but NOT identical to Java regex.

https://opensearch.org/docs/latest/query-dsl/term/regexp/
https://lucene.apache.org/core/8_0_0/core/org/apache/lucene/util/automaton/RegExp.html

@jgaleotti Do you consider adding Java Regexp for this heuristic calculation as acceptable?


// Helper methods for advanced operations

private int calculateEditDistance(String s1, String s2, boolean allowTranspositions) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

geneneric helper functions on strings should not be here, but rather in client-java/distance-heuristics/src/main/java/org/evomaster/client/java/distance/heuristics/DistanceHelper.java

// }
@GetMapping("gte/{gte}")
public List<Age> findGteAge(@PathVariable("gte") Integer gte) throws IOException {
return ageRepo.findGteAge(gte);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all these endpoints should return 404 if no data is found

Solution<RestIndividual> solution = initAndRun(args);

// assertHasAtLeastOne(solution, HttpVerb.GET, 404, "/students/{q}", null);
assertHasAtLeastOne(solution, HttpVerb.GET, 200, "/students/{lastName}", null);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add assertions for both 404 and 200 cases

// Term selector tests
@GetMapping("category/{category}")
public List<Product> findByCategory(@PathVariable String category) throws IOException {
return productRepository.findByCategory(category);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do return 404 if nothing is found in these endpoints, as it will simplify writing assertions/checks in the tests


Solution<RestIndividual> solution = initAndRun(args);

assertHasAtLeastOne(solution, HttpVerb.GET, 200, "/queries/category/{category}", null);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add assertions on 404

}

@Test
public void testRangeQueries() throws Throwable {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are these E2E repeated with same configurations? can have single tests with all the assertions.
otherwise, if you only want to test specific endpoints, you have to pass args parameters to specify them, eg, with --endpointPrefix

@@ -0,0 +1,21 @@
package com.opensearch.queries;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

folder e2e-tests does not exist any more (we did a major refactoring of folder structures recently)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing that.

@mmiguerodriguez
Copy link
Collaborator Author

mmiguerodriguez commented Nov 18, 2025

@arcuri82 is there any known issue with the evomaster-e2e-tests-spring-rest-rsa module? Most of the times I try building the project I'm having issues with that...

[INFO] evomaster-e2e-tests-spring-rest-rsa ................ FAILURE [  0.150 s]
[INFO] evomaster-e2e-tests-spring-rpc-grpc ................ SKIPPED
[INFO] evomaster-e2e-tests-spring-rpc-thrift .............. SKIPPED
[INFO] evomaster-core-integration-tests ................... SKIPPED
[INFO] evomaster-core-driver-it ........................... SKIPPED
[INFO] evomaster-core-graphql-it .......................... SKIPPED
[INFO] evomaster-core-it .................................. SKIPPED
[INFO] evomaster-test-old-libraries ....................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------

Is there any way to prevent those errors?

@arcuri82
Copy link
Collaborator

@mmiguerodriguez hi. there is no known current issue about evomaster-e2e-tests-spring-rest-rsa. what is the error you are getting?

@mmiguerodriguez
Copy link
Collaborator Author

mmiguerodriguez commented Nov 20, 2025

I'm not completely sure what was the issue, perhaps different Java version used by Maven and IntelliJ builds...
I've modified my IntelliJ to use Java 17 and maven too. Now it's fixed.

I'll be reviewing why there's some errors on the build/tests. I've already made some of the adjustements.

@arcuri82
Copy link
Collaborator

@mmiguerodriguez ah, yes. we moved to JDK 17 recently... and might move to 21 in the near future

@mmiguerodriguez
Copy link
Collaborator Author

We'll need to adjust for_developers.md since it may be outdated.

@arcuri82
Copy link
Collaborator

@mmiguerodriguez good point! i ll do now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants