1 7 8 package org.netbeans.modules.tasklist.usertasks.schedule; 9 10 import java.util.ArrayList ; 11 import java.util.List ; 12 import junit.framework.TestCase; 13 import org.netbeans.modules.tasklist.usertasks.model.Dependency; 14 import org.netbeans.modules.tasklist.usertasks.model.UserTask; 15 import org.netbeans.modules.tasklist.usertasks.model.UserTaskList; 16 17 22 public class ScheduleUtilsTest extends TestCase { 23 public ScheduleUtilsTest(String testName) { 24 super(testName); 25 } 26 27 31 public void testSortForDependencies() { 32 UserTaskList utl = new UserTaskList(); 33 UserTask a = new UserTask("a", utl); 34 UserTask b = new UserTask("b", utl); 35 UserTask c = new UserTask("c", utl); 36 37 c.getDependencies().add(new Dependency(b, Dependency.END_BEGIN)); 38 b.getDependencies().add(new Dependency(a, Dependency.END_BEGIN)); 39 40 List <UserTask> tasks = new ArrayList <UserTask>(); 41 tasks.add(c); 42 tasks.add(a); 43 tasks.add(b); 44 45 ScheduleUtils.sortForDependencies(tasks); 46 47 assertEquals(tasks.get(0), a); 48 assertEquals(tasks.get(1), b); 49 assertEquals(tasks.get(2), c); 50 } 51 52 70 public void testBackflow() { 71 boolean[][] deps = new boolean[][] { 72 {false, true, true, false}, 73 {false, false, false, false}, 74 {false, true, false, false}, 75 {false, false, true, false} 76 }; 77 float[] durations = new float[] {3, 2, 4, 2}; 78 float[] ct = ScheduleUtils.backflow(deps, durations); 79 assertEquals(ct.length, 4); 80 assertEquals(ct[0], 3, 1e-5); 81 assertEquals(ct[1], 9, 1e-5); 82 assertEquals(ct[2], 7, 1e-5); 83 assertEquals(ct[3], 2, 1e-5); 84 } 85 86 90 public void testCreatePriorityListBackflow() { 91 UserTaskList utl = new UserTaskList(); 92 UserTask a = new UserTask("A", utl); 93 UserTask b = new UserTask("B", utl); 94 UserTask c = new UserTask("C", utl); 95 UserTask d = new UserTask("D", utl); 96 a.getDependencies().add(new Dependency(b, Dependency.END_BEGIN)); 97 c.getDependencies().add(new Dependency(b, Dependency.END_BEGIN)); 98 a.getDependencies().add(new Dependency(c, Dependency.END_BEGIN)); 99 d.getDependencies().add(new Dependency(c, Dependency.END_BEGIN)); 100 a.setEffort(3); 101 b.setEffort(2); 102 c.setEffort(4); 103 d.setEffort(2); 104 105 List <UserTask> v = new ArrayList <UserTask>(); 106 v.add(a); 107 v.add(b); 108 v.add(c); 109 v.add(d); 110 111 ScheduleUtils.createPriorityListBackflow(v); 112 113 assertEquals("B", v.get(0).getSummary()); 114 assertEquals("C", v.get(1).getSummary()); 115 assertEquals("A", v.get(2).getSummary()); 116 assertEquals("D", v.get(3).getSummary()); 117 } 118 } 119 | Popular Tags |