Skip to content

Commit

Permalink
Merge pull request #175 from campudus/putEmptyJSON
Browse files Browse the repository at this point in the history
verify PUT requests on cells should have a value
  • Loading branch information
zingmane committed Apr 11, 2018
2 parents 8caa0ab + 68dd4e4 commit 4a04aa8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ uploads*
classes/
!src/test/resources/com/campudus/tableaux/uploads
bin/
out/
**.DS_Store

# Gradle
.gradle/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ import java.util.UUID
import com.campudus.tableaux.controller.TableauxController
import com.campudus.tableaux.database.domain.{CellAnnotationType, Pagination}
import com.campudus.tableaux.helper.JsonUtils._
import com.campudus.tableaux.{NoJsonFoundException, TableauxConfig}
import com.campudus.tableaux.{InvalidJsonException, NoJsonFoundException, TableauxConfig}
import org.vertx.scala.core.json.JsonArray
import io.vertx.scala.ext.web.RoutingContext
import org.vertx.scala.router.routing._

import scala.concurrent.Future
import scala.util.matching.Regex

object TableauxRouter {
Expand Down Expand Up @@ -299,7 +300,11 @@ class TableauxRouter(override val config: TableauxConfig, val controller: Tablea
asyncGetReply {
for {
json <- getJson(context)
updated <- controller.replaceCellValue(tableId.toLong, columnId.toLong, rowId.toLong, json.getValue("value"))
updated <- if (json.containsKey("value")) {
controller.replaceCellValue(tableId.toLong, columnId.toLong, rowId.toLong, json.getValue("value"))
} else {
Future.failed(InvalidJsonException("request must contain a value", "value_is_missing"))
}
} yield updated
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,12 @@ class LinkTest extends LinkTestBase {
}
}

@Test
def putEmptyLink(implicit c: TestContext): Unit = exceptionTest("error.json.value_is_missing") {
setupTwoTablesWithEmptyLinks().flatMap(linkColumnId =>
sendRequest("PUT", s"/tables/1/columns/$linkColumnId/rows/1", Json.obj("blub" -> "bla")))
}

@Test
def putLinkValues(implicit c: TestContext): Unit = {
okTest {
Expand Down

0 comments on commit 4a04aa8

Please sign in to comment.