|
Lines 22-29
Link Here
|
| 22 |
import org.eclipse.hyades.models.common.testprofile.TPFExecutionResult; |
22 |
import org.eclipse.hyades.models.common.testprofile.TPFExecutionResult; |
| 23 |
import org.eclipse.hyades.models.common.testprofile.TPFInvocationEvent; |
23 |
import org.eclipse.hyades.models.common.testprofile.TPFInvocationEvent; |
| 24 |
import org.eclipse.hyades.models.common.testprofile.TPFTest; |
24 |
import org.eclipse.hyades.models.common.testprofile.TPFTest; |
| 25 |
import org.eclipse.hyades.models.common.testprofile.TPFTestSuite; |
|
|
| 26 |
import org.eclipse.hyades.test.core.util.EMFUtil; |
| 27 |
import org.eclipse.hyades.test.ui.TestUIConstants; |
25 |
import org.eclipse.hyades.test.ui.TestUIConstants; |
| 28 |
import org.eclipse.hyades.test.ui.TestUIImages; |
26 |
import org.eclipse.hyades.test.ui.TestUIImages; |
| 29 |
import org.eclipse.hyades.test.ui.internal.model.EventUtil; |
27 |
import org.eclipse.hyades.test.ui.internal.model.EventUtil; |
|
Lines 39-50
Link Here
|
| 39 |
|
37 |
|
| 40 |
/** |
38 |
/** |
| 41 |
* @author jgout |
39 |
* @author jgout |
|
|
40 |
* @author jcanches |
| 42 |
* @since 3.2 |
41 |
* @since 3.2 |
| 43 |
*/ |
42 |
*/ |
| 44 |
public class DefaultExecutionResultProxyNode extends TypedElementProxyNode implements IExecutionResultProxyNode, IPersistableProxyNode { |
43 |
public class DefaultExecutionResultProxyNode extends TypedElementProxyNode implements IExecutionResultProxyNode, IPersistableProxyNode { |
| 45 |
|
44 |
|
|
|
45 |
private final static String TAG_VERDICT = "verdict"; //$NON-NLS-1$ |
| 46 |
private final static String TAG_TIMESTAMP = "timestamp"; //$NON-NLS-1$ |
| 47 |
|
| 46 |
private IProxyNode[] children; |
48 |
private IProxyNode[] children; |
| 47 |
private int verdict; |
49 |
private int verdict; |
|
|
50 |
private long timestamp; |
| 51 |
private String cachedName; |
| 48 |
|
52 |
|
| 49 |
/** |
53 |
/** |
| 50 |
* @param er |
54 |
* @param er |
|
Lines 53-59
Link Here
|
| 53 |
public DefaultExecutionResultProxyNode(TPFExecutionResult er, Object parent) { |
57 |
public DefaultExecutionResultProxyNode(TPFExecutionResult er, Object parent) { |
| 54 |
super(er, parent); |
58 |
super(er, parent); |
| 55 |
|
59 |
|
| 56 |
String name; |
|
|
| 57 |
LinkedList c = new LinkedList(); |
60 |
LinkedList c = new LinkedList(); |
| 58 |
TPFExecutionHistory history = er.getExecutionHistory(); |
61 |
TPFExecutionHistory history = er.getExecutionHistory(); |
| 59 |
if (history != null ) { |
62 |
if (history != null ) { |
|
Lines 64-106
Link Here
|
| 64 |
} |
67 |
} |
| 65 |
children = (IProxyNode[]) c.toArray(new IProxyNode[c.size()]); |
68 |
children = (IProxyNode[]) c.toArray(new IProxyNode[c.size()]); |
| 66 |
//- save the name of this element |
69 |
//- save the name of this element |
| 67 |
if(er.getName() != null) { |
70 |
String name = er.getName(); |
| 68 |
name = er.getName(); |
71 |
String testName = null; |
|
|
72 |
TPFTest test = er.getTest(); |
| 73 |
if(test != null) { |
| 74 |
testName = test.getName(); |
| 75 |
} |
| 76 |
if (name != null) { |
| 77 |
if (testName != null && !testName.equals(name)) { |
| 78 |
name += " [" + testName + "]"; //$NON-NLS-1$//$NON-NLS-2$ |
| 79 |
} |
| 69 |
} else { |
80 |
} else { |
| 70 |
name = "unamed"; //$NON-NLS-1$ |
81 |
if (testName != null) { |
| 71 |
} |
82 |
name = testName; |
| 72 |
TPFTest test = er.getTest(); |
83 |
} |
| 73 |
if((er.getTest() != null) && (((er.getTest()).getName()) != null)) { |
|
|
| 74 |
if (test instanceof TPFTestSuite) { |
| 75 |
if (er.getExecutionHistory().getExecutionEvents()!=null && er.getExecutionHistory().getExecutionEvents().size()>0) { |
| 76 |
long timeStamp = ((TPFExecutionEvent)er.getExecutionHistory().getExecutionEvents().get(0)).getTimestamp(); |
| 77 |
String dateStamp = EventUtil.getTime(timeStamp); |
| 78 |
name += " ["+dateStamp+"]"; //$NON-NLS-1$//$NON-NLS-2$ |
| 79 |
} |
| 80 |
} else { |
| 81 |
name += " [" + (er.getTest()).getName() + "]"; //$NON-NLS-1$ //$NON-NLS-2$ |
| 82 |
} |
| 83 |
} |
84 |
} |
| 84 |
setName(name); |
85 |
setName(name); |
|
|
86 |
if (!(parent instanceof IExecutionResultProxyNode)) { |
| 87 |
if (er.getExecutionHistory().getExecutionEvents() != null && er.getExecutionHistory().getExecutionEvents().size()>0) { |
| 88 |
timestamp = ((TPFExecutionEvent)er.getExecutionHistory().getExecutionEvents().get(0)).getTimestamp(); |
| 89 |
} |
| 90 |
} |
| 85 |
verdict = er.getVerdict().getValue(); |
91 |
verdict = er.getVerdict().getValue(); |
| 86 |
} |
92 |
} |
| 87 |
|
93 |
|
| 88 |
public DefaultExecutionResultProxyNode(IMemento memento, Object parent) { |
94 |
public DefaultExecutionResultProxyNode(IMemento memento, Object parent) { |
| 89 |
super(memento, parent); |
95 |
super(memento, parent); |
| 90 |
Integer v = memento.getInteger(TestUIConstants.TAG_VERDICT); |
96 |
Integer v = memento.getInteger(TAG_VERDICT); |
| 91 |
if(v == null) { |
97 |
String l = memento.getString(TAG_TIMESTAMP); |
|
|
98 |
if(v == null || l == null) { |
| 92 |
//- old memento, we need to rebuild the proxy from execution file |
99 |
//- old memento, we need to rebuild the proxy from execution file |
| 93 |
throw new ProxyNeedToBeRebuiltException(); |
100 |
throw new ProxyNeedToBeRebuiltException(); |
| 94 |
} else { |
101 |
} else { |
| 95 |
verdict = v.intValue(); |
102 |
verdict = v.intValue(); |
| 96 |
} |
103 |
} |
|
|
104 |
try { |
| 105 |
timestamp = Long.parseLong(l); |
| 106 |
} catch (NumberFormatException e) { |
| 107 |
timestamp = 0L; |
| 108 |
} |
| 97 |
IMemento [] childrenMemento = memento.getChildren(TestUIConstants.TAG_CHILD); |
109 |
IMemento [] childrenMemento = memento.getChildren(TestUIConstants.TAG_CHILD); |
| 98 |
LinkedList execChildren = new LinkedList(); |
110 |
LinkedList execChildren = new LinkedList(); |
| 99 |
for (int i = 0; i < childrenMemento.length; i++) { |
111 |
for (int i = 0; i < childrenMemento.length; i++) { |
| 100 |
IMemento mementoChild = childrenMemento[i]; |
112 |
IMemento mementoChild = childrenMemento[i]; |
| 101 |
//- inherit the TAG_URI_ROOT which is an extra data contained by the parent |
113 |
//- inherit the TAG_URI_ROOT which is an extra data contained by the parent |
| 102 |
mementoChild.putString(TestUIConstants.TAG_URI_ROOT, memento.getString(TestUIConstants.TAG_URI_ROOT)); |
114 |
mementoChild.putString(TestUIConstants.TAG_URI_ROOT, memento.getString(TestUIConstants.TAG_URI_ROOT)); |
| 103 |
String type = mementoChild.getString(TestUIConstants.TAG_TYPE); |
115 |
String type = getType(); |
| 104 |
if(type == null) { |
116 |
if(type == null) { |
| 105 |
throw new ProxyNeedToBeRebuiltException(); |
117 |
throw new ProxyNeedToBeRebuiltException(); |
| 106 |
} |
118 |
} |
|
Lines 133-138
Link Here
|
| 133 |
} |
145 |
} |
| 134 |
} |
146 |
} |
| 135 |
|
147 |
|
|
|
148 |
public String getText() { |
| 149 |
if (timestamp != 0L) { |
| 150 |
if (cachedName == null) { |
| 151 |
String dateStamp = EventUtil.getTime(timestamp); |
| 152 |
cachedName = super.getText() + " ["+dateStamp+"]"; //$NON-NLS-1$//$NON-NLS-2$ |
| 153 |
} |
| 154 |
return cachedName; |
| 155 |
} |
| 156 |
return super.getText(); |
| 157 |
} |
| 158 |
|
| 136 |
public Image getImage() { |
159 |
public Image getImage() { |
| 137 |
return TestUIImages.INSTANCE.getImage(TestUIImages.IMG_EXECUTION); |
160 |
return TestUIImages.INSTANCE.getImage(TestUIImages.IMG_EXECUTION); |
| 138 |
} |
161 |
} |
|
Lines 142-148
Link Here
|
| 142 |
} |
165 |
} |
| 143 |
|
166 |
|
| 144 |
public TPFExecutionResult getExecutionResult() { |
167 |
public TPFExecutionResult getExecutionResult() { |
| 145 |
EObject exec = EMFUtil.getResourceSet().getEObject(getOriginatorURI(), true); |
168 |
EObject exec = super.getEObject(); |
| 146 |
if (exec instanceof TPFExecutionResult) { |
169 |
if (exec instanceof TPFExecutionResult) { |
| 147 |
return (TPFExecutionResult) exec; |
170 |
return (TPFExecutionResult) exec; |
| 148 |
} else { |
171 |
} else { |
|
Lines 154-173
Link Here
|
| 154 |
return verdict; |
177 |
return verdict; |
| 155 |
} |
178 |
} |
| 156 |
|
179 |
|
| 157 |
public String getFactoryID() { |
180 |
protected String getNodeKind() { |
| 158 |
return "EMFResourceProxyFactory"; //$NON-NLS-1$ |
181 |
return TestUIConstants.EXECUTION_RESULT_NODE; |
| 159 |
} |
182 |
} |
| 160 |
|
183 |
|
| 161 |
public boolean saveState(IMemento memento) { |
184 |
public boolean saveState(IMemento memento) { |
| 162 |
//- data to retrieve the correct object |
185 |
//- data to retrieve the correct object |
| 163 |
memento.putString(TestUIConstants.TAG_NODE_KIND, TestUIConstants.EXECUTION_RESULT_NODE); |
186 |
memento.putInteger(TAG_VERDICT, getVerdict()); |
| 164 |
memento.putInteger(TestUIConstants.TAG_VERDICT, getVerdict()); |
187 |
memento.putString(TAG_TIMESTAMP, Long.toString(timestamp)); |
| 165 |
//- data from TypedElementProxyNode |
|
|
| 166 |
memento.putString(TestUIConstants.TAG_TYPE, getType()); |
| 167 |
//- data from CMNNamedElementProxyNode |
| 168 |
memento.putString(TestUIConstants.TAG_NAME, getText()); |
| 169 |
//- data from EObjectProxyNode |
| 170 |
memento.putString(TestUIConstants.TAG_URI_FRAGMENT, getOriginatorURI().fragment()); |
| 171 |
//- children (testcases) |
188 |
//- children (testcases) |
| 172 |
for (int i = 0; i < children.length; i++) { |
189 |
for (int i = 0; i < children.length; i++) { |
| 173 |
DefaultExecutionResultProxyNode child = (DefaultExecutionResultProxyNode)children[i]; |
190 |
DefaultExecutionResultProxyNode child = (DefaultExecutionResultProxyNode)children[i]; |
|
Lines 176-182
Link Here
|
| 176 |
return false; |
193 |
return false; |
| 177 |
} |
194 |
} |
| 178 |
} |
195 |
} |
| 179 |
return true; |
196 |
return super.saveState(memento); |
| 180 |
} |
197 |
} |
| 181 |
|
198 |
|
| 182 |
|
199 |
|