1 package org.tigris.scarab.om; 2 3 48 49 import org.tigris.scarab.test.BaseScarabTestCase; 50 import org.tigris.scarab.util.ScarabConstants; 51 52 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 { 66 super.setUp(); 67 createTestIssueType(); 68 83 } 84 85 public void testGetTemplateId() throws Exception 86 { 87 assertEquals(Integer.parseInt(issueType.getTemplateId().toString()), 88 Integer.parseInt(issueType.getIssueTypeId().toString()) + 1); 89 } 90 91 public void testGetInstanceByName() throws Exception 92 { 93 IssueType retIssueType = IssueType.getInstance(issueType.getName()); 94 assertEquals(retIssueType.getName(), issueType.getName()); 95 } 96 97 public void testCopy() throws Exception 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 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 123 { 124 issueType.createDefaultGroups(); 125 testGetAttributeGroups(2); 126 } 127 128 public void testGetAttributeGroups(int expectedSize) throws Exception 129 { 130 assertEquals(expectedSize, 131 issueType.getAttributeGroups(null, true).size()); 132 } 133 134 public void testCreateNewGroup() throws Exception 135 { 136 System.out.println("\ntestCreateNewGroup()"); 137 ag = issueType.createNewGroup(); 138 } 139 140 public void testGetDedupeSequence() throws Exception 141 { 142 testGetTemplateId(); 143 testCreateNewGroup(); 144 145 assertEquals(issueType.getDedupeSequence(), 2); 146 } 147 148 public void testAddRIssueTypeAttribute() throws Exception 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 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 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 172 { 173 testGetRIssueTypeAttributes(); 174 System.out.println("\ntestGetUserAttributes()"); 175 assertEquals(issueType.getUserAttributes(false).size(), 1); 176 } 177 178 public void testGetRIssueTypeOptions() throws Exception 179 { 180 testAddRIssueTypeAttribute(); 181 System.out.println("\ntestGetIssueTypeOptions()"); 182 assertEquals(issueType.getRIssueTypeOptions(getPlatformAttribute(), false).size(), 8); 183 } 184 185 public void testGetAvailableAttributes() throws Exception 186 { 187 testAddRIssueTypeAttribute(); 188 System.out.println("\ntestGetAvailableAttributes()"); 189 assertTrue(issueType.getAvailableAttributes("data").size()>0); 190 } 191 192 } 193 | Popular Tags |