@@ -61,7 +61,7 @@ class DerivedTransformerSuite extends DucktapeSuite {
6161
6262 val actualComplex =
6363 List (
64- expectedPrimitive.transformInto [ComplexPerson ],
64+ expectedPrimitive.to [ComplexPerson ],
6565 expectedPrimitive.into[ComplexPerson ].transform(),
6666 expectedPrimitive.via(ComplexPerson .apply),
6767 expectedPrimitive.intoVia(ComplexPerson .apply).transform(),
@@ -71,7 +71,7 @@ class DerivedTransformerSuite extends DucktapeSuite {
7171
7272 val actualPrimitive =
7373 List (
74- expectedComplex.transformInto [PrimitivePerson ],
74+ expectedComplex.to [PrimitivePerson ],
7575 expectedComplex.into[PrimitivePerson ].transform(),
7676 expectedComplex.via(PrimitivePerson .apply),
7777 expectedComplex.intoVia(PrimitivePerson .apply).transform(),
@@ -105,7 +105,7 @@ class DerivedTransformerSuite extends DucktapeSuite {
105105
106106 val actualComplex =
107107 List (
108- primitive.transformInto [ComplexPerson ],
108+ primitive.to [ComplexPerson ],
109109 primitive.into[ComplexPerson ].transform(),
110110 primitive.via(ComplexPerson .apply),
111111 primitive.intoVia(ComplexPerson .apply).transform(),
@@ -126,12 +126,12 @@ class DerivedTransformerSuite extends DucktapeSuite {
126126 val expectedFromEnum2Mapping = expectedFromEnum1Mapping.map(_.swap)
127127
128128 Enum1 .values.foreach { value =>
129- val actual = value.transformInto [Enum2 ]
129+ val actual = value.to [Enum2 ]
130130 assertEquals(expectedFromEnum1Mapping(value), actual)
131131 }
132132
133133 Enum2 .values.foreach { value =>
134- val actual = value.transformInto [Enum1 ]
134+ val actual = value.to [Enum1 ]
135135 assertEquals(expectedFromEnum2Mapping(value), actual)
136136 }
137137 }
@@ -144,7 +144,7 @@ class DerivedTransformerSuite extends DucktapeSuite {
144144 val expected = LessFields (1 , 2 , 3 )
145145 val actual =
146146 List (
147- more.transformInto [LessFields ],
147+ more.to [LessFields ],
148148 more.into[LessFields ].transform(),
149149 more.via(LessFields .apply),
150150 more.intoVia(LessFields .apply).transform(),
@@ -170,7 +170,7 @@ class DerivedTransformerSuite extends DucktapeSuite {
170170
171171 val actual =
172172 List (
173- person.transformInto [Person2 ],
173+ person.to [Person2 ],
174174 person.into[Person2 ].transform(),
175175 person.via(Person2 .apply),
176176 person.intoVia(Person2 .apply).transform(),
@@ -185,8 +185,8 @@ class DerivedTransformerSuite extends DucktapeSuite {
185185 val wrappedString = Wrapped (" asd" )
186186 val unwrapped = " asd"
187187
188- assertEquals(wrappedString.transformInto [String ], unwrapped)
189- assertEquals(unwrapped.transformInto [Wrapped [String ]], wrappedString)
188+ assertEquals(wrappedString.to [String ], unwrapped)
189+ assertEquals(unwrapped.to [Wrapped [String ]], wrappedString)
190190 }
191191
192192 test(" products with AnyVal fields with type params roundrip to their primitives" ) {
@@ -198,7 +198,7 @@ class DerivedTransformerSuite extends DucktapeSuite {
198198
199199 val actualUnwrapped =
200200 List (
201- person.transformInto [UnwrappedPerson [Long ]],
201+ person.to [UnwrappedPerson [Long ]],
202202 person.into[UnwrappedPerson [Long ]].transform(),
203203 person.via(UnwrappedPerson .apply[Long ]),
204204 person.intoVia(UnwrappedPerson .apply[Long ]).transform(),
@@ -208,7 +208,7 @@ class DerivedTransformerSuite extends DucktapeSuite {
208208
209209 val actualPerson =
210210 List (
211- unwrapped.transformInto [Person [Long ]],
211+ unwrapped.to [Person [Long ]],
212212 unwrapped.into[Person [Long ]].transform(),
213213 unwrapped.via(Person .apply[Long ]),
214214 unwrapped.intoVia(Person .apply[Long ]).transform(),
@@ -220,6 +220,27 @@ class DerivedTransformerSuite extends DucktapeSuite {
220220 actualPerson.foreach(actual => assertEquals(actual, person))
221221 }
222222
223+ test(" transformers are derived for products with supertypes of the original product type" ) {
224+ case class ProductSuper (iterable : Iterable [CharSequence ], number : Number , charSeq : CharSequence )
225+ case class ProductSub (iterable : List [String ], number : java.lang.Integer , charSeq : String )
226+
227+ val prodSub = ProductSub (List (" test" ), 1 , " test" )
228+ val expected = ProductSuper (Iterable (" test" ), 1 , " test" )
229+
230+ val actual =
231+ List (
232+ prodSub.to[ProductSuper ],
233+ prodSub.into[ProductSuper ].transform(),
234+ prodSub.via(ProductSuper .apply),
235+ prodSub.intoVia(ProductSuper .apply).transform(),
236+ Transformer .define[ProductSub , ProductSuper ].build().transform(prodSub),
237+ Transformer .defineVia[ProductSub ](ProductSuper .apply).build().transform(prodSub),
238+ )
239+
240+ actual.foreach(assertEquals(_, expected))
241+ }
242+
243+
223244 test(" derivation fails when going from a product with less fields to a product with more fields" ) {
224245 assertFailsToCompileWith {
225246 """
@@ -228,7 +249,7 @@ class DerivedTransformerSuite extends DucktapeSuite {
228249
229250 val less = LessFields(1, 2, 3)
230251
231- val derived = less.transformInto [MoreFields]
252+ val derived = less.to [MoreFields]
232253 """
233254 }(" No field named 'field4' found in LessFields" )
234255 }
@@ -242,6 +263,6 @@ class DerivedTransformerSuite extends DucktapeSuite {
242263 }
243264
244265 test(" derivation fails when going from a sum with more cases to a sum with less cases" ) {
245- assertFailsToCompileWith(" MoreCases.Case3.transformInto [LessCases]" )(" No child named 'Case4' found in LessCases" )
266+ assertFailsToCompileWith(" MoreCases.Case3.to [LessCases]" )(" No child named 'Case4' found in LessCases" )
246267 }
247268}
0 commit comments