private static void prepareSessionState(SessionState ss) {
    ss.setIsHiveServerQuery(true);
    ss.setOverriddenConfigurations(DummyRecord.CONFIGURATION_OPTIONS_CHANGED);
    ss.setUserIpAddress(DummyRecord.CLIENT_ADDRESS);
    ss.getConf().setInt(SerDeUtils.LIST_SINK_OUTPUT_PROTOCOL, DummyRecord.HIVERSERVER2_PROTOCOL_VERSION);
  }
This unit test asserts that the record is created as expected from the various hive source objects like:
DriverContext, SessionState, QueryInfo, etc.
itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/queryhistory/TestQueryHistoryService.java