From e01340289b14dc2ded58a5ff0079e03ffde41564 Mon Sep 17 00:00:00 2001 From: Parisa Tejari Date: Tue, 9 Jan 2024 16:36:34 +0100 Subject: [PATCH] replace executeQuery() with executeUpdate() to stop throwing exceptions when the query does not have a result. --- .../doa/LocalEGADOAApplicationTests.java | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/src/test/java/no/uio/ifi/localega/doa/LocalEGADOAApplicationTests.java b/src/test/java/no/uio/ifi/localega/doa/LocalEGADOAApplicationTests.java index 39782c9..024c630 100644 --- a/src/test/java/no/uio/ifi/localega/doa/LocalEGADOAApplicationTests.java +++ b/src/test/java/no/uio/ifi/localega/doa/LocalEGADOAApplicationTests.java @@ -63,26 +63,15 @@ public static void setup() { PreparedStatement file = connection.prepareStatement("SELECT local_ega.insert_file('body.enc','requester@elixir-europe.org');"); file.executeQuery(); PreparedStatement header = connection.prepareStatement("UPDATE local_ega.files SET header = '637279707434676801000000010000006c00000000000000aa7ad1bb4f93bf5e4fb3bc28a95bc4d80bf2fd8075e69eb2ee15e0a4f08f1d78ab98c8fd9b50e675f71311936e8d0c6f73538962b836355d5d4371a12eae46addb43518b5236fb9554249710a473026f34b264a61d2ba52ed11abc1efa1d3478fa40a710' WHERE id = 1;"); - try { - header.executeQuery(); - } catch (Exception e) { - log.info(e.getMessage()); - } + header.executeUpdate(); PreparedStatement finalize = connection.prepareStatement("UPDATE local_ega.files SET archive_path = 'test/body.enc', status = 'READY', stable_id = 'EGAF00000000014' WHERE id = 1;"); - try { - finalize.executeQuery(); - } catch (Exception e) { - log.info(e.getMessage()); - } + finalize.executeUpdate(); connection.close(); + props.setProperty("user", "lega_out"); connection = DriverManager.getConnection(url, props); PreparedStatement dataset = connection.prepareStatement("INSERT INTO local_ega_ebi.filedataset(file_id, dataset_stable_id) values(1, 'EGAD00010000919');"); - try { - dataset.executeQuery(); - } catch (Exception e) { - log.info(e.getMessage()); - } + dataset.executeUpdate(); connection.close(); JSONArray tokens = Unirest.get("http://localhost:8000/tokens").asJson().getBody().getArray();