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

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

Merged
merged 2 commits into from Nov 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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