Monday, 23 January 2023

PlantUML: alt, else: specify if-else clause in sequence diagram

‘alt/else’ keyword can be used to address multiple cases in a sequence diagram. This is one of the grouping construct, a grouping construct is closed by end keyword.

 

altElse.txt

@startuml

title "Login successful flow"
header "User login"
footer %page% of %lastpage%

Client -> LoginServer: Enter user name
Client -> LoginServer: Enter password
Client -> LoginServer: Submit the form 
LoginServer -> ADServer: Check the credentials

alt#green #lightblue login successful
	ADServer -> LoginServer: Login Successful
	LoginServer -> Client: Login Successful

else #gold username is not exists
	ADServer -> LoginServer: Username not found
	LoginServer -> Client: User is not registered with the website

else #red invalid credentials
	ADServer -> LoginServer: Credentials mismatch
	LoginServer -> Client: Invalid username or password

end

@enduml

 

Above snippet generates below diagram.


 

 

Previous                                                    Next                                                    Home

No comments:

Post a Comment