Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix(list): add support for special characters in list update (DEV-200) (
#1934)

* fix(list): add support for special characters in list update (DEV-200)

* update test
  • Loading branch information
mpro7 committed Nov 5, 2021
1 parent c75039f commit 3c2865c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 38 deletions.
Expand Up @@ -1091,24 +1091,6 @@ class ListsResponderADM(responderData: ResponderData) extends Responder(responde
apiRequestID: UUID
): Future[NodeInfoGetResponseADM] = {

def verifyUpdatedNode(updatedNode: ListNodeInfoADM): Unit = {

if (changeNodeRequest.labels.nonEmpty) {
if (updatedNode.getLabels.stringLiterals.diff(changeNodeRequest.labels.get.value).nonEmpty)
throw UpdateNotPerformedException("Lists's 'labels' were not updated. Please report this as a possible bug.")
}

if (changeNodeRequest.comments.nonEmpty) {
if (updatedNode.getComments.stringLiterals.diff(changeNodeRequest.comments.get.value).nonEmpty)
throw UpdateNotPerformedException("List's 'comments' was not updated. Please report this as a possible bug.")
}

if (changeNodeRequest.name.nonEmpty) {
if (updatedNode.getName.nonEmpty && updatedNode.getName.get != changeNodeRequest.name.get.value)
throw UpdateNotPerformedException("List's 'name' was not updated. Please report this as a possible bug.")
}
}

/**
* The actual task run with an IRI lock.
*/
Expand Down Expand Up @@ -1140,13 +1122,9 @@ class ListsResponderADM(responderData: ResponderData) extends Responder(responde
)

response = maybeNodeADM match {
case Some(rootNode: ListRootNodeInfoADM) =>
verifyUpdatedNode(rootNode)
RootNodeInfoGetResponseADM(listinfo = rootNode)
case Some(rootNode: ListRootNodeInfoADM) => RootNodeInfoGetResponseADM(listinfo = rootNode)

case Some(childNode: ListChildNodeInfoADM) =>
verifyUpdatedNode(childNode)
ChildNodeInfoGetResponseADM(nodeinfo = childNode)
case Some(childNode: ListChildNodeInfoADM) => ChildNodeInfoGetResponseADM(nodeinfo = childNode)

case _ =>
throw UpdateNotPerformedException(s"Node $nodeIri was not updated. Please report this as a possible bug.")
Expand Down
Expand Up @@ -87,9 +87,7 @@ class NewListsRouteADMFeatureE2ESpec
|}""".stripMargin

"The Lists Route (/admin/lists)" when {

"used to query information about lists" should {

"return all lists" in {
val request = Get(baseApiUrl + s"/admin/lists")
.addHeader(RawHeader(FeatureToggle.REQUEST_HEADER, "new-list-admin-routes:1=on")) ~> addCredentials(
Expand Down Expand Up @@ -340,7 +338,6 @@ class NewListsRouteADMFeatureE2ESpec
}

"return a DuplicateValueException during list creation when the supplied list IRI is not unique" in {

// duplicate list IRI
val params =
s"""
Expand All @@ -366,7 +363,6 @@ class NewListsRouteADMFeatureE2ESpec
}

"add a child with a custom IRI" in {

val createChildNodeWithCustomIriRequest =
s"""
|{ "id": "$customChildNodeIRI",
Expand Down Expand Up @@ -423,7 +419,6 @@ class NewListsRouteADMFeatureE2ESpec
}

"used to modify list information" should {

val newListIri = new MutableTestIri
val firstChildIri = new MutableTestIri
val secondChildIri = new MutableTestIri
Expand Down Expand Up @@ -504,7 +499,6 @@ class NewListsRouteADMFeatureE2ESpec
}

"return a BadRequestException during list creation when payload is not correct" in {

// no project IRI
val params01 =
s"""
Expand Down Expand Up @@ -555,14 +549,14 @@ class NewListsRouteADMFeatureE2ESpec

}

"update basic list information" in {

"update basic list information using special characters" in {
val updateListInfo: String =
s"""{
| "listIri": "${newListIri.get}",
| "projectIri": "${SharedTestDataADM.ANYTHING_PROJECT_IRI}",
| "labels": [{ "value": "Neue geänderte Liste", "language": "de"}, { "value": "Changed list", "language": "en"}],
| "comments": [{ "value": "Neuer Kommentar", "language": "de"}, { "value": "New comment", "language": "en"}]
| "name": "neue Name mit A'postroph",
| "labels": [{ "value": "Neue geänderte Liste mit A'postroph", "language": "de"}, { "value": "Changed list with a'postrophe", "language": "en"}],
| "comments": [{ "value": "Neuer Kommentar mit A'postroph", "language": "de"}, { "value": "New comment with a'postrophe", "language": "en"}]
|}""".stripMargin

clientTestDataCollector.addFile(
Expand Down Expand Up @@ -662,7 +656,6 @@ class NewListsRouteADMFeatureE2ESpec
}

"update basic list information with repeated comment and label in different languages" in {

val updateListInfoWithRepeatedCommentAndLabelValuesRequest: String =
s"""{
| "listIri": "http://rdfh.ch/lists/0001/treeList",
Expand Down Expand Up @@ -750,7 +743,6 @@ class NewListsRouteADMFeatureE2ESpec
}

"return a BadRequestException during list change when payload is not correct" in {

val encodedListUrl = java.net.URLEncoder.encode(newListIri.get, "utf-8")

// empty list IRI
Expand Down Expand Up @@ -886,7 +878,6 @@ class NewListsRouteADMFeatureE2ESpec
}

"add second child to list - to the root node" in {

val name = "second"
val label = "New Second Child List Node Value"
val comment = "New Second Child List Node Comment"
Expand Down Expand Up @@ -958,7 +949,6 @@ class NewListsRouteADMFeatureE2ESpec
}

"add child to second child node" in {

val name = "third"
val label = "New Third Child List Node Value"
val comment = "New Third Child List Node Comment"
Expand Down Expand Up @@ -1028,6 +1018,7 @@ class NewListsRouteADMFeatureE2ESpec
)
)
}

"update node information of node that has custom IRI with a new name" in {
val newName = "modified third child"
val updateNodeName =
Expand Down

0 comments on commit 3c2865c

Please sign in to comment.