Skip to content

Commit

Permalink
feat: add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pj-cegeka committed Oct 3, 2023
1 parent bcd36ef commit b3d0fad
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,4 +139,9 @@ public void theRetrievedMemberIsEmpty(int memberCount) {
public void theRetrievedMemberIsEmpty(String collectionName, int memberCount) {
assertEquals(memberCount, memberRepository.getMemberCountOfCollection(collectionName));
}

@Then("I delete all members from the {string} collection")
public void theRetrievedMemberIsEmpty(String collectionName) {
memberRepository.deleteMembersByCollection(collectionName);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Feature: MemberRepository
When I save the members using the MemberRepository
Then The member with id "http://test-data/mobility-hindrance/1/1" can be retrieved from the database
And The retrieved member has the same properties as the 1 member in the table and has sequenceNr 15
And I delete all members from the "mobility-hindrances" collection

Scenario: Saving members without a sequenceNr which gets a sequenceNr assigned
Given The following members
Expand All @@ -29,6 +30,8 @@ Feature: MemberRepository
And The retrieved member has the same properties as the 3 member in the table and has sequenceNr 1
Then The member with id "http://test-data/gipod/1/2" can be retrieved from the database
And The retrieved member has the same properties as the 5 member in the table and has sequenceNr 2
And I delete all members from the "mobility-hindrances" collection
And I delete all members from the "gipod" collection

Scenario: The repository can delete all members of a certain collection
Given The following members
Expand All @@ -46,6 +49,8 @@ Feature: MemberRepository
And The member with id "http://test-data/gipod/1/2" will not exist
And The sequence for "gipod" will have been removed
And The sequence for "mobility-hindrances" will still exist
And I delete all members from the "mobility-hindrances" collection
And I delete all members from the "gipod" collection

Scenario: The repository can indicate if members exist or not
Given The following members
Expand All @@ -54,6 +59,7 @@ Feature: MemberRepository
When I save the members using the MemberRepository
Then The member with id "http://test-data/mobility-hindrance/1/1" will exist
And The member with id "http://test-data/mobility-hindrance/fantasy-id" will not exist
And I delete all members from the "mobility-hindrances" collection

Scenario: The repository can provide a stream of the eventsource
Given The following members
Expand All @@ -66,6 +72,8 @@ Feature: MemberRepository
When I save the members using the MemberRepository
Then I can get an ordered stream from all the members of the "mobility-hindrances" collection containing 3 members
And I can get an ordered stream from all the members of the "gipod" collection containing 2 members
And I delete all members from the "mobility-hindrances" collection
And I delete all members from the "gipod" collection

Scenario: The repository can bulk retrieve members
Given The following members
Expand All @@ -79,13 +87,17 @@ Feature: MemberRepository
When I try to retrieve the following members by Id
| http://test-data/mobility-hindrance/1/1 | http://test-data/mobility-hindrance/1/2 | http://test-data/mobility-hindrance/1/3 |
Then I expect a list of 3 members
Scenario: The repository can indicate if members exist or not
Given The following members
| id | collectionName | sequenceNr | versionOf |
| http://test-data/mobility-hindrance/1/1 | mobility-hindrances | [blank] | http://test-data/mobility-hindrance/1 |
When I save the members using the MemberRepository
Then The member with id "http://test-data/mobility-hindrance/1/1" will exist
And The member with id "http://test-data/mobility-hindrance/fantasy-id" will not exist
And I delete all members from the "mobility-hindrances" collection
And I delete all members from the "gipod" collection

Scenario: The repository can indicate if members exist or not
Given The following members
| id | collectionName | sequenceNr | versionOf |
| http://test-data/mobility-hindrance/1/1 | mobility-hindrances | [blank] | http://test-data/mobility-hindrance/1 |
When I save the members using the MemberRepository
Then The member with id "http://test-data/mobility-hindrance/1/1" will exist
And The member with id "http://test-data/mobility-hindrance/fantasy-id" will not exist
And I delete all members from the "mobility-hindrances" collection

Scenario: Delete a member with a certain id
Given The following members
Expand All @@ -97,20 +109,22 @@ Feature: MemberRepository
When I delete the member with id "http://test-data/mobility-hindrance/1/1"
Then The member with id "http://test-data/mobility-hindrance/1/2" will exist
And The member with id "http://test-data/mobility-hindrance/1/1" will not exist
And I delete all members from the "mobility-hindrances" collection

Scenario: Find member by collection name and sequence number greater than
Given The following members
| id | collectionName | sequenceNr | versionOf |
| http://test-data/mobility-hindrance/1/1 | mobility-hindrances | 5 | http://test-data/mobility-hindrance/1 |
| http://test-data/mobility-hindrance/1/2 | mobility-hindrances | 12 | http://test-data/mobility-hindrance/1 |
| http://test-data/mobility-hindrance/1/3 | mobility-hindrances | 3 | http://test-data/mobility-hindrance/1 |
When I save the members using the MemberRepository
And I search for the first member from collection "mobility-hindrances" and sequenceNr greater than -1
Then The retrieved member has the same properties as the 3 member in the table and has sequenceNr 3
When I search for the first member from collection "mobility-hindrances" and sequenceNr greater than 3
Then The retrieved member has the same properties as the 1 member in the table and has sequenceNr 5
When I search for the first member from collection "mobility-hindrances" and sequenceNr greater than 15
Then The retrieved member is empty
Scenario: Find member by collection name and sequence number greater than
Given The following members
| id | collectionName | sequenceNr | versionOf |
| http://test-data/mobility-hindrance/1/1 | mobility-hindrances | 5 | http://test-data/mobility-hindrance/1 |
| http://test-data/mobility-hindrance/1/2 | mobility-hindrances | 12 | http://test-data/mobility-hindrance/1 |
| http://test-data/mobility-hindrance/1/3 | mobility-hindrances | 3 | http://test-data/mobility-hindrance/1 |
When I save the members using the MemberRepository
And I search for the first member from collection "mobility-hindrances" and sequenceNr greater than -1
Then The retrieved member has the same properties as the 3 member in the table and has sequenceNr 3
When I search for the first member from collection "mobility-hindrances" and sequenceNr greater than 3
Then The retrieved member has the same properties as the 1 member in the table and has sequenceNr 5
When I search for the first member from collection "mobility-hindrances" and sequenceNr greater than 15
Then The retrieved member is empty
And I delete all members from the "mobility-hindrances" collection

Scenario: Get current number of members
Given The following members
Expand All @@ -121,4 +135,6 @@ Feature: MemberRepository
| http://test-data/other/1/1 | other | 4 | http://test-data/mobility-hindrance/1 |
When I save the members using the MemberRepository
Then The number of members is 4
Then The number of members of the "mobility-hindrances" collection is 3
And The number of members of the "mobility-hindrances" collection is 3
And I delete all members from the "mobility-hindrances" collection
And I delete all members from the "other" collection

0 comments on commit b3d0fad

Please sign in to comment.