001: /**
002: * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
003: *
004: * Permission is hereby granted, free of charge, to any person obtaining a copy
005: * of this software and associated documentation files (the "Software"), to deal
006: * in the Software without restriction, including without limitation the rights
007: * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
008: * copies of the Software, and to permit persons to whom the Software is
009: * furnished to do so, subject to the following conditions:
010: *
011: * The above copyright notice and this permission notice shall be included in
012: * all copies or substantial portions of the Software.
013: *
014: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
015: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
016: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
017: * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
018: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
019: * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
020: * SOFTWARE.
021: */package com.liferay.portlet.journal.service.persistence;
022:
023: import com.liferay.portal.kernel.bean.BeanLocatorUtil;
024: import com.liferay.portal.service.persistence.BasePersistenceTestCase;
025:
026: import com.liferay.portlet.journal.NoSuchContentSearchException;
027: import com.liferay.portlet.journal.model.JournalContentSearch;
028:
029: /**
030: * <a href="JournalContentSearchPersistenceTest.java.html"><b><i>View Source</i></b></a>
031: *
032: * @author Brian Wing Shun Chan
033: *
034: */
035: public class JournalContentSearchPersistenceTest extends
036: BasePersistenceTestCase {
037: protected void setUp() throws Exception {
038: super .setUp();
039:
040: _persistence = (JournalContentSearchPersistence) BeanLocatorUtil
041: .locate(_TX_IMPL);
042: }
043:
044: public void testCreate() throws Exception {
045: long pk = nextLong();
046:
047: JournalContentSearch journalContentSearch = _persistence
048: .create(pk);
049:
050: assertNotNull(journalContentSearch);
051:
052: assertEquals(journalContentSearch.getPrimaryKey(), pk);
053: }
054:
055: public void testRemove() throws Exception {
056: JournalContentSearch newJournalContentSearch = addJournalContentSearch();
057:
058: _persistence.remove(newJournalContentSearch);
059:
060: JournalContentSearch existingJournalContentSearch = _persistence
061: .fetchByPrimaryKey(newJournalContentSearch
062: .getPrimaryKey());
063:
064: assertNull(existingJournalContentSearch);
065: }
066:
067: public void testUpdateNew() throws Exception {
068: addJournalContentSearch();
069: }
070:
071: public void testUpdateExisting() throws Exception {
072: long pk = nextLong();
073:
074: JournalContentSearch newJournalContentSearch = _persistence
075: .create(pk);
076:
077: newJournalContentSearch.setGroupId(nextLong());
078: newJournalContentSearch.setCompanyId(nextLong());
079: newJournalContentSearch.setPrivateLayout(randomBoolean());
080: newJournalContentSearch.setLayoutId(nextLong());
081: newJournalContentSearch.setPortletId(randomString());
082: newJournalContentSearch.setArticleId(randomString());
083:
084: _persistence.update(newJournalContentSearch);
085:
086: JournalContentSearch existingJournalContentSearch = _persistence
087: .findByPrimaryKey(newJournalContentSearch
088: .getPrimaryKey());
089:
090: assertEquals(existingJournalContentSearch.getContentSearchId(),
091: newJournalContentSearch.getContentSearchId());
092: assertEquals(existingJournalContentSearch.getGroupId(),
093: newJournalContentSearch.getGroupId());
094: assertEquals(existingJournalContentSearch.getCompanyId(),
095: newJournalContentSearch.getCompanyId());
096: assertEquals(existingJournalContentSearch.getPrivateLayout(),
097: newJournalContentSearch.getPrivateLayout());
098: assertEquals(existingJournalContentSearch.getLayoutId(),
099: newJournalContentSearch.getLayoutId());
100: assertEquals(existingJournalContentSearch.getPortletId(),
101: newJournalContentSearch.getPortletId());
102: assertEquals(existingJournalContentSearch.getArticleId(),
103: newJournalContentSearch.getArticleId());
104: }
105:
106: public void testFindByPrimaryKeyExisting() throws Exception {
107: JournalContentSearch newJournalContentSearch = addJournalContentSearch();
108:
109: JournalContentSearch existingJournalContentSearch = _persistence
110: .findByPrimaryKey(newJournalContentSearch
111: .getPrimaryKey());
112:
113: assertEquals(existingJournalContentSearch,
114: newJournalContentSearch);
115: }
116:
117: public void testFindByPrimaryKeyMissing() throws Exception {
118: long pk = nextLong();
119:
120: try {
121: _persistence.findByPrimaryKey(pk);
122:
123: fail("Missing entity did not throw NoSuchContentSearchException");
124: } catch (NoSuchContentSearchException nsee) {
125: }
126: }
127:
128: public void testFetchByPrimaryKeyExisting() throws Exception {
129: JournalContentSearch newJournalContentSearch = addJournalContentSearch();
130:
131: JournalContentSearch existingJournalContentSearch = _persistence
132: .fetchByPrimaryKey(newJournalContentSearch
133: .getPrimaryKey());
134:
135: assertEquals(existingJournalContentSearch,
136: newJournalContentSearch);
137: }
138:
139: public void testFetchByPrimaryKeyMissing() throws Exception {
140: long pk = nextLong();
141:
142: JournalContentSearch missingJournalContentSearch = _persistence
143: .fetchByPrimaryKey(pk);
144:
145: assertNull(missingJournalContentSearch);
146: }
147:
148: protected JournalContentSearch addJournalContentSearch()
149: throws Exception {
150: long pk = nextLong();
151:
152: JournalContentSearch journalContentSearch = _persistence
153: .create(pk);
154:
155: journalContentSearch.setGroupId(nextLong());
156: journalContentSearch.setCompanyId(nextLong());
157: journalContentSearch.setPrivateLayout(randomBoolean());
158: journalContentSearch.setLayoutId(nextLong());
159: journalContentSearch.setPortletId(randomString());
160: journalContentSearch.setArticleId(randomString());
161:
162: _persistence.update(journalContentSearch);
163:
164: return journalContentSearch;
165: }
166:
167: private static final String _TX_IMPL = JournalContentSearchPersistence.class
168: .getName()
169: + ".transaction";
170: private JournalContentSearchPersistence _persistence;
171: }
|