SlcExecution persistence
authorMathieu Baudier <mbaudier@argeo.org>
Thu, 23 Jul 2009 18:18:58 +0000 (18:18 +0000)
committerMathieu Baudier <mbaudier@argeo.org>
Thu, 23 Jul 2009 18:18:58 +0000 (18:18 +0000)
Security

git-svn-id: https://svn.argeo.org/slc/trunk@2745 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

17 files changed:
integration-tests/org.argeo.slc.it.webapp/src/test/resources/org/argeo/slc/it/webapp/applicationContext.xml
modules/server/org.argeo.slc.server.catalina/META-INF/MANIFEST.MF
modules/server/org.argeo.slc.webapp.war/WEB-INF/security.xml
modules/server/org.argeo.slc.webapp.war/WEB-INF/slc-service-servlet.xml
runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/DefaultExecutionFlowDescriptorConverter.java
runtime/org.argeo.slc.launcher/src/main/java/org/argeo/slc/cli/SlcMain.java
runtime/org.argeo.slc.launcher/src/main/java/org/argeo/slc/server/client/impl/AbstractHttpServicesClient.java
runtime/org.argeo.slc.launcher/src/main/resources/org/argeo/slc/server/client/spring.xml
runtime/org.argeo.slc.server/src/main/java/org/argeo/slc/web/mvc/process/GetSlcExecution.java [new file with mode: 0644]
runtime/org.argeo.slc.server/src/main/java/org/argeo/slc/web/mvc/process/NewSlcExecutionController.java
runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/process/RealizedFlow.java
runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/process/SlcExecution.java
runtime/org.argeo.slc.support.castor/src/test/java/org/argeo/slc/castor/SlcExecutionCastorTest.java
runtime/org.argeo.slc.support.hibernate/pom.xml
runtime/org.argeo.slc.support.hibernate/src/main/resources/org/argeo/slc/hibernate/process/SlcExecution.hbm.xml
runtime/org.argeo.slc.support.hibernate/src/test/java/org/argeo/slc/hibernate/process/CastorSlcExecutionHibernateTest.java [new file with mode: 0644]
runtime/org.argeo.slc.unit/src/main/java/org/argeo/slc/unit/process/SlcExecutionTestUtils.java

index 3d7b057670506680cda150adc863c55bd6f33874..85c7f031fd7ba44105733226e42573e3c488ed2b 100644 (file)
@@ -8,4 +8,7 @@
 
        <import resource="classpath:org/argeo/slc/server/client/spring.xml" />
 
+       <bean id="serverHttpClient" parent="slcTemplate.serverHttpClient">
+       </bean>
+
 </beans>
\ No newline at end of file
index ad5203f46cdb63b0f1462b49ee64079820ccab6a..e35fd4006d7dd67d8be10a6222bafbd606bfce41 100644 (file)
@@ -3,6 +3,8 @@ Fragment-Host: com.springsource.org.apache.catalina;bundle-version="[6
  .0.16,7.0.0)"\r
 Bundle-Version: 0.11.4.SNAPSHOT\r
 Bundle-SymbolicName: org.argeo.slc.server.catalina\r
-Import-Package: org.springframework.security.providers,\r
- org.springframework.security,\r
- org.springframework.security.ui\r
+Import-Package: org.springframework.security,\r
+ org.springframework.security.providers,\r
+ org.springframework.security.ui,\r
+ org.springframework.security.userdetails,\r
+ org.springframework.security.ui.savedrequest\r
index 32db8e1d09aac95460f2f6b0e51e809425ef3a5d..35397ad70748a7e5e08702d3a40ac1b8085ed8b6 100644 (file)
@@ -4,7 +4,7 @@
               http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-2.0.4.xsd">
 
        <http realm="User Interface" >
-               <intercept-url pattern="/**" access="ROLE_USER,ROLE_ANONYMOUS,ROLE_ADMIN" />
+               <intercept-url pattern="/**" access="ROLE_USER,ROLE_ADMIN" />
                <http-basic />
                <anonymous />
        </http>
index 5ea3a76744356d1c53cc7c0cfcefda4b8a5b2e7c..b4143a3ca2f88935dfbe33d797d55c0472eeab3f 100644 (file)
                <constructor-arg ref="slcExecutionDao" />
        </bean>
 
+       <bean name="/getSlcExecution.service" class="org.argeo.slc.web.mvc.process.GetSlcExecution">
+               <property name="slcExecutionDao" ref="slcExecutionDao" />
+               <property name="unmarshaller" ref="unmarshaller" />
+       </bean>
+
        <bean name="/newSlcExecution.service"
                class="org.argeo.slc.web.mvc.process.NewSlcExecutionController">
                <property name="agentFactory" ref="agentFactory" />
                <property name="unmarshaller" ref="unmarshaller" />
+               <property name="marshaller" ref="marshaller" />
                <property name="slcExecutionService" ref="slcExecutionService" />
        </bean>
 
index b2b613494c5c5d90be063d418b0290236447db90..968debcb7ca25f7a992dcc0d15ae2e81a2c76755 100644 (file)
@@ -39,11 +39,16 @@ public class DefaultExecutionFlowDescriptorConverter implements
                        ExecutionFlowDescriptor executionFlowDescriptor) {
                Map<String, Object> values = executionFlowDescriptor.getValues();
                Map<String, Object> convertedValues = new HashMap<String, Object>();
+               ExecutionSpec executionSpec = executionFlowDescriptor
+                               .getExecutionSpec();
 
-               if (values != null) {
+               if (executionSpec == null)
+                       log.warn("Execution spec is null for " + executionFlowDescriptor);
+
+               if (values != null && executionSpec != null) {
                        values: for (String key : values.keySet()) {
-                               ExecutionSpecAttribute attribute = executionFlowDescriptor
-                                               .getExecutionSpec().getAttributes().get(key);
+                               ExecutionSpecAttribute attribute = executionSpec
+                                               .getAttributes().get(key);
 
                                if (attribute.getIsFrozen())
                                        continue values;
index 14fad229b59d6441607b86b388dc2e30c5ca3cb8..e8e5352e764c02123dcfe88fa066b0d19fd7cfed 100644 (file)
@@ -13,9 +13,9 @@ import org.apache.commons.cli.Options;
 import org.apache.commons.cli.ParseException;
 import org.apache.commons.io.IOUtils;
 import org.argeo.slc.SlcException;
-import org.argeo.slc.server.client.SlcServerHttpClient;
 import org.argeo.slc.server.client.impl.SlcServerHttpClientImpl;
 
+@SuppressWarnings("static-access")
 public class SlcMain {
        public enum Type {
                standalone, agent, server
@@ -23,8 +23,10 @@ public class SlcMain {
 
        private static Boolean debug = true;
 
-       private final static String BOOTSTRAP_LOG4J_CONFIG = "org/argeo/slc/cli/bootstrapLog4j.properties";
-       private final static String DEFAULT_AGENT_CONTEXT = "classpath:org/argeo/slc/cli/spring-agent-default.xml";
+       // private final static String BOOTSTRAP_LOG4J_CONFIG =
+       // "org/argeo/slc/cli/bootstrapLog4j.properties";
+       // private final static String DEFAULT_AGENT_CONTEXT =
+       // "classpath:org/argeo/slc/cli/spring-agent-default.xml";
 
        private final static Option typeOpt = OptionBuilder.withLongOpt("mode")
                        .withArgName("mode").hasArg().withDescription(
index 43f8fe16a9a82bbdc127b42ab447aa17d07c786b..569f42c6f80afc6f96e74a09d6d05ec9ec797334 100644 (file)
@@ -5,7 +5,9 @@ import java.io.InputStreamReader;
 import java.io.OutputStreamWriter;
 import java.io.Reader;
 import java.io.Writer;
+import java.net.Authenticator;
 import java.net.HttpURLConnection;
+import java.net.PasswordAuthentication;
 import java.net.URL;
 import java.net.URLEncoder;
 import java.util.Map;
@@ -27,6 +29,10 @@ import org.springframework.util.Assert;
 public abstract class AbstractHttpServicesClient implements HttpServicesClient {
        private final static Log log = LogFactory
                        .getLog(AbstractHttpServicesClient.class);
+
+       private String user;
+       private String password;
+
        private Unmarshaller unmarshaller;
        private Marshaller marshaller;
        private String baseUrl;
@@ -35,9 +41,19 @@ public abstract class AbstractHttpServicesClient implements HttpServicesClient {
        private Long retryPeriod = 1000l;
        private Long defaultTimeout = 30 * 1000l;
 
+       public void init() {
+               if (user != null && password != null)
+                       Authenticator.setDefault(new Authenticator() {
+                               protected PasswordAuthentication getPasswordAuthentication() {
+                                       return new PasswordAuthentication(user, password
+                                                       .toCharArray());
+                               }
+                       });
+       }
+
        @SuppressWarnings(value = { "unchecked" })
        public <T> T callService(String path, Map<String, String> parameters) {
-               return (T)callService(path, parameters, null);
+               return (T) callService(path, parameters, null);
        }
 
        @SuppressWarnings(value = { "unchecked" })
@@ -101,6 +117,7 @@ public abstract class AbstractHttpServicesClient implements HttpServicesClient {
 
        protected Object callServiceLowLevel(String path,
                        Map<String, String> parameters, Object body) throws IOException {
+
                Assert.notNull(baseUrl, "base url");
                HttpURLConnection connection = null;
                Writer writer = null;
@@ -217,4 +234,12 @@ public abstract class AbstractHttpServicesClient implements HttpServicesClient {
                return defaultTimeout;
        }
 
+       public void setUser(String user) {
+               this.user = user;
+       }
+
+       public void setPassword(String password) {
+               this.password = password;
+       }
+
 }
index c9af00057c720d9cc7d81fd1acc76b1e62e0f346..a4546c0caa2d2ac979f4e8a5b456efc993587a59 100644 (file)
@@ -1,7 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <beans xmlns="http://www.springframework.org/schema/beans"
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-       xmlns:aop="http://www.springframework.org/schema/aop"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
        xmlns:tx="http://www.springframework.org/schema/tx"
        xsi:schemaLocation="
         http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"
@@ -10,8 +9,11 @@
        <import resource="classpath:org/argeo/slc/castor/spring.xml" />
 
        <!-- Http client -->
-       <bean id="slcDefault.serverHttpClient" class="org.argeo.slc.server.client.impl.SlcServerHttpClientImpl"
-               lazy-init="true">
+       <bean id="slcTemplate.serverHttpClient"
+               class="org.argeo.slc.server.client.impl.SlcServerHttpClientImpl"
+               init-method="init" abstract="true">
+               <property name="user" value="demo" />
+               <property name="password" value="demo" />
                <property name="unmarshaller" ref="slcDefault.castor.marshaller" />
                <property name="marshaller" ref="slcDefault.castor.marshaller" />
                <property name="baseUrl" value="http://localhost:7070/org.argeo.slc.webapp/" />
diff --git a/runtime/org.argeo.slc.server/src/main/java/org/argeo/slc/web/mvc/process/GetSlcExecution.java b/runtime/org.argeo.slc.server/src/main/java/org/argeo/slc/web/mvc/process/GetSlcExecution.java
new file mode 100644 (file)
index 0000000..eea87a6
--- /dev/null
@@ -0,0 +1,42 @@
+package org.argeo.slc.web.mvc.process;\r
+\r
+import javax.servlet.http.HttpServletRequest;\r
+import javax.servlet.http.HttpServletResponse;\r
+\r
+import org.argeo.slc.dao.process.SlcExecutionDao;\r
+import org.argeo.slc.msg.ObjectList;\r
+import org.argeo.slc.process.SlcExecution;\r
+import org.argeo.slc.web.mvc.AbstractServiceController;\r
+import org.springframework.oxm.Unmarshaller;\r
+import org.springframework.web.servlet.ModelAndView;\r
+import org.springframework.xml.transform.StringSource;\r
+\r
+/** Lists SLC executions possibly filtering them. */\r
+public class GetSlcExecution extends AbstractServiceController {\r
+       private SlcExecutionDao slcExecutionDao;\r
+       private Unmarshaller unmarshaller;\r
+\r
+       @Override\r
+       protected void handleServiceRequest(HttpServletRequest request,\r
+                       HttpServletResponse response, ModelAndView modelAndView)\r
+                       throws Exception {\r
+               String uuid = request.getParameter("uuid");\r
+               SlcExecution slcExecution = slcExecutionDao.getSlcExecution(uuid);\r
+\r
+               StringSource source = new StringSource(slcExecution\r
+                               .getRealizedFlowsXml());\r
+               ObjectList ol2 = (ObjectList) unmarshaller.unmarshal(source);\r
+               ol2.fill(slcExecution.getRealizedFlows());\r
+\r
+               modelAndView.addObject(slcExecution);\r
+       }\r
+\r
+       public void setSlcExecutionDao(SlcExecutionDao slcExecutionDao) {\r
+               this.slcExecutionDao = slcExecutionDao;\r
+       }\r
+\r
+       public void setUnmarshaller(Unmarshaller unmarshaller) {\r
+               this.unmarshaller = unmarshaller;\r
+       }\r
+\r
+}\r
index 7b03f3b9bed0b4d7454bdd75dfae9eb659574250..d4a67b19d91ed51f1cdcb061b8bf692b73a3dd22 100644 (file)
@@ -9,15 +9,18 @@ import javax.servlet.http.HttpServletResponse;
 import org.apache.commons.logging.Log;\r
 import org.apache.commons.logging.LogFactory;\r
 import org.argeo.slc.msg.MsgConstants;\r
+import org.argeo.slc.msg.ObjectList;\r
 import org.argeo.slc.process.SlcExecution;\r
 import org.argeo.slc.process.SlcExecutionStep;\r
 import org.argeo.slc.runtime.SlcAgent;\r
 import org.argeo.slc.runtime.SlcAgentFactory;\r
 import org.argeo.slc.services.SlcExecutionService;\r
 import org.argeo.slc.web.mvc.AbstractServiceController;\r
+import org.springframework.oxm.Marshaller;\r
 import org.springframework.oxm.Unmarshaller;\r
 import org.springframework.util.Assert;\r
 import org.springframework.web.servlet.ModelAndView;\r
+import org.springframework.xml.transform.StringResult;\r
 import org.springframework.xml.transform.StringSource;\r
 \r
 /** Send a new SlcExecution. */\r
@@ -27,6 +30,7 @@ public class NewSlcExecutionController extends AbstractServiceController {
 \r
        private SlcAgentFactory agentFactory;\r
        private Unmarshaller unmarshaller;\r
+       private Marshaller marshaller;\r
        private SlcExecutionService slcExecutionService;\r
 \r
        @Override\r
@@ -71,6 +75,12 @@ public class NewSlcExecutionController extends AbstractServiceController {
                slcExecution.getSteps().add(\r
                                new SlcExecutionStep(SlcExecutionStep.TYPE_START,\r
                                                "Process started from the Web UI"));\r
+\r
+               ObjectList ol = new ObjectList(slcExecution.getRealizedFlows());\r
+               StringResult result = new StringResult();\r
+               marshaller.marshal(ol, result);\r
+               slcExecution.setRealizedFlowsXml(result.toString());\r
+\r
                slcExecutionService.newExecution(slcExecution);\r
 \r
                SlcAgent agent = agentFactory.getAgent(agentId);\r
@@ -89,4 +99,8 @@ public class NewSlcExecutionController extends AbstractServiceController {
                this.slcExecutionService = slcExecutionService;\r
        }\r
 \r
+       public void setMarshaller(Marshaller marshaller) {\r
+               this.marshaller = marshaller;\r
+       }\r
+\r
 }\r
index c47308eef3c0764749653b16802a9a08303dbb94..308b906e70d84991c7156fce6544f63851e0902d 100644 (file)
@@ -1,9 +1,13 @@
 package org.argeo.slc.process;
 
+import java.io.Serializable;
+
 import org.argeo.slc.execution.ExecutionFlowDescriptor;
 import org.argeo.slc.execution.ExecutionSpec;
 
-public class RealizedFlow {
+public class RealizedFlow implements Serializable {
+       private static final long serialVersionUID = 1L;
+
        private String moduleName;
        private String moduleVersion;
        private ExecutionFlowDescriptor flowDescriptor;
index 7a81facf612b1c6529ef8a2fdd825d4c9057ef17..626af3eb6770cd43f85b238e81d45b056aa66a8e 100644 (file)
@@ -28,6 +28,7 @@ public class SlcExecution implements Serializable {
        /** TODO: Synchronize */\r
        private List<SlcExecutionStep> steps = new ArrayList<SlcExecutionStep>();\r
        private List<RealizedFlow> realizedFlows = new ArrayList<RealizedFlow>();\r
+       private String realizedFlowsXml = null;\r
 \r
        public List<RealizedFlow> getRealizedFlows() {\r
                return realizedFlows;\r
@@ -143,4 +144,13 @@ public class SlcExecution implements Serializable {
                                return steps.get(steps.size() - 1).getBegin();\r
                }\r
        }\r
+\r
+       public String getRealizedFlowsXml() {\r
+               return realizedFlowsXml;\r
+       }\r
+\r
+       public void setRealizedFlowsXml(String realizedFlowsXml) {\r
+               this.realizedFlowsXml = realizedFlowsXml;\r
+       }\r
+\r
 }\r
index bfd6a7e11da56b2fe9ecf549c20903ecdc1c3943..3a9e847b8505283ae2827289deceb64794764957 100644 (file)
@@ -1,17 +1,12 @@
 package org.argeo.slc.castor;\r
 \r
 import java.text.SimpleDateFormat;\r
-import java.util.ArrayList;\r
-import java.util.List;\r
 import java.util.UUID;\r
 \r
-import org.argeo.slc.execution.ExecutionFlowDescriptor;\r
 import org.argeo.slc.msg.process.SlcExecutionRequest;\r
 import org.argeo.slc.msg.process.SlcExecutionStepsRequest;\r
-import org.argeo.slc.process.RealizedFlow;\r
 import org.argeo.slc.process.SlcExecution;\r
 import org.argeo.slc.process.SlcExecutionStep;\r
-import org.argeo.slc.unit.execution.ExecutionFlowDescriptorTestUtils;\r
 import org.argeo.slc.unit.process.SlcExecutionTestUtils;\r
 import org.springframework.xml.transform.StringResult;\r
 \r
@@ -70,18 +65,8 @@ public class SlcExecutionCastorTest extends AbstractCastorTestCase {
        }\r
 \r
        public void testMarshUnmarsh() throws Exception {\r
-               SlcExecution slcExec = SlcExecutionTestUtils.createSimpleSlcExecution();\r
-               List<RealizedFlow> realizedFlows = new ArrayList<RealizedFlow>();\r
-               RealizedFlow realizedFlow = new RealizedFlow();\r
-               ExecutionFlowDescriptor flowDescriptor = ExecutionFlowDescriptorTestUtils\r
-                               .createSimpleExecutionFlowDescriptor();\r
-               realizedFlow.setModuleName("test.module");\r
-               realizedFlow.setModuleVersion("1.0.0");\r
-               realizedFlow.setFlowDescriptor(flowDescriptor);\r
-               realizedFlow.setExecutionSpec(flowDescriptor.getExecutionSpec());\r
-               realizedFlows.add(realizedFlow);\r
-               slcExec.setRealizedFlows(realizedFlows);\r
-\r
+               SlcExecution slcExec = SlcExecutionTestUtils\r
+                               .createSlcExecutionWithRealizedFlows();\r
                marshUnmarsh(slcExec, false);\r
        }\r
 }\r
index ed93e07d8306058ef5217c952dc9a8147f7fe91d..0adaab3190987ee6837b2878a5ef3a53fc63d1be 100644 (file)
@@ -1,4 +1,5 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <parent>
                <groupId>org.argeo.slc</groupId>
index 6eb4c08c0de6c538d3f94755820bf8f03cccc60a..788073d66700052b3fddcb8104bc66493549a895 100644 (file)
@@ -10,8 +10,9 @@
                <property name="host" column="HOST" />\r
                <property name="user" column="USER" />\r
                <property name="type" column="TYPE" />\r
-               <property name="status" column="STATUS" />\r
-\r
+               <property name="status" column="STATUS" />
+               <property name="realizedFlowsXml" column="REALIZED_FLOWS_XML"
+                       type="text" />\r
                <list name="steps" cascade="all" table="SLC_EXECUTIONS_STEPS"\r
                        lazy="false">\r
                        <cache usage="read-write" />\r
diff --git a/runtime/org.argeo.slc.support.hibernate/src/test/java/org/argeo/slc/hibernate/process/CastorSlcExecutionHibernateTest.java b/runtime/org.argeo.slc.support.hibernate/src/test/java/org/argeo/slc/hibernate/process/CastorSlcExecutionHibernateTest.java
new file mode 100644 (file)
index 0000000..a43e922
--- /dev/null
@@ -0,0 +1,61 @@
+package org.argeo.slc.hibernate.process;\r
+\r
+import java.sql.SQLException;\r
+\r
+import org.argeo.slc.dao.process.SlcExecutionDao;\r
+import org.argeo.slc.hibernate.unit.HibernateTestCase;\r
+import org.argeo.slc.msg.ObjectList;\r
+import org.argeo.slc.process.SlcExecution;\r
+import org.argeo.slc.unit.process.SlcExecutionTestUtils;\r
+import org.hibernate.HibernateException;\r
+import org.hibernate.Session;\r
+import org.springframework.orm.hibernate3.HibernateCallback;\r
+import org.springframework.oxm.Marshaller;\r
+import org.springframework.oxm.Unmarshaller;\r
+import org.springframework.xml.transform.StringResult;\r
+import org.springframework.xml.transform.StringSource;\r
+\r
+public class CastorSlcExecutionHibernateTest extends HibernateTestCase {\r
+\r
+       public void testSaveWithRealizedFlowsXml() throws Exception {\r
+               SlcExecutionDao dao = getBean(SlcExecutionDao.class);\r
+\r
+               SlcExecution slcExec = SlcExecutionTestUtils\r
+                               .createSlcExecutionWithRealizedFlows();\r
+\r
+               ObjectList ol = new ObjectList(slcExec.getRealizedFlows());\r
+               StringResult result = new StringResult();\r
+               getBean(Marshaller.class).marshal(ol, result);\r
+               slcExec.setRealizedFlowsXml(result.toString());\r
+\r
+               dao.create(slcExec);\r
+\r
+               SlcExecution slcExecPersisted = dao.getSlcExecution(slcExec.getUuid());\r
+               assertSlcExecution(slcExec, slcExecPersisted);\r
+\r
+               StringSource source = new StringSource(slcExecPersisted\r
+                               .getRealizedFlowsXml());\r
+               ObjectList ol2 = (ObjectList) getBean(Unmarshaller.class).unmarshal(\r
+                               source);\r
+               ol2.fill(slcExec.getRealizedFlows());\r
+\r
+       }\r
+\r
+       public void assertSlcExecution(final SlcExecution expected,\r
+                       final SlcExecution persisted) {\r
+               getHibernateTemplate().execute(new HibernateCallback() {\r
+\r
+                       public Object doInHibernate(Session session)\r
+                                       throws HibernateException, SQLException {\r
+                               session.refresh(persisted);\r
+                               SlcExecutionTestUtils.assertSlcExecution(expected, persisted);\r
+                               return null;\r
+                       }\r
+               });\r
+       }\r
+\r
+       @Override\r
+       protected String getApplicationContextLocation() {\r
+               return "org/argeo/slc/hibernate/withCastor.xml";\r
+       }\r
+}\r
index 8bf94160175e87784f2ed313bda2c8582b90af3f..e83f1cb8ab2b744f9607476b5fd586fae5124799 100644 (file)
@@ -4,10 +4,15 @@ import static junit.framework.Assert.assertEquals;
 import static junit.framework.Assert.assertNotNull;\r
 import static org.argeo.slc.unit.UnitUtils.assertDateSec;\r
 \r
+import java.util.ArrayList;\r
+import java.util.List;\r
 import java.util.UUID;\r
 \r
+import org.argeo.slc.execution.ExecutionFlowDescriptor;\r
+import org.argeo.slc.process.RealizedFlow;\r
 import org.argeo.slc.process.SlcExecution;\r
 import org.argeo.slc.process.SlcExecutionStep;\r
+import org.argeo.slc.unit.execution.ExecutionFlowDescriptorTestUtils;\r
 \r
 public abstract class SlcExecutionTestUtils {\r
 \r
@@ -22,6 +27,21 @@ public abstract class SlcExecutionTestUtils {
                return slcExec;\r
        }\r
 \r
+       public static SlcExecution createSlcExecutionWithRealizedFlows() {\r
+               SlcExecution slcExec = SlcExecutionTestUtils.createSimpleSlcExecution();\r
+               List<RealizedFlow> realizedFlows = new ArrayList<RealizedFlow>();\r
+               RealizedFlow realizedFlow = new RealizedFlow();\r
+               ExecutionFlowDescriptor flowDescriptor = ExecutionFlowDescriptorTestUtils\r
+                               .createSimpleExecutionFlowDescriptor();\r
+               realizedFlow.setModuleName("test.module");\r
+               realizedFlow.setModuleVersion("1.0.0");\r
+               realizedFlow.setFlowDescriptor(flowDescriptor);\r
+               realizedFlow.setExecutionSpec(flowDescriptor.getExecutionSpec());\r
+               realizedFlows.add(realizedFlow);\r
+               slcExec.setRealizedFlows(realizedFlows);\r
+               return slcExec;\r
+       }\r
+\r
        public static void assertSlcExecution(SlcExecution expected,\r
                        SlcExecution reached) {\r
                assertNotNull(reached);\r