1
2
3
4
5 package com.jcabi.github;
6
7 import jakarta.json.Json;
8 import jakarta.json.JsonObject;
9 import java.io.IOException;
10 import org.apache.commons.lang3.RandomStringUtils;
11 import org.hamcrest.MatcherAssert;
12 import org.hamcrest.Matchers;
13 import org.junit.jupiter.api.AfterAll;
14 import org.junit.jupiter.api.BeforeAll;
15 import org.junit.jupiter.api.Test;
16
17
18
19
20
21
22 @OAuthScope(OAuthScope.Scope.REPO)
23 final class RtReleaseITCase {
24
25
26
27
28 private static Repos repos;
29
30
31
32
33 private static Repo repo;
34
35
36
37
38
39 private static RepoRule rule = new RepoRule();
40
41
42
43
44 @BeforeAll
45 static void setUp() throws IOException {
46 final GitHub github = GitHubIT.connect();
47 RtReleaseITCase.repos = github.repos();
48 RtReleaseITCase.repo = RtReleaseITCase.rule.repo(RtReleaseITCase.repos);
49 }
50
51
52
53
54 @AfterAll
55 static void tearDown() throws IOException {
56 if (RtReleaseITCase.repos != null && RtReleaseITCase.repo != null) {
57 RtReleaseITCase.repos.remove(RtReleaseITCase.repo.coordinates());
58 }
59 }
60
61 @Test
62 void canEditRelease() throws IOException {
63 final Release release = RtReleaseITCase.repo.releases().create(
64 RandomStringUtils.secure().nextAlphanumeric(10)
65 );
66 final JsonObject patch = Json.createObjectBuilder()
67 .add("tag_name", RandomStringUtils.secure().nextAlphanumeric(10))
68 .add("name", "jcabi GitHub test release")
69 .add("body", "jcabi GitHub was here!")
70 .build();
71 release.patch(patch);
72 final JsonObject json = RtReleaseITCase.repo.releases()
73 .get(release.number()).json();
74 for (final String property : patch.keySet()) {
75 MatcherAssert.assertThat(
76 "Values are not equal",
77 json.getString(property),
78 Matchers.equalTo(patch.getString(property))
79 );
80 }
81 }
82
83 }