Closed wsuchy closed 5 years ago
My assumption was that this test should cover only the basic functionality (what it does by now). By looking at the coverage you can clearly see that all lines are now covered. I don't think that exploding the scope of it makes much sense as there are also different things to focus on.
well, the code that was introduced in #333 now clearly has a problem which I wanted you discover through the test:
import com.salesforce.op.features.types._
import collection.JavaConverters._
val jm = new java.util.HashMap[String, java.lang.Boolean]()
jm.put("nullValue", null)
jm.toBinaryMap // NullPointerException !
I propose to add a test for null values and modify the code from #333 with following:
def toBinaryMap: BinaryMap = new BinaryMap(
Option(v).map(_.asScala.collect { case (k, v) if v != null => v.booleanValue() }.toMap).getOrElse(Map.empty)
)
I am aware of that and assumed that you are fine with this by merging my PR.
Clearly we need to fix it as we don't want to have any NPE flying around.
Hmmm I wouldn't say that null
s must be implicitly omitted. Why not convert them to false in Boolean and 0 in Integer?
Or maybe leave exceptions as a suggestion for the user that there is a problem with the data?
Replacing with default values would be even worse. Let's have then explicit handling for null values as follows, e.g. for RealMap:
def toRealMap: RealMap = new RealMap(
Option(v).map(_.asScala.map {
case (k, null) => (k, null.asInstanceOf[Double])
case (k, x) => (k, x.doubleValue())
}.toMap).getOrElse(Map.empty)
)
Thanks for the contribution! Unfortunately we can't verify the commit author(s): Matthew m***@s***.com. One possible solution is to add that email to your GitHub account. Alternatively you can change your commits to another email and force push the change. After getting your commits associated with your GitHub account, refresh the status of this Pull Request.
Thanks for the contribution! Before we can merge this, we need @wsuchy to sign the Salesforce.com Contributor License Agreement.
Codecov Report
57.93% <100%> (+6.86%)
Continue to review full report at Codecov.