mirror of
https://github.com/Kingsrook/qqq.git
synced 2025-07-19 05:30:43 +00:00
Add basic test for RDBMS Assessor; change h2 to not upshift all names (and backout some places where we'd previously worked around that)
This commit is contained in:
@ -101,12 +101,6 @@ public class RDBMSTableMetaDataBuilder
|
|||||||
String schemaName = null;
|
String schemaName = null;
|
||||||
String tableNameForMetaDataQueries = tableName;
|
String tableNameForMetaDataQueries = tableName;
|
||||||
|
|
||||||
if(backendMetaData.getVendor().equals("h2"))
|
|
||||||
{
|
|
||||||
databaseName = databaseName.toUpperCase();
|
|
||||||
tableNameForMetaDataQueries = tableName.toUpperCase();
|
|
||||||
}
|
|
||||||
|
|
||||||
try(ResultSet tableResultSet = databaseMetaData.getTables(databaseName, schemaName, tableNameForMetaDataQueries, null))
|
try(ResultSet tableResultSet = databaseMetaData.getTables(databaseName, schemaName, tableNameForMetaDataQueries, null))
|
||||||
{
|
{
|
||||||
if(!tableResultSet.next())
|
if(!tableResultSet.next())
|
||||||
|
@ -153,12 +153,22 @@ public class TestUtils
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
public static RDBMSBackendMetaData defineBackend()
|
public static RDBMSBackendMetaData defineBackend()
|
||||||
{
|
{
|
||||||
return (new RDBMSBackendMetaData()
|
RDBMSBackendMetaData rdbmsBackendMetaData = new RDBMSBackendMetaData()
|
||||||
.withName(DEFAULT_BACKEND_NAME)
|
.withName(DEFAULT_BACKEND_NAME)
|
||||||
.withVendor("h2")
|
.withVendor("h2")
|
||||||
.withHostName("mem")
|
.withHostName("mem")
|
||||||
.withDatabaseName("test_database")
|
.withDatabaseName("test_database")
|
||||||
.withUsername("sa"));
|
.withUsername("sa");
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// by default h2 up-shifts all names, which isn't how we expected //
|
||||||
|
// things to be, so, tell it not to do that. //
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
String jdbcUrl = ConnectionManager.getJdbcUrl(rdbmsBackendMetaData);
|
||||||
|
jdbcUrl += ";DATABASE_TO_UPPER=FALSE";
|
||||||
|
rdbmsBackendMetaData.setJdbcUrl(jdbcUrl);
|
||||||
|
|
||||||
|
return rdbmsBackendMetaData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -438,8 +438,8 @@ class QueryManagerTest extends BaseTest
|
|||||||
""");
|
""");
|
||||||
List<Map<String, Object>> rows = QueryManager.executeStatementForRows(connection, "SELECT * FROM test_table");
|
List<Map<String, Object>> rows = QueryManager.executeStatementForRows(connection, "SELECT * FROM test_table");
|
||||||
assertNotNull(rows);
|
assertNotNull(rows);
|
||||||
assertEquals(47, rows.get(0).get("INT_COL"));
|
assertEquals(47, rows.get(0).get("int_col"));
|
||||||
assertEquals("Q", rows.get(0).get("CHAR_COL"));
|
assertEquals("Q", rows.get(0).get("char_col"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,73 @@
|
|||||||
|
/*
|
||||||
|
* QQQ - Low-code Application Framework for Engineers.
|
||||||
|
* Copyright (C) 2021-2025. Kingsrook, LLC
|
||||||
|
* 651 N Broad St Ste 205 # 6917 | Middletown DE 19709 | United States
|
||||||
|
* contact@kingsrook.com
|
||||||
|
* https://github.com/Kingsrook/
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.kingsrook.qqq.backend.module.rdbms.model.metadata;
|
||||||
|
|
||||||
|
|
||||||
|
import com.kingsrook.qqq.backend.core.context.QContext;
|
||||||
|
import com.kingsrook.qqq.backend.core.instances.assessment.QInstanceAssessor;
|
||||||
|
import com.kingsrook.qqq.backend.module.rdbms.TestUtils;
|
||||||
|
import com.kingsrook.qqq.backend.module.rdbms.actions.RDBMSActionTest;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
** Unit test for RDBMSBackendAssessor
|
||||||
|
*******************************************************************************/
|
||||||
|
class RDBMSBackendAssessorTest extends RDBMSActionTest
|
||||||
|
{
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
**
|
||||||
|
*******************************************************************************/
|
||||||
|
@Test
|
||||||
|
void testSuccess() throws Exception
|
||||||
|
{
|
||||||
|
TestUtils.primeTestDatabase("prime-test-database.sql");
|
||||||
|
QInstanceAssessor assessor = new QInstanceAssessor(QContext.getQInstance());
|
||||||
|
assessor.assess();
|
||||||
|
assessor.printSummary();
|
||||||
|
assertEquals(0, assessor.getErrors().size());
|
||||||
|
assertEquals(0, assessor.getWarnings().size());
|
||||||
|
assertEquals(0, assessor.getExitCode());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
**
|
||||||
|
*******************************************************************************/
|
||||||
|
@Test
|
||||||
|
void testIssues() throws Exception
|
||||||
|
{
|
||||||
|
//////////////////////////////
|
||||||
|
// don't prime the database //
|
||||||
|
//////////////////////////////
|
||||||
|
// TestUtils.primeTestDatabase("prime-test-database.sql");
|
||||||
|
QInstanceAssessor assessor = new QInstanceAssessor(QContext.getQInstance());
|
||||||
|
assessor.assess();
|
||||||
|
assessor.printSummary();
|
||||||
|
assertNotEquals(0, assessor.getErrors().size());
|
||||||
|
assertNotEquals(0, assessor.getExitCode());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -122,6 +122,7 @@ public class SharingMetaDataProvider
|
|||||||
qInstance.addTable(new QTableMetaData()
|
qInstance.addTable(new QTableMetaData()
|
||||||
.withName(User.TABLE_NAME)
|
.withName(User.TABLE_NAME)
|
||||||
.withPrimaryKeyField("id")
|
.withPrimaryKeyField("id")
|
||||||
|
.withBackendDetails(new RDBMSTableBackendDetails().withTableName("user"))
|
||||||
.withBackendName(TestUtils.DEFAULT_BACKEND_NAME)
|
.withBackendName(TestUtils.DEFAULT_BACKEND_NAME)
|
||||||
.withFieldsFromEntity(User.class)
|
.withFieldsFromEntity(User.class)
|
||||||
.withRecordSecurityLock(new RecordSecurityLock()
|
.withRecordSecurityLock(new RecordSecurityLock()
|
||||||
@ -132,6 +133,7 @@ public class SharingMetaDataProvider
|
|||||||
qInstance.addTable(new QTableMetaData()
|
qInstance.addTable(new QTableMetaData()
|
||||||
.withName(Group.TABLE_NAME)
|
.withName(Group.TABLE_NAME)
|
||||||
.withPrimaryKeyField("id")
|
.withPrimaryKeyField("id")
|
||||||
|
.withBackendDetails(new RDBMSTableBackendDetails().withTableName("group"))
|
||||||
.withBackendName(TestUtils.DEFAULT_BACKEND_NAME)
|
.withBackendName(TestUtils.DEFAULT_BACKEND_NAME)
|
||||||
.withFieldsFromEntity(Group.class));
|
.withFieldsFromEntity(Group.class));
|
||||||
QInstanceEnricher.setInferredFieldBackendNames(qInstance.getTable(Group.TABLE_NAME));
|
QInstanceEnricher.setInferredFieldBackendNames(qInstance.getTable(Group.TABLE_NAME));
|
||||||
@ -139,6 +141,7 @@ public class SharingMetaDataProvider
|
|||||||
qInstance.addTable(new QTableMetaData()
|
qInstance.addTable(new QTableMetaData()
|
||||||
.withName(Client.TABLE_NAME)
|
.withName(Client.TABLE_NAME)
|
||||||
.withPrimaryKeyField("id")
|
.withPrimaryKeyField("id")
|
||||||
|
.withBackendDetails(new RDBMSTableBackendDetails().withTableName("client"))
|
||||||
.withBackendName(TestUtils.DEFAULT_BACKEND_NAME)
|
.withBackendName(TestUtils.DEFAULT_BACKEND_NAME)
|
||||||
.withFieldsFromEntity(Client.class));
|
.withFieldsFromEntity(Client.class));
|
||||||
QInstanceEnricher.setInferredFieldBackendNames(qInstance.getTable(Client.TABLE_NAME));
|
QInstanceEnricher.setInferredFieldBackendNames(qInstance.getTable(Client.TABLE_NAME));
|
||||||
|
Reference in New Issue
Block a user