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.NoSuchOrgLaborException;
024: import com.liferay.portal.kernel.bean.BeanLocatorUtil;
025: import com.liferay.portal.model.OrgLabor;
026: import com.liferay.portal.service.persistence.BasePersistenceTestCase;
027:
028: /**
029: * <a href="OrgLaborPersistenceTest.java.html"><b><i>View Source</i></b></a>
030: *
031: * @author Brian Wing Shun Chan
032: *
033: */
034: public class OrgLaborPersistenceTest extends BasePersistenceTestCase {
035: protected void setUp() throws Exception {
036: super .setUp();
037:
038: _persistence = (OrgLaborPersistence) BeanLocatorUtil
039: .locate(_TX_IMPL);
040: }
041:
042: public void testCreate() throws Exception {
043: long pk = nextLong();
044:
045: OrgLabor orgLabor = _persistence.create(pk);
046:
047: assertNotNull(orgLabor);
048:
049: assertEquals(orgLabor.getPrimaryKey(), pk);
050: }
051:
052: public void testRemove() throws Exception {
053: OrgLabor newOrgLabor = addOrgLabor();
054:
055: _persistence.remove(newOrgLabor);
056:
057: OrgLabor existingOrgLabor = _persistence
058: .fetchByPrimaryKey(newOrgLabor.getPrimaryKey());
059:
060: assertNull(existingOrgLabor);
061: }
062:
063: public void testUpdateNew() throws Exception {
064: addOrgLabor();
065: }
066:
067: public void testUpdateExisting() throws Exception {
068: long pk = nextLong();
069:
070: OrgLabor newOrgLabor = _persistence.create(pk);
071:
072: newOrgLabor.setOrganizationId(nextLong());
073: newOrgLabor.setTypeId(nextInt());
074: newOrgLabor.setSunOpen(nextInt());
075: newOrgLabor.setSunClose(nextInt());
076: newOrgLabor.setMonOpen(nextInt());
077: newOrgLabor.setMonClose(nextInt());
078: newOrgLabor.setTueOpen(nextInt());
079: newOrgLabor.setTueClose(nextInt());
080: newOrgLabor.setWedOpen(nextInt());
081: newOrgLabor.setWedClose(nextInt());
082: newOrgLabor.setThuOpen(nextInt());
083: newOrgLabor.setThuClose(nextInt());
084: newOrgLabor.setFriOpen(nextInt());
085: newOrgLabor.setFriClose(nextInt());
086: newOrgLabor.setSatOpen(nextInt());
087: newOrgLabor.setSatClose(nextInt());
088:
089: _persistence.update(newOrgLabor);
090:
091: OrgLabor existingOrgLabor = _persistence
092: .findByPrimaryKey(newOrgLabor.getPrimaryKey());
093:
094: assertEquals(existingOrgLabor.getOrgLaborId(), newOrgLabor
095: .getOrgLaborId());
096: assertEquals(existingOrgLabor.getOrganizationId(), newOrgLabor
097: .getOrganizationId());
098: assertEquals(existingOrgLabor.getTypeId(), newOrgLabor
099: .getTypeId());
100: assertEquals(existingOrgLabor.getSunOpen(), newOrgLabor
101: .getSunOpen());
102: assertEquals(existingOrgLabor.getSunClose(), newOrgLabor
103: .getSunClose());
104: assertEquals(existingOrgLabor.getMonOpen(), newOrgLabor
105: .getMonOpen());
106: assertEquals(existingOrgLabor.getMonClose(), newOrgLabor
107: .getMonClose());
108: assertEquals(existingOrgLabor.getTueOpen(), newOrgLabor
109: .getTueOpen());
110: assertEquals(existingOrgLabor.getTueClose(), newOrgLabor
111: .getTueClose());
112: assertEquals(existingOrgLabor.getWedOpen(), newOrgLabor
113: .getWedOpen());
114: assertEquals(existingOrgLabor.getWedClose(), newOrgLabor
115: .getWedClose());
116: assertEquals(existingOrgLabor.getThuOpen(), newOrgLabor
117: .getThuOpen());
118: assertEquals(existingOrgLabor.getThuClose(), newOrgLabor
119: .getThuClose());
120: assertEquals(existingOrgLabor.getFriOpen(), newOrgLabor
121: .getFriOpen());
122: assertEquals(existingOrgLabor.getFriClose(), newOrgLabor
123: .getFriClose());
124: assertEquals(existingOrgLabor.getSatOpen(), newOrgLabor
125: .getSatOpen());
126: assertEquals(existingOrgLabor.getSatClose(), newOrgLabor
127: .getSatClose());
128: }
129:
130: public void testFindByPrimaryKeyExisting() throws Exception {
131: OrgLabor newOrgLabor = addOrgLabor();
132:
133: OrgLabor existingOrgLabor = _persistence
134: .findByPrimaryKey(newOrgLabor.getPrimaryKey());
135:
136: assertEquals(existingOrgLabor, newOrgLabor);
137: }
138:
139: public void testFindByPrimaryKeyMissing() throws Exception {
140: long pk = nextLong();
141:
142: try {
143: _persistence.findByPrimaryKey(pk);
144:
145: fail("Missing entity did not throw NoSuchOrgLaborException");
146: } catch (NoSuchOrgLaborException nsee) {
147: }
148: }
149:
150: public void testFetchByPrimaryKeyExisting() throws Exception {
151: OrgLabor newOrgLabor = addOrgLabor();
152:
153: OrgLabor existingOrgLabor = _persistence
154: .fetchByPrimaryKey(newOrgLabor.getPrimaryKey());
155:
156: assertEquals(existingOrgLabor, newOrgLabor);
157: }
158:
159: public void testFetchByPrimaryKeyMissing() throws Exception {
160: long pk = nextLong();
161:
162: OrgLabor missingOrgLabor = _persistence.fetchByPrimaryKey(pk);
163:
164: assertNull(missingOrgLabor);
165: }
166:
167: protected OrgLabor addOrgLabor() throws Exception {
168: long pk = nextLong();
169:
170: OrgLabor orgLabor = _persistence.create(pk);
171:
172: orgLabor.setOrganizationId(nextLong());
173: orgLabor.setTypeId(nextInt());
174: orgLabor.setSunOpen(nextInt());
175: orgLabor.setSunClose(nextInt());
176: orgLabor.setMonOpen(nextInt());
177: orgLabor.setMonClose(nextInt());
178: orgLabor.setTueOpen(nextInt());
179: orgLabor.setTueClose(nextInt());
180: orgLabor.setWedOpen(nextInt());
181: orgLabor.setWedClose(nextInt());
182: orgLabor.setThuOpen(nextInt());
183: orgLabor.setThuClose(nextInt());
184: orgLabor.setFriOpen(nextInt());
185: orgLabor.setFriClose(nextInt());
186: orgLabor.setSatOpen(nextInt());
187: orgLabor.setSatClose(nextInt());
188:
189: _persistence.update(orgLabor);
190:
191: return orgLabor;
192: }
193:
194: private static final String _TX_IMPL = OrgLaborPersistence.class
195: .getName()
196: + ".transaction";
197: private OrgLaborPersistence _persistence;
198: }
|