-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MODLD-599: LCCN pattern validation (#1637)
- Loading branch information
1 parent
4e42554
commit ee4f166
Showing
8 changed files
with
174 additions
and
0 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
...citation/mod-linked-data/features/lccn-pattern-validation/lccn-pattern-validation.feature
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,38 @@ | ||
Feature: LCCN pattern validation | ||
|
||
Background: | ||
* url baseUrl | ||
* call login testUser | ||
* def testUserHeaders = { 'Content-Type': 'application/json', 'x-okapi-token': '#(okapitoken)', 'Accept': '*/*' } | ||
* configure headers = testUserHeaders | ||
|
||
Scenario: Create resources with enabled validation and then repeat with disabled validation | ||
# Step 1: Enable validation | ||
* def getSpecificationsCall = call getSpecifications { profileParam: "bibliographic", familyParam: "MARC" } | ||
* def specificationId = getSpecificationsCall.response.specifications[0].id | ||
* def getRulesCall = call getRules { specificationId: '#(specificationId)' } | ||
* def ruleId = karate.filter(getRulesCall.response.rules, function (rule) { return rule.code === "invalidLccnSubfieldValue" })[0].id | ||
* call patchRule { specificationId: '#(specificationId)', ruleId: '#(ruleId)', isEnabled: true } | ||
|
||
# Step 2: Create a work | ||
* def workRequest = read('samples/work-request.json') | ||
* def postWorkCall = call postResource { resourceRequest: '#(workRequest)' } | ||
* def workId = postWorkCall.response.resource['http://bibfra.me/vocab/lite/Work'].id | ||
|
||
# Step 3: Create valid instance | ||
* def validInstanceRequest = read('samples/valid-instance-request.json') | ||
* call postResource { resourceRequest: '#(validInstanceRequest)' } | ||
|
||
# Step 4: Fail to create invalid instance | ||
* def invalidInstanceRequest = read('samples/invalid-instance-request.json') | ||
Given path 'linked-data/resource' | ||
And request invalidInstanceRequest | ||
When method POST | ||
Then status 400 | ||
And match $.errors[0].code == "lccn_does_not_match_pattern" | ||
|
||
# Step 5: Disable validation | ||
* call patchRule { specificationId: '#(specificationId)', ruleId: '#(ruleId)', isEnabled: false } | ||
|
||
# Step 6: Create invalid instance | ||
* call postResource { resourceRequest: '#(invalidInstanceRequest)' } |
39 changes: 39 additions & 0 deletions
39
...on/mod-linked-data/features/lccn-pattern-validation/samples/invalid-instance-request.json
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,39 @@ | ||
{ | ||
"resource":{ | ||
"http://bibfra.me/vocab/lite/Instance":{ | ||
"http://bibfra.me/vocab/marc/title":[ | ||
{ | ||
"http://bibfra.me/vocab/marc/Title":{ | ||
"http://bibfra.me/vocab/marc/mainTitle":[ | ||
"Invalid instance main title" | ||
] | ||
} | ||
} | ||
], | ||
"http://library.link/vocab/map":[ | ||
{ | ||
"http://library.link/identifier/LCCN":{ | ||
"http://bibfra.me/vocab/lite/name":[ | ||
"n!1234567890" | ||
], | ||
"http://bibfra.me/vocab/marc/status":[ | ||
{ | ||
"http://bibfra.me/vocab/lite/label":[ | ||
"current" | ||
], | ||
"http://bibfra.me/vocab/lite/link":[ | ||
"http://id.loc.gov/vocabulary/mstatus/current" | ||
] | ||
} | ||
] | ||
} | ||
} | ||
], | ||
"_workReference":[ | ||
{ | ||
"id": "#(workId)" | ||
} | ||
] | ||
} | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
...tion/mod-linked-data/features/lccn-pattern-validation/samples/valid-instance-request.json
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,39 @@ | ||
{ | ||
"resource":{ | ||
"http://bibfra.me/vocab/lite/Instance":{ | ||
"http://bibfra.me/vocab/marc/title":[ | ||
{ | ||
"http://bibfra.me/vocab/marc/Title":{ | ||
"http://bibfra.me/vocab/marc/mainTitle":[ | ||
"Valid instance main title" | ||
] | ||
} | ||
} | ||
], | ||
"http://library.link/vocab/map":[ | ||
{ | ||
"http://library.link/identifier/LCCN":{ | ||
"http://bibfra.me/vocab/lite/name":[ | ||
" 1234567890" | ||
], | ||
"http://bibfra.me/vocab/marc/status":[ | ||
{ | ||
"http://bibfra.me/vocab/lite/label":[ | ||
"current" | ||
], | ||
"http://bibfra.me/vocab/lite/link":[ | ||
"http://id.loc.gov/vocabulary/mstatus/current" | ||
] | ||
} | ||
] | ||
} | ||
} | ||
], | ||
"_workReference":[ | ||
{ | ||
"id": "#(workId)" | ||
} | ||
] | ||
} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...urces/citation/mod-linked-data/features/lccn-pattern-validation/samples/work-request.json
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,15 @@ | ||
{ | ||
"resource":{ | ||
"http://bibfra.me/vocab/lite/Work":{ | ||
"http://bibfra.me/vocab/marc/title":[ | ||
{ | ||
"http://bibfra.me/vocab/marc/Title":{ | ||
"http://bibfra.me/vocab/marc/mainTitle":[ | ||
"Work main title" | ||
] | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
...ata/src/main/resources/citation/mod-linked-data/features/util/crud-specifications.feature
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,31 @@ | ||
Feature: CRUD operations on a specifications | ||
Background: | ||
* url baseUrl | ||
|
||
@getSpecifications | ||
Scenario: Get a collection of specifications | ||
Given path 'specification-storage/specifications' | ||
And param profile = profileParam | ||
And param family = familyParam | ||
When method Get | ||
Then status 200 | ||
* def response = $ | ||
|
||
@getRules | ||
Scenario: Get a collection of rules of a specification | ||
Given path 'specification-storage/specifications/' + specificationId + '/rules' | ||
When method Get | ||
Then status 200 | ||
* def response = $ | ||
|
||
@patchRule | ||
Scenario: Update a specification rule | ||
Given path 'specification-storage/specifications/' + specificationId + '/rules/' + ruleId | ||
And request | ||
""" | ||
{ | ||
"enabled": "#(isEnabled)" | ||
} | ||
""" | ||
When method Patch | ||
Then status 204 |
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
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
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