-
Notifications
You must be signed in to change notification settings - Fork 181
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modified PR after the request changes and added tests
Signed-off-by: Denisa Dan <[email protected]>
- Loading branch information
Denisa Dan
committed
Mar 23, 2017
1 parent
67e7ccb
commit 05cebbb
Showing
6 changed files
with
290 additions
and
164 deletions.
There are no files selected for viewing
42 changes: 18 additions & 24 deletions
42
...cloudslang/base/examples/yoda/contains.sl → .../base/examples/yoda/samples_false.prop.sl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,18 @@ | ||
# (c) Copyright 2017 Hewlett-Packard Enterprise Development Company, L.P. | ||
# All rights reserved. This program and the accompanying materials | ||
# are made available under the terms of the Apache License v2.0 which accompany this distribution. | ||
# | ||
# The Apache License is available at | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
######################################################################################################################## | ||
#!! | ||
#! @description: Decision that checks the state of a System Property file. | ||
#! | ||
#! @result CONTAINS: System Property is set at default value. | ||
#! @result DOES_NOT_CONTAIN: System Property is not set at default value. | ||
#!!# | ||
######################################################################################################################## | ||
|
||
namespace: io.cloudslang.base.examples.yoda | ||
|
||
decision: | ||
name: contains | ||
|
||
results: | ||
- CONTAINS: ${get_sp('io.cloudslang.base.examples.properties.default_quote', 'false') == 'true'} | ||
- DOES_NOT_CONTAIN | ||
# (c) Copyright 2017 Hewlett-Packard Enterprise Development Company, L.P. | ||
# All rights reserved. This program and the accompanying materials | ||
# are made available under the terms of the Apache License v2.0 which accompany this distribution. | ||
# | ||
# The Apache License is available at | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
######################################################################################################################## | ||
# System property file for base.examples.yoda operations. | ||
# | ||
# io.cloudslang.base.examples.properties.default_quote: value of default quote | ||
# | ||
######################################################################################################################## | ||
|
||
namespace: io.cloudslang.base.examples.yoda | ||
|
||
properties: | ||
- default_quote: 'false' |
36 changes: 18 additions & 18 deletions
36
...dslang/base/examples/yoda/samples.prop.sl → ...g/base/examples/yoda/samples_true.prop.sl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
# (c) Copyright 2017 Hewlett-Packard Enterprise Development Company, L.P. | ||
# All rights reserved. This program and the accompanying materials | ||
# are made available under the terms of the Apache License v2.0 which accompany this distribution. | ||
# | ||
# The Apache License is available at | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
######################################################################################################################## | ||
# System property file for base.examples.yoda operations. | ||
# | ||
# io.cloudslang.base.examples.properties.default_quote: value of default quote | ||
# | ||
######################################################################################################################## | ||
|
||
namespace: io.cloudslang.base.examples.properties | ||
|
||
properties: | ||
- default_quote: 'true' | ||
# (c) Copyright 2017 Hewlett-Packard Enterprise Development Company, L.P. | ||
# All rights reserved. This program and the accompanying materials | ||
# are made available under the terms of the Apache License v2.0 which accompany this distribution. | ||
# | ||
# The Apache License is available at | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
######################################################################################################################## | ||
# System property file for base.examples.yoda operations. | ||
# | ||
# io.cloudslang.base.examples.properties.default_quote: value of default quote | ||
# | ||
######################################################################################################################## | ||
|
||
namespace: io.cloudslang.base.examples.yoda | ||
|
||
properties: | ||
- default_quote: 'true' |
133 changes: 72 additions & 61 deletions
133
content/io/cloudslang/base/examples/yoda/generate_random_quote.sl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,72 @@ | ||
# (c) Copyright 2017 Hewlett-Packard Enterprise Development Company, L.P. | ||
# All rights reserved. This program and the accompanying materials | ||
# are made available under the terms of the Apache License v2.0 which accompany this distribution. | ||
# | ||
# The Apache License is available at | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
######################################################################################################################## | ||
#!! | ||
#! @description: The flow displays a Yoda quote based on a random number generator. | ||
#! | ||
#! @input file_path: The path for the file that contains the quotes. | ||
#! | ||
#! @result SUCCESS: The quote was displayed successfully. | ||
#! @result FAILURE: Failure occurred during execution. | ||
#!!# | ||
######################################################################################################################## | ||
|
||
namespace: io.cloudslang.base.examples.yoda | ||
|
||
imports: | ||
math: io.cloudslang.base.math | ||
base: io.cloudslang.base.print | ||
fs: io.cloudslang.base.filesystem | ||
|
||
flow: | ||
name: generate_random_quote | ||
|
||
inputs: | ||
- file_path | ||
|
||
workflow: | ||
- read_quotes: | ||
do: | ||
fs.read_from_file: | ||
- file_path: ${file_path} | ||
publish: | ||
- read_text | ||
navigate: | ||
- SUCCESS: generate_random_number | ||
- FAILURE: FAILURE | ||
|
||
- generate_random_number: | ||
do: | ||
math.random_number_generator: | ||
- min: '0' | ||
- max: ${str(len(read_text.strip().split(';')) - 2)} | ||
publish: | ||
- random_number | ||
navigate: | ||
- SUCCESS: print_quote | ||
- FAILURE: FAILURE | ||
|
||
- print_quote: | ||
do: | ||
base.print_text: | ||
- text: ${str(read_text.split(';')[int(random_number)])} | ||
navigate: | ||
- SUCCESS: SUCCESS | ||
results: | ||
- SUCCESS | ||
- FAILURE | ||
# (c) Copyright 2017 Hewlett-Packard Enterprise Development Company, L.P. | ||
# All rights reserved. This program and the accompanying materials | ||
# are made available under the terms of the Apache License v2.0 which accompany this distribution. | ||
# | ||
# The Apache License is available at | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
######################################################################################################################## | ||
#!! | ||
#! @description: The flow displays a Yoda quote based on a random number generator. | ||
#! | ||
#! @input file_path: The path for the file that contains the quotes. | ||
#! | ||
#! @output quotes: A list with all the quotes from the file. | ||
#! @output random_quote: The quote randomly selected. | ||
#! | ||
#! @result SUCCESS: The quote was displayed successfully. | ||
#! @result FAILURE: Failure occurred during execution. | ||
#!!# | ||
######################################################################################################################## | ||
|
||
namespace: io.cloudslang.base.examples.yoda | ||
|
||
imports: | ||
math: io.cloudslang.base.math | ||
base: io.cloudslang.base.print | ||
fs: io.cloudslang.base.filesystem | ||
|
||
flow: | ||
name: generate_random_quote | ||
|
||
inputs: | ||
- file_path | ||
|
||
workflow: | ||
- read_quotes: | ||
do: | ||
fs.read_from_file: | ||
- file_path: ${file_path} | ||
publish: | ||
- read_text | ||
- quotes : ${str(read_text)} | ||
navigate: | ||
- SUCCESS: generate_random_number | ||
- FAILURE: FAILURE | ||
|
||
- generate_random_number: | ||
do: | ||
math.random_number_generator: | ||
- min: '0' | ||
- max: ${str(len(quotes.strip().split(';')) - 2)} | ||
- quotes | ||
publish: | ||
- random_number | ||
- random_quote: ${str(quotes.split(';')[int(random_number)])} | ||
navigate: | ||
- SUCCESS: print_quote | ||
- FAILURE: FAILURE | ||
|
||
- print_quote: | ||
do: | ||
base.print_text: | ||
- text: ${str(random_quote)} | ||
navigate: | ||
- SUCCESS: SUCCESS | ||
|
||
outputs: | ||
- quotes | ||
- random_quote | ||
|
||
results: | ||
- SUCCESS | ||
- FAILURE |
124 changes: 63 additions & 61 deletions
124
content/io/cloudslang/base/examples/yoda/quote_check.sl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,64 @@ | ||
# (c) Copyright 2017 Hewlett-Packard Enterprise Development Company, L.P. | ||
# All rights reserved. This program and the accompanying materials | ||
# are made available under the terms of the Apache License v2.0 which accompany this distribution. | ||
# | ||
# The Apache License is available at | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
######################################################################################################################## | ||
#!! | ||
#! @description: The flow is based on a System Property file | ||
#! If it is set on true it displays the default quote, otherwise generates a random quote. | ||
#! | ||
#! @input default_quote : quote with a default value. | ||
#! @input file_path: The path for the file that contains the quotes. | ||
#! | ||
#! @result SUCCESS: Flow completed successfully. | ||
#! @result FAILURE: Failure occurred during execution. | ||
#!!# | ||
######################################################################################################################## | ||
|
||
namespace: io.cloudslang.base.examples.yoda | ||
|
||
imports: | ||
base: io.cloudslang.base.print | ||
fs: io.cloudslang.base.filesystem | ||
math: io.cloudslang.base.math | ||
quote_generator: io.cloudslang.base.examples.yoda | ||
|
||
flow: | ||
name: quote_check | ||
|
||
inputs: | ||
- default_quote: | ||
default: "Do or do not, there is no try!" | ||
private: true | ||
- file_path | ||
|
||
workflow: | ||
- print_quote: | ||
do: | ||
quote_generator.contains: [] | ||
navigate: | ||
- CONTAINS: print_default_quote | ||
- DOES_NOT_CONTAIN: print_random_quote | ||
|
||
- print_random_quote: | ||
do: | ||
quote_generator.generate_random_quote: | ||
- file_path | ||
navigate: | ||
- SUCCESS: SUCCESS | ||
- FAILURE: FAILURE | ||
|
||
- print_default_quote: | ||
do: | ||
base.print_text: | ||
- text: ${default_quote} | ||
navigate: | ||
- SUCCESS: SUCCESS | ||
results: | ||
- SUCCESS | ||
# (c) Copyright 2017 Hewlett-Packard Enterprise Development Company, L.P. | ||
# All rights reserved. This program and the accompanying materials | ||
# are made available under the terms of the Apache License v2.0 which accompany this distribution. | ||
# | ||
# The Apache License is available at | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
######################################################################################################################## | ||
#!! | ||
#! @description: The flow is based on a System Property file. | ||
#! If it is set on true it displays the default quote, otherwise generates a random quote. | ||
#! | ||
#! @input default_quote : quote with a default value. | ||
#! @input file_path: The path for the file that contains the quotes. | ||
#! | ||
#! @result SUCCESS: Flow completed successfully. | ||
#! @result FAILURE: Failure occurred during execution. | ||
#!!# | ||
######################################################################################################################## | ||
|
||
namespace: io.cloudslang.base.examples.yoda | ||
|
||
imports: | ||
base: io.cloudslang.base.print | ||
fs: io.cloudslang.base.filesystem | ||
math: io.cloudslang.base.math | ||
quote_generator: io.cloudslang.base.examples.yoda | ||
utils: io.cloudslang.base.utils | ||
|
||
flow: | ||
name: quote_check | ||
|
||
inputs: | ||
- default_quote: | ||
default: "Do or do not, there is no try!" | ||
private: true | ||
- file_path | ||
|
||
workflow: | ||
- print_quote: | ||
do: | ||
utils.is_true: | ||
- bool_value: ${str(get_sp('io.cloudslang.base.examples.yoda.default_quote', 'false'))} | ||
navigate: | ||
- 'TRUE': print_default_quote | ||
- 'FALSE': print_random_quote | ||
|
||
- print_random_quote: | ||
do: | ||
quote_generator.generate_random_quote: | ||
- file_path | ||
navigate: | ||
- SUCCESS: SUCCESS | ||
- FAILURE: FAILURE | ||
|
||
- print_default_quote: | ||
do: | ||
base.print_text: | ||
- text: ${default_quote} | ||
navigate: | ||
- SUCCESS: SUCCESS | ||
results: | ||
- SUCCESS | ||
- FAILURE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# (c) Copyright 2014-2017 Hewlett-Packard Enterprise Development Company, L.P. | ||
# All rights reserved. This program and the accompanying materials | ||
# are made available under the terms of the Apache License v2.0 which accompany this distribution. | ||
# | ||
# The Apache License is available at | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
######################################################################################################################## | ||
test_quote_check_sp_true: | ||
description: Tests that quote_check finishes with SUCCESS for the default case | ||
testSuites: [yoda] | ||
testFlowPath: test.io.cloudslang.base.examples.test_quote_check | ||
systemPropertiesFile: ${project_path}/configuration/properties/io/cloudslang/base/examples/yoda/samples_true.prop.sl | ||
inputs: | ||
- file_path: ${project_path}/resources/base/examples/yoda/yoda_quotes.txt | ||
result: SUCCESS_PRINTING_DEFAULT | ||
|
||
test_quote_check_sp_false: | ||
description: Tests that quote_check returns a random quote when the properties file is set on false | ||
testSuites: [yoda] | ||
testFlowPath: test.io.cloudslang.base.examples.test_quote_check | ||
systemPropertiesFile: ${project_path}/configuration/properties/io/cloudslang/base/examples/yoda/samples_false.prop.sl | ||
inputs: | ||
- file_path: ${project_path}/resources/base/examples/yoda/yoda_quotes.txt | ||
result: QUOTE_EXISTS | ||
|
||
test_quote_check_sp_not_specified: | ||
description: Tests that quote_check returns a random quote when the properties file is not specified | ||
testSuites: [yoda] | ||
testFlowPath: test.io.cloudslang.base.examples.test_quote_check | ||
inputs: | ||
- file_path: ${project_path}/resources/base/examples/yoda/yoda_quotes.txt | ||
result: QUOTE_EXISTS |
Oops, something went wrong.