@Override
    public void recordStateFinished(StateInstance stateInstance, ProcessContext context) {
        if (stateInstance != null) {

            stateInstance.setSerializedOutputParams(paramsSerializer.serialize(stateInstance.getOutputParams()));
            stateInstance.setSerializedException(exceptionSerializer.serialize(stateInstance.getException()));
            executeUpdate(stateLogStoreSqls.getRecordStateFinishedSql(dbType), STATE_INSTANCE_TO_STATEMENT_FOR_UPDATE,
                    stateInstance);

            //A switch to skip branch report on branch success, in order to optimize performance
            StateMachineConfig stateMachineConfig = (StateMachineConfig) context.getVariable(
                    DomainConstants.VAR_NAME_STATEMACHINE_CONFIG);
            if (!(stateMachineConfig instanceof DbStateMachineConfig
                    && !((DbStateMachineConfig)stateMachineConfig).isRmReportSuccessEnable()
                    && ExecutionStatus.SU.equals(stateInstance.getStatus()))) {
                branchReport(stateInstance, context);
            }
        }
    }
@Test
    public void testRecordStateFinished() {
        DbAndReportTcStateLogStore dbAndReportTcStateLogStore = new DbAndReportTcStateLogStore();
        StateInstanceImpl stateMachineInstance = new StateInstanceImpl();
        ProcessContextImpl context = new ProcessContextImpl();
        context.setVariable(DomainConstants.VAR_NAME_STATEMACHINE_CONFIG,  new DbStateMachineConfig());
        Assertions.assertThrows(NullPointerException.class,
                () -> dbAndReportTcStateLogStore.recordStateFinished(stateMachineInstance, context));
    }