protected long[] addForbiddenGroups() throws Exception {
    Group forbiddenGroup1 = GroupTestUtil.addGroup();

    _forbiddenGroupIds[0] = forbiddenGroup1.getGroupId();

    Group forbiddenGroup2 = GroupTestUtil.addGroup();

    _forbiddenGroupIds[1] = forbiddenGroup2.getGroupId();

    return _forbiddenGroupIds;
  }
  protected long[] addStandardGroups() throws Exception {
    Group standardGroup1 = GroupTestUtil.addGroup();

    _standardGroupIds[0] = standardGroup1.getGroupId();

    Group standardGroup2 = GroupTestUtil.addGroup();

    _standardGroupIds[1] = standardGroup2.getGroupId();

    return _standardGroupIds;
  }
  protected long[] addRequiredGroups() throws Exception {
    Group requiredGroup1 = GroupTestUtil.addGroup();

    _requiredGroupIds[0] = requiredGroup1.getGroupId();

    Group requiredGroup2 = GroupTestUtil.addGroup();

    _requiredGroupIds[1] = requiredGroup2.getGroupId();

    return _requiredGroupIds;
  }
  @Before
  public void setUp() throws Exception {
    _group = GroupTestUtil.addGroup();
    _liveGroup = GroupTestUtil.addGroup();

    ExportImportLifecycleEventListenerRegistryUtil.register(
        new MockExportImportLifecycleListener());

    _firedExportImportLifecycleEventsMap = new HashMap<>();

    _parameterMap = ExportImportConfigurationParameterMapFactory.buildParameterMap();
  }
  @BeforeClass
  public static void setUpClass() throws Exception {
    _user = UserTestUtil.addUser();

    long classNameId = PortalUtil.getClassNameId(LiferayRepository.class.getName());

    _group = GroupTestUtil.addGroup();

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

    _repository =
        RepositoryLocalServiceUtil.addRepository(
            TestPropsValues.getUserId(),
            _group.getGroupId(),
            classNameId,
            DLFolderConstants.DEFAULT_PARENT_FOLDER_ID,
            "Repository A",
            StringPool.BLANK,
            "Test Portlet",
            new UnicodeProperties(),
            true,
            serviceContext);

    Object[] objects = setUp(_group.getGroupId(), StringPool.BLANK, serviceContext);

    _defaultRepositoryFolder = (Folder) objects[0];
    _defaultRepositoryDLFileVersion = (DLFileVersion) objects[1];

    objects = setUp(_repository.getRepositoryId(), "-NewRepository", serviceContext);

    _newRepositoryFolder = (Folder) objects[0];
  }
  @Before
  public void setUp() throws Exception {
    _group = GroupTestUtil.addGroup();
    _user = TestPropsValues.getUser();

    _kbFolder = addKBFolder(KBFolderConstants.DEFAULT_PARENT_FOLDER_ID);
  }
  @Before
  public void setUp() throws Exception {
    group = GroupTestUtil.addGroup();

    ddmStructureTestHelper = new DDMStructureTestHelper(group);
    ddmStructureLayoutTestHelper = new DDMStructureLayoutTestHelper(group);
  }
  public Group addGroup() throws Exception {
    Group group = GroupTestUtil.addGroup();

    _groups.add(group);

    return group;
  }
  protected void addWikiNode() throws Exception {
    if (_group == null) {
      _group = GroupTestUtil.addGroup();
    }

    _node = WikiTestUtil.addNode(_group.getGroupId());
  }
  @Before
  @Override
  public void setUp() throws Exception {
    super.setUp();

    _group = GroupTestUtil.addGroup();
  }
  protected Group addScopeGroup() throws Exception {
    Group group = GroupTestUtil.addGroup();

    Layout layout = LayoutTestUtil.addLayout(group);

    Map<Locale, String> nameMap = new HashMap<>();

    String name = RandomTestUtil.randomString();

    nameMap.put(LocaleUtil.getDefault(), name);

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

    return GroupLocalServiceUtil.addGroup(
        TestPropsValues.getUserId(),
        group.getParentGroupId(),
        Layout.class.getName(),
        layout.getPlid(),
        GroupConstants.DEFAULT_LIVE_GROUP_ID,
        nameMap,
        RandomTestUtil.randomLocaleStringMap(),
        GroupConstants.TYPE_SITE_OPEN,
        true,
        GroupConstants.DEFAULT_MEMBERSHIP_RESTRICTION,
        StringPool.SLASH + FriendlyURLNormalizerUtil.normalize(name),
        false,
        true,
        serviceContext);
  }
  @Before
  public void setUp() throws Exception {
    group = GroupTestUtil.addGroup();

    actorUser = UserTestUtil.addUser("actor", group.getGroupId());
    creatorUser = UserTestUtil.addUser("creator", group.getGroupId());

    assetEntry = SocialActivityTestUtil.addAssetEntry(creatorUser, group, null);

    SocialActivityHierarchyEntryThreadLocal.clear();
  }
  @Before
  public void setUp() throws Exception {
    setUpPermissionThreadLocal();
    setUpPrincipalThreadLocal();

    _group = GroupTestUtil.addGroup();

    setUpParentFolder();
    setUpResourcePermission();

    List<DLFileEntryType> dlFileEntryTypes =
        DLFileEntryTypeLocalServiceUtil.getFileEntryTypes(
            PortalUtil.getCurrentAndAncestorSiteGroupIds(_group.getGroupId()));

    for (DLFileEntryType dlFileEntryType : dlFileEntryTypes) {
      String fileEntryTypeKey = dlFileEntryType.getFileEntryTypeKey();

      if (fileEntryTypeKey.equals(DLFileEntryTypeConstants.FILE_ENTRY_TYPE_KEY_CONTRACT)) {

        _contractDLFileEntryTypeId = dlFileEntryType.getFileEntryTypeId();
      }
    }

    ExpandoTable expandoTable =
        ExpandoTableLocalServiceUtil.addDefaultTable(
            PortalUtil.getDefaultCompanyId(), DLFileEntry.class.getName());

    ExpandoColumnLocalServiceUtil.addColumn(
        expandoTable.getTableId(),
        _EXPANDO_ATTRIBUTE_NAME,
        ExpandoColumnConstants.STRING,
        StringPool.BLANK);

    _serviceContext = getServiceContext();

    FileEntry fileEntry =
        DLAppServiceUtil.addFileEntry(
            _group.getGroupId(),
            _parentFolder.getFolderId(),
            _SOURCE_FILE_NAME,
            ContentTypes.APPLICATION_OCTET_STREAM,
            _TITLE,
            StringPool.BLANK,
            StringPool.BLANK,
            _DATA_VERSION_1,
            _serviceContext);

    _fileVersion =
        DLFileVersionLocalServiceUtil.getFileVersion(
            fileEntry.getFileEntryId(), DLFileEntryConstants.VERSION_DEFAULT);
  }
  @Before
  public void setUp() throws Exception {
    _sourceStore = _storeFactory.getStore(_CLASS_NAME_FILE_SYSTEM_STORE);

    _storeFactory.setStore(_CLASS_NAME_FILE_SYSTEM_STORE);

    _group = GroupTestUtil.addGroup();

    _convertProcess =
        (ConvertProcess) InstancePool.get(DocumentLibraryConvertProcess.class.getName());

    _convertProcess.setParameterValues(
        new String[] {_CLASS_NAME_DB_STORE, Boolean.TRUE.toString()});
  }
  @Before
  public void setUp() throws Exception {
    group = GroupTestUtil.addGroup();
    user = UserTestUtil.addUser();

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

    doSetUp();

    ServiceTestUtil.setUser(user);

    permissionChecker = PermissionThreadLocal.getPermissionChecker();

    addPortletModelViewPermission();
  }
  @Test
  public void testDifferentFriendlyURLDifferentLocaleDifferentLayoutSet() throws Exception {

    Map<Locale, String> friendlyURLMap = new HashMap<>();

    friendlyURLMap.put(LocaleUtil.SPAIN, "/casa");
    friendlyURLMap.put(LocaleUtil.US, "/home");

    addLayout(_group.getGroupId(), false, friendlyURLMap);

    Group group = GroupTestUtil.addGroup();

    _groups.add(group);

    addLayout(group.getGroupId(), true, friendlyURLMap);
  }
  @Test
  public void testExportImportLayoutSetPrototypeInvalidLARType() throws Exception {

    // Import a layout set prototype to a layout set

    LayoutSetPrototype layoutSetPrototype =
        LayoutTestUtil.addLayoutSetPrototype(RandomTestUtil.randomString());

    try {
      group = layoutSetPrototype.getGroup();
      importedGroup = GroupTestUtil.addGroup();

      long[] layoutIds = new long[0];

      try {
        exportImportLayouts(layoutIds, getImportParameterMap());

        Assert.fail();
      } catch (LARTypeException lte) {
      }

      // Import a layout set prototype to a layout prototyope

      LayoutPrototype layoutPrototype =
          LayoutTestUtil.addLayoutPrototype(RandomTestUtil.randomString());

      importedGroup = layoutPrototype.getGroup();

      try {
        exportImportLayouts(layoutIds, getImportParameterMap());

        Assert.fail();
      } catch (LARTypeException lte) {
      }
    } finally {
      LayoutSetPrototypeLocalServiceUtil.deleteLayoutSetPrototype(layoutSetPrototype);

      group = null;
    }
  }
  @Test
  public void testDifferentFriendlyURLDifferentLocaleDifferentGroup() throws Exception {

    Map<Locale, String> friendlyURLMap = new HashMap<>();

    friendlyURLMap.put(LocaleUtil.SPAIN, "/casa");
    friendlyURLMap.put(LocaleUtil.US, "/home");

    try {
      addLayout(_group.getGroupId(), false, friendlyURLMap);
    } catch (LayoutFriendlyURLsException lfurle) {
      Assert.fail();
    }

    Group group = GroupTestUtil.addGroup();

    _groups.add(group);

    try {
      addLayout(group.getGroupId(), false, friendlyURLMap);
    } catch (LayoutFriendlyURLsException lfurle) {
      Assert.fail();
    }
  }
 @Before
 public void setUp() throws Exception {
   _group = GroupTestUtil.addGroup();
 }
  @Before
  public void setUp() throws Exception {
    _liveGroup = GroupTestUtil.addGroup();
    _stagingGroup = GroupTestUtil.addGroup();

    ServiceContext serviceContext =
        ServiceContextTestUtil.getServiceContext(
            _stagingGroup.getGroupId(), TestPropsValues.getUserId());

    _fileEntry =
        DLAppLocalServiceUtil.addFileEntry(
            TestPropsValues.getUserId(),
            _stagingGroup.getGroupId(),
            DLFolderConstants.DEFAULT_PARENT_FOLDER_ID,
            RandomTestUtil.randomString() + ".txt",
            ContentTypes.TEXT_PLAIN,
            RandomTestUtil.randomBytes(TikaSafeRandomizerBumper.INSTANCE),
            serviceContext);

    ThumbnailCapability thumbnailCapability =
        _fileEntry.getRepositoryCapability(ThumbnailCapability.class);

    _fileEntry = thumbnailCapability.setLargeImageId(_fileEntry, _fileEntry.getFileEntryId());

    TestReaderWriter testReaderWriter = new TestReaderWriter();

    _portletDataContextExport =
        PortletDataContextFactoryUtil.createExportPortletDataContext(
            _stagingGroup.getCompanyId(),
            _stagingGroup.getGroupId(),
            new HashMap<String, String[]>(),
            new Date(System.currentTimeMillis() - Time.HOUR),
            new Date(),
            testReaderWriter);

    Document document = SAXReaderUtil.createDocument();

    Element manifestRootElement = document.addElement("root");

    manifestRootElement.addElement("header");

    testReaderWriter.addEntry("/manifest.xml", document.asXML());

    Element rootElement = SAXReaderUtil.createElement("root");

    _portletDataContextExport.setExportDataRootElement(rootElement);

    _stagingPrivateLayout = LayoutTestUtil.addLayout(_stagingGroup, true);
    _stagingPublicLayout = LayoutTestUtil.addLayout(_stagingGroup, false);

    _portletDataContextExport.setPlid(_stagingPublicLayout.getPlid());

    _portletDataContextImport =
        PortletDataContextFactoryUtil.createImportPortletDataContext(
            _liveGroup.getCompanyId(),
            _liveGroup.getGroupId(),
            new HashMap<String, String[]>(),
            new TestUserIdStrategy(),
            testReaderWriter);

    _portletDataContextImport.setImportDataRootElement(rootElement);

    Element missingReferencesElement = rootElement.addElement("missing-references");

    _portletDataContextImport.setMissingReferencesElement(missingReferencesElement);

    _livePublicLayout = LayoutTestUtil.addLayout(_liveGroup, false);

    _portletDataContextImport.setPlid(_livePublicLayout.getPlid());

    _portletDataContextImport.setSourceGroupId(_stagingGroup.getGroupId());

    rootElement.addElement("entry");

    _referrerStagedModel =
        JournalTestUtil.addArticle(
            _stagingGroup.getGroupId(),
            RandomTestUtil.randomString(),
            RandomTestUtil.randomString());
  }
  @Before
  public void setUp() throws Exception {
    _group = GroupTestUtil.addGroup();

    _user = UserTestUtil.addGroupUser(_group, RoleConstants.SITE_MEMBER);
  }
  @Before
  public void setUp() throws Exception {
    _group = GroupTestUtil.addGroup();

    _ddlRecordSetTestHelper = new DDLRecordSetTestHelper(_group);
  }