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

MODLD-601: LCCN deduplication #1634

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
Feature: CRUD operations on settings
Background:
* url baseUrl

@getSettings
Scenario: Get settings
Given path 'settings/entries'
And param query = query
When method GET
Then status 200
* def response = $

@putSetting
Scenario: Put a setting
Given path 'settings/entries/' + id
And request settingRequest
When method PUT
Then status 200
* def response = $

@postSetting
Scenario: Post a setting
Given path 'settings/entries/'
And request settingRequest
When method POST
Then status 204

@getSetting
Scenario: Get a setting
Given path 'settings/entries/' + id
When method GET
Then status 200
* def response = $
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Feature: Resource validation
Background:
* url baseUrl

@validationErrorWithCodeOnResourceCreation
Scenario: Post a resource and verify bad request
Given path 'linked-data/resource'
And request resource
When method POST
Then status 400
And match $.errors[0].code == code
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
Feature: LCCN validation for duplicates.

Background:
* url baseUrl
* call login testUser
* def testUserHeaders = { 'Content-Type': 'application/json', 'x-okapi-token': '#(okapitoken)', 'Accept': '*/*' }
* configure headers = testUserHeaders

Scenario: Create a new resource in Linked Data, enable LCCN deduplication and try to create a resource with same LCCN.
# Step 1: Enable LCCN deduplication
* def settingRequest = read('samples/setting-request.json')
* def settingsResponse = call postSetting
* def setting = call getSetting { id: '#(settingRequest.id)'}
* karate.log('##setting##', setting)
* def settingsResponse = call getSettings { query: '(scope==ui-quick-marc.lccn-duplicate-check.manage and key==lccn-duplicate-check)'}
* karate.log('##settings##', settingsResponse)

# Step 2: Create work and instance
* def workRequest = read('samples/work-request.json')
* def workResponse = call postResource { resourceRequest: '#(workRequest)' }
* def workId = workResponse.response.resource['http://bibfra.me/vocab/lite/Work'].id

* def instanceRequest = read('samples/instance-request.json')
* def instanceResponse = call postResource { resourceRequest: '#(instanceRequest)' }

# Step 3: Update the instance with same LCCN (here we check linked-data -> mod-search interaction and id exclusion)
* def instanceId = instanceResponse.response.resource['http://bibfra.me/vocab/lite/Instance'].id
* call putResource { id: '#(instanceId)' , resourceRequest: '#(instanceRequest)' }

# Temp debug step, checking instance with LCCN exists in search
Given path 'search/instances'
And param query = '(lccn=nn0987654321)'
And param limit = 10
And param offset = 0
When method GET
Then status 200
* def inventoryInstanceSearchResponse = $
* karate.log('##inventoryInstanceSearchResponse##', inventoryInstanceSearchResponse)

# Step 4: Create new instance with existing LCCN, verify bad request
* def invalidInstanceRequest = read('samples/invalid-instance-request.json')
* call validationErrorWithCodeOnResourceCreation { resource: '#(invalidInstanceRequest)', code: 'lccn_not_unique'}

# Step 5: Disable LCCN deduplication setting
* eval settingRequest.value.duplicateLccnCheckingEnabled = false
* call putSetting { id : '#(settingRequest.id)', settingRequest : '#(settingRequest)'}

# Step 6: Create new instance with existing LCCN, verify success
* call postResource { resourceRequest: '#(invalidInstanceRequest)' }
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"resource":{
"http://bibfra.me/vocab/lite/Instance":{
"http://bibfra.me/vocab/marc/title":[
{
"http://bibfra.me/vocab/marc/Title":{
"http://bibfra.me/vocab/bflc/nonSortNum":[
"1"
],
"http://bibfra.me/vocab/marc/mainTitle":[
"deduplication_main_title"
]
}
}
],
"http://library.link/vocab/map":[
{
"http://library.link/identifier/LCCN":{
"http://bibfra.me/vocab/lite/name":[
"nn0987654321"
],
"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)"
}
]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"resource":{
"http://bibfra.me/vocab/lite/Instance":{
"http://bibfra.me/vocab/marc/title":[
{
"http://bibfra.me/vocab/marc/Title":{
"http://bibfra.me/vocab/bflc/nonSortNum":[
"1"
],
"http://bibfra.me/vocab/marc/mainTitle":[
"main_title"
]
}
}
],
"http://library.link/vocab/map":[
{
"http://library.link/identifier/LCCN":{
"http://bibfra.me/vocab/lite/name":[
"nn0987654321"
],
"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)"
}
]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f45",
"scope": "ui-quick-marc.lccn-duplicate-check.manage",
"key": "lccn-duplicate-check",
"value": {
"duplicateLccnCheckingEnabled": true
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"resource":{
"http://bibfra.me/vocab/lite/Work":{
"http://bibfra.me/vocab/marc/title":[
{
"http://bibfra.me/vocab/marc/Title":{
"http://bibfra.me/vocab/bflc/nonSortNum":[
"1"
],
"http://bibfra.me/vocab/marc/mainTitle":[
"deduplication_main_title"
],
"http://bibfra.me/vocab/marc/partNumber":[
"1"
],
"http://bibfra.me/vocab/marc/partName":[
"part 1"
]
}
}
],
"http://bibfra.me/vocab/marc/content":[
{
"http://bibfra.me/vocab/marc/term":[
"cartographic image"
],
"http://bibfra.me/vocab/lite/link":[
"http://id.loc.gov/vocabulary/contentTypes/cri"
]
}
]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ Feature: mod-linked-data integration tests
| 'mod-quick-marc' |
| 'mod-linked-data' |
| 'mod-record-specifications' |
| 'mod-settings' |
| 'folio_quick-marc' |

* table userPermissions
| name |
Expand Down Expand Up @@ -55,6 +57,10 @@ Feature: mod-linked-data integration tests
| 'specification-storage.specifications.collection.get' |
| 'specification-storage.specification.rules.collection.get' |
| 'specification-storage.specification.rules.item.patch' |
| 'ui-quick-marc.settings.lccn-duplicate-check.edit' |
| 'mod-settings.entries.collection.get' |
| 'mod-settings.entries.item.get' |
| 'mod-settings.entries.item.put' |

Scenario: create tenant and users for testing
Given call read('classpath:common/setup-users.feature')
5 changes: 5 additions & 0 deletions mod-linked-data/src/main/resources/karate-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ function fn() {
getResourceGraph: karate.read('classpath:citation/mod-linked-data/features/util/crud-resource.feature@getResourceGraph'),
getResourceSupportCheck: karate.read('classpath:citation/mod-linked-data/features/util/crud-resource.feature@getResourceSupportCheck'),
getResourcePreview: karate.read('classpath:citation/mod-linked-data/features/util/crud-resource.feature@getResourcePreview'),
validationErrorWithCodeOnResourceCreation: karate.read('classpath:citation/mod-linked-data/features/util/validation-resource.feature@validationErrorWithCodeOnResourceCreation'),
getSettings: karate.read('classpath:citation/mod-linked-data/features/util/crud-settings.feature@getSettings'),
putSetting: karate.read('classpath:citation/mod-linked-data/features/util/crud-settings.feature@putSetting'),
postSetting: karate.read('classpath:citation/mod-linked-data/features/util/crud-settings.feature@postSetting'),
getSetting: karate.read('classpath:citation/mod-linked-data/features/util/crud-settings.feature@getSetting'),
AndreiBordak marked this conversation as resolved.
Show resolved Hide resolved
postImport: karate.read('classpath:citation/mod-linked-data/features/util/crud-resource.feature@postImport'),
getSpecifications: karate.read('classpath:citation/mod-linked-data/features/util/crud-specifications.feature@getSpecifications'),
getRules: karate.read('classpath:citation/mod-linked-data/features/util/crud-specifications.feature@getRules'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,9 @@ void importBibRecordFromSrsToLinkedData() {
void lccnPatternValidation() {
runFeatureTest("lccn-pattern-validation/lccn-pattern-validation.feature");
}

@Test
void lccnDeduplication() {
runFeatureTest("validation/lccn/deduplication/lccn-deduplication.feature");
}
}