1 package org
.argeo
.slc
.hibernate
.process
;
5 import org
.argeo
.slc
.core
.process
.SlcExecution
;
6 import org
.argeo
.slc
.core
.process
.SlcExecutionStep
;
7 import org
.argeo
.slc
.core
.process
.SlcExecutionTestUtils
;
8 import org
.argeo
.slc
.dao
.process
.SlcExecutionDao
;
9 import org
.argeo
.slc
.unit
.AbstractSpringTestCase
;
11 public class SlcExecutionHibernateTest
extends AbstractSpringTestCase
{
13 public void testSave() {
14 SlcExecutionDao dao
= getBean(SlcExecutionDao
.class);
16 SlcExecution slcExec
= SlcExecutionTestUtils
.createSimpleSlcExecution();
17 slcExec
.getSteps().add(new SlcExecutionStep("LOG", "A log line"));
18 slcExec
.getSteps().add(new SlcExecutionStep("LOG", "Two log\nlines"));
22 SlcExecution slcExecPersisted
= dao
.getSlcExecution(slcExec
.getUuid());
23 SlcExecutionTestUtils
.assertSlcExecution(slcExec
, slcExecPersisted
);
24 assertEquals(2, slcExecPersisted
.getSteps().size());
25 SlcExecutionTestUtils
.assertSlcExecutionStep(slcExec
.getSteps().get(0),
26 slcExecPersisted
.getSteps().get(0));
27 SlcExecutionTestUtils
.assertSlcExecutionStep(slcExec
.getSteps().get(1),
28 slcExecPersisted
.getSteps().get(1));
31 public void testModify() {
32 SlcExecutionDao dao
= getBean(SlcExecutionDao
.class);
34 // slcExecution Creation
35 SlcExecution slcExec
= SlcExecutionTestUtils
.createSimpleSlcExecution();
36 slcExec
.getSteps().add(new SlcExecutionStep("LOG", "A log line"));
37 slcExec
.getSteps().add(new SlcExecutionStep("LOG", "Two log\nlines"));
41 // slcExecution retrieval and update
42 SlcExecution slcExecRetrieved
= dao
.getSlcExecution(slcExec
.getUuid());
44 List
<String
> logLineListStep0
= slcExecRetrieved
.getSteps().get(0)
46 for (String logLine
: logLineListStep0
)
47 logLine
= logLine
+ "appended Log text";
49 slcExecRetrieved
.getSteps().get(0).setLogLines(logLineListStep0
);
50 slcExecRetrieved
.getSteps().add(
51 new SlcExecutionStep("LOG", "Three \n log \n lines"));
53 dao
.update(slcExecRetrieved
);
55 // updated slcExecution retrieval and comparison
56 SlcExecution slcExecUpdated
= dao
.getSlcExecution(slcExec
.getUuid());
58 SlcExecutionTestUtils
.assertSlcExecution(slcExecRetrieved
,
60 assertEquals(3, slcExecUpdated
.getSteps().size());
61 SlcExecutionTestUtils
.assertSlcExecutionStep(slcExecUpdated
.getSteps()
62 .get(0), slcExecRetrieved
.getSteps().get(0));
63 SlcExecutionTestUtils
.assertSlcExecutionStep(slcExecUpdated
.getSteps()
64 .get(1), slcExecRetrieved
.getSteps().get(1));
65 SlcExecutionTestUtils
.assertSlcExecutionStep(slcExecUpdated
.getSteps()
66 .get(2), slcExecRetrieved
.getSteps().get(2));
70 protected String
getApplicationContextLocation() {
71 return "org/argeo/slc/hibernate/applicationContext.xml";