Implemented delete

This commit is contained in:
Darin Kelkhoff
2021-11-30 18:10:22 -06:00
parent 01142017a3
commit c0ad05d119
3 changed files with 110 additions and 13 deletions

View File

@ -160,6 +160,31 @@ class QPicoCliImplementationTest
/*******************************************************************************
**
*******************************************************************************/
@Test
public void test_tableDelete() throws Exception
{
TestOutput testOutput = testCli("person", "delete", "--primaryKey", "2,4");
JSONObject deleteResult = JsonUtils.toJSONObject(testOutput.getOutput());
assertNotNull(deleteResult);
assertEquals(2, deleteResult.getJSONArray("records").length());
assertEquals(2, deleteResult.getJSONArray("records").getJSONObject(0).getInt("primaryKey"));
assertEquals(4, deleteResult.getJSONArray("records").getJSONObject(1).getInt("primaryKey"));
TestUtils.runTestSql("SELECT id FROM person", (rs -> {
int rowsFound = 0;
while(rs.next())
{
rowsFound++;
assertTrue(rs.getInt(1) == 1 || rs.getInt(1) == 3 || rs.getInt(1) == 5);
}
assertEquals(3, rowsFound);
}));
}
/*******************************************************************************
**
*******************************************************************************/

View File

@ -42,6 +42,18 @@ public class TestUtils
/*******************************************************************************
**
*******************************************************************************/
public static void runTestSql(String sql, QueryManager.ResultSetProcessor resultSetProcessor) throws Exception
{
ConnectionManager connectionManager = new ConnectionManager();
Connection connection = connectionManager.getConnection(new RDBSMBackendMetaData(defineBackend()));
QueryManager.executeStatement(connection, sql, resultSetProcessor);
}
/*******************************************************************************
**
*******************************************************************************/