@OpenApiAll
public class ScenarioManager
extends java.lang.Object
Scenario can be manipulated from Open API.
Scenario class represents a use case scenario. It contains methods for manipulating it.ScenarioManager class contains utility methods for creating and manipulating scenarios.
// Scenario manipulation should be wrapped with the session management calls.
SessionManager sessionManager = SessionManager.getInstance();
sessionManager.createSession("Create scenario");
// Creates a use case scenario.
Scenario scenario = ScenarioManager.createScenario(useCase);
// Sets the scenario name.
scenario.setName("Extract money from ATM.");
// Adds a basic flow step.
FlowStep flowStep1 = scenario.addFlowStep();
// Sets a name for the basic flow step.
flowStep1.setName("Insert card");
FlowStep flowStep2 = scenario.addFlowStep();
flowStep2.setName("Enter pin");
FlowStep flowStep3 = scenario.addFlowStep();
flowStep3.setName("Good bye");
// Adds an alternative condition for the basic flow step.
AlternativeCondition condition = scenario.addAlternativeCondition(flowStep2);
// Sets a condition guard.
condition.setIfCondition("Pin correct");
// Sets a name for the alternative flow step.
FlowStep flowStep = condition.getAlternativeFlowSteps().get(0);
flowStep.setName("Extract money");
// Adds an exception type to the basic flow step.
ExceptionType exceptionType = scenario.addExceptionType(flowStep2);
// Sets a name for the exception type.
exceptionType.setName("Card expired");
// Sets a name for the exceptional flow step.
FlowStep exceptionalFlowStep = exceptionType.getExceptionalFlowSteps().get(0);
exceptionalFlowStep.setName("Inform customer about expired card");
sessionManager.closeSession();
// Opens and layouts the scenario diagram.
ScenarioManager.displayScenario(scenario, true, true, "Open ATM Scenario");
For more information about the use case scenario, see the "Use Case Scenario" section in the "MagicDraw UserManual.pdf".
| Constructor and Description |
|---|
ScenarioManager() |
| Modifier and Type | Method and Description |
|---|---|
static Scenario |
createScenario(UseCase useCase)
Creates and initializes scenario for a given use case.
|
static void |
displayScenario(Scenario scenario,
boolean openDiagram,
boolean layout,
java.lang.String sessionName)
Displays scenario on the diagram.
|
static void |
setScenarioFactory(ScenarioFactory scenarioFactory)
Sets scenario factory with which to create scenarios.
|
public static Scenario createScenario(UseCase useCase)
useCase - use case for which to create scenario.public static void setScenarioFactory(ScenarioFactory scenarioFactory)
scenarioFactory - scenario factory with which to create scenarios.public static void displayScenario(Scenario scenario, boolean openDiagram, boolean layout, java.lang.String sessionName)
scenario - scenario to display.openDiagram - indicates whether scenario diagram should be opened.layout - indicates whether scenario diagram should be layouted.sessionName - name of the session to use in undo/redo history.