Skip to content
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

Constants for feature paths #1701

Merged
merged 3 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tests/karate/src/test/java/be/features/LAO/create.feature
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ Feature: Create a pop LAO
# Call read(...) makes this feature and the called feature share the same scope
# Meaning they share def variables, configurations ...
# Especially JS functions defined in the called features can be directly used here thanks to Karate shared scopes
* call read('classpath:be/features/utils/server.feature')
* call read('classpath:be/features/utils/mockClient.feature')
* call read('classpath:be/features/utils/constants.feature')
* call read(serverFeature)
* call read(mockClientFeature)
* def organizer = call createMockClient
* def validLao = organizer.createValidLao()

Expand Down
6 changes: 3 additions & 3 deletions tests/karate/src/test/java/be/features/LAO/update.feature
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ Feature: Update a LAO
# Call read(...) makes this feature and the called feature share the same scope
# Meaning they share def variables, configurations ...
# Especially JS functions defined in the called features can be directly used here thanks to Karate shared scopes
* call read('classpath:be/features/utils/server.feature')
* call read('classpath:be/features/utils/mockClient.feature')
* call read('classpath:be/features/utils/constants.feature')
* call read(serverFeature)
* call read(mockClientFeature)
* def organizer = call createMockClient
* def lao = organizer.createValidLao()

# This call executes all the steps to create a valid lao on the server before every scenario
# (lao creation, subscribe, catchup)
* call read('classpath:be/features/utils/simpleScenarios.feature@name=valid_lao') { organizer: '#(organizer)', lao: '#(lao)' }
* call read(createLaoScenario) { organizer: '#(organizer)', lao: '#(lao)' }

Scenario: Update Lao should succeed with a valid update request with new lao name
Given def updateLaoRequest =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ Feature: Request messages by id from other servers
# Call read(...) makes this feature and the called feature share the same scope
# Meaning they share def variables, configurations ...
# Especially JS functions defined in the called features can be directly used here thanks to Karate shared scopes
* call read('classpath:be/features/utils/server.feature')
* call read('classpath:be/features/utils/mockClient.feature')
* call read('classpath:be/features/utils/constants.feature')
* call read(serverFeature)
* call read(mockClientFeature)
* def mockServer = call createMockClient
* def lao = mockServer.createValidLao()

Expand All @@ -24,7 +24,7 @@ Feature: Request messages by id from other servers

# This call executes all the steps to create a valid lao on the server before every scenario
# (lao creation, subscribe, catchup)
* call read('classpath:be/features/utils/simpleScenarios.feature@name=valid_lao') { organizer: '#(mockServer)', lao: '#(lao)' }
* call read(createLaoScenario) { organizer: '#(mockServer)', lao: '#(lao)' }

# Check that after sending a heartbeat message with unknown message id, the server responds with a
# getMessagesByID requesting this message
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ Feature: Send heartbeats to other servers
# Call read(...) makes this feature and the called feature share the same scope
# Meaning they share def variables, configurations ...
# Especially JS functions defined in the called features can be directly used here thanks to Karate shared scopes
* call read('classpath:be/features/utils/server.feature')
* call read('classpath:be/features/utils/mockClient.feature')
* call read('classpath:be/features/utils/constants.feature')
* call read(serverFeature)
* call read(mockClientFeature)
* def mockServer = call createMockClient
* def lao = mockServer.createValidLao()
* def validRollCall = mockServer.createValidRollCall(lao)

# This call executes all the steps to create a valid lao on the server before every scenario
# (lao creation, subscribe, catchup)
* call read('classpath:be/features/utils/simpleScenarios.feature@name=valid_lao') { organizer: '#(mockServer)', lao: '#(lao)' }
* call read(createLaoScenario) { organizer: '#(mockServer)', lao: '#(lao)' }

# After lao creation, wait and do nothing (30 seconds for now) and check that a heartbeat message was received
Scenario: Server should send heartbeat messages automatically after a time interval
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ Feature: Simple Transactions for digital cash
# Call read(...) makes this feature and the called feature share the same scope
# Meaning they share def variables, configurations ...
# Especially JS functions defined in the called features can be directly used here thanks to Karate shared scopes
* call read('classpath:be/features/utils/server.feature')
* call read('classpath:be/features/utils/mockClient.feature')
* call read('classpath:be/features/utils/constants.feature')
* call read(serverFeature)
* call read(mockClientFeature)
* def organizer = call createMockClient
* def recipient = call createMockClient
* def lao = organizer.createValidLao()
* def rollCall = organizer.createValidRollCall(lao)

# This call executes all the steps to set up a lao, complete a roll call and subscribe to the coin channel
* call read('classpath:be/features/utils/simpleScenarios.feature@name=setup_coin_channel') { organizer: '#(organizer)', lao: '#(lao)', rollCall: '#(rollCall)' }
* call read(setupCoinChannelScenario) { organizer: '#(organizer)', lao: '#(lao)', rollCall: '#(rollCall)' }

Scenario: Valid transaction: issue 32 mini-Laos to an attendee
Given def transaction = organizer.issueCoins(recipient, 32);
Expand Down Expand Up @@ -60,7 +60,7 @@ Feature: Simple Transactions for digital cash
Scenario: Transfer valid amount should work
# This call issues initialAmount coins to the recipient
Given def initialAmount = 32
And call read('classpath:be/utils/simpleScenarios.feature@name=valid_coin_issuance') { organizer: '#(organizer)', lao: '#(lao)', rollCall: '#(rollCall)', recipient: '#(recipient)', amount: '#(initialAmount)' }
And call read(validCoinIssuanceScenario) { organizer: '#(organizer)', lao: '#(lao)', rollCall: '#(rollCall)', recipient: '#(recipient)', amount: '#(initialAmount)' }
And def transaction = organizer.issueCoins(recipient, 20);
And def postTransaction = transaction.post()
And def input = transaction.inputs[1]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ Feature: Cast a vote
# Call read(...) makes this feature and the called feature share the same scope
# Meaning they share def variables, configurations ...
# Especially JS functions defined in the called features can be directly used here thanks to Karate shared scopes
* call read('classpath:be/features/utils/server.feature')
* call read('classpath:be/features/utils/mockClient.feature')
* call read('classpath:be/features/utils/constants.feature')
* call read(serverFeature)
* call read(mockClientFeature)
* def organizer = call createMockClient
* def lao = organizer.createValidLao()
* def rollCall = organizer.createValidRollCall(lao)
* def election = organizer.createValidElection(lao)
* def question = election.createQuestion()

# This call executes all the steps to set up a lao, complete a roll call and open an election with one question
* call read('classpath:be/features/utils/simpleScenarios.feature@name=election_open') { organizer: '#(organizer)', lao: '#(lao)', rollCall: '#(rollCall)', election: '#(election)', question: '#(question)' }
* call read(openElectionScenario) { organizer: '#(organizer)', lao: '#(lao)', rollCall: '#(rollCall)', election: '#(election)', question: '#(question)' }
* def vote = question.createVote(0)
* def castVote = election.castVote(vote)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ Feature: Terminate an election
# Call read(...) makes this feature and the called feature share the same scope
# Meaning they share def variables, configurations ...
# Especially JS functions defined in the called features can be directly used here thanks to Karate shared scopes
* call read('classpath:be/features/utils/server.feature')
* call read('classpath:be/features/utils/mockClient.feature')
* call read('classpath:be/features/utils/constants.feature')
* call read(serverFeature)
* call read(mockClientFeature)
* def organizer = call createMockClient
* def lao = organizer.createValidLao()
* def rollCall = organizer.createValidRollCall(lao)
* def election = organizer.createValidElection(lao)
* def question = election.createQuestion()

# This call executes all the steps to set up a lao, complete a roll call, open an election and cast a vote
* call read('classpath:be/features/utils/simpleScenarios.feature@name=cast_vote') { organizer: '#(organizer)', lao: '#(lao)', rollCall: '#(rollCall)', election: '#(election)', question: '#(question)' }
* call read(castVoteScenario) { organizer: '#(organizer)', lao: '#(lao)', rollCall: '#(rollCall)', election: '#(election)', question: '#(question)' }
* def electionEnd = election.close()

# After a successful election setup and cast vote sending a valid election end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ Feature: Open an Election
# Call read(...) makes this feature and the called feature share the same scope
# Meaning they share def variables, configurations ...
# Especially JS functions defined in the called features can be directly used here thanks to Karate shared scopes
* call read('classpath:be/features/utils/server.feature')
* call read('classpath:be/features/utils/mockClient.feature')
* call read('classpath:be/features/utils/constants.feature')
* call read(serverFeature)
* call read(mockClientFeature)
* def organizer = call createMockClient
* def lao = organizer.createValidLao()
* def rollCall = organizer.createValidRollCall(lao)
* def election = organizer.createValidElection(lao)
* def question = election.createQuestion()

# This call executes all the steps to set up a lao, complete a roll call and create an election with one question
* call read('classpath:be/features/utils/simpleScenarios.feature@name=election_setup') { organizer: '#(organizer)', lao: '#(lao)', rollCall: '#(rollCall)', election: '#(election)', question: '#(question)' }
* call read(setupElectionScenario) { organizer: '#(organizer)', lao: '#(lao)', rollCall: '#(rollCall)', election: '#(election)', question: '#(question)' }
* def electionOpen = election.open()

# Testing after creating an election, the backend returns an result
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ Feature: Setup an Election
# Call read(...) makes this feature and the called feature share the same scope
# Meaning they share def variables, configurations ...
# Especially JS functions defined in the called features can be directly used here thanks to Karate shared scopes
* call read('classpath:be/features/utils/server.feature')
* call read('classpath:be/features/utils/mockClient.feature')
* call read('classpath:be/features/utils/constants.feature')
* call read(serverFeature)
* call read(mockClientFeature)
* def organizer = call createMockClient
* def lao = organizer.createValidLao()
* def rollCall = organizer.createValidRollCall(lao)
Expand All @@ -16,7 +16,7 @@ Feature: Setup an Election

# This call executes all the steps to set up a lao and complete a roll call, to get a valid pop token
# (lao creation, subscribe, catchup, roll call creation, roll call open, roll call close)
* call read('classpath:be/features/utils/simpleScenarios.feature@name=close_roll_call') { organizer: '#(organizer)', lao: '#(lao)', rollCall: '#(rollCall)' }
* call read(closeRollCallScenario) { organizer: '#(organizer)', lao: '#(lao)', rollCall: '#(rollCall)' }

# Testing if after a successful roll call, sending a valid election
# setup results in a valid response from the backend
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ Feature: Close a Roll Call
# Call read(...) makes this feature and the called feature share the same scope
# Meaning they share def variables, configurations ...
# Especially JS functions defined in the called features can be directly used here thanks to Karate shared scopes
* call read('classpath:be/features/utils/server.feature')
* call read('classpath:be/features/utils/mockClient.feature')
* call read('classpath:be/features/utils/constants.feature')
* call read(serverFeature)
* call read(mockClientFeature)
* def organizer = call createMockClient
* def lao = organizer.createValidLao()
* def rollCall = organizer.createValidRollCall(lao)

# This call executes all the steps to open a valid roll call on the server before every scenario
# (lao creation, subscribe, catchup, roll call creation, roll call open)
* call read('classpath:be/features/utils/simpleScenarios.feature@name=open_roll_call') { organizer: '#(organizer)', lao: '#(lao)', rollCall: '#(rollCall)' }
* call read(openRollCallScenario) { organizer: '#(organizer)', lao: '#(lao)', rollCall: '#(rollCall)' }
* def closeRollCall = rollCall.close()

# Testing if after setting up a valid lao, subscribing to it, sending a catchup
Expand Down Expand Up @@ -79,7 +79,7 @@ Feature: Close a Roll Call
Scenario: Closing a Roll Call that was not opened on the server returns an error
Given def newRollCall = organizer.createValidRollCall(lao)
# This call creates the new roll call on the server without opening it
And call read('classpath:be/utils/simpleScenarios.feature@name=valid_roll_call') { organizer: '#(organizer)', lao: '#(lao)', rollCall: '#(newRollCall)' }
And call read(createRollCallScenario) { organizer: '#(organizer)', lao: '#(lao)', rollCall: '#(newRollCall)' }
And def closeNewRollCall = newRollCall.close()
And def validCloseRollCall =
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ Feature: Create a Roll Call
# Call read(...) makes this feature and the called feature share the same scope
# Meaning they share def variables, configurations ...
# Especially JS functions defined in the called features can be directly used here thanks to Karate shared scopes
* call read('classpath:be/features/utils/server.feature')
* call read('classpath:be/features/utils/mockClient.feature')
* call read('classpath:be/features/utils/constants.feature')
* call read(serverFeature)
* call read(mockClientFeature)
* def organizer = call createMockClient
* def lao = organizer.createValidLao()
* def validRollCall = organizer.createValidRollCall(lao)

# This call executes all the steps to create a valid lao on the server before every scenario
# (lao creation, subscribe, catchup)
* call read('classpath:be/features/utils/simpleScenarios.feature@name=valid_lao') { organizer: '#(organizer)', lao: '#(lao)' }
* call read(createLaoScenario) { organizer: '#(organizer)', lao: '#(lao)' }

# Testing if after setting up a valid lao, subscribing to it and sending a catchup
# we send a valid roll call create request and expect to receive a valid response
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ Feature: Roll Call Open
# Call read(...) makes this feature and the called feature share the same scope
# Meaning they share def variables, configurations ...
# Especially JS functions defined in the called features can be directly used here thanks to Karate shared scopes
* call read('classpath:be/features/utils/server.feature')
* call read('classpath:be/features/utils/mockClient.feature')
* call read('classpath:be/features/utils/constants.feature')
* call read(serverFeature)
* call read(mockClientFeature)
* def organizer = call createMockClient
* def lao = organizer.createValidLao()
* def rollCall = organizer.createValidRollCall(lao)

# This call executes all the steps to create a valid roll call on the server before every scenario
# (lao creation, subscribe, catchup, roll call creation)
* call read('classpath:be/features/utils/simpleScenarios.feature@name=valid_roll_call') { organizer: '#(organizer)', lao: '#(lao)', rollCall: '#(rollCall)' }
* call read(createRollCallScenario) { organizer: '#(organizer)', lao: '#(lao)', rollCall: '#(rollCall)' }
* def openRollCall = rollCall.open()

# This scenario tests a valid roll call open message.
Expand Down
17 changes: 17 additions & 0 deletions tests/karate/src/test/java/be/features/utils/constants.feature
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,20 @@ Feature: Constants

* def rootChannel = '/root'
* def random = Java.type('be.utils.RandomUtils')

# Paths to util features
* def utilsPath = 'classpath:be/features/utils/'
* def serverFeature = utilsPath + 'server.feature'
* def mockClientFeature = utilsPath + 'mockClient.feature'

# Paths to scenarios defined in simpleScenarios
* def simpleScenario = 'classpath:be/features/utils/simpleScenarios.feature@name='
* def createLaoScenario = simpleScenario + 'create_lao'
* def createRollCallScenario = simpleScenario + 'create_roll_call'
* def openRollCallScenario = simpleScenario + 'open_roll_call'
* def closeRollCallScenario = simpleScenario + 'close_roll_call'
* def setupElectionScenario = simpleScenario + 'election_setup'
* def openElectionScenario = simpleScenario + 'election_open'
* def castVoteScenario = simpleScenario + 'cast_vote'
* def setupCoinChannelScenario = simpleScenario + 'setup_coin_channel'
* def validCoinIssuanceScenario = simpleScenario + 'valid_coin_issuance'
Loading
Loading