Our modeling tools provide an API for creating and manipulating a Use Case Scenario for a use case:

See an example of how to create the use case scenario with the basic, alternative, and exceptional flows. After the use case scenario is created, the Activity diagram is opened. In the Activity diagram, the use case scenario is represented as an action flow.

	SessionManager.getInstance().createSession(...);
	// 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.getInstance().closeSession();

    // Opens and layouts the Activity diagram. 
    ScenarioManager.displayScenario(scenario, true, true, "Open ATM Scenario");

More information is available in javadoc.

 You can find the code examples in

  • <installation_directory>\openapi\examples\scenario