1 package org
.argeo
.slc
.unit
.test
.tree
;
5 import org
.argeo
.slc
.core
.build
.Distribution
;
6 import org
.argeo
.slc
.core
.deploy
.DeployedSystem
;
7 import org
.argeo
.slc
.core
.deploy
.DeploymentData
;
8 import org
.argeo
.slc
.core
.deploy
.TargetData
;
9 import org
.argeo
.slc
.core
.process
.SlcExecution
;
10 import org
.argeo
.slc
.core
.process
.SlcExecutionStep
;
11 import org
.argeo
.slc
.core
.structure
.SimpleSElement
;
12 import org
.argeo
.slc
.core
.structure
.tree
.TreeSPath
;
13 import org
.argeo
.slc
.core
.structure
.tree
.TreeSRegistry
;
14 import org
.argeo
.slc
.core
.test
.SimpleResultPart
;
15 import org
.argeo
.slc
.core
.test
.SimpleTestRun
;
16 import org
.argeo
.slc
.core
.test
.TestStatus
;
17 import org
.argeo
.slc
.core
.test
.tree
.PartSubList
;
18 import org
.argeo
.slc
.core
.test
.tree
.TreeTestResult
;
19 import org
.argeo
.slc
.msg
.test
.tree
.ResultPartRequest
;
20 import org
.argeo
.slc
.unit
.process
.SlcExecutionTestUtils
;
22 public abstract class TreeTestResultTestUtils
{
24 public static TreeTestResult
createSimpleTreeTestResult() {
25 TreeTestResult treeTestResult
= new TreeTestResult();
26 treeTestResult
.setUuid(UUID
.randomUUID().toString());
27 return treeTestResult
;
30 public static TreeTestResult
createCompleteTreeTestResult() {
31 SlcExecution slcExecution
= SlcExecutionTestUtils
32 .createSimpleSlcExecution();
33 SlcExecutionStep step
= new SlcExecutionStep("JUnit step");
34 slcExecution
.getSteps().add(step
);
36 TreeTestResult ttr
= createMinimalConsistentTreeTestResult(slcExecution
);
38 ttr
.addResultPart(createSimpleResultPartPassed());
39 ttr
.addResultPart(createSimpleResultPartFailed());
40 ttr
.addResultPart(createSimpleResultPartError());
44 public static TreeTestResult
createMinimalConsistentTreeTestResult(
45 SlcExecution slcExecution
) {
46 SimpleTestRun testRun
= new SimpleTestRun();
47 testRun
.setUuid(UUID
.randomUUID().toString());
49 String pathStr
= "/test";
50 TreeSPath path
= new TreeSPath(pathStr
);
52 TreeSRegistry registry
= new TreeSRegistry();
53 SimpleSElement elem
= new SimpleSElement("Unit Test");
54 elem
.getTags().put("myTag", "myTagValue");
55 registry
.register(path
, elem
);
57 TreeTestResult ttr
= createSimpleTreeTestResult();
58 ttr
.getAttributes().put("testCase", "UNIT");
61 ttr
.notifyCurrentPath(registry
, path
);
62 ttr
.notifyTestRun(testRun
);
63 testRun
.setTestResult(ttr
);
64 testRun
.setDeployedSystem(new DeployedSystem() {
65 private String uuid
= UUID
.randomUUID().toString();
67 public String
getDeployedSystemId() {
71 public Distribution
getDistribution() {
75 public DeploymentData
getDeploymentData() {
76 // TODO Auto-generated method stub
80 public TargetData
getTargetData() {
81 // TODO Auto-generated method stub
86 testRun
.notifySlcExecution(slcExecution
);
90 public static SimpleResultPart
createSimpleResultPartPassed() {
91 SimpleResultPart partPassed
= new SimpleResultPart();
92 String msgPassed
= "message\nnew line";
93 partPassed
.setStatus(TestStatus
.PASSED
);
94 partPassed
.setMessage(msgPassed
);
98 public static SimpleResultPart
createSimpleResultPartFailed() {
99 SimpleResultPart partFailed
= new SimpleResultPart();
100 String msgFailed
= "too bad";
101 partFailed
.setStatus(TestStatus
.FAILED
);
102 partFailed
.setMessage(msgFailed
);
106 public static SimpleResultPart
createSimpleResultPartError() {
107 SimpleResultPart partFailed
= new SimpleResultPart();
108 String msgFailed
= "crashed\nanother line";
109 partFailed
.setStatus(TestStatus
.ERROR
);
110 partFailed
.setMessage(msgFailed
);
111 partFailed
.setException(new Exception("Test Exception"));
115 public static ResultPartRequest
createSimpleResultPartRequest(
116 TreeTestResult ttr
) {
117 TreeSPath path
= ttr
.getCurrentPath();
118 PartSubList lst
= ttr
.getResultParts().get(path
);
119 SimpleResultPart part
= (SimpleResultPart
) lst
.getParts().get(2);
121 ResultPartRequest req
= new ResultPartRequest(ttr
, path
, part
);
122 req
.setPath(ttr
.getCurrentPath());
127 private TreeTestResultTestUtils() {