public synchronized void addHistory(TaskRunStatus status) {
        historyTaskRunMap.put(status.getQueryId(), status);
        taskName2Status.put(status.getTaskName(), status);
    }
@Test
    public void testCRUD(@Mocked RepoExecutor repo) {
        TaskRunStatus status = new TaskRunStatus();
        status.setQueryId("aaa");
        status.setTaskName("t1");
        status.setState(Constants.TaskRunState.SUCCESS);
        new MockUp<TableKeeper>() {
            @Mock
            public boolean isReady() {
                return true;
            }
        };
        String jsonString = StringEscapeUtils.escapeJava(GsonUtils.GSON.toJson(status));
        new Expectations() {
            {
                repo.executeDML(String.format("INSERT INTO _statistics_.task_run_history (task_id, task_run_id, task_name, " +
                        "task_state, create_time, finish_time, expire_time, history_content_json) " +
                        "VALUES(0, 'aaa', 't1', 'SUCCESS', '1970-01-01 08:00:00', " +
                        "'1970-01-01 08:00:00', '1970-01-01 08:00:00', " +
                        "'%s')", jsonString));
            }
        };

        TaskRunHistoryTable history = new TaskRunHistoryTable();
        history.addHistory(status);

        // lookup by params
        TGetTasksParams params = new TGetTasksParams();
        new Expectations() {
            {
                repo.executeDQL("SELECT history_content_json FROM _statistics_.task_run_history WHERE TRUE AND  " +
                        "get_json_string(history_content_json, 'dbName') = 'default_cluster:d1'");
            }
        };
        params.setDb("d1");
        history.lookup(params);

        new Expectations() {
            {
                repo.executeDQL("SELECT history_content_json FROM _statistics_.task_run_history WHERE TRUE AND  " +
                        "task_state = 'SUCCESS'");
            }
        };
        params.setDb(null);
        params.setState("SUCCESS");
        history.lookup(params);

        new Expectations() {
            {
                repo.executeDQL("SELECT history_content_json FROM _statistics_.task_run_history WHERE TRUE AND  " +
                        "task_name = 't1'");
            }
        };
        params.setDb(null);
        params.setState(null);
        params.setTask_name("t1");
        history.lookup(params);

        new Expectations() {
            {
                repo.executeDQL("SELECT history_content_json FROM _statistics_.task_run_history WHERE TRUE AND  " +
                        "task_run_id = 'q1'");
            }
        };
        params.setDb(null);
        params.setState(null);
        params.setTask_name(null);
        params.setQuery_id("q1");
        history.lookup(params);

        // lookup by task names
        String dbName = "";
        Set<String> taskNames = Set.of("t1", "t2");
        new Expectations() {
            {
                repo.executeDQL("SELECT history_content_json FROM _statistics_.task_run_history WHERE TRUE AND  " +
                        "task_name IN ('t1','t2')");
            }
        };
        history.lookupByTaskNames(dbName, taskNames);
    }