Package: TraceTreeNode

TraceTreeNode

nameinstructionbranchcomplexitylinemethod
TraceTreeNode(ANamedTraceDefinition)
M: 54 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 13 C: 0
0%
M: 1 C: 0
0%
addChild(ITreeNode)
M: 38 C: 0
0%
M: 8 C: 0
0%
M: 5 C: 0
0%
M: 9 C: 0
0%
M: 1 C: 0
0%
getAdapter(Class)
M: 2 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getChildren()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getInfo()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getName()
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getParent()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getTestTotal()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getTraceDefinition()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getTraceStore()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
hasChild(String)
M: 21 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
hasChildren()
M: 8 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
loadTests()
M: 131 C: 0
0%
M: 10 C: 0
0%
M: 6 C: 0
0%
M: 21 C: 0
0%
M: 1 C: 0
0%
removeChild(TraceTestTreeNode)
M: 9 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
setInfo(TracesXmlStoreReader.TraceInfo)
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
setParent(ITreeNode)
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
setSkippedCount(int)
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
setTestTotal(int)
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
toString()
M: 38 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
unloadTests()
M: 11 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*
2: * #%~
3: * Combinatorial Testing
4: * %%
5: * Copyright (C) 2008 - 2014 Overture
6: * %%
7: * This program is free software: you can redistribute it and/or modify
8: * it under the terms of the GNU General Public License as
9: * published by the Free Software Foundation, either version 3 of the
10: * License, or (at your option) any later version.
11: *
12: * This program is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15: * GNU General Public License for more details.
16: *
17: * You should have received a copy of the GNU General Public
18: * License along with this program. If not, see
19: * <http://www.gnu.org/licenses/gpl-3.0.html>.
20: * #~%
21: */
22: package org.overture.ide.plugins.combinatorialtesting.views.treeView;
23:
24: import java.io.IOException;
25: import java.util.ArrayList;
26: import java.util.List;
27:
28: import org.eclipse.core.runtime.IAdaptable;
29: import org.eclipse.swt.widgets.Display;
30: import org.overture.ast.definitions.ANamedTraceDefinition;
31: import org.overture.ct.utils.TraceHelperNotInitializedException;
32: import org.overture.ct.utils.TraceTestResult;
33: import org.overture.ide.plugins.combinatorialtesting.TracesXmlStoreReader.TraceInfo;
34: import org.overture.ide.plugins.combinatorialtesting.store.StorageManager;
35: import org.overture.ide.plugins.combinatorialtesting.views.TraceAstUtility;
36: import org.xml.sax.SAXException;
37:
38: public class TraceTreeNode implements IAdaptable, ITreeNode
39: {
40:
41:         private ANamedTraceDefinition traceDefinition;
42:         private ITreeNode parent;
43:         private List<ITreeNode> children;
44:         private int testSkippedCount = 0;
45:         private int testTotal = 0;
46:         private StorageManager traceStore;
47:         private TraceInfo info;
48:
49:         public TraceTreeNode(ANamedTraceDefinition traceDef) throws SAXException,
50:                         IOException, ClassNotFoundException,
51:                         TraceHelperNotInitializedException
52:         {
53:                 this.traceDefinition = traceDef;
54:                 traceStore = new StorageManager(TraceAstUtility.getProject(traceDef), traceDef);
55:                 this.children = new ArrayList<ITreeNode>();
56:
57:                 setInfo(traceStore.getTraceInfo());
58:
59:                 Integer totalTests = traceStore.getTraceTestCount();
60:                 this.setTestTotal(totalTests);
61:
62:                 this.setSkippedCount(traceStore.getSkippedCount(traceDef.getName().getName()));
63:
64:•                if (totalTests > 0)
65:                 {
66:                         this.addChild(new NotYetReadyTreeNode());
67:                 }
68:         }
69:
70:         public ITreeNode getParent()
71:         {
72:                 return parent;
73:         }
74:
75:         public ANamedTraceDefinition getTraceDefinition()
76:         {
77:                 return traceDefinition;
78:         }
79:
80:         public void setSkippedCount(int skippedCount)
81:         {
82:                 testSkippedCount = skippedCount;
83:         }
84:
85:         @Override
86:         public String toString()
87:         {
88:•                if (testSkippedCount != 0)
89:                 {
90:                         return getName() + " (" + getTestTotal() + " skipped "
91:                                         + testSkippedCount + ")";
92:                 } else
93:                 {
94:                         return getName() + " (" + getTestTotal() + ")";
95:                 }
96:         }
97:
98:         public String getName()
99:         {
100:
101:                 return traceDefinition.getName().getName();
102:
103:         }
104:
105:         public void setParent(ITreeNode parent)
106:         {
107:                 this.parent = parent;
108:         }
109:
110:         public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter)
111:         {
112:                 return null;
113:         }
114:
115:         public void addChild(ITreeNode child)
116:         {
117:•                if (!children.contains(child))
118:                 {
119:                         boolean contains = false;
120:•                        for (ITreeNode node : getChildren())
121:                         {
122:•                                if (node.getName().equals(child.getName()))
123:                                 {
124:                                         contains = true;
125:                                 }
126:                         }
127:•                        if (!contains)
128:                         {
129:                                 children.add(child);
130:                                 child.setParent(this);
131:                         }
132:                 }
133:         }
134:
135:         public void removeChild(TraceTestTreeNode child)
136:         {
137:                 children.remove(child);
138:                 child.setParent(null);
139:         }
140:
141:         public List<ITreeNode> getChildren()
142:         {
143:                 return children;
144:         }
145:
146:         public boolean hasChildren()
147:         {
148:•                return children.size() > 0;
149:         }
150:
151:         public boolean hasChild(String name)
152:         {
153:•                for (ITreeNode node : children)
154:                 {
155:•                        if (node.getName().equals(name))
156:                         {
157:                                 return true;
158:                         }
159:
160:                 }
161:                 return false;
162:         }
163:
164:         /**
165:          * @param testTotal
166:          * the testTotal to set
167:          */
168:         public void setTestTotal(int testTotal)
169:         {
170:                 this.testTotal = testTotal;
171:         }
172:
173:         /**
174:          * @return the testTotal
175:          */
176:         public int getTestTotal()
177:         {
178:                 return testTotal;
179:         }
180:
181:
182:         public void loadTests() throws Exception
183:         {
184:                 children.clear();
185:
186:                 Long size = new Long(traceStore.getTraceTestCount());
187:
188:                 GroupSizeCalculator gs = new GroupSizeCalculator(size);
189:
190:•                if (!gs.hasGroups())
191:                 {
192:                         List<TraceTestResult> traceStatus = traceStore.getTraceTests();
193:•                        for (TraceTestResult traceTestStatus : traceStatus)
194:                         {
195:                                 this.addChild(new TraceTestTreeNode(traceTestStatus));
196:                         }
197:                 } else
198:                 {
199:
200:                         Long currentCount = new Long(0);
201:•                        for (int i = 0; i < gs.getNumberOfGroups() - 1
202:                                         && currentCount < size; i++)
203:                         {
204:                                 final TraceTestGroup group = new TraceTestGroup(currentCount + 1, currentCount
205:                                                 + gs.getGroupSize() + 1);
206:                                 currentCount += gs.getGroupSize();
207:                                 this.addChild(group);
208:                                 Display.getCurrent().syncExec(new Runnable()
209:                                 {
210:
211:                                         public void run()
212:                                         {
213:
214:                                                 try
215:                                                 {
216:                                                         group.loadGroupStatus();
217:                                                 } catch (Exception e)
218:                                                 {
219:                                                         e.printStackTrace();
220:                                                 }
221:                                         }
222:                                 });
223:
224:                         }
225:•                        if (!currentCount.equals(size))
226:                         {
227:                                 final TraceTestGroup group = new TraceTestGroup(currentCount + 1, size + 1);
228:                                 this.addChild(group);
229:                                 Display.getCurrent().syncExec(new Runnable()
230:                                 {
231:
232:                                         public void run()
233:                                         {
234:
235:                                                 try
236:                                                 {
237:                                                         group.loadGroupStatus();
238:                                                 } catch (Exception e)
239:                                                 {
240:                                                         e.printStackTrace();
241:                                                 }
242:                                         }
243:                                 });
244:                         }
245:                 }
246:         }
247:
248:         public void unloadTests()
249:         {
250:                 children.clear();
251:                 children.add(new NotYetReadyTreeNode());
252:         }
253:
254:         private void setInfo(TraceInfo info)
255:         {
256:                 this.info = info;
257:         }
258:
259:         public TraceInfo getInfo()
260:         {
261:                 return info;
262:         }
263:
264:         public StorageManager getTraceStore()
265:         {
266:                 return traceStore;
267:         }
268:
269: }