KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > tasklist > usertasks > model > TaskTest


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.tasklist.usertasks.model;
21
22 import junit.framework.Test;
23 import junit.framework.TestCase;
24 import junit.framework.TestSuite;
25 import org.netbeans.modules.tasklist.usertasks.util.UTUtils;
26
27 /**
28  *
29  * @author Petr Kuzel
30  */

31 public class TaskTest extends TestCase {
32
33     public TaskTest(java.lang.String JavaDoc testName) {
34         super(testName);
35     }
36
37     public static Test suite() {
38         TestSuite suite = new TestSuite(TaskTest.class);
39         return suite;
40     }
41
42     /**
43      * Test for UserTask.getEffort() method
44      */

45     public void testGetEffort() {
46         UserTaskList utl = new UserTaskList();
47         UserTask root = new UserTask("root", utl); // NOI18N
48
root.setValuesComputed(true);
49         
50         UserTask a = new UserTask("a", utl); // NOI18N
51
a.setEffort(200);
52         assertTrue(a.getEffort() == 200);
53         
54         UserTask b = new UserTask("b", utl); // NOI18N
55
b.setEffort(300);
56         
57         root.getSubtasks().add(a);
58         root.getSubtasks().add(b);
59         
60         assertTrue(root.computeEffort() == 500);
61         assertTrue(root.getEffort() == 500);
62     }
63
64     /**
65      * Test for UserTask.getEffort() method
66      */

67     public void testGetEffort2() {
68         UserTaskList utl = new UserTaskList();
69         UserTask root = new UserTask("root", utl); // NOI18N
70
root.setValuesComputed(true);
71         
72         UserTask a = new UserTask("a", utl); // NOI18N
73
a.setEffort(200);
74         a.setPercentComplete(25);
75         
76         UserTask b = new UserTask("b", utl); // NOI18N
77
b.setEffort(300);
78         b.setPercentComplete(75);
79         
80         root.getSubtasks().add(a);
81         root.getSubtasks().add(b);
82         
83         assertEquals((50 + 225) * 100 / (500), root.getPercentComplete());
84     }
85     
86     /**
87      * Tests dependencies between tasks.
88      */

89     public void testDependencies() {
90         UserTaskList utl = new UserTaskList();
91         UserTask a = new UserTask("a", utl);
92         UserTask b = new UserTask("b", utl);
93         utl.getSubtasks().add(a);
94         utl.getSubtasks().add(b);
95         
96         a.getDependencies().add(new Dependency(b, Dependency.END_BEGIN));
97         
98         b.setDone(true);
99         assertTrue(b.isDone());
100         assertFalse(a.isDone());
101         
102         a.setDone(true);
103         assertTrue(b.isDone());
104         assertTrue(a.isDone());
105         
106         b.setDone(false);
107         assertFalse(b.isDone());
108         assertFalse(a.isDone());
109     }
110 }
111
Popular Tags