From 1963e5aff987f36bd908525af8f92e67a0e21bcc Mon Sep 17 00:00:00 2001 From: Ayush Dubey Date: Thu, 16 Jun 2022 07:17:40 +0530 Subject: [PATCH] upgraded omrs version to 2.5.0 --- pom.xml | 4 +- .../integrationtests/BaseIntegrationTest.java | 50 +++++++++++-------- .../scheduler/ReportsSchedulerTest.java | 2 +- 3 files changed, 31 insertions(+), 25 deletions(-) diff --git a/pom.xml b/pom.xml index 2f14b2d7..838e3a98 100644 --- a/pom.xml +++ b/pom.xml @@ -15,7 +15,7 @@ 2.10.3 true true - 2.1.6 + 2.5.0 2.17.1 0.94.2 @@ -62,7 +62,7 @@ 1.8 1.8 - + UTF-8 diff --git a/src/test/java/org/bahmni/reports/report/integrationtests/BaseIntegrationTest.java b/src/test/java/org/bahmni/reports/report/integrationtests/BaseIntegrationTest.java index 3a5a2f11..40b8bc26 100644 --- a/src/test/java/org/bahmni/reports/report/integrationtests/BaseIntegrationTest.java +++ b/src/test/java/org/bahmni/reports/report/integrationtests/BaseIntegrationTest.java @@ -17,6 +17,7 @@ import org.bahmni.reports.wrapper.CsvReport; import org.bahmni.webclients.HttpClient; import org.dbunit.DatabaseUnitException; +import org.dbunit.DatabaseUnitRuntimeException; import org.dbunit.database.DatabaseConfig; import org.dbunit.database.DatabaseConnection; import org.dbunit.database.IDatabaseConnection; @@ -35,8 +36,8 @@ import org.openmrs.test.SkipBaseSetup; import org.springframework.http.ResponseEntity; import org.springframework.mock.web.MockHttpServletResponse; +import org.springframework.test.annotation.Commit; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.transaction.TransactionConfiguration; import org.springframework.test.context.web.WebAppConfiguration; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.MvcResult; @@ -63,7 +64,7 @@ @RunWith(SpringJUnit4ClassRunner.class) @WebAppConfiguration @Transactional -@TransactionConfiguration(defaultRollback = false) +@Commit @SkipBaseSetup public class BaseIntegrationTest extends BaseContextSensitiveTest { @@ -211,27 +212,32 @@ protected JasperReportBuilder fetchReportBuilder(String reportName, String start } @Override - public void deleteAllData() throws Exception { - Context.clearSession(); - Connection connection = this.getConnection(); - this.turnOffDBConstraints(connection); - String[] types = {"Table"}; - IDatabaseConnection dbUnitConn = this.setupDatabaseConnection(connection); - ResultSet resultSet = connection.getMetaData().getTables((String) null, "PUBLIC", "%", types); - DefaultDataSet dataset = new DefaultDataSet(); - - while (resultSet.next()) { - String tableName = resultSet.getString(3); - dataset.addTable(new DefaultTable(tableName)); + public void deleteAllData() { + try { + Context.clearSession(); + Connection connection = this.getConnection(); + this.turnOffDBConstraints(connection); + String[] types = {"Table"}; + IDatabaseConnection dbUnitConn = this.setupDatabaseConnection(connection); + ResultSet resultSet = connection.getMetaData().getTables((String) null, "PUBLIC", "%", types); + DefaultDataSet dataset = new DefaultDataSet(); + + while (resultSet.next()) { + String tableName = resultSet.getString(3); + dataset.addTable(new DefaultTable(tableName)); + } + + DatabaseOperation.DELETE_ALL.execute(dbUnitConn, dataset); + this.turnOnDBConstraints(connection); + connection.commit(); + this.updateSearchIndex(); + } + catch (DatabaseUnitException | SQLException var6) { + throw new DatabaseUnitRuntimeException(var6); } - - DatabaseOperation.DELETE_ALL.execute(dbUnitConn, dataset); - this.turnOnDBConstraints(connection); - connection.commit(); - this.updateSearchIndex(); } - private void turnOffDBConstraints(Connection connection) throws SQLException { + protected void turnOffDBConstraints(Connection connection) throws SQLException { String constraintsOffSql; if (this.useInMemoryDatabase().booleanValue()) { constraintsOffSql = "SET REFERENTIAL_INTEGRITY FALSE"; @@ -244,7 +250,7 @@ private void turnOffDBConstraints(Connection connection) throws SQLException { ps.close(); } - private IDatabaseConnection setupDatabaseConnection(Connection connection) throws DatabaseUnitException { + protected IDatabaseConnection setupDatabaseConnection(Connection connection) throws DatabaseUnitException { DatabaseConnection dbUnitConn = new DatabaseConnection(connection); if (this.useInMemoryDatabase().booleanValue()) { DatabaseConfig config = dbUnitConn.getConfig(); @@ -254,7 +260,7 @@ private IDatabaseConnection setupDatabaseConnection(Connection connection) throw return dbUnitConn; } - private void turnOnDBConstraints(Connection connection) throws SQLException { + protected void turnOnDBConstraints(Connection connection) throws SQLException { String constraintsOnSql; if (this.useInMemoryDatabase().booleanValue()) { constraintsOnSql = "SET REFERENTIAL_INTEGRITY TRUE"; diff --git a/src/test/java/org/bahmni/reports/scheduler/ReportsSchedulerTest.java b/src/test/java/org/bahmni/reports/scheduler/ReportsSchedulerTest.java index 6cdb2bef..94e0ff55 100644 --- a/src/test/java/org/bahmni/reports/scheduler/ReportsSchedulerTest.java +++ b/src/test/java/org/bahmni/reports/scheduler/ReportsSchedulerTest.java @@ -27,6 +27,7 @@ import static org.bahmni.reports.scheduler.ReportStatus.COMPLETED; import static org.bahmni.reports.scheduler.ReportStatus.ERROR; import static org.bahmni.reports.scheduler.ReportStatus.QUEUED; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; @@ -35,7 +36,6 @@ import static org.mockito.Mockito.when; import static org.powermock.api.mockito.PowerMockito.mockStatic; import static org.powermock.api.mockito.PowerMockito.whenNew; -import static org.springframework.test.util.MatcherAssertionErrors.assertThat; @RunWith(PowerMockRunner.class) @PowerMockIgnore({"org.hibernate.*", "org.springframework.*", "javax.management.*"})