Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
SfIssue |
|
| 1.1818181818181819;1.182 | ||||
SfIssue$AjcClosure1 |
|
| 1.1818181818181819;1.182 | ||||
SfIssue$AjcClosure11 |
|
| 1.1818181818181819;1.182 | ||||
SfIssue$AjcClosure13 |
|
| 1.1818181818181819;1.182 | ||||
SfIssue$AjcClosure15 |
|
| 1.1818181818181819;1.182 | ||||
SfIssue$AjcClosure17 |
|
| 1.1818181818181819;1.182 | ||||
SfIssue$AjcClosure3 |
|
| 1.1818181818181819;1.182 | ||||
SfIssue$AjcClosure5 |
|
| 1.1818181818181819;1.182 | ||||
SfIssue$AjcClosure7 |
|
| 1.1818181818181819;1.182 | ||||
SfIssue$AjcClosure9 |
|
| 1.1818181818181819;1.182 |
1 | 0 | /** |
2 | * Copyright (c) 2013-2017, jcabi.com | |
3 | * All rights reserved. | |
4 | * | |
5 | * Redistribution and use in source and binary forms, with or without | |
6 | * modification, are permitted provided that the following conditions | |
7 | * are met: 1) Redistributions of source code must retain the above | |
8 | * copyright notice, this list of conditions and the following | |
9 | * disclaimer. 2) Redistributions in binary form must reproduce the above | |
10 | * copyright notice, this list of conditions and the following | |
11 | * disclaimer in the documentation and/or other materials provided | |
12 | * with the distribution. 3) Neither the name of the jcabi.com nor | |
13 | * the names of its contributors may be used to endorse or promote | |
14 | * products derived from this software without specific prior written | |
15 | * permission. | |
16 | * | |
17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
18 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT | |
19 | * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND | |
20 | * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL | |
21 | * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | |
22 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
23 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
24 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | |
26 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | |
28 | * OF THE POSSIBILITY OF SUCH DAMAGE. | |
29 | */ | |
30 | package com.jcabi.github.safe; | |
31 | ||
32 | import com.jcabi.aspects.Immutable; | |
33 | import com.jcabi.aspects.Loggable; | |
34 | import com.jcabi.github.Comments; | |
35 | import com.jcabi.github.Event; | |
36 | import com.jcabi.github.Issue; | |
37 | import com.jcabi.github.IssueLabels; | |
38 | import com.jcabi.github.Repo; | |
39 | import com.jcabi.github.mock.MkGithub; | |
40 | import com.jcabi.log.Logger; | |
41 | import java.io.IOException; | |
42 | import javax.json.JsonObject; | |
43 | import lombok.EqualsAndHashCode; | |
44 | ||
45 | /** | |
46 | * Safe issue. | |
47 | * | |
48 | * @author Yegor Bugayenko (yegor@tpc2.com) | |
49 | * @version $Id: 9d4c330ed45d61bc18095a742992b884897f67fa $ | |
50 | * @since 0.36 | |
51 | */ | |
52 | 0 | @Immutable |
53 | @Loggable(Loggable.DEBUG) | |
54 | 0 | @EqualsAndHashCode(of = "origin") |
55 | public final class SfIssue implements Issue { | |
56 | ||
57 | /** | |
58 | * Original issue. | |
59 | */ | |
60 | private final transient Issue origin; | |
61 | ||
62 | /** | |
63 | * Public ctor. | |
64 | * @param issue The original issue | |
65 | */ | |
66 | 0 | public SfIssue(final Issue issue) { |
67 | 0 | this.origin = issue; |
68 | 0 | } |
69 | ||
70 | @Override | |
71 | public String toString() { | |
72 | 0 | return this.origin.toString(); |
73 | } | |
74 | ||
75 | @Override | |
76 | public JsonObject json() throws IOException { | |
77 | JsonObject json; | |
78 | try { | |
79 | 0 | json = this.origin.json(); |
80 | 0 | } catch (final AssertionError ex) { |
81 | 0 | json = new MkGithub().randomRepo() |
82 | 0 | .issues().create("", "").json(); |
83 | 0 | Logger.warn(this, "failed to fetch issue: %[exception]s", ex); |
84 | 0 | } |
85 | 0 | return json; |
86 | } | |
87 | ||
88 | @Override | |
89 | public void patch(final JsonObject json) throws IOException { | |
90 | try { | |
91 | 0 | this.origin.patch(json); |
92 | 0 | } catch (final AssertionError ex) { |
93 | 0 | Logger.warn(this, "failed to patch issue: %[exception]s", ex); |
94 | 0 | } |
95 | 0 | } |
96 | ||
97 | @Override | |
98 | public Repo repo() { | |
99 | 0 | return this.origin.repo(); |
100 | } | |
101 | ||
102 | @Override | |
103 | public int number() { | |
104 | 0 | return this.origin.number(); |
105 | } | |
106 | ||
107 | @Override | |
108 | public Comments comments() { | |
109 | 0 | return new SfComments(this.origin.comments()); |
110 | } | |
111 | ||
112 | @Override | |
113 | public IssueLabels labels() { | |
114 | 0 | return this.origin.labels(); |
115 | } | |
116 | ||
117 | @Override | |
118 | public Iterable<Event> events() throws IOException { | |
119 | 0 | return this.origin.events(); |
120 | } | |
121 | ||
122 | @Override | |
123 | public boolean exists() throws IOException { | |
124 | 0 | return this.origin.exists(); |
125 | } | |
126 | ||
127 | @Override | |
128 | public int compareTo(final Issue issue) { | |
129 | 0 | return this.origin.compareTo(issue); |
130 | } | |
131 | } |