Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: stabilize unit test SpaceApplicationMigrationTest - EXO-66907 #174

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,24 @@
import org.exoplatform.social.core.space.*;
import org.exoplatform.social.core.space.model.Space;
import org.exoplatform.social.core.space.spi.SpaceService;
import org.gatein.pc.api.Portlet;
import org.gatein.pc.api.PortletContext;
import org.gatein.pc.api.PortletInvoker;
import org.gatein.pc.api.PortletInvokerException;
import org.gatein.pc.api.info.PortletInfo;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner;


import java.util.Collections;
import java.util.HashSet;

import static org.junit.Assert.*;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

@RunWith(MockitoJUnitRunner.class)
@ConfiguredBy({
Expand Down Expand Up @@ -60,13 +68,33 @@ public SpaceApplicationMigrationTest() {
}

@Before
public void setUp() {
public void setUp() throws PortletInvokerException {
container = getContainer();
this.spaceService = container.getComponentInstanceOfType(SpaceService.class);
this.navigationService = container.getComponentInstanceOfType(NavigationService.class);
this.identityRegistry = container.getComponentInstanceOfType(IdentityRegistry.class);
this.entityManagerService = container.getComponentInstanceOfType(EntityManagerService.class);
this.settingService = container.getComponentInstanceOfType(SettingService.class);
PortletInvoker portletInvoker = mock(PortletInvoker.class);
Portlet portlet = new Portlet() {
@Override
public PortletContext getContext() {
return null;
}

@Override
public PortletInfo getInfo() {
return null;
}

@Override
public boolean isRemote() {
return false;
}
};
when(portletInvoker.getPortlets()).thenReturn(Collections.singleton(portlet));
container.unregisterComponent(PortletInvoker.class);
container.registerComponentInstance(PortletInvoker.class, portletInvoker);
HashSet<MembershipEntry> memberships = new HashSet<MembershipEntry>();
memberships.add(new MembershipEntry("/platform/users", "*"));
memberships.add(new MembershipEntry("/platform/administrators", "*"));
Expand Down