From 7637cd78f1e599803819c93c600f1b73e4f79c9e Mon Sep 17 00:00:00 2001 From: James Cullimore Date: Mon, 18 Mar 2019 16:14:45 +0000 Subject: [PATCH] issue #46 updated update multiple test with missing id to check that it throws the exception correctly --- .../common/controllers/data/SaveTest.java | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/src/test/java/com/manywho/services/sql/suites/common/controllers/data/SaveTest.java b/src/test/java/com/manywho/services/sql/suites/common/controllers/data/SaveTest.java index a05417f..36cab10 100644 --- a/src/test/java/com/manywho/services/sql/suites/common/controllers/data/SaveTest.java +++ b/src/test/java/com/manywho/services/sql/suites/common/controllers/data/SaveTest.java @@ -14,7 +14,7 @@ public class SaveTest extends ServiceFunctionalTest { @Test public void testCreate() throws Exception { - DbConfigurationTest.setPropertiesIfNotInitialized("postgresql"); + DbConfigurationTest.setPropertiesIfNotInitialized("mysql"); try (Connection connection = getSql2o().open()) { String sql = "CREATE TABLE " + escapeTableName("country") + "(" + "id integer NOT NULL," + @@ -41,7 +41,7 @@ public void testCreate() throws Exception { @Test public void testUpdate() throws Exception { - DbConfigurationTest.setPropertiesIfNotInitialized("postgresql"); + DbConfigurationTest.setPropertiesIfNotInitialized("mysql"); try (Connection connection = getSql2o().open()) { String sql = "CREATE TABLE " + escapeTableName("country") + "(" + "id integer NOT NULL," + @@ -124,7 +124,7 @@ private void assertCountOfTestTable (int expected) throws Exception { @Test public void createMultipleTest() throws Exception { - DbConfigurationTest.setPropertiesIfNotInitialized("postgresql"); + DbConfigurationTest.setPropertiesIfNotInitialized("mysql"); createTestTable(); @@ -156,7 +156,7 @@ public void updateMultipleTest() throws Exception { @Test public void updateAndCreateTest() throws Exception { - DbConfigurationTest.setPropertiesIfNotInitialized("postgresql"); + DbConfigurationTest.setPropertiesIfNotInitialized("mysql"); createTestTable(); @@ -178,12 +178,22 @@ public void updateMultipleMissingId() throws Exception { insertToTestTable(1,"first"); - DefaultApiRequest.saveDataRequestAndAssertion("/data", - "suites/common/data/save/update/update-multiple-missing-request.json", - configurationParameters(), - "suites/common/data/save/update/update-multiple-missing-response.json", - dispatcher - ); + try { + DefaultApiRequest.saveDataRequestAndAssertion("/data", + "suites/common/data/save/update/update-multiple-missing-request.json", + configurationParameters(), + "suites/common/data/save/update/update-multiple-missing-response.json", + dispatcher + ); + } catch (Exception ex) { + if (ex.getCause() instanceof RecordNotFoundException) { + return; + } + ex.printStackTrace(); + Assert.fail("Unexpected exception: " +ex); + throw ex; + } + Assert.fail("Expected RecordNotFoundException"); } @After