* @version $Revision$
*****************************************************************************/
-package test.splat.util;
+package test.splat.util;
import java.util.ArrayList;
import java.util.Date;
import org.splat.dal.bo.kernel.User;
+import org.splat.dal.bo.som.KnowledgeElement;
+import org.splat.dal.bo.som.KnowledgeElementType;
import org.splat.dal.bo.som.ProgressState;
+import org.splat.dal.bo.som.Scenario;
import org.splat.dal.bo.som.SimulationContext;
import org.splat.dal.bo.som.Study;
import org.splat.exception.BusinessException;
* Utility class for creating test entities.
*/
public class TestEntitiesGenerator {
-
+
/**
* Create a transient user.
- *
- * @param userName the userName
+ *
+ * @param userName
+ * the userName
* @return a transient StepCommentDTO
- * @throws BusinessException if something's wrong
+ * @throws BusinessException
+ * if something's wrong
*/
- public static User getTestUser(final String userName) throws BusinessException {
+ public static User getTestUser(final String userName)
+ throws BusinessException {
User.Properties uprop = new User.Properties();
- uprop.setUsername(userName)
- .setName("TST_Username")
- .setFirstName("TST_FirstName")
- .setDisplayName("TST_test.user")
- .setMailAddress("noreply@salome-platform.org")
- .addRole("TST-User");
+ uprop.setUsername(userName).setName("TST_Username").setFirstName(
+ "TST_FirstName").setDisplayName("TST_test.user")
+ .setMailAddress("noreply@salome-platform.org").addRole(
+ "TST-User");
uprop.disableCheck();
User user = new User(uprop);
return user;
/**
* Create a transient study.
- *
- * @param user the user that will be placed in 'manager' and 'actor' properties
+ *
+ * @param user
+ * the user that will be placed in 'manager' and 'actor' properties
* @return the test study
- * @throws BusinessException if something's wrong
+ * @throws BusinessException
+ * if something's wrong
*/
- public static Study getTestStudy(final User user) throws BusinessException{
+ public static Study getTestStudy(final User user) throws BusinessException {
Study.Properties studyProps = new Study.Properties();
- studyProps.setActor(user)
- .setManager(user)
+ studyProps.setActor(user).setManager(user)
.setTitle("a test study")
- //.setDescription("description")
- .setDate(new Date())
- .setReference("test reference")
+ // .setDescription("description")
+ .setDate(new Date()).setReference("test reference")
.setSimulationContexts(new ArrayList<SimulationContext>())
.setState(ProgressState.inWORK);
Study study = new Study(studyProps);
return study;
}
+
+ /**
+ * Create a transient test scenario.
+ *
+ * @param study
+ * the owner study
+ * @return the created scenario
+ * @throws BusinessException
+ * if creation is failed
+ */
+ public static Scenario getTestScenario(final Study study)
+ throws BusinessException {
+ Scenario.Properties sprops = new Scenario.Properties().setTitle(
+ "TST_Scenario").setManager(study.getAuthor()).setOwnerStudy(
+ study);
+ Scenario aScenario = new Scenario(sprops);
+ study.getScenariiList().add(aScenario);
+ return aScenario;
+ }
+
+ /**
+ * Create a transient knowledge element.
+ *
+ * @param scen
+ * the owner scenario
+ * @param ktype
+ * the knowledge type
+ * @param title
+ * the knowledge title
+ * @return the created knowledge element
+ * @throws BusinessException
+ * if creation is failed
+ */
+ public static KnowledgeElement getTestKnowledgeElement(final Scenario scen,
+ final KnowledgeElementType ktype, final String title)
+ throws BusinessException {
+
+ KnowledgeElement.Properties kprops = new KnowledgeElement.Properties();
+ Date aDate = new Date();
+
+ kprops
+ .setTitle(title)
+ .setAuthor(scen.getAuthor())
+ .setOwnerScenario(scen)
+ .setType(ktype)
+ .setDate(aDate)
+ .setValue(
+ "This is the test knowledge element.\nIt is created by the unit test.");
+
+ return new KnowledgeElement(kprops);
+ }
}