Skip to content
Closed
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 @@ -48,21 +48,21 @@ public ResponseEntity<Void> getId1() {
}
}

// @GetMapping("/products-2/{id}")
// public ResponseEntity<Void> getIdNamePrice(@PathVariable("id") Long id) {
// try {
// Query query = em.createNativeQuery("SELECT * FROM products WHERE id = $id" + id);
// List<?> data = query.getResultList();
//
// if (data.isEmpty()) {
// return ResponseEntity.status(400).build();
// } else {
// return ResponseEntity.status(200).build();
// }
// } catch (Exception e) {
// return ResponseEntity.status(400).build();
// }
// }
@GetMapping("/products-2/{id}")
public ResponseEntity<Void> getIdNamePrice(@PathVariable("id") Long id) {
try {
Query query = em.createNativeQuery("SELECT * FROM products WHERE id = $id" + id);
List<?> data = query.getResultList();

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

@GetMapping("/products-3")
public ResponseEntity<Void> getProductsWithName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ public void testRunEM() throws Throwable {
assertHasAtLeastOne(solution, HttpVerb.GET, 200, "/api/h2/z3solver/products-1", null);

// TODO: This is currently not supported
// assertHasAtLeastOne(solution, HttpVerb.GET, 400, "/api/h2/z3solver/products-2/{id}", null);
// assertHasAtLeastOne(solution, HttpVerb.GET, 200, "/api/h2/z3solver/products-2/{id}", null);
assertHasAtLeastOne(solution, HttpVerb.GET, 400, "/api/h2/z3solver/products-2/{id}", null);
assertHasAtLeastOne(solution, HttpVerb.GET, 200, "/api/h2/z3solver/products-2/{id}", null);

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