001
014
015 package com.liferay.portal.util.subscriptions;
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 BaseSubscriptionRootContainerModelTestCase
026 extends BaseSubscriptionTestCase {
027
028 @Test
029 public void testSubscriptionRootContainerModelWhenAddingBaseModelInContainerModel()
030 throws Exception {
031
032 addSubscriptionContainerModel(PARENT_CONTAINER_MODEL_ID_DEFAULT);
033
034 long containerModelId = addContainerModel(
035 PARENT_CONTAINER_MODEL_ID_DEFAULT);
036
037 addBaseModel(containerModelId);
038
039 Assert.assertEquals(1, MailServiceTestUtil.getInboxSize());
040 }
041
042 @Test
043 public void testSubscriptionRootContainerModelWhenAddingBaseModelInRootContainerModel()
044 throws Exception {
045
046 addSubscriptionContainerModel(PARENT_CONTAINER_MODEL_ID_DEFAULT);
047
048 addBaseModel(PARENT_CONTAINER_MODEL_ID_DEFAULT);
049
050 Assert.assertEquals(1, MailServiceTestUtil.getInboxSize());
051 }
052
053 @Test
054 public void testSubscriptionRootContainerModelWhenAddingBaseModelInSubcontainerModel()
055 throws Exception {
056
057 addSubscriptionContainerModel(PARENT_CONTAINER_MODEL_ID_DEFAULT);
058
059 long containerModelId = addContainerModel(
060 PARENT_CONTAINER_MODEL_ID_DEFAULT);
061
062 long subcontainerModelId = addContainerModel(containerModelId);
063
064 addBaseModel(subcontainerModelId);
065
066 Assert.assertEquals(1, MailServiceTestUtil.getInboxSize());
067 }
068
069 @Test
070 public void testSubscriptionRootContainerModelWhenUpdatingBaseModelInContainerModel()
071 throws Exception {
072
073 long containerModelId = addContainerModel(
074 PARENT_CONTAINER_MODEL_ID_DEFAULT);
075
076 long baseModelId = addBaseModel(containerModelId);
077
078 addSubscriptionContainerModel(PARENT_CONTAINER_MODEL_ID_DEFAULT);
079
080 updateBaseModel(baseModelId);
081
082 Assert.assertEquals(1, MailServiceTestUtil.getInboxSize());
083 }
084
085 @Test
086 public void testSubscriptionRootContainerModelWhenUpdatingBaseModelInRootContainerModel()
087 throws Exception {
088
089 long baseModelId = addBaseModel(PARENT_CONTAINER_MODEL_ID_DEFAULT);
090
091 addSubscriptionContainerModel(PARENT_CONTAINER_MODEL_ID_DEFAULT);
092
093 updateBaseModel(baseModelId);
094
095 Assert.assertEquals(1, MailServiceTestUtil.getInboxSize());
096 }
097
098 @Test
099 public void testSubscriptionRootContainerModelWhenUpdatingBaseModelInSubcontainerModel()
100 throws Exception {
101
102 long containerModelId = addContainerModel(
103 PARENT_CONTAINER_MODEL_ID_DEFAULT);
104
105 long subcontainerModelId = addContainerModel(containerModelId);
106
107 long baseModelId = addBaseModel(subcontainerModelId);
108
109 addSubscriptionContainerModel(PARENT_CONTAINER_MODEL_ID_DEFAULT);
110
111 updateBaseModel(baseModelId);
112
113 Assert.assertEquals(1, MailServiceTestUtil.getInboxSize());
114 }
115
116 protected abstract void addSubscriptionContainerModel(long containerModelId)
117 throws Exception;
118
119 }