|
| 1 | +package com.codacy.client.bitbucket.v2 |
| 2 | + |
| 3 | +import org.scalatest.{Matchers, _} |
| 4 | +import play.api.libs.json.Json |
| 5 | + |
| 6 | +class IssueSpecs extends FlatSpec with Matchers { |
| 7 | + |
| 8 | + "IssueSpecs" should "successfully parse Issue" in { |
| 9 | + val input = |
| 10 | + """ |
| 11 | + |{ |
| 12 | + | "priority": "major", |
| 13 | + | "kind": "bug", |
| 14 | + | "repository": { |
| 15 | + | "links": { |
| 16 | + | "self": { |
| 17 | + | "href": "https://bitbucket.org/!api/2.0/repositories/mrfyda/scalatests" |
| 18 | + | }, |
| 19 | + | "html": { |
| 20 | + | "href": "https://bitbucket.org/mrfyda/scalatests" |
| 21 | + | }, |
| 22 | + | "avatar": { |
| 23 | + | "href": "https://bytebucket.org/ravatar/%7B75411621-5a51-4bd4-a982-1d86cedd309e%7D?ts=default" |
| 24 | + | } |
| 25 | + | }, |
| 26 | + | "type": "repository", |
| 27 | + | "name": "ScalaTests", |
| 28 | + | "full_name": "mrfyda/scalatests", |
| 29 | + | "uuid": "{75411621-5a51-4bd4-a982-1d86cedd309e}" |
| 30 | + | }, |
| 31 | + | "links": { |
| 32 | + | "attachments": { |
| 33 | + | "href": "https://bitbucket.org/!api/2.0/repositories/mrfyda/scalatests/issues/1/attachments" |
| 34 | + | }, |
| 35 | + | "self": { |
| 36 | + | "href": "https://bitbucket.org/!api/2.0/repositories/mrfyda/scalatests/issues/1" |
| 37 | + | }, |
| 38 | + | "watch": { |
| 39 | + | "href": "https://bitbucket.org/!api/2.0/repositories/mrfyda/scalatests/issues/1/watch" |
| 40 | + | }, |
| 41 | + | "comments": { |
| 42 | + | "href": "https://bitbucket.org/!api/2.0/repositories/mrfyda/scalatests/issues/1/comments" |
| 43 | + | }, |
| 44 | + | "html": { |
| 45 | + | "href": "https://bitbucket.org/mrfyda/scalatests/issues/1/2e95d690c2c58a72e1a0bb4cd76808a4c0c60db4" |
| 46 | + | }, |
| 47 | + | "vote": { |
| 48 | + | "href": "https://bitbucket.org/!api/2.0/repositories/mrfyda/scalatests/issues/1/vote" |
| 49 | + | } |
| 50 | + | }, |
| 51 | + | "reporter": { |
| 52 | + | "username": "mrfyda", |
| 53 | + | "display_name": "Rafael Cortês", |
| 54 | + | "account_id": "557058:cb3153a1-1a69-4374-a536-fefac8f1cc64", |
| 55 | + | "links": { |
| 56 | + | "self": { |
| 57 | + | "href": "https://bitbucket.org/!api/2.0/users/mrfyda" |
| 58 | + | }, |
| 59 | + | "html": { |
| 60 | + | "href": "https://bitbucket.org/mrfyda/" |
| 61 | + | }, |
| 62 | + | "avatar": { |
| 63 | + | "href": "https://bitbucket.org/account/mrfyda/avatar/" |
| 64 | + | } |
| 65 | + | }, |
| 66 | + | "type": "user", |
| 67 | + | "uuid": "{1e960327-38ba-4100-919e-5a677e668cad}" |
| 68 | + | }, |
| 69 | + | "title": "2e95d690c2c58a72e1a0bb4cd76808a4c0c60db4", |
| 70 | + | "component": null, |
| 71 | + | "votes": 0, |
| 72 | + | "watches": 1, |
| 73 | + | "content": { |
| 74 | + | "raw": "hello world", |
| 75 | + | "markup": "markdown", |
| 76 | + | "html": "<p>hello world</p>", |
| 77 | + | "type": "rendered" |
| 78 | + | }, |
| 79 | + | "assignee": null, |
| 80 | + | "state": "new", |
| 81 | + | "version": null, |
| 82 | + | "edited_on": null, |
| 83 | + | "created_on": "2018-09-02T09:08:01.435083+00:00", |
| 84 | + | "milestone": null, |
| 85 | + | "updated_on": "2018-09-02T09:08:01.435083+00:00", |
| 86 | + | "type": "issue", |
| 87 | + | "id": 1 |
| 88 | + |} |
| 89 | + """.stripMargin |
| 90 | + val json = Json.parse(input) |
| 91 | + val value = json.validate[Issue] |
| 92 | + |
| 93 | + value.fold(e => |
| 94 | + fail(s"$e"), |
| 95 | + r => r.id shouldBe 1 |
| 96 | + ) |
| 97 | + } |
| 98 | + |
| 99 | +} |
0 commit comments