Skip to content

Add test for empty where #1162

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@ public class Z3SolverTypesRest {
@Autowired
private EntityManager em;

// // TODO: Fix this. This fails to load, as when the WHERE clause is empty, it fails to calculate the failedWhere
// @GetMapping("/products")
// public ResponseEntity<Void> getEmptyWhere() {
// Query query = em.createNativeQuery(
// "select (1) from products");
// List<?> data = query.getResultList();
//
// if (data.isEmpty()) {
// return ResponseEntity.status(400).build();
// } else {
// return ResponseEntity.status(200).build();
// }
// }
// TODO: Fix this. This fails to load, as when the WHERE clause is empty, it fails to calculate the failedWhere
@GetMapping("/products")
public ResponseEntity<Void> getEmptyWhere() {
Query query = em.createNativeQuery(
"select (1) from products");
List<?> data = query.getResultList();

if (data.isEmpty()) {
return ResponseEntity.status(400).build();
} else {
return ResponseEntity.status(200).build();
}
}

@GetMapping("/products-1")
public ResponseEntity<Void> getId1() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
assertFalse(solution.getIndividuals().isEmpty());

// TODO: Add support for queries with empty WHERE in the select
// assertHasAtLeastOne(solution, HttpVerb.GET, 400, "/api/h2/z3solver/products", null);
// assertHasAtLeastOne(solution, HttpVerb.GET, 200, "/api/h2/z3solver/products", null);
assertHasAtLeastOne(solution, HttpVerb.GET, 400, "/api/h2/z3solver/products", null);
assertHasAtLeastOne(solution, HttpVerb.GET, 200, "/api/h2/z3solver/products", null);

Check failure on line 41 in e2e-tests/spring-rest-h2-z3solver/src/test/java/org/evomaster/e2etests/spring/h2/z3solver/Z3SolverEMTest.java

View workflow job for this annotation

GitHub Actions / JUnit Test Report

Z3SolverEMTest.testRunEM

Seed 44. Missing 200 GET /api/h2/z3solver/products null REST calls: 200 GET /api/h2/z3solver/products-1 , auth=NoAuth 200 GET /v2/api-docs , auth=NoAuth 400 GET /api/h2/z3solver/products-1?EMextraParam123=42 , auth=NoAuth 400 GET /api/h2/z3solver/products-3?EMextraParam123=42 , auth=NoAuth 400 GET /api/h2/z3solver/products?EMextraParam123=42 , auth=NoAuth ==> expected: <true> but was: <false>
Raw output
org.opentest4j.AssertionFailedError: 
Seed 44. Missing 200 GET /api/h2/z3solver/products null
REST calls:
200 GET /api/h2/z3solver/products-1 , auth=NoAuth
200 GET /v2/api-docs , auth=NoAuth
400 GET /api/h2/z3solver/products-1?EMextraParam123=42 , auth=NoAuth
400 GET /api/h2/z3solver/products-3?EMextraParam123=42 , auth=NoAuth
400 GET /api/h2/z3solver/products?EMextraParam123=42 , auth=NoAuth
 ==> expected: <true> but was: <false>
	at org.junit.jupiter.api.AssertionUtils.fail(AssertionUtils.java:55)
	at org.junit.jupiter.api.AssertTrue.assertTrue(AssertTrue.java:40)
	at org.junit.jupiter.api.Assertions.assertTrue(Assertions.java:193)
	at org.evomaster.e2etests.utils.RestTestBase.assertHasAtLeastOne(RestTestBase.java:313)
	at org.evomaster.e2etests.spring.h2.z3solver.Z3SolverEMTest.lambda$testRunEM$0(Z3SolverEMTest.java:41)
	at org.evomaster.e2etests.utils.EnterpriseTestBase.lambda$null$4(EnterpriseTestBase.java:233)
	at org.evomaster.e2etests.utils.EnterpriseTestBase.handleFlaky(EnterpriseTestBase.java:454)
	at org.evomaster.e2etests.utils.EnterpriseTestBase.lambda$runTestHandlingFlaky$5(EnterpriseTestBase.java:229)
	at org.junit.jupiter.api.AssertTimeout.lambda$assertTimeoutPreemptively$2(AssertTimeout.java:102)
	at org.junit.jupiter.api.AssertTimeout.lambda$assertTimeoutPreemptively$4(AssertTimeout.java:138)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:750)

assertHasAtLeastOne(solution, HttpVerb.GET, 400, "/api/h2/z3solver/products-1", null);
assertHasAtLeastOne(solution, HttpVerb.GET, 200, "/api/h2/z3solver/products-1", null);
Expand Down
Loading