Files
github-api/src/test/java/org/kohsuke/github/GHIssueEventTest.java
Liam Newman 9d8460bb81 Enable automatic code formatter with CI validation
This may be controversial but it we're doing it. Having code formatting needs to be consistent
and a non-issue during code review. I'm willing modify the configuration if people see a strong
need, but formatting needs to be present and enforced.
2019-11-13 13:28:23 -08:00

61 lines
1.8 KiB
Java

package org.kohsuke.github;
import java.io.IOException;
import java.util.List;
import org.junit.Test;
/**
* @author Martin van Zijl
*/
public class GHIssueEventTest extends AbstractGitHubApiTestBase {
@Test
public void testEventsForSingleIssue() throws Exception {
// Create the issue.
GHRepository repo = getRepository();
GHIssueBuilder builder = repo.createIssue("Test from the API");
GHIssue issue = builder.create();
// Generate some events.
issue.addLabels("test-label");
// Test that the events are present.
List<GHIssueEvent> list = issue.listEvents().asList();
assertEquals(1, list.size());
GHIssueEvent event = list.get(0);
assertEquals(issue.getNumber(), event.getIssue().getNumber());
assertEquals("labeled", event.getEvent());
// Test that we can get a single event directly.
GHIssueEvent eventFromRepo = repo.getIssueEvent(event.getId());
assertEquals(event.getId(), eventFromRepo.getId());
assertEquals(event.getCreatedAt(), eventFromRepo.getCreatedAt());
// Close the issue.
issue.close();
}
@Test
public void testRepositoryEvents() throws Exception {
GHRepository repo = getRepository();
List<GHIssueEvent> list = repo.listIssueEvents().asList();
assertTrue(list.size() > 0);
int i = 0;
for (GHIssueEvent event : list) {
assertNotNull(event.getIssue());
if (i++ > 10)
break;
}
}
protected GHRepository getRepository() throws IOException {
return getRepository(gitHub);
}
private GHRepository getRepository(GitHub gitHub) throws IOException {
return gitHub.getOrganization("github-api-test-org").getRepository("github-api");
}
}