Salome HOME
Show and Edit description functionalities are implemented
[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.dal.bo.som.Visibility;
20 import org.splat.exception.BusinessException;
21
22 /**
23  * Utility class for creating test entities.
24  */
25 public class TestEntitiesGenerator {
26         
27         /**
28          * Create a transient user.
29          *
30          * @param userName the userName
31          * @return a transient StepCommentDTO
32          * @throws BusinessException if something's wrong
33          */
34         public static User getTestUser(final String userName) throws BusinessException {
35
36                 User.Properties uprop = new User.Properties();
37                 uprop.setUsername(userName)
38                                 .setName("TST_Username")
39                                 .setFirstName("TST_FirstName")
40                                 .setDisplayName("TST_test.user")
41                                 .setMailAddress("noreply@salome-platform.org")
42                                 .addRole("TST-User");
43                 uprop.disableCheck();
44                 User user = new User(uprop);
45                 return user;
46         }
47
48         /**
49          * Create a transient study.
50          *
51          * @param user the user that will be placed in 'manager' and 'actor' properties
52          * @return the test study
53          * @throws BusinessException if something's wrong
54          */
55         public static Study getTestStudy(final User user) throws BusinessException{
56                 Study.Properties studyProps = new Study.Properties();
57                 studyProps.setActor(user)
58                                 .setManager(user)
59                                 .setTitle("a test study")
60                                 //.setDescription("description")
61                                 .setDate(new Date())
62                                 .setReference("test reference")
63                                 .setSimulationContexts(new ArrayList<SimulationContext>())
64                                 .setState(ProgressState.inWORK)
65                                 .setVisibility(Visibility.PUBLIC);
66                 Study study = new Study(studyProps);
67                 return study;
68         }
69 }