Skip to content

Commit

Permalink
LPS-91113 Fix tests. Deploy portlet as method is now taking it to acc…
Browse files Browse the repository at this point in the history
…ount if portlet is deployed or not.
  • Loading branch information
marianoalvarosaiz committed Mar 16, 2019
1 parent 57a8ba4 commit a2b68d5
Showing 1 changed file with 21 additions and 0 deletions.
Expand Up @@ -14,11 +14,13 @@

package com.liferay.portal.service;

import com.liferay.petra.string.StringPool;
import com.liferay.portal.deploy.hot.ServiceBag;
import com.liferay.portal.kernel.bean.ClassLoaderBeanHandler;
import com.liferay.portal.kernel.model.Group;
import com.liferay.portal.kernel.model.Layout;
import com.liferay.portal.kernel.model.Portlet;
import com.liferay.portal.kernel.model.PortletApp;
import com.liferay.portal.kernel.model.PortletPreferences;
import com.liferay.portal.kernel.model.PortletPreferencesIds;
import com.liferay.portal.kernel.portlet.PortletPreferencesFactoryUtil;
Expand All @@ -33,6 +35,7 @@
import com.liferay.portal.kernel.util.PortalClassLoaderUtil;
import com.liferay.portal.kernel.util.PortletKeys;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.model.impl.PortletAppImpl;
import com.liferay.portal.service.util.test.PortletPreferencesImplTestUtil;
import com.liferay.portal.service.util.test.PortletPreferencesTestUtil;
import com.liferay.portal.spring.aop.AopInvocationHandler;
Expand All @@ -45,6 +48,7 @@
import java.util.List;
import java.util.Map;

import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.ClassRule;
Expand Down Expand Up @@ -74,6 +78,13 @@ public void setUp() throws Exception {
_layout.getCompanyId(), String.valueOf(_PORTLET_ID));
}

@After
public void tearDown() {
_portlet.setPortletApp(_DUMMY_PORTLET_APP);

PortletLocalServiceUtil.destroyPortlet(_portlet);
}

@Test
public void testAddPortletPreferencesWithDefaultMultipleXML()
throws Exception {
Expand Down Expand Up @@ -830,6 +841,8 @@ public void testGetLayoutPortletPreferencesCountByPlidAndPortletId()
PortletPreferencesTestUtil.addLayoutPortletPreferences(
_layout, _portlet);

PortletLocalServiceUtil.deployPortlet(_portlet);

Assert.assertEquals(
1,
PortletPreferencesLocalServiceUtil.getPortletPreferencesCount(
Expand Down Expand Up @@ -1177,6 +1190,8 @@ public void testGetOriginalLayoutPortletPreferencesCountByPlidAndPortletId()
PortletPreferencesTestUtil.addLayoutPortletPreferences(
_layout, _portlet);

PortletLocalServiceUtil.deployPortlet(_portlet);

Assert.assertEquals(
1,
PortletPreferencesLocalServiceUtil.getPortletPreferencesCount(
Expand Down Expand Up @@ -1516,6 +1531,9 @@ protected void resetService() throws Exception {
_serviceBag.replace();
}

private static final PortletApp _DUMMY_PORTLET_APP = new PortletAppImpl(
StringPool.CONTENT);

private static final String[] _MULTIPLE_VALUES = {"value1", "value2"};

private static final String _NAME = "name";
Expand All @@ -1530,7 +1548,10 @@ protected void resetService() throws Exception {
private final List<Group> _groups = new ArrayList<>();

private Layout _layout;

@DeleteAfterTestRun
private Portlet _portlet;

private ServiceBag<PortletPreferencesLocalService> _serviceBag;

private static class TestPortletPreferencesLocalServiceWrapper
Expand Down

0 comments on commit a2b68d5

Please sign in to comment.