@Nullable
    public static BranchType getBranchType() {
        if (inGlobalTransaction()) {
            BranchType branchType = (BranchType) CONTEXT_HOLDER.get(KEY_BRANCH_TYPE);
            if (branchType != null) {
                return branchType;
            }
            //Returns the default branch type.
            return DEFAULT_BRANCH_TYPE != null ? DEFAULT_BRANCH_TYPE : BranchType.AT;
        }
        return null;
    }
@Test
    public void testGetBranchType() {
        RootContext.bindBranchType(DEFAULT_BRANCH_TYPE);

        //before bind xid, branchType is null
        assertThat(RootContext.getBranchType()).isNull();
        //after bind xid, branchType is not null
        RootContext.bind(DEFAULT_XID);
        assertThat(RootContext.getBranchType()).isEqualTo(DEFAULT_BRANCH_TYPE);

        RootContext.unbind();
        assertThat(RootContext.unbindBranchType()).isEqualTo(DEFAULT_BRANCH_TYPE);
        assertThat(RootContext.getBranchType()).isNull();
    }