001
014
015 package com.liferay.portlet.subscriptions.test;
016
017 import com.liferay.portal.util.test.MailServiceTestUtil;
018
019 import org.junit.Assert;
020 import org.junit.Test;
021
022
025 public abstract class BaseSubscriptionAuthorTestCase
026 extends BaseSubscriptionTestCase {
027
028 @Test
029 public void testSubscriptionForAuthorWhenAddingBaseModel()
030 throws Exception {
031
032 long containerModelId = addContainerModel(
033 creatorUser.getUserId(),
034 BaseSubscriptionTestCase.PARENT_CONTAINER_MODEL_ID_DEFAULT);
035
036 addSubscription(creatorUser.getUserId(), containerModelId);
037
038 addBaseModel(creatorUser.getUserId(), containerModelId);
039
040 if (isSubscriptionForAuthorEnabled()) {
041 Assert.assertEquals(1, MailServiceTestUtil.getInboxSize());
042 }
043 else {
044 Assert.assertEquals(0, MailServiceTestUtil.getInboxSize());
045 }
046 }
047
048 @Test
049 public void testSubscriptionForAuthorWhenUpdatingBaseModel()
050 throws Exception {
051
052 long containerModelId = addContainerModel(
053 creatorUser.getUserId(), PARENT_CONTAINER_MODEL_ID_DEFAULT);
054
055 long baseModelId = addBaseModel(
056 creatorUser.getUserId(), containerModelId);
057
058 addSubscription(creatorUser.getUserId(), containerModelId);
059
060 updateBaseModel(creatorUser.getUserId(), baseModelId);
061
062 if (isSubscriptionForAuthorEnabled()) {
063 Assert.assertEquals(1, MailServiceTestUtil.getInboxSize());
064 }
065 else {
066 Assert.assertEquals(0, MailServiceTestUtil.getInboxSize());
067 }
068 }
069
070 protected abstract void addSubscription(long userId, long containerModelId)
071 throws Exception;
072
073 protected boolean isSubscriptionForAuthorEnabled() {
074 return false;
075 }
076
077 }