001: package org.tigris.scarab.om;
002:
003: /* ================================================================
004: * Copyright (c) 2000-2002 CollabNet. All rights reserved.
005: *
006: * Redistribution and use in source and binary forms, with or without
007: * modification, are permitted provided that the following conditions are
008: * met:
009: *
010: * 1. Redistributions of source code must retain the above copyright
011: * notice, this list of conditions and the following disclaimer.
012: *
013: * 2. Redistributions in binary form must reproduce the above copyright
014: * notice, this list of conditions and the following disclaimer in the
015: * documentation and/or other materials provided with the distribution.
016: *
017: * 3. The end-user documentation included with the redistribution, if
018: * any, must include the following acknowlegement: "This product includes
019: * software developed by Collab.Net <http://www.Collab.Net/>."
020: * Alternately, this acknowlegement may appear in the software itself, if
021: * and wherever such third-party acknowlegements normally appear.
022: *
023: * 4. The hosted project names must not be used to endorse or promote
024: * products derived from this software without prior written
025: * permission. For written permission, please contact info@collab.net.
026: *
027: * 5. Products derived from this software may not use the "Tigris" or
028: * "Scarab" names nor may "Tigris" or "Scarab" appear in their names without
029: * prior written permission of Collab.Net.
030: *
031: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
032: * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
033: * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
034: * IN NO EVENT SHALL COLLAB.NET OR ITS CONTRIBUTORS BE LIABLE FOR ANY
035: * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
036: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
037: * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
038: * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
039: * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
040: * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
041: * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
042: *
043: * ====================================================================
044: *
045: * This software consists of voluntary contributions made by many
046: * individuals on behalf of Collab.Net.
047: */
048:
049: import org.tigris.scarab.test.BaseScarabTestCase;
050: import org.tigris.scarab.util.ScarabConstants;
051:
052: /**
053: * A Testing Suite for the om.Issue class.
054: *
055: * @author <a href="mailto:jon@latchkey.com">Jon S. Stevens</a>
056: * @version $Id: IssueTypeTest.java 9446 2005-03-12 11:59:50Z jorgeuriarte $
057: */
058: public class IssueTypeTest extends BaseScarabTestCase {
059:
060: private IssueType issueType = null;
061: private AttributeGroup ag = null;
062:
063: public void setUp() throws Exception {
064: super .setUp();
065: createTestIssueType();
066: /*
067: testGetTemplateId();
068: testGetInstanceByName();
069: testCopy();
070: createTestIssueType();
071: testCreateDefaultGroups();
072: testCreateNewGroup();
073: testGetDedupeSequence();
074: testAddRIssueTypeAttribute();
075: testGetRIssueTypeAttributes();
076: testGetRIssueTypeAttribute();
077: testGetUserAttributes();
078: testGetRIssueTypeOptions();
079: testGetAvailableAttributes();
080: */
081: }
082:
083: public void testGetTemplateId() throws Exception {
084: assertEquals(Integer.parseInt(issueType.getTemplateId()
085: .toString()), Integer.parseInt(issueType
086: .getIssueTypeId().toString()) + 1);
087: }
088:
089: public void testGetInstanceByName() throws Exception {
090: IssueType retIssueType = IssueType.getInstance(issueType
091: .getName());
092: assertEquals(retIssueType.getName(), issueType.getName());
093: }
094:
095: public void testCopy() throws Exception {
096: IssueType newIssueType = issueType.copyIssueType();
097: assertEquals(newIssueType.getName(), issueType.getName()
098: + " (copy)");
099: assertEquals(newIssueType.getDescription(), issueType
100: .getDescription());
101: assertEquals(newIssueType.getParentId(), issueType
102: .getParentId());
103: IssueType template = IssueTypePeer.retrieveByPK(newIssueType
104: .getTemplateId());
105: IssueType newTemplate = IssueTypePeer.retrieveByPK(issueType
106: .getTemplateId());
107: assertEquals(template.getName(), newTemplate.getName());
108: }
109:
110: public void createTestIssueType() throws Exception {
111: issueType = new IssueType();
112: issueType.setName("test issue type");
113: issueType.setParentId(ScarabConstants.INTEGER_0);
114: issueType.save();
115: IssueType template = new IssueType();
116: template.setName("test issue type template");
117: template.setParentId(issueType.getIssueTypeId());
118: template.save();
119: }
120:
121: public void testCreateDefaultGroups() throws Exception {
122: issueType.createDefaultGroups();
123: testGetAttributeGroups(2);
124: }
125:
126: public void testGetAttributeGroups(int expectedSize)
127: throws Exception {
128: assertEquals(expectedSize, issueType.getAttributeGroups(null,
129: true).size());
130: }
131:
132: public void testCreateNewGroup() throws Exception {
133: System.out.println("\ntestCreateNewGroup()");
134: ag = issueType.createNewGroup();
135: }
136:
137: public void testGetDedupeSequence() throws Exception {
138: testGetTemplateId();
139: testCreateNewGroup();
140:
141: assertEquals(issueType.getDedupeSequence(), 2);
142: }
143:
144: public void testAddRIssueTypeAttribute() throws Exception {
145: testGetTemplateId();
146: testCreateNewGroup();
147: System.out.println("\ntestAddRIssueTypeAttribute()");
148: ag.addAttribute(getPlatformAttribute());
149: ag.addAttribute(getAssignAttribute());
150: }
151:
152: public void testGetRIssueTypeAttributes() throws Exception {
153: testAddRIssueTypeAttribute();
154: assertEquals(issueType.getRIssueTypeAttributes(false,
155: "non-user").size(), 1);
156: assertEquals(issueType.getRIssueTypeAttributes(false, "user")
157: .size(), 1);
158: }
159:
160: public void testGetRIssueTypeAttribute() throws Exception {
161: System.out.println("\ntestGetRIssueTypeAttribute()");
162: System.out.println(issueType
163: .getRIssueTypeAttribute(getPlatformAttribute()));
164: System.out.println(issueType
165: .getRIssueTypeAttribute(getAssignAttribute()));
166: }
167:
168: public void testGetUserAttributes() throws Exception {
169: testGetRIssueTypeAttributes();
170: System.out.println("\ntestGetUserAttributes()");
171: assertEquals(issueType.getUserAttributes(false).size(), 1);
172: }
173:
174: public void testGetRIssueTypeOptions() throws Exception {
175: testAddRIssueTypeAttribute();
176: System.out.println("\ntestGetIssueTypeOptions()");
177: assertEquals(issueType.getRIssueTypeOptions(
178: getPlatformAttribute(), false).size(), 8);
179: }
180:
181: public void testGetAvailableAttributes() throws Exception {
182: testAddRIssueTypeAttribute();
183: System.out.println("\ntestGetAvailableAttributes()");
184: assertTrue(issueType.getAvailableAttributes("data").size() > 0);
185: }
186:
187: }
|