private static void _populateContextFromThreadLocals(Map<String, Serializable> context) {

    if (!context.containsKey("companyId")) {
      context.put("companyId", CompanyThreadLocal.getCompanyId());
    }

    if (!context.containsKey("defaultLocale")) {
      context.put("defaultLocale", LocaleThreadLocal.getDefaultLocale());
    }

    if (!context.containsKey("groupId")) {
      context.put("groupId", GroupThreadLocal.getGroupId());
    }

    if (!context.containsKey("principalName")) {
      context.put("principalName", PrincipalThreadLocal.getName());
    }

    if (!context.containsKey("principalPassword")) {
      context.put("principalPassword", PrincipalThreadLocal.getPassword());
    }

    if (!context.containsKey("siteDefaultLocale")) {
      context.put("siteDefaultLocale", LocaleThreadLocal.getSiteDefaultLocale());
    }

    if (!context.containsKey("themeDisplayLocale")) {
      context.put("themeDisplayLocale", LocaleThreadLocal.getThemeDisplayLocale());
    }
  }
  @Test
  public void testLocalizedSiteAddFileEntryType() throws Exception {
    Group group = GroupTestUtil.addGroup();

    ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(group.getGroupId());

    Locale locale = LocaleThreadLocal.getSiteDefaultLocale();

    try {
      LocaleThreadLocal.setSiteDefaultLocale(LocaleUtil.SPAIN);

      String name = RandomTestUtil.randomString();
      String description = RandomTestUtil.randomString();
      DDMStructure ddmStructure =
          DDMStructureTestUtil.addStructure(
              DLFileEntry.class.getName(), new Locale[] {LocaleUtil.SPAIN}, LocaleUtil.SPAIN);

      DLFileEntryType dlFileEntryType =
          DLFileEntryTypeLocalServiceUtil.addFileEntryType(
              TestPropsValues.getUserId(),
              group.getGroupId(),
              name,
              description,
              new long[] {ddmStructure.getStructureId()},
              serviceContext);

      Assert.assertEquals(name, dlFileEntryType.getName(LocaleUtil.US, true));
      Assert.assertEquals(description, dlFileEntryType.getDescription(LocaleUtil.US, true));
    } finally {
      LocaleThreadLocal.setSiteDefaultLocale(locale);
    }
  }