1 package org
.argeo
.slc
.unit
.process
;
3 import static junit
.framework
.Assert
.assertEquals
;
4 import static junit
.framework
.Assert
.assertNotNull
;
5 import static org
.argeo
.slc
.unit
.UnitUtils
.assertDateSec
;
7 import java
.util
.ArrayList
;
11 import org
.argeo
.slc
.execution
.ExecutionFlowDescriptor
;
12 import org
.argeo
.slc
.process
.RealizedFlow
;
13 import org
.argeo
.slc
.process
.SlcExecution
;
14 import org
.argeo
.slc
.process
.SlcExecutionStep
;
15 import org
.argeo
.slc
.unit
.execution
.ExecutionFlowDescriptorTestUtils
;
17 public abstract class SlcExecutionTestUtils
{
19 public static SlcExecution
createSimpleSlcExecution() {
20 SlcExecution slcExec
= new SlcExecution();
21 slcExec
.setUuid(UUID
.randomUUID().toString());
22 slcExec
.setHost("localhost");
23 slcExec
.setUser("user");
24 slcExec
.setType("slcAnt");
25 slcExec
.setStatus("STARTED");
26 slcExec
.getAttributes().put("ant.file", "/test");
30 public static SlcExecution
createSlcExecutionWithRealizedFlows() {
31 SlcExecution slcExec
= SlcExecutionTestUtils
.createSimpleSlcExecution();
32 List
<RealizedFlow
> realizedFlows
= new ArrayList
<RealizedFlow
>();
33 RealizedFlow realizedFlow
= new RealizedFlow();
34 ExecutionFlowDescriptor flowDescriptor
= ExecutionFlowDescriptorTestUtils
35 .createSimpleExecutionFlowDescriptor();
36 realizedFlow
.setModuleName("test.module");
37 realizedFlow
.setModuleVersion("1.0.0");
38 realizedFlow
.setFlowDescriptor(flowDescriptor
);
39 realizedFlow
.setExecutionSpec(flowDescriptor
.getExecutionSpec());
40 realizedFlows
.add(realizedFlow
);
41 slcExec
.setRealizedFlows(realizedFlows
);
45 public static void assertSlcExecution(SlcExecution expected
,
46 SlcExecution reached
) {
47 assertNotNull(reached
);
48 assertEquals(expected
.getHost(), reached
.getHost());
49 assertEquals(expected
.getUser(), reached
.getUser());
50 assertEquals(expected
.getType(), reached
.getType());
51 assertEquals(expected
.getStatus(), reached
.getStatus());
54 assertEquals(expected
.getAttributes().size(), reached
.getAttributes()
56 for (String key
: expected
.getAttributes().keySet()) {
57 String expectedValue
= expected
.getAttributes().get(key
);
58 String reachedValue
= reached
.getAttributes().get(key
);
59 assertNotNull(reachedValue
);
60 assertEquals(expectedValue
, reachedValue
);
63 assertEquals(expected
.getSteps().size(), reached
.getSteps().size());
64 for (int i
= 0; i
< expected
.getSteps().size(); i
++) {
65 SlcExecutionStep stepExpected
= expected
.getSteps().get(i
);
66 SlcExecutionStep stepReached
= reached
.getSteps().get(i
);
67 assertSlcExecutionStep(stepExpected
, stepReached
);
71 public static void assertSlcExecutionStep(SlcExecutionStep expected
,
72 SlcExecutionStep reached
) {
73 assertNotNull(reached
);
74 assertEquals(expected
.getUuid(), reached
.getUuid());
75 assertEquals(expected
.getType(), reached
.getType());
76 assertDateSec(expected
.getBegin(), reached
.getBegin());
79 private SlcExecutionTestUtils() {