-
Notifications
You must be signed in to change notification settings - Fork 30
[vrotsc,vrotsc-annotations] (#869) Add Workflow Canvas Item for Switch Component #910
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 6 commits
2c4ba42
5694343
6cc122f
c387fa1
cf2c0cd
5e9fac1
a7a028b
89929f0
3c075c4
babb10c
d05e9ae
baa8d9a
7eb9455
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| import { Workflow, SwitchItem } from "vrotsc-annotations"; | ||
|
|
||
| @Workflow({ | ||
| name: "Switch Boolean Cases", | ||
| path: "VMware/PSCoE", | ||
| description: "Switch test with boolean conditions and mixed types", | ||
| attributes: { | ||
| isEnabled: { | ||
| type: "boolean" | ||
| }, | ||
| priority: { | ||
| type: "number" | ||
| }, | ||
| } | ||
| }) | ||
| export class SwitchBooleanCases { | ||
|
|
||
| @SwitchItem({ | ||
| cases: [ | ||
| { condition: true, target: "enableFeature", variable: "isEnabled", type: "boolean", comparator: "===" }, | ||
| { condition: false, target: "disableFeature", variable: "isEnabled", type: "boolean", comparator: "===" } | ||
| ], | ||
| defaultTarget: "handleUndefined" | ||
| }) | ||
| public switchByBoolean(isEnabled: boolean, priority: number) { | ||
| // Boolean switch logic | ||
| } | ||
|
|
||
| public enableFeature() { | ||
| System.log("Feature is enabled"); | ||
| } | ||
|
|
||
| public disableFeature() { | ||
| System.log("Feature is disabled"); | ||
| } | ||
|
|
||
| public handleUndefined() { | ||
| System.log("Boolean value is undefined"); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| import { Workflow, SwitchItem } from "vrotsc-annotations"; | ||
|
|
||
| @Workflow({ | ||
| name: "Switch Edge Cases", | ||
| path: "VMware/PSCoE", | ||
| description: "Switch test covering edge cases - various operators, no default target, and complex conditions", | ||
| attributes: { | ||
| errorCode: { | ||
| type: "number" | ||
| }, | ||
| priority: { | ||
| type: "number" | ||
| }, | ||
| status: { | ||
| type: "string" | ||
| }, | ||
| } | ||
| }) | ||
| export class SwitchEdgeCases { | ||
|
|
||
| @SwitchItem({ | ||
| cases: [ | ||
| { condition: 404, target: "handleNotFound", variable: "errorCode", type: "number", comparator: "===" }, | ||
| { condition: 500, target: "handleServerError", variable: "errorCode", type: "number", comparator: "!==" }, | ||
| { condition: 403, target: "handleForbidden", variable: "errorCode", type: "number", comparator: "==" } | ||
| ], | ||
| // No default target - will fall through to next item | ||
| }) | ||
| public switchErrorCodes(errorCode: number) { | ||
| // Error code switch without default using various equality operators | ||
| System.log("Processing error code: " + errorCode); | ||
| } | ||
|
|
||
| @SwitchItem({ | ||
| cases: [ | ||
| { condition: 1, target: "lowPriority", variable: "priority", type: "number", comparator: "<=" }, | ||
| { condition: 5, target: "mediumPriority", variable: "priority", type: "number", comparator: ">" }, | ||
| { condition: 10, target: "highPriority", variable: "priority", type: "number", comparator: ">=" } | ||
| ], | ||
| defaultTarget: "handleInvalidPriority" | ||
| }) | ||
| public switchPriority(priority: number) { | ||
| // Priority switch using comparison operators | ||
| System.log("Processing priority: " + priority); | ||
| } | ||
|
|
||
| @SwitchItem({ | ||
| cases: [ | ||
| { condition: "active", target: "processActive", variable: "status", type: "string", comparator: "===" }, | ||
| { condition: "pending", target: "processPending", variable: "status", type: "string", comparator: "!=" }, | ||
| { condition: "inactive", target: "processInactive", variable: "status", type: "string", comparator: "!==" } | ||
| ], | ||
| defaultTarget: "handleUnknownStatus" | ||
| }) | ||
| public switchStatus(status: string) { | ||
| // String status switch with mixed operators | ||
| System.log("Processing status: " + status); | ||
| } | ||
|
|
||
| public handleNotFound() { | ||
| System.log("404 - Resource not found"); | ||
| } | ||
|
|
||
| public handleServerError() { | ||
| System.log("500 - Internal server error"); | ||
| } | ||
|
|
||
| public handleForbidden() { | ||
| System.log("403 - Access forbidden"); | ||
| } | ||
|
|
||
| public lowPriority() { | ||
| System.log("Low priority task (<=1)"); | ||
| } | ||
|
|
||
| public mediumPriority() { | ||
| System.log("Medium priority task (>5)"); | ||
| } | ||
|
|
||
| public highPriority() { | ||
| System.log("High priority task (>=10)"); | ||
| } | ||
|
|
||
| public handleInvalidPriority() { | ||
| System.log("Invalid priority level"); | ||
| } | ||
|
|
||
| public processActive() { | ||
| System.log("Processing active status"); | ||
| } | ||
|
|
||
| public processPending() { | ||
| System.log("Processing pending status (not equal to 'pending')"); | ||
| } | ||
|
|
||
| public processInactive() { | ||
| System.log("Processing inactive status (not strictly equal to 'inactive')"); | ||
| } | ||
|
|
||
| public handleUnknownStatus() { | ||
| System.log("Unknown status - using default handler"); | ||
| } | ||
|
|
||
| public fallbackHandler() { | ||
| System.log("Unhandled error code - using fallback"); | ||
| } | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.