1
2
3
4
5 package com.jcabi.github.mock;
6
7 import com.jcabi.github.PullComment;
8 import jakarta.json.Json;
9 import java.io.IOException;
10 import org.hamcrest.MatcherAssert;
11 import org.hamcrest.Matchers;
12 import org.junit.jupiter.api.Test;
13
14
15
16
17
18 final class MkPullCommentTest {
19
20
21
22
23 @Test
24 void retrieveAsJson() throws Exception {
25 final PullComment comment = MkPullCommentTest.comment();
26 MatcherAssert.assertThat(
27 "String does not start with expected value",
28 comment.json().getString("url"),
29 Matchers.startsWith("http://")
30 );
31 }
32
33
34
35
36
37 @Test
38 void executePatchRequest() throws Exception {
39 final String path = "/path/to/file.txt";
40 final PullComment comment = MkPullCommentTest.comment();
41 comment.patch(Json.createObjectBuilder().add("path", path).build());
42 MatcherAssert.assertThat(
43 "String does not contain expected value",
44 comment.json().toString(),
45 Matchers.containsString(path)
46 );
47 }
48
49
50
51
52
53 private static PullComment comment() throws IOException {
54 return new MkGitHub()
55 .randomRepo()
56 .pulls()
57 .create("hello", "head", "base")
58 .comments()
59 .post("comment", "commit", "/", 1);
60 }
61 }