BackgroundTaskThreadLocalManagerImpl implements BackgroundTaskThreadLocalManager { @Override public void setThreadLocalValues( Map<String, Serializable> threadLocalValues) { if (MapUtil.isEmpty(threadLocalValues)) { return; } long companyId = GetterUtil.getLong(threadLocalValues.get("companyId")); if (companyId > 0) { CompanyThreadLocal.setCompanyId(requireCompany(companyId)); } Boolean clusterInvoke = (Boolean)threadLocalValues.get("clusterInvoke"); if (clusterInvoke != null) { ClusterInvokeThreadLocal.setEnabled(clusterInvoke); } Locale defaultLocale = (Locale)threadLocalValues.get("defaultLocale"); if (defaultLocale != null) { LocaleThreadLocal.setDefaultLocale(defaultLocale); } long groupId = GetterUtil.getLong(threadLocalValues.get("groupId")); if (groupId > 0) { GroupThreadLocal.setGroupId(groupId); } String principalName = GetterUtil.getString( threadLocalValues.get("principalName")); if (Validator.isNotNull(principalName)) { PrincipalThreadLocal.setName(principalName); } if (Validator.isNotNull(principalName)) { User user = _userLocalService.fetchUser( PrincipalThreadLocal.getUserId()); PermissionChecker permissionChecker = _permissionCheckerFactory.create(user); PermissionThreadLocal.setPermissionChecker(permissionChecker); } Locale siteDefaultLocale = (Locale)threadLocalValues.get( "siteDefaultLocale"); if (siteDefaultLocale != null) { LocaleThreadLocal.setSiteDefaultLocale(siteDefaultLocale); } Locale themeDisplayLocale = (Locale)threadLocalValues.get( "themeDisplayLocale"); if (themeDisplayLocale != null) { LocaleThreadLocal.setThemeDisplayLocale(themeDisplayLocale); } }  @Override void deserializeThreadLocals(
		Map<String, Serializable> taskContextMap); @Override Map<String, Serializable> getThreadLocalValues(); @Override void serializeThreadLocals(
		Map<String, Serializable> taskContextMap); @Override void setThreadLocalValues(
		Map<String, Serializable> threadLocalValues);  }
@Test public void testSetThreadLocalValues() { Map<String, Serializable> threadLocalValues = initializeThreadLocalValues(); backgroundTaskThreadLocalManagerImpl.setThreadLocalValues( threadLocalValues); assertThreadLocalValues(); }