blob: 6cdf90e23d4945c00c613e7943b4fb859d570351 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
/*******************************************************************************
* Copyright (c) 2011 GitHub Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Kevin Sawicki (GitHub Inc.) - initial API and implementation
*******************************************************************************/
package org.eclipse.egit.github.core.tests.live;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import java.io.IOException;
import java.util.List;
import org.eclipse.egit.github.core.CommitComment;
import org.eclipse.egit.github.core.PullRequest;
import org.eclipse.egit.github.core.PullRequestMarker;
import org.eclipse.egit.github.core.Repository;
import org.eclipse.egit.github.core.RepositoryId;
import org.eclipse.egit.github.core.SearchRepository;
import org.eclipse.egit.github.core.User;
import org.eclipse.egit.github.core.service.IssueService;
import org.eclipse.egit.github.core.service.PullRequestService;
import org.junit.Test;
/**
* Live pull request tests
*/
public class PullRequestTest extends LiveTest {
private void checkMarker(PullRequestMarker marker) {
assertNotNull(marker);
assertNotNull(marker.getLabel());
assertNotNull(marker.getSha());
assertNotNull(marker.getRef());
User user = marker.getUser();
assertNotNull(user);
assertNotNull(user.getLogin());
Repository repo = marker.getRepo();
assertNotNull(repo);
assertNotNull(repo.getOwner());
assertNotNull(repo.getName());
}
/**
* Test fetching a pull request
*
* @throws IOException
*/
@Test
public void fetch() throws IOException {
PullRequestService service = new PullRequestService(client);
PullRequest request = service.getPullRequest(new SearchRepository(
"technoweenie", "faraday"), 15);
assertNotNull(request);
assertNotNull(request.getHtmlUrl());
assertNotNull(request.getDiffUrl());
assertNotNull(request.getPatchUrl());
checkMarker(request.getHead());
checkMarker(request.getBase());
}
/**
* Test fetching all pull requests
*
* @throws IOException
*/
@Test
public void fetchAll() throws IOException {
PullRequestService service = new PullRequestService(client);
List<PullRequest> requests = service.getPullRequests(
new SearchRepository("technoweenie", "faraday"),
IssueService.STATE_CLOSED);
assertNotNull(requests);
assertFalse(requests.isEmpty());
for (PullRequest request : requests) {
assertNotNull(request);
assertNotNull(request.getUpdatedAt());
assertNotNull(request.getCreatedAt());
assertNotNull(request.getHtmlUrl());
assertNotNull(request.getDiffUrl());
assertNotNull(request.getPatchUrl());
}
}
/**
* Test getting pull request comments
*
* @throws IOException
*/
@Test
public void fetchComments() throws IOException {
PullRequestService service = new PullRequestService(client);
RepositoryId repo = RepositoryId.create("defunkt", "resque");
List<CommitComment> comments = service.getComments(repo, 277);
assertNotNull(comments);
assertFalse(comments.isEmpty());
for (CommitComment comment : comments) {
assertNotNull(comment);
assertNotNull(comment.getUrl());
assertNotNull(comment.getBody());
CommitComment fetched = service.getComment(repo, comment.getId());
assertNotNull(fetched);
assertEquals(comment.getId(), fetched.getId());
assertEquals(comment.getUrl(), fetched.getUrl());
assertEquals(comment.getBody(), fetched.getBody());
}
}
}
|