Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix(candeletecardinalities): return correct response on route negativ…
…e case (DEV-36) (#1910)

* fix(cardinalities): use canDo response instead of BadRequest

* fix: return propertyIsUsed

* test: add test which confirms cardinality can't be deleted

* test: add test data

* refactor: move client test data collection to separated method

* add missing type

* refactor: improve CollectClientTestData method

* add files to expected client test data

* add missing files extensions
  • Loading branch information
mpro7 committed Sep 29, 2021
1 parent 8df70a2 commit 652c747
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 277 deletions.
4 changes: 4 additions & 0 deletions webapi/scripts/expected-client-test-data.txt
Expand Up @@ -193,6 +193,10 @@ test-data/v2/ontologies/add-cardinalities-to-class-nothing-response.json
test-data/v2/ontologies/all-ontology-metadata-response.json
test-data/v2/ontologies/anything-ontology.json
test-data/v2/ontologies/can-do-response.json
test-data/v2/ontologies/candeletecardinalities-false-request.json
test-data/v2/ontologies/candeletecardinalities-false-response.json
test-data/v2/ontologies/candeletecardinalities-true-request.json
test-data/v2/ontologies/candeletecardinalities-true-response.json
test-data/v2/ontologies/change-class-comment-request.json
test-data/v2/ontologies/change-class-label-request.json
test-data/v2/ontologies/change-gui-order-request.json
Expand Down
Expand Up @@ -129,9 +129,6 @@ object Cardinalities {

submittedPropertyToDelete: SmartIri = cardinalitiesToDelete.head._1
propertyIsUsed: Boolean <- isPropertyUsedInResources(settings, storeManager, submittedPropertyToDelete)
_ = if (propertyIsUsed) {
throw BadRequestException("Property is used in data. The cardinality cannot be deleted.")
}

// Make an update class definition in which the cardinality to delete is removed

Expand Down Expand Up @@ -170,7 +167,7 @@ object Cardinalities {
throw BadRequestException(msg)
}
)
} yield CanDoResponseV2(true)
} yield CanDoResponseV2(!propertyIsUsed)
}

/**
Expand Down

0 comments on commit 652c747

Please sign in to comment.