From 9d191324ffb3ba11e7e66eb525672528467453a0 Mon Sep 17 00:00:00 2001 From: Ashish Trivedi Date: Sun, 26 Jul 2020 18:17:00 +0530 Subject: [PATCH] #1321 --- transaction-script/pom.xml | 35 +++++++++++++------ .../transactionscript/Hotel.java | 23 ++++++++++++ .../transactionscript/HotelDao.java | 23 ++++++++++++ .../transactionscript/HotelDaoImpl.java | 23 ++++++++++++ .../transactionscript/Room.java | 23 ++++++++++++ .../TransactionScriptApp.java | 26 ++++++++++++-- .../transactionscript/HotelTest.java | 28 ++++++++++++--- 7 files changed, 164 insertions(+), 17 deletions(-) diff --git a/transaction-script/pom.xml b/transaction-script/pom.xml index 64e824ead..f51bf36cf 100644 --- a/transaction-script/pom.xml +++ b/transaction-script/pom.xml @@ -1,4 +1,28 @@ + @@ -16,12 +40,6 @@ com.h2database h2 - - com.h2database - h2 - 1.4.200 - test - org.junit.jupiter junit-jupiter-engine @@ -31,12 +49,7 @@ org.mockito mockito-core - - com.h2database - h2 - - diff --git a/transaction-script/src/main/java/com/ashishtrivedi16/transactionscript/Hotel.java b/transaction-script/src/main/java/com/ashishtrivedi16/transactionscript/Hotel.java index 212a0df68..58705e5e6 100644 --- a/transaction-script/src/main/java/com/ashishtrivedi16/transactionscript/Hotel.java +++ b/transaction-script/src/main/java/com/ashishtrivedi16/transactionscript/Hotel.java @@ -1,3 +1,26 @@ +/* + * The MIT License + * Copyright © 2014-2019 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + package com.ashishtrivedi16.transactionscript; import java.util.Optional; diff --git a/transaction-script/src/main/java/com/ashishtrivedi16/transactionscript/HotelDao.java b/transaction-script/src/main/java/com/ashishtrivedi16/transactionscript/HotelDao.java index 7efa3c9e6..71d9860ba 100644 --- a/transaction-script/src/main/java/com/ashishtrivedi16/transactionscript/HotelDao.java +++ b/transaction-script/src/main/java/com/ashishtrivedi16/transactionscript/HotelDao.java @@ -1,3 +1,26 @@ +/* + * The MIT License + * Copyright © 2014-2019 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + package com.ashishtrivedi16.transactionscript; import java.util.Optional; diff --git a/transaction-script/src/main/java/com/ashishtrivedi16/transactionscript/HotelDaoImpl.java b/transaction-script/src/main/java/com/ashishtrivedi16/transactionscript/HotelDaoImpl.java index 88e7984a6..f1b509416 100644 --- a/transaction-script/src/main/java/com/ashishtrivedi16/transactionscript/HotelDaoImpl.java +++ b/transaction-script/src/main/java/com/ashishtrivedi16/transactionscript/HotelDaoImpl.java @@ -1,3 +1,26 @@ +/* + * The MIT License + * Copyright © 2014-2019 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + package com.ashishtrivedi16.transactionscript; import java.sql.Connection; diff --git a/transaction-script/src/main/java/com/ashishtrivedi16/transactionscript/Room.java b/transaction-script/src/main/java/com/ashishtrivedi16/transactionscript/Room.java index 55a93ddec..c4ad7bfd6 100644 --- a/transaction-script/src/main/java/com/ashishtrivedi16/transactionscript/Room.java +++ b/transaction-script/src/main/java/com/ashishtrivedi16/transactionscript/Room.java @@ -1,3 +1,26 @@ +/* + * The MIT License + * Copyright © 2014-2019 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + package com.ashishtrivedi16.transactionscript; /** diff --git a/transaction-script/src/main/java/com/ashishtrivedi16/transactionscript/TransactionScriptApp.java b/transaction-script/src/main/java/com/ashishtrivedi16/transactionscript/TransactionScriptApp.java index dfd980b46..22f4bcdd6 100644 --- a/transaction-script/src/main/java/com/ashishtrivedi16/transactionscript/TransactionScriptApp.java +++ b/transaction-script/src/main/java/com/ashishtrivedi16/transactionscript/TransactionScriptApp.java @@ -1,9 +1,31 @@ +/* + * The MIT License + * Copyright © 2014-2019 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + package com.ashishtrivedi16.transactionscript; import java.sql.SQLException; import java.util.List; import javax.sql.DataSource; -import org.h2.jdbc.JdbcSQLException; import org.h2.jdbcx.JdbcDataSource; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -65,7 +87,7 @@ public class TransactionScriptApp { try (var connection = dataSource.getConnection(); var statement = connection.createStatement()) { statement.execute(RoomSchemaSql.CREATE_SCHEMA_SQL); - } catch (JdbcSQLException e) { + } catch (Exception e) { throw new CustomException(e.getMessage(), e); } } diff --git a/transaction-script/src/test/java/com/ashishtrivedi16/transactionscript/HotelTest.java b/transaction-script/src/test/java/com/ashishtrivedi16/transactionscript/HotelTest.java index 6c16b2df5..ca1d7718c 100644 --- a/transaction-script/src/test/java/com/ashishtrivedi16/transactionscript/HotelTest.java +++ b/transaction-script/src/test/java/com/ashishtrivedi16/transactionscript/HotelTest.java @@ -1,6 +1,28 @@ +/* + * The MIT License + * Copyright © 2014-2019 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + package com.ashishtrivedi16.transactionscript; -import org.h2.jdbc.JdbcSQLException; import org.h2.jdbcx.JdbcDataSource; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -10,8 +32,6 @@ import java.sql.SQLException; import java.util.List; import static org.junit.jupiter.api.Assertions.*; -import static org.junit.jupiter.api.Assumptions.assumeTrue; -import static org.mockito.Mockito.*; /** * Tests {@link Hotel} @@ -94,7 +114,7 @@ public class HotelTest { try (var connection = dataSource.getConnection(); var statement = connection.createStatement()) { statement.execute(RoomSchemaSql.CREATE_SCHEMA_SQL); - } catch (JdbcSQLException e) { + } catch (Exception e) { throw new CustomException(e.getMessage(), e); } }