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 ActivityTest extends BaseScarabTestCase { 59 60 public void testCreateLong() throws Exception { 61 System.out.println("\ntestCreateLong()"); 62 ActivitySet trans = getEditActivitySet(); 63 Activity activity = ActivityManager.createNumericActivity(getIssue0(), getPlatformAttribute(), trans, 64 "new activity long create", null, new Integer (5), new Integer (6)); 65 activity.save(); 66 ActivitySet newtrans = activity.getActivitySet(); 67 assertEquals("getActivitySet expected: " + trans.getActivitySetId() + " got: " + newtrans.getActivitySetId(), 68 trans.getActivitySetId().toString(), newtrans.getActivitySetId().toString()); 69 Activity retActivity = ActivityManager.getInstance(activity.getActivityId(), false); 70 assertEquals("OldValue", activity.getOldValue(), retActivity.getOldValue()); 71 assertEquals("NewValue", activity.getNewValue(), retActivity.getNewValue()); 72 assertEquals("Attribute", activity.getAttribute(), retActivity.getAttribute()); 73 } 74 75 public void testCreateShort() throws Exception { 76 System.out.println("\ntestCreateShort()"); 77 ActivitySet trans = getEditActivitySet(); 78 79 Activity activity = ActivityManager.createTextActivity(getIssue0(), getPlatformAttribute(), trans, 80 "new activity long create", null, "oldValue", "newValue"); 81 activity.save(); 82 83 ActivitySet newtrans = activity.getActivitySet(); 84 assertEquals("getActivitySet expected: " + trans.getActivitySetId() + " got: " + newtrans.getActivitySetId(), 85 trans.getActivitySetId().toString(), newtrans.getActivitySetId().toString()); 86 Activity retActivity = ActivityManager.getInstance(activity.getActivityId(), false); 87 assertEquals("OldValue", activity.getOldValue(), retActivity.getOldValue()); 88 assertEquals("NewValue", activity.getNewValue(), retActivity.getNewValue()); 89 assertEquals("Attribute", activity.getAttribute(), retActivity.getAttribute()); 90 } 91 92 public void testGetAttribute() throws Exception { 93 System.out.println("\ntestGetAttribute()"); 94 Activity retActivity = ActivityManager.getInstance(new NumberKey(1), false); 95 Integer key = retActivity.getAttribute().getAttributeId(); 96 assertTrue("AttId expected: 11 got: " + key, key.intValue() == 11); 97 } 98 99 protected ActivitySet getEditActivitySet() throws Exception { 100 Attachment attach = new Attachment(); 101 attach.setTextFields(getUser1(), getIssue0(), Attachment.MODIFICATION__PK); 102 attach.setName("commenttest"); 103 attach.save(); 104 105 ActivitySet trans = ActivitySetManager.getInstance(ActivitySetTypePeer.EDIT_ISSUE__PK, getUser1(), attach); 106 trans.save(); 107 return trans; 108 } 109 110 protected Attribute getPlatformAttribute() throws Exception { 111 112 return AttributeManager.getInstance(new NumberKey(5)); 113 } 114 } | Popular Tags |