@@ -50,4 +50,97 @@ class UserSpecs extends FlatSpec with Matchers {
50
50
emails => emails.length shouldBe 3
51
51
)
52
52
}
53
+ it should " successfully parse a JSON into an array of Team" in {
54
+ val input = """
55
+ |[
56
+ |{
57
+ |"permission": "collaborator",
58
+ |"type": "team_permission",
59
+ |"user": {
60
+ |"username": "jllopes",
61
+ |"display_name": "João Lopes",
62
+ |"account_id": "123asdfas87afsd8f9asd7as",
63
+ |"links": {
64
+ |"self": {
65
+ |"href": "https://bitbucket.org/!api/2.0/users/jllopes"
66
+ |},
67
+ |"html": {
68
+ |"href": "https://bitbucket.org/jllopes/"
69
+ |},
70
+ |"avatar": {
71
+ |"href": "https://bitbucket.org/account/jllopes/avatar/"
72
+ |}
73
+ |},
74
+ |"nickname": "jllopes",
75
+ |"type": "user",
76
+ |"uuid": "{42417371-64fe-4cde-b528-b7454e8a0aaf}"
77
+ |},
78
+ |"team": {
79
+ |"username": "testteam1",
80
+ |"display_name": "TestTeam1",
81
+ |"type": "team",
82
+ |"uuid": "{85ea8027-2a7f-4094-828d-f20c935d373a}",
83
+ |"links": {
84
+ |"self": {
85
+ |"href": "https://bitbucket.org/!api/2.0/teams/testteam1"
86
+ |},
87
+ |"html": {
88
+ |"href": "https://bitbucket.org/testteam1/"
89
+ |},
90
+ |"avatar": {
91
+ |"href": "https://bitbucket.org/account/testteam1/avatar/"
92
+ |}
93
+ |}
94
+ |}
95
+ |},
96
+ |{
97
+ |"permission": "collaborator",
98
+ |"type": "team_permission",
99
+ |"user": {
100
+ |"username": "jllopes",
101
+ |"display_name": "João Lopes",
102
+ |"account_id": "123asdfas87afsd8f9asd7as",
103
+ |"links": {
104
+ |"self": {
105
+ |"href": "https://bitbucket.org/!api/2.0/users/jllopes"
106
+ |},
107
+ |"html": {
108
+ |"href": "https://bitbucket.org/jllopes/"
109
+ |},
110
+ |"avatar": {
111
+ |"href": "https://bitbucket.org/account/jllopes/avatar/"
112
+ |}
113
+ |},
114
+ |"nickname": "jllopes",
115
+ |"type": "user",
116
+ |"uuid": "{42417371-64fe-4cde-b528-b7454e8a0aaf}"
117
+ |},
118
+ |"team": {
119
+ |"username": "testteam2",
120
+ |"display_name": "TestTeam2",
121
+ |"type": "team",
122
+ |"uuid": "{7ec1171b-3df1-4c00-bfcf-2d4eda99e44a}",
123
+ |"links": {
124
+ |"self": {
125
+ |"href": "https://bitbucket.org/!api/2.0/teams/testteam2"
126
+ |},
127
+ |"html": {
128
+ |"href": "https://bitbucket.org/testteam2/"
129
+ |},
130
+ |"avatar": {
131
+ |"href": "https://bitbucket.org/account/testteam2/avatar/"
132
+ |}
133
+ |}
134
+ |}
135
+ |}
136
+ |]
137
+ """ .stripMargin
138
+ val json = Json .parse(input)
139
+ val value = json.validate[Seq [Team ]]
140
+
141
+ value.fold(e =>
142
+ fail(s " $e" ),
143
+ teams => teams.length shouldBe 2
144
+ )
145
+ }
53
146
}
0 commit comments