Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ libraryDependencies ++= Seq(
Dependencies.Compile.awsJavaSDK_simpledb % "provided",
Dependencies.Compile.awsJavaSDK_sns % "provided",
Dependencies.Compile.awsJavaSDK_sqs % "provided",
Dependencies.Compile.slf4j
Dependencies.Compile.slf4j,
Dependencies.Test.scalaTest
)


Expand Down
5 changes: 5 additions & 0 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ object Dependencies {
val logback = "ch.qos.logback" % "logback-classic" % V.logback
}

object Test {

val scalaTest = "org.scalatest" %% "scalatest" % "2.2.4" % "test"
}

object IntegrationTest {

val scalaTest = "org.scalatest" %% "scalatest" % "2.2.4" % "it"
Expand Down
4 changes: 2 additions & 2 deletions src/main/scala/dynamodb/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,9 @@ package object dynamodb {
implicit val attributeValueToByteArraySet = (x: AttributeValue) => catchAndRethrowConversion { x.getBS.asScala.map(_.array).toSet }

/** string AttributeValue to Boolean */
implicit val attributeValueToBoolean = (x: AttributeValue) => catchAndRethrowConversion { x.getS.toBoolean }
implicit val attributeValueToBoolean = (x: AttributeValue) => catchAndRethrowConversion { x.getBOOL }
/** string set AttributeValue to Set[Boolean] */
implicit val attributeValueToBooleanSet = (x: AttributeValue) => catchAndRethrowConversion { x.getSS.asScala.map(_.toBoolean).toSet }
implicit val attributeValueToBooleanSet = (x: AttributeValue) => catchAndRethrowConversion { x.getL.asScala.map(_.getBOOL).toSet }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to have alternative in case of failure for all the .getSS because .getSS can also be .getL + .getS.
I had that problem when reading something written by a Python client


/** string AttributeValue to BigInt */
implicit val attributeValueToBigInt = (x: AttributeValue) => catchAndRethrowConversion { BigInt(x.getS) }
Expand Down
24 changes: 24 additions & 0 deletions src/test/scala/dynamodb/BooleanConversionSpec.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package dynamodb

import com.github.dwhjames.awswrap.dynamodb._
import scala.collection.JavaConverters._
import org.scalatest.{FlatSpec, Matchers}

class BooleanConversionSpec extends FlatSpec with Matchers {


it should "convert from DynamoDb Bool to Scala Boolean" in {

val attributeValue = new AttributeValue().withBOOL(false)
val bool = attributeValueToBoolean(attributeValue)
bool shouldBe false
}

it should "convert from DynamoDb Bool Collection to Scala Boolean Set" in {

val attributeValue = new AttributeValue().withBOOL(false)
val attributeValueList = new AttributeValue().withL(Seq(attributeValue).asJava)
val bool = attributeValueToBooleanSet(attributeValueList)
bool shouldBe Set(false)
}
}