Search in sources :

Example 1 with CommandState

use of org.smartdata.common.CommandState in project SSM by Intel-bigdata.

the class TestDBMethod method testInsertCommandsTable.

@Test
public void testInsertCommandsTable() throws Exception {
    String dbFile = TestDBUtil.getUniqueDBFilePath();
    Connection conn = null;
    try {
        conn = Util.createSqliteConnection(dbFile);
        Util.initializeDataBase(conn);
        DBAdapter dbAdapter = new DBAdapter(conn);
        CommandInfo command1 = new CommandInfo(0, 1, ActionType.None, CommandState.EXECUTING, "test", 123123333l, 232444444l);
        CommandInfo command2 = new CommandInfo(0, 78, ActionType.ConvertToEC, CommandState.PAUSED, "tt", 123178333l, 232444994l);
        CommandInfo[] commands = { command1, command2 };
        dbAdapter.insertCommandsTable(commands);
        String cidCondition = ">= 2 ";
        String ridCondition = "= 78 ";
        CommandState state = null;
        CommandState state1 = CommandState.PAUSED;
        List<CommandInfo> com = dbAdapter.getCommandsTableItem(cidCondition, ridCondition, state);
        Assert.assertTrue(com.get(0).getActionType() == ActionType.ConvertToEC);
        Assert.assertTrue(com.get(0).getState() == CommandState.PAUSED);
        List<CommandInfo> com1 = dbAdapter.getCommandsTableItem(null, null, state1);
        Assert.assertTrue(com1.get(0).getState() == CommandState.PAUSED);
    } finally {
        if (conn != null) {
            conn.close();
        }
        File file = new File(dbFile);
        file.deleteOnExit();
    }
}
Also used : CommandInfo(org.smartdata.common.command.CommandInfo) Connection(java.sql.Connection) CommandState(org.smartdata.common.CommandState) File(java.io.File) Test(org.junit.Test)

Aggregations

File (java.io.File)1 Connection (java.sql.Connection)1 Test (org.junit.Test)1 CommandState (org.smartdata.common.CommandState)1 CommandInfo (org.smartdata.common.command.CommandInfo)1