1 /*****************************************************************************
5 * Creation date Feb 12, 2013
8 *****************************************************************************/
10 package test.splat.util;
12 import java.util.ArrayList;
13 import java.util.Date;
15 import org.splat.dal.bo.kernel.User;
16 import org.splat.dal.bo.som.KnowledgeElement;
17 import org.splat.dal.bo.som.KnowledgeElementType;
18 import org.splat.dal.bo.som.Scenario;
19 import org.splat.dal.bo.som.SimulationContext;
20 import org.splat.dal.bo.som.Study;
21 import org.splat.exception.BusinessException;
24 * Utility class for creating test entities.
26 public class TestEntitiesGenerator {
29 * Create a transient user.
33 * @return a transient StepCommentDTO
34 * @throws BusinessException
35 * if something's wrong
37 public static User getTestUser(final String userName)
38 throws BusinessException {
40 User.Properties uprop = new User.Properties();
41 uprop.setUsername(userName).setName("TST_Username").setFirstName(
42 "TST_FirstName").setDisplayName("TST_test.user")
43 .setMailAddress("noreply@salome-platform.org").addRole(
46 User user = new User(uprop);
51 * Create a transient study.
54 * the user that will be placed in 'manager' and 'actor' properties
55 * @return the test study
56 * @throws BusinessException
57 * if something's wrong
59 public static Study getTestStudy(final User user) throws BusinessException {
60 Study.Properties studyProps = new Study.Properties();
61 studyProps.setActor(user).setManager(user)
62 .setTitle("a test study")
63 // .setDescription("description")
64 .setDate(new Date()).setReference("test reference")
65 .setSimulationContexts(new ArrayList<SimulationContext>());
66 Study study = new Study(studyProps);
71 * Create a transient test scenario.
75 * @return the created scenario
76 * @throws BusinessException
77 * if creation is failed
79 public static Scenario getTestScenario(final Study study)
80 throws BusinessException {
81 Scenario.Properties sprops = new Scenario.Properties().setTitle(
82 "TST_Scenario").setManager(study.getAuthor()).setOwnerStudy(
84 Scenario aScenario = new Scenario(sprops);
85 study.getScenariiList().add(aScenario);
90 * Create a transient knowledge element.
98 * @return the created knowledge element
99 * @throws BusinessException
100 * if creation is failed
102 public static KnowledgeElement getTestKnowledgeElement(final Scenario scen,
103 final KnowledgeElementType ktype, final String title)
104 throws BusinessException {
106 KnowledgeElement.Properties kprops = new KnowledgeElement.Properties();
107 Date aDate = new Date();
111 .setAuthor(scen.getAuthor())
112 .setOwnerScenario(scen)
116 "This is the test knowledge element.\nIt is created by the unit test.");
118 return new KnowledgeElement(kprops);