KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > tigris > scarab > om > IssueTypeTest


1 package org.tigris.scarab.om;
2
3 /* ================================================================
4  * Copyright (c) 2000-2002 CollabNet. All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are
8  * met:
9  *
10  * 1. Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  *
13  * 2. Redistributions in binary form must reproduce the above copyright
14  * notice, this list of conditions and the following disclaimer in the
15  * documentation and/or other materials provided with the distribution.
16  *
17  * 3. The end-user documentation included with the redistribution, if
18  * any, must include the following acknowlegement: "This product includes
19  * software developed by Collab.Net <http://www.Collab.Net/>."
20  * Alternately, this acknowlegement may appear in the software itself, if
21  * and wherever such third-party acknowlegements normally appear.
22  *
23  * 4. The hosted project names must not be used to endorse or promote
24  * products derived from this software without prior written
25  * permission. For written permission, please contact info@collab.net.
26  *
27  * 5. Products derived from this software may not use the "Tigris" or
28  * "Scarab" names nor may "Tigris" or "Scarab" appear in their names without
29  * prior written permission of Collab.Net.
30  *
31  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
32  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
33  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
34  * IN NO EVENT SHALL COLLAB.NET OR ITS CONTRIBUTORS BE LIABLE FOR ANY
35  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
37  * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
38  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
39  * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
40  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
41  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
42  *
43  * ====================================================================
44  *
45  * This software consists of voluntary contributions made by many
46  * individuals on behalf of Collab.Net.
47  */

48
49 import org.tigris.scarab.test.BaseScarabTestCase;
50 import org.tigris.scarab.util.ScarabConstants;
51
52 /**
53  * A Testing Suite for the om.Issue class.
54  *
55  * @author <a HREF="mailto:jon@latchkey.com">Jon S. Stevens</a>
56  * @version $Id: IssueTypeTest.java 9446 2005-03-12 11:59:50Z jorgeuriarte $
57  */

58 public class IssueTypeTest extends BaseScarabTestCase
59 {
60
61     private IssueType issueType = null;
62     private AttributeGroup ag = null;
63
64
65     public void setUp() throws Exception JavaDoc {
66         super.setUp();
67         createTestIssueType();
68         /*
69         testGetTemplateId();
70         testGetInstanceByName();
71         testCopy();
72         createTestIssueType();
73         testCreateDefaultGroups();
74         testCreateNewGroup();
75         testGetDedupeSequence();
76         testAddRIssueTypeAttribute();
77         testGetRIssueTypeAttributes();
78         testGetRIssueTypeAttribute();
79         testGetUserAttributes();
80         testGetRIssueTypeOptions();
81         testGetAvailableAttributes();
82         */

83     }
84     
85     public void testGetTemplateId() throws Exception JavaDoc
86     {
87         assertEquals(Integer.parseInt(issueType.getTemplateId().toString()),
88                      Integer.parseInt(issueType.getIssueTypeId().toString()) + 1);
89     }
90
91     public void testGetInstanceByName() throws Exception JavaDoc
92     {
93         IssueType retIssueType = IssueType.getInstance(issueType.getName());
94         assertEquals(retIssueType.getName(), issueType.getName());
95     }
96
97     public void testCopy() throws Exception JavaDoc
98     {
99         IssueType newIssueType = issueType.copyIssueType();
100         assertEquals(newIssueType.getName(), issueType.getName() + " (copy)");
101         assertEquals(newIssueType.getDescription(), issueType.getDescription());
102         assertEquals(newIssueType.getParentId(), issueType.getParentId());
103         IssueType template = IssueTypePeer
104               .retrieveByPK(newIssueType.getTemplateId());
105         IssueType newTemplate = IssueTypePeer
106               .retrieveByPK(issueType.getTemplateId());
107         assertEquals(template.getName(), newTemplate.getName());
108     }
109
110     public void createTestIssueType() throws Exception JavaDoc
111     {
112         issueType = new IssueType();
113         issueType.setName("test issue type");
114         issueType.setParentId(ScarabConstants.INTEGER_0);
115         issueType.save();
116         IssueType template = new IssueType();
117         template.setName("test issue type template");
118         template.setParentId(issueType.getIssueTypeId());
119         template.save();
120     }
121
122     public void testCreateDefaultGroups() throws Exception JavaDoc
123     {
124         issueType.createDefaultGroups();
125         testGetAttributeGroups(2);
126     }
127
128     public void testGetAttributeGroups(int expectedSize) throws Exception JavaDoc
129     {
130         assertEquals(expectedSize,
131                      issueType.getAttributeGroups(null, true).size());
132     }
133
134     public void testCreateNewGroup() throws Exception JavaDoc
135     {
136         System.out.println("\ntestCreateNewGroup()");
137         ag = issueType.createNewGroup();
138     }
139
140     public void testGetDedupeSequence() throws Exception JavaDoc
141     {
142         testGetTemplateId();
143         testCreateNewGroup();
144         
145         assertEquals(issueType.getDedupeSequence(), 2);
146     }
147
148     public void testAddRIssueTypeAttribute() throws Exception JavaDoc
149     {
150         testGetTemplateId();
151         testCreateNewGroup();
152         System.out.println("\ntestAddRIssueTypeAttribute()");
153         ag.addAttribute(getPlatformAttribute());
154         ag.addAttribute(getAssignAttribute());
155     }
156
157     public void testGetRIssueTypeAttributes() throws Exception JavaDoc
158     {
159         testAddRIssueTypeAttribute();
160         assertEquals(issueType.getRIssueTypeAttributes(false, "non-user").size(), 1);
161         assertEquals(issueType.getRIssueTypeAttributes(false, "user").size(), 1);
162     }
163
164     public void testGetRIssueTypeAttribute() throws Exception JavaDoc
165     {
166         System.out.println("\ntestGetRIssueTypeAttribute()");
167         System.out.println(issueType.getRIssueTypeAttribute(getPlatformAttribute()));
168         System.out.println(issueType.getRIssueTypeAttribute(getAssignAttribute()));
169     }
170
171     public void testGetUserAttributes() throws Exception JavaDoc
172     {
173         testGetRIssueTypeAttributes();
174         System.out.println("\ntestGetUserAttributes()");
175         assertEquals(issueType.getUserAttributes(false).size(), 1);
176     }
177
178     public void testGetRIssueTypeOptions() throws Exception JavaDoc
179     {
180         testAddRIssueTypeAttribute();
181         System.out.println("\ntestGetIssueTypeOptions()");
182         assertEquals(issueType.getRIssueTypeOptions(getPlatformAttribute(), false).size(), 8);
183     }
184
185     public void testGetAvailableAttributes() throws Exception JavaDoc
186     {
187         testAddRIssueTypeAttribute();
188         System.out.println("\ntestGetAvailableAttributes()");
189         assertTrue(issueType.getAvailableAttributes("data").size()>0);
190     }
191
192 }
193
Popular Tags