1 package org.tigris.scarab.om; 2 3 48 49 import org.apache.torque.om.NumberKey; 50 import org.tigris.scarab.test.BaseScarabTestCase; 51 52 58 public class AttributeValueTest extends BaseScarabTestCase 59 { 60 private AttributeValue attVal = null; 61 private AttributeValue attVal2 = null; 62 private AttributeValue newAttVal = null; 63 private Issue issue = null; 64 65 66 public void testSomething() throws Exception 67 { 68 issue = getIssue0(); 69 attVal = issue.getAttributeValue(AttributeManager.getInstance(new NumberKey("9"))); 71 attVal2 = issue.getAttributeValue(AttributeManager.getInstance(new NumberKey("1"))); 73 74 testCopy(); 75 testSave(); 76 testGetQueryKey(); 77 testIsRequired(); 78 testIsSet(); 79 testIsSet2(); 80 testGetRModuleAttribute(); 81 testGetAttributeOption(); 82 } 83 84 85 private void testCopy() throws Exception 86 { 87 System.out.println("\ntestCopy()"); 88 newAttVal = attVal.copy(); 89 Attachment attachment = AttachmentManager.getInstance(); 90 attachment.setName("activitySet test"); 91 attachment.setData("Test comment"); 92 attachment.setTextFields(getUser1(), issue, Attachment.COMMENT__PK); 93 attachment.save(); 94 ActivitySet trans = 95 ActivitySetManager.getInstance(new Integer (1), getUser1(), attachment); 96 trans.save(); 97 newAttVal.startActivitySet(trans); 98 newAttVal.setOptionId(new Integer (70)); 99 newAttVal.setUserId(new Integer (1)); 100 } 101 102 private void testSave() throws Exception 103 { 104 System.out.println("\ntestSave()"); 105 newAttVal.save(); 106 } 107 108 private void testGetOptionIdAsString() throws Exception 109 { 110 System.out.println("\ntestGetOptionIdAsString()"); 111 assertEquals("70", newAttVal.getOptionIdAsString()); 112 } 113 114 private void testGetQueryKey() throws Exception 115 { 116 System.out.println("\ntestGetQueryKey()"); 117 assertEquals(newAttVal.getValueId().toString(), newAttVal.getQueryKey()); 118 System.out.println("query key= " + newAttVal.getQueryKey()); 119 } 120 121 private void testIsRequired() throws Exception 122 { 123 System.out.println("\ntestIsRequired()"); 124 assertEquals(false, newAttVal.isRequired()); 126 } 127 128 private void testIsSet() throws Exception 129 { 130 System.out.println("\ntestIsSet()"); 131 assertEquals(true, newAttVal.isSet()); 132 } 133 134 private void testIsSet2() throws Exception 135 { 136 System.out.println("\ntestIsSet2()"); 137 attVal2.setValue("description"); 138 assertEquals(true, attVal2.isSet()); 139 } 140 141 private void testGetRModuleAttribute() throws Exception 142 { 143 System.out.println("\ntestGetRModuleAttribute()"); 144 assertEquals(attVal.getAttributeId(), newAttVal.getRModuleAttribute().getAttributeId()); 145 } 146 147 private void testGetAttributeOption() throws Exception 148 { 149 System.out.println("\ntestGetAttributeOption()"); 150 System.out.println("get att opt = " + newAttVal.getAttributeOption()); 151 } 152 153 protected ScarabUser getUser1() 154 throws Exception 155 { 156 return ScarabUserManager.getInstance(new NumberKey(1), false); 157 158 } 159 } 160 | Popular Tags |