@@ -265,4 +265,126 @@ class RemoteRepositorySpecs extends FlatSpec with Matchers {
265265
266266 parsed shouldBe true
267267 }
268+
269+ it should " successfully parse a JSON with null author while getting info for PRs" in {
270+
271+ val input =
272+ """
273+ |{
274+ | "description": "",
275+ | "links": {
276+ | "decline": {
277+ | "href": "https://bitbucket.org/wtv"
278+ | },
279+ | "commits": {
280+ | "href": "https://bitbucket.org/wtv"
281+ | },
282+ | "self": {
283+ | "href": "https://bitbucket.org/wtv"
284+ | },
285+ | "comments": {
286+ | "href": "https://bitbucket.org/wtv"
287+ | },
288+ | "merge": {
289+ | "href": "https://bitbucket.org/wtv"
290+ | },
291+ | "html": {
292+ | "href": "https://bitbucket.org/wtv"
293+ | },
294+ | "activity": {
295+ | "href": "https://bitbucket.org/wtv"
296+ | },
297+ | "diff": {
298+ | "href": "https://bitbucket.org/wtv"
299+ | },
300+ | "approve": {
301+ | "href": "https://bitbucket.org/wtv"
302+ | },
303+ | "statuses": {
304+ | "href": "https://bitbucket.org/wtv"
305+ | }
306+ | },
307+ | "title": "Potatos",
308+ | "close_source_branch": true,
309+ | "merge_commit": null,
310+ | "destination": {
311+ | "commit": {
312+ | "hash": "aaaaaaaaaaaa",
313+ | "links": {
314+ | "self": {
315+ | "href": "https://bitbucket.org/wtv"
316+ | }
317+ | }
318+ | },
319+ | "repository": {
320+ | "links": {
321+ | "self": {
322+ | "href": "https://bitbucket.org/wtv"
323+ | },
324+ | "html": {
325+ | "href": "https://bitbucket.org/wtv"
326+ | },
327+ | "avatar": {
328+ | "href": "https://bitbucket.org/wtv"
329+ | }
330+ | },
331+ | "type": "repository",
332+ | "name": "my-potatos",
333+ | "full_name": "codacy/my-potatos",
334+ | "uuid": "{70bb8ec5-0c14-4964-aaaa-ebb4b2235ecf}"
335+ | },
336+ | "branch": {
337+ | "name": "master"
338+ | }
339+ | },
340+ | "state": "OPEN",
341+ | "closed_by": null,
342+ | "source": {
343+ | "commit": {
344+ | "hash": "bbbbbbbbbbbb",
345+ | "links": {
346+ | "self": {
347+ | "href": "https://bitbucket.org/wtv"
348+ | }
349+ | }
350+ | },
351+ | "repository": {
352+ | "links": {
353+ | "self": {
354+ | "href": "https://bitbucket.org/wtv"
355+ | },
356+ | "html": {
357+ | "href": "https://bitbucket.org/wtv"
358+ | },
359+ | "avatar": {
360+ | "href": "https://bitbucket.org/wtv"
361+ | }
362+ | },
363+ | "type": "repository",
364+ | "name": "my-potatos",
365+ | "full_name": "codacy/my-potatos",
366+ | "uuid": "{c08af10a-b49f-4a7a-9edb-6a66b3495a6f}"
367+ | },
368+ | "branch": {
369+ | "name": "add-more-potatos"
370+ | }
371+ | },
372+ | "comment_count": 0,
373+ | "author": null,
374+ | "created_on": "2016-04-05T14:35:41.678131+00:00",
375+ | "reason": "",
376+ | "updated_on": "2016-11-01T14:25:45.932586+00:00",
377+ | "type": "pullrequest",
378+ | "id": 333,
379+ | "task_count": 0
380+ |}
381+ """ .stripMargin
382+ val json = Json .parse(input)
383+ val value = json.validate[PullRequest ]
384+
385+ val parsed = value.fold(e => false , r => r.destCommit.isDefined)
386+
387+ parsed shouldBe true
388+
389+ }
268390}
0 commit comments