Skip to content

2.12 creator test #510

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

Merged
merged 2 commits into from
Feb 25, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,14 @@ libraryDependencies ++= Seq(
"com.fasterxml.jackson.core" % "jackson-core" % jacksonVersion,
"com.fasterxml.jackson.core" % "jackson-annotations" % jacksonVersion,
"com.fasterxml.jackson.core" % "jackson-databind" % jacksonVersion,
) ++ {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, scalaMajor)) if scalaMajor <= 11 =>
Seq("com.thoughtworks.paranamer" % "paranamer" % "2.8")
case _ => Seq.empty
}
} ++ Seq(
"com.thoughtworks.paranamer" % "paranamer" % "2.8",
// test dependencies
"com.fasterxml.jackson.datatype" % "jackson-datatype-joda" % jacksonVersion % Test,
"com.fasterxml.jackson.datatype" % "jackson-datatype-guava" % jacksonVersion % Test,
"com.fasterxml.jackson.datatype" % "jackson-datatype-jdk8" % jacksonVersion % Test,
"com.fasterxml.jackson.module" % "jackson-module-jsonSchema" % jacksonJsonSchemaVersion % Test,
"io.swagger" % "swagger-core" % "1.6.2" % Test,
"org.scalatest" %% "scalatest" % "3.2.3" % Test
"org.scalatest" %% "scalatest" % "3.2.5" % Test
)

// build.properties
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,20 @@ object PositiveLong {
def apply(str: String): PositiveLong = new PositiveLong(str.toLong)
}

// Minimal reproducing class for the first failure case.
// The `apply` methods have the same _parameter names_, which causes:
// Conflicting property-based creators: already had explicitly marked creator [method regression.ConflictingJsonCreator#apply(long)],
// encountered another: [method regression.ConflictingJsonCreator#apply(java.lang.String)]
class ConflictingJsonCreator private (val value: Long) {
override def toString() = s"ConflictingJsonCreator($value)"
}
object ConflictingJsonCreator {
@JsonCreator
def apply(value: Long): ConflictingJsonCreator = new ConflictingJsonCreator(value)
@JsonCreator
def apply(value: String): ConflictingJsonCreator = new ConflictingJsonCreator(value.toLong)
}

object CreatorTest
{
class CreatorTestBean(val a: String, var b: String)
Expand Down Expand Up @@ -163,4 +177,17 @@ class CreatorTest extends DeserializationFixture {
val node: JsonNode = f.valueToTree[IntNode](10)
f.convertValue(node, new TypeReference[PositiveLong] {}).value shouldEqual node.asLong()
}

it should "support multiple creator annotations with the same parameter names" in { f =>
val node: JsonNode = f.valueToTree[IntNode](10)
// Ensure that the parameters are actually named `value`
ConflictingJsonCreator(value=10L).value shouldEqual node.asLong()
ConflictingJsonCreator(value="10").value shouldEqual node.asLong()
f.convertValue(node, new TypeReference[ConflictingJsonCreator] {}).value shouldEqual node.asLong()
}

it should "not have a problem constructors and member name conflicts" in { f =>
val node: JsonNode = f.valueToTree[IntNode](10)
f.convertValue(node, new TypeReference[PositiveLong] {}).value shouldEqual node.asLong()
}
}