This repository has been archived by the owner on Apr 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support case classes with private constructors
- Loading branch information
1 parent
8dcca02
commit da94f11
Showing
2 changed files
with
18 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
import java.time.ZonedDateTime | ||
import java.util.Date | ||
|
||
import com.softwaremill.macros.customize.{customize, mask} | ||
import org.scalatest.{FlatSpec, Matchers} | ||
|
@@ -26,11 +25,26 @@ class ToStringMaskTest extends FlatSpec with Matchers { | |
// then | ||
u.toString should be("User30(2,***)") | ||
} | ||
|
||
it should "work on case classes with private constructors" in { | ||
// given | ||
val u = UserPrivate("[email protected]") | ||
|
||
// then | ||
u.toString should be("UserPrivate(1,***)") | ||
} | ||
} | ||
|
||
@customize | ||
case class User30(id: Int, @mask email: String) | ||
|
||
@customize | ||
case class UserPrivate private(id: Int, @mask email: String) | ||
|
||
object UserPrivate { | ||
def apply(email: String) = new UserPrivate(1, email) | ||
} | ||
|
||
object User30 { | ||
def apply(id: Int) = new User30(id, "[email protected]") | ||
} |