@@ -8,6 +8,7 @@ import ch.linkyard.scim.model.User.UserRef
8
8
import ch .linkyard .scim .model .Codecs .given
9
9
10
10
import java .net .URI
11
+ import ch .linkyard .scim .model .User .ValueWithTypeAndDisplay
11
12
12
13
class UserSpec extends AnyFunSpec with Matchers with OptionValues {
13
14
@@ -28,12 +29,35 @@ class UserSpec extends AnyFunSpec with Matchers with OptionValues {
28
29
json should include(" urn:ietf:params:scim:schemas:core:2.0:User" )
29
30
}
30
31
32
+ it(" should serialize primary email" ) {
33
+ val json = User (User .Root (
34
+ id = Some (" 2819c223-7f76-453a-919d-413861904646" ),
35
+
36
+ emails
= Some (
List (
ValueWithTypeAndDisplay (
Some (
" [email protected] " ),
None ,
None ,
Some (
true ))))
37
+ )).json.noSpaces
38
+ json should include(
""" {"value":"[email protected] ","primary":true}""" )
39
+ }
40
+
41
+ it(" should serialize multiple emails with type" ) {
42
+ val json = User (User .Root (
43
+ id = Some (" 2819c223-7f76-453a-919d-413861904646" ),
44
+
45
+ emails = Some (List (
46
+ ValueWithTypeAndDisplay (
Some (
" [email protected] " ),
Some (
" work" ),
None ,
Some (
true )),
47
+ ValueWithTypeAndDisplay (
Some (
" [email protected] " ),
Some (
" home" ),
None ),
48
+ ))
49
+ )).json.noSpaces
50
+ json should include(
""" {"value":"[email protected] ","display":"work","primary":true}""" )
51
+ json should include(
""" {"value":"[email protected] ","display":"home"}""" )
52
+ }
53
+
31
54
it(" should parse 'userMinimal'" ) {
32
55
val root = User (Jsons .userMinimal).rootOrDefault
33
56
root.userName should be(
" [email protected] " )
34
57
root.id.value should be(" 2819c223-7f76-453a-919d-413861904646" )
35
58
root.name should be(None )
36
59
}
60
+
37
61
it(" should parse 'userMinimalExternal'" ) {
38
62
val root = User (Jsons .userMinimalExternal).rootOrDefault
39
63
root.userName should be(
" [email protected] " )
0 commit comments