1 package org
.argeo
.slc
.castor
;
3 import java
.text
.SimpleDateFormat
;
4 import java
.util
.ArrayList
;
8 import org
.argeo
.slc
.execution
.ExecutionFlowDescriptor
;
9 import org
.argeo
.slc
.msg
.process
.SlcExecutionRequest
;
10 import org
.argeo
.slc
.msg
.process
.SlcExecutionStepsRequest
;
11 import org
.argeo
.slc
.process
.RealizedFlow
;
12 import org
.argeo
.slc
.process
.SlcExecution
;
13 import org
.argeo
.slc
.process
.SlcExecutionStep
;
14 import org
.argeo
.slc
.unit
.execution
.ExecutionFlowDescriptorTestUtils
;
15 import org
.argeo
.slc
.unit
.process
.SlcExecutionTestUtils
;
16 import org
.springframework
.xml
.transform
.StringResult
;
18 public class SlcExecutionCastorTest
extends AbstractCastorTestCase
{
19 public void testMarshalling() throws Exception
{
20 SlcExecution slcExec
= SlcExecutionTestUtils
.createSimpleSlcExecution();
22 SlcExecutionRequest msgSave
= new SlcExecutionRequest();
23 msgSave
.setSlcExecution(slcExec
);
25 StringResult msgSaveXml
= marshalAndValidate(msgSave
);
27 SimpleDateFormat sdf
= new SimpleDateFormat("yyyy-MM-dd HH:mm");
28 SlcExecutionStep step0
= new SlcExecutionStep();
29 step0
.setUuid(UUID
.randomUUID().toString());
30 step0
.setBegin(sdf
.parse("2008-04-17 18:21"));
32 step0
.addLog("A log message\nand another line");
34 SlcExecutionStep step1
= new SlcExecutionStep();
35 step1
.setUuid(UUID
.randomUUID().toString());
36 step1
.setBegin(sdf
.parse("2008-04-17 18:25"));
38 step1
.addLog("A nother log message");
40 SlcExecutionStepsRequest msgNotif
= new SlcExecutionStepsRequest();
41 msgNotif
.addStep(step0
);
42 msgNotif
.addStep(step1
);
43 msgNotif
.setSlcExecutionUuid(slcExec
.getUuid());
45 StringResult msgNotifXml
= marshalAndValidate(msgNotif
);
47 SlcExecutionRequest msgSaveUnm
= unmarshal(msgSaveXml
);
48 assertNotNull(msgSaveUnm
);
49 SlcExecutionTestUtils
.assertSlcExecution(slcExec
, msgSaveUnm
52 SlcExecutionStepsRequest msgNotifUnm
= unmarshal(msgNotifXml
);
53 assertNotNull(msgNotifUnm
);
54 assertEquals(slcExec
.getUuid(), msgNotifUnm
.getSlcExecutionUuid());
55 assertEquals(2, msgNotifUnm
.getSteps().size());
56 SlcExecutionTestUtils
.assertSlcExecutionStep(step0
, msgNotifUnm
58 SlcExecutionTestUtils
.assertSlcExecutionStep(step1
, msgNotifUnm
61 SlcExecution slcExecUnm
= msgSaveUnm
.getSlcExecution();
62 slcExecUnm
.getSteps().addAll(msgNotifUnm
.getSteps());
64 SlcExecutionRequest msgUpdate
= new SlcExecutionRequest();
65 msgUpdate
.setSlcExecution(slcExecUnm
);
66 StringResult msgUpdateXml
= marshalAndValidate(msgUpdate
);
68 SlcExecutionRequest msgUpdateUnm
= unmarshal(msgUpdateXml
);
69 assertNotNull(msgUpdateUnm
);
72 public void testMarshUnmarsh() throws Exception
{
73 SlcExecution slcExec
= SlcExecutionTestUtils
.createSimpleSlcExecution();
74 List
<RealizedFlow
> realizedFlows
= new ArrayList
<RealizedFlow
>();
75 RealizedFlow realizedFlow
= new RealizedFlow();
76 ExecutionFlowDescriptor flowDescriptor
= ExecutionFlowDescriptorTestUtils
77 .createSimpleExecutionFlowDescriptor();
78 realizedFlow
.setModuleName("test.module");
79 realizedFlow
.setModuleVersion("1.0.0");
80 realizedFlow
.setFlowDescriptor(flowDescriptor
);
81 realizedFlow
.setExecutionSpec(flowDescriptor
.getExecutionSpec());
82 realizedFlows
.add(realizedFlow
);
83 slcExec
.setRealizedFlows(realizedFlows
);
85 marshUnmarsh(slcExec
, false);