From f45057a05881638e87508eadfae35afab6130ee7 Mon Sep 17 00:00:00 2001 From: Hugh Simpson Date: Sat, 1 Feb 2025 10:32:52 +0000 Subject: [PATCH] add failing test --- .../scalaland/chimney/PatcherProductSpec.scala | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/chimney/src/test/scala/io/scalaland/chimney/PatcherProductSpec.scala b/chimney/src/test/scala/io/scalaland/chimney/PatcherProductSpec.scala index c39b76224..5526c4a31 100644 --- a/chimney/src/test/scala/io/scalaland/chimney/PatcherProductSpec.scala +++ b/chimney/src/test/scala/io/scalaland/chimney/PatcherProductSpec.scala @@ -3,6 +3,7 @@ package io.scalaland.chimney import io.scalaland.chimney.dsl.* import io.scalaland.chimney.fixtures.* +import java.util.UUID import scala.annotation.unused class PatcherProductSpec extends ChimneySpec { @@ -18,6 +19,21 @@ class PatcherProductSpec extends ChimneySpec { foo.using(bar).patch ==> Foo(10, "", 10.0) } + test( + """patch an product type object with a product type patch object containing a "subset" of fields including a UUID""" + ) { + case class Foo(id: Int, externalReference: UUID) + case class Bar(externalReference: UUID) + + val uuid1 = UUID.randomUUID() + val uuid2 = UUID.randomUUID() + val foo = Foo(42, uuid1) + val bar = Bar(uuid2) + + foo.patchUsing(bar) ==> Foo(42, uuid2) + foo.using(bar).patch ==> Foo(42, uuid2) + } + test( "patch a product with non-Option field with a product type patch object with all Option fields, applying value from Some and leaving original value in None" ) {