Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
fix(value): make impossible to set list root node as a value (DEV-973) (
#2088) * add method checking if list is a root node or not * improve ignoring trig files * refactor HierarchicalListValueContentV2 object * cleanup * add list root checkiing method to ValueResponderV2 + test * remove list root checking from ValueMessangerV2 * add new query to handle 2 checks + merge checking methods * move throwing to responder * fix formatting & bad merge * fix failing test * refactor check method to return value + move error handling to responder * add UNIT tests for util method * remove unused template * review changes * cleanup
- Loading branch information
Showing
7 changed files
with
190 additions
and
36 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -36,7 +36,7 @@ sipi/test | |
*.bak | ||
*.rdb | ||
.sbtrc | ||
/*.trig | ||
**/*.trig | ||
|
||
dependencies.txt | ||
/client-test-data.zip | ||
|
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
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
48 changes: 48 additions & 0 deletions
48
webapi/src/test/scala/org/knora/webapi/responders/v2/ResourceUtilV2Spec.scala
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,48 @@ | ||
/* | ||
* Copyright © 2021 - 2022 Swiss National Data and Service Center for the Humanities and/or DaSCH Service Platform contributors. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.knora.webapi.responders.v2 | ||
|
||
import akka.util.Timeout | ||
import org.knora.webapi.CoreSpec | ||
import org.knora.webapi.messages.store.triplestoremessages.RdfDataObject | ||
|
||
import scala.concurrent.ExecutionContextExecutor | ||
|
||
object ResourceUtilV2Spec {} | ||
|
||
class ResourceUtilV2Spec extends CoreSpec() { | ||
implicit val timeout: Timeout = settings.defaultTimeout | ||
implicit val ec: ExecutionContextExecutor = system.dispatcher | ||
|
||
override lazy val rdfDataObjects = List( | ||
RdfDataObject(path = "test_data/all_data/anything-data.ttl", name = "http://www.knora.org/data/0001/anything") | ||
) | ||
|
||
"ResourceUtil" when { | ||
"called `checkListNodeExistsAndIsRootNode` method" should { | ||
"return FALSE for list child node" in { | ||
val nodeIri = "http://rdfh.ch/lists/0001/otherTreeList01" | ||
val checkNode = ResourceUtilV2.checkListNodeExistsAndIsRootNode(nodeIri, appActor) | ||
|
||
checkNode.onComplete(_.get should be(Right(false))) | ||
} | ||
|
||
"return TRUE for list root node" in { | ||
val nodeIri = "http://rdfh.ch/lists/0001/otherTreeList" | ||
val checkNode = ResourceUtilV2.checkListNodeExistsAndIsRootNode(nodeIri, appActor) | ||
|
||
checkNode.onComplete(_.get should be(Right(true))) | ||
} | ||
|
||
"should return NONE for nonexistent list" in { | ||
val nodeIri = "http://rdfh.ch/lists/0001/otherTreeList77" | ||
val checkNode = ResourceUtilV2.checkListNodeExistsAndIsRootNode(nodeIri, appActor) | ||
|
||
checkNode.onComplete(_.get should be(Left(None))) | ||
} | ||
} | ||
} | ||
} |
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