]> SALOME platform Git repositories - tools/siman.git/blob - Workspace/Siman-Common/src/test/splat/util/TestEntitiesGenerator.java
Salome HOME
Simulation context type selection is fixed in study search. Lucene is no more used...
[tools/siman.git] / Workspace / Siman-Common / src / test / splat / util / TestEntitiesGenerator.java
1 /*****************************************************************************
2  * Company         EURIWARE
3  * Application     SIMAN
4  * File            $Id$ 
5  * Creation date   Feb 12, 2013
6  * @author         $Author$
7  * @version        $Revision$
8  *****************************************************************************/
9
10 package test.splat.util; 
11
12 import java.util.ArrayList;
13 import java.util.Date;
14
15 import org.splat.dal.bo.kernel.User;
16 import org.splat.dal.bo.som.ProgressState;
17 import org.splat.dal.bo.som.SimulationContext;
18 import org.splat.dal.bo.som.Study;
19 import org.splat.exception.BusinessException;
20
21 /**
22  * Utility class for creating test entities.
23  */
24 public class TestEntitiesGenerator {
25         
26         /**
27          * Create a transient user.
28          *
29          * @param userName the userName
30          * @return a transient StepCommentDTO
31          * @throws BusinessException if something's wrong
32          */
33         public static User getTestUser(final String userName) throws BusinessException {
34
35                 User.Properties uprop = new User.Properties();
36                 uprop.setUsername(userName)
37                                 .setName("TST_Username")
38                                 .setFirstName("TST_FirstName")
39                                 .setDisplayName("TST_test.user")
40                                 .setMailAddress("noreply@salome-platform.org")
41                                 .addRole("TST-User");
42                 uprop.disableCheck();
43                 User user = new User(uprop);
44                 return user;
45         }
46
47         /**
48          * Create a transient study.
49          *
50          * @param user the user that will be placed in 'manager' and 'actor' properties
51          * @return the test study
52          * @throws BusinessException if something's wrong
53          */
54         public static Study getTestStudy(final User user) throws BusinessException{
55                 Study.Properties studyProps = new Study.Properties();
56                 studyProps.setActor(user)
57                                 .setManager(user)
58                                 .setTitle("a test study")
59                                 //.setDescription("description")
60                                 .setDate(new Date())
61                                 .setReference("test reference")
62                                 .setSimulationContexts(new ArrayList<SimulationContext>())
63                                 .setState(ProgressState.inWORK);
64                 Study study = new Study(studyProps);
65                 return study;
66         }
67 }