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.portal.service.persistence;
022:
023: import com.liferay.portal.NoSuchUserTrackerPathException;
024: import com.liferay.portal.kernel.bean.BeanLocatorUtil;
025: import com.liferay.portal.model.UserTrackerPath;
026: import com.liferay.portal.service.persistence.BasePersistenceTestCase;
027:
028: /**
029: * <a href="UserTrackerPathPersistenceTest.java.html"><b><i>View Source</i></b></a>
030: *
031: * @author Brian Wing Shun Chan
032: *
033: */
034: public class UserTrackerPathPersistenceTest extends
035: BasePersistenceTestCase {
036: protected void setUp() throws Exception {
037: super .setUp();
038:
039: _persistence = (UserTrackerPathPersistence) BeanLocatorUtil
040: .locate(_TX_IMPL);
041: }
042:
043: public void testCreate() throws Exception {
044: long pk = nextLong();
045:
046: UserTrackerPath userTrackerPath = _persistence.create(pk);
047:
048: assertNotNull(userTrackerPath);
049:
050: assertEquals(userTrackerPath.getPrimaryKey(), pk);
051: }
052:
053: public void testRemove() throws Exception {
054: UserTrackerPath newUserTrackerPath = addUserTrackerPath();
055:
056: _persistence.remove(newUserTrackerPath);
057:
058: UserTrackerPath existingUserTrackerPath = _persistence
059: .fetchByPrimaryKey(newUserTrackerPath.getPrimaryKey());
060:
061: assertNull(existingUserTrackerPath);
062: }
063:
064: public void testUpdateNew() throws Exception {
065: addUserTrackerPath();
066: }
067:
068: public void testUpdateExisting() throws Exception {
069: long pk = nextLong();
070:
071: UserTrackerPath newUserTrackerPath = _persistence.create(pk);
072:
073: newUserTrackerPath.setUserTrackerId(nextLong());
074: newUserTrackerPath.setPath(randomString());
075: newUserTrackerPath.setPathDate(nextDate());
076:
077: _persistence.update(newUserTrackerPath);
078:
079: UserTrackerPath existingUserTrackerPath = _persistence
080: .findByPrimaryKey(newUserTrackerPath.getPrimaryKey());
081:
082: assertEquals(existingUserTrackerPath.getUserTrackerPathId(),
083: newUserTrackerPath.getUserTrackerPathId());
084: assertEquals(existingUserTrackerPath.getUserTrackerId(),
085: newUserTrackerPath.getUserTrackerId());
086: assertEquals(existingUserTrackerPath.getPath(),
087: newUserTrackerPath.getPath());
088: assertEquals(existingUserTrackerPath.getPathDate(),
089: newUserTrackerPath.getPathDate());
090: }
091:
092: public void testFindByPrimaryKeyExisting() throws Exception {
093: UserTrackerPath newUserTrackerPath = addUserTrackerPath();
094:
095: UserTrackerPath existingUserTrackerPath = _persistence
096: .findByPrimaryKey(newUserTrackerPath.getPrimaryKey());
097:
098: assertEquals(existingUserTrackerPath, newUserTrackerPath);
099: }
100:
101: public void testFindByPrimaryKeyMissing() throws Exception {
102: long pk = nextLong();
103:
104: try {
105: _persistence.findByPrimaryKey(pk);
106:
107: fail("Missing entity did not throw NoSuchUserTrackerPathException");
108: } catch (NoSuchUserTrackerPathException nsee) {
109: }
110: }
111:
112: public void testFetchByPrimaryKeyExisting() throws Exception {
113: UserTrackerPath newUserTrackerPath = addUserTrackerPath();
114:
115: UserTrackerPath existingUserTrackerPath = _persistence
116: .fetchByPrimaryKey(newUserTrackerPath.getPrimaryKey());
117:
118: assertEquals(existingUserTrackerPath, newUserTrackerPath);
119: }
120:
121: public void testFetchByPrimaryKeyMissing() throws Exception {
122: long pk = nextLong();
123:
124: UserTrackerPath missingUserTrackerPath = _persistence
125: .fetchByPrimaryKey(pk);
126:
127: assertNull(missingUserTrackerPath);
128: }
129:
130: protected UserTrackerPath addUserTrackerPath() throws Exception {
131: long pk = nextLong();
132:
133: UserTrackerPath userTrackerPath = _persistence.create(pk);
134:
135: userTrackerPath.setUserTrackerId(nextLong());
136: userTrackerPath.setPath(randomString());
137: userTrackerPath.setPathDate(nextDate());
138:
139: _persistence.update(userTrackerPath);
140:
141: return userTrackerPath;
142: }
143:
144: private static final String _TX_IMPL = UserTrackerPathPersistence.class
145: .getName()
146: + ".transaction";
147: private UserTrackerPathPersistence _persistence;
148: }
|