本文整理汇总了Java中com.jcabi.github.Github类的典型用法代码示例。如果您正苦于以下问题:Java Github类的具体用法?Java Github怎么用?Java Github使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Github类属于com.jcabi.github包,在下文中一共展示了Github类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: originalWorksFine
import com.jcabi.github.Github; //导入依赖的package包/类
/**
* The original Action works fine, throws no exception, so no Github Issue
* should be opened.
* @throws Exception If something goes wrong.
*/
@Test
public void originalWorksFine() throws Exception {
final Github github = this.mockGithub();
final Action original = this.mockAction();
Mockito.doNothing().when(original).perform();
final Action vigilant = new VigilantAction(original, github);
vigilant.perform();
final Issues all = github.repos()
.get(new Coordinates.Simple("amihaiemil/comdor"))
.issues();
MatcherAssert.assertThat(
all.iterate(new HashMap<>()),
Matchers.iterableWithSize(0)
);
}
开发者ID:amihaiemil,项目名称:comdor,代码行数:23,代码来源:VigilantActionTestCase.java
示例2: perform
import com.jcabi.github.Github; //导入依赖的package包/类
@Override
public void perform(Command command, Logger logger) throws IOException {
final String author = command.authorLogin();
final Github github = command.issue().repo().github();
final Request follow = github.entry()
.uri().path("/user/following/").path(author).back()
.method("PUT");
logger.info("Following Github user " + author + " ...");
try {
final int status = follow.fetch().status();
if(status != HttpURLConnection.HTTP_NO_CONTENT) {
logger.error("User follow status response is " + status + " . Should have been 204 (NO CONTENT)");
} else {
logger.info("Followed user " + author + " .");
}
} catch (final IOException ex) {//don't rethrow, this is just a cosmetic step, not critical.
logger.error("IOException while trying to follow the user.");
}
this.next().perform(command, logger);
}
开发者ID:opencharles,项目名称:charles-rest,代码行数:21,代码来源:Follow.java
示例3: getsAuthorEmail
import com.jcabi.github.Github; //导入依赖的package包/类
@Test
public void getsAuthorEmail() throws Exception {
MkStorage storage = new MkStorage.Synced(new MkStorage.InFile());
MkGithub authorGh = new MkGithub(storage, "amihaiemil");
authorGh.users().self().emails().add(Arrays.asList("[email protected]"));
Repo authorRepo = authorGh.randomRepo();
Comment com = authorRepo.issues().create("", "").comments().post("@charlesmike do something");
Github agentGh = new MkGithub(storage, "charlesmike");
Issue issue = agentGh.repos().get(authorRepo.coordinates()).issues().get(com.issue().number());
Command comm = Mockito.mock(Command.class);
JsonObject authorInfo = Json.createObjectBuilder().add("login", "amihaiemil").build();
JsonObject json = Json.createObjectBuilder()
.add("user", authorInfo)
.add("body", com.json().getString("body"))
.add("id", 2)
.build();
Mockito.when(comm.json()).thenReturn(json);
Mockito.when(comm.issue()).thenReturn(issue);
ValidCommand vc = new ValidCommand(comm);
assertTrue(vc.authorEmail().equals("[email protected]"));
}
开发者ID:opencharles,项目名称:charles-rest,代码行数:26,代码来源:ValidCommandTestCase.java
示例4: starsRepo
import com.jcabi.github.Github; //导入依赖的package包/类
/**
* StarRepo can successfully star a given repository.
* @throws Exception If something goes wrong.
*/
@Test
public void starsRepo() throws Exception {
Logger logger = Mockito.mock(Logger.class);
Mockito.doNothing().when(logger).info(Mockito.anyString());
Mockito.doThrow(new IllegalStateException("Unexpected error; test failed")).when(logger).error(Mockito.anyString());
Github gh = new MkGithub("amihaiemil");
Repo repo = gh.repos().create(
new RepoCreate("amihaiemil.github.io", false)
);
Command com = Mockito.mock(Command.class);
Issue issue = Mockito.mock(Issue.class);
Mockito.when(issue.repo()).thenReturn(repo);
Mockito.when(com.issue()).thenReturn(issue);
Step sr = new StarRepo(Mockito.mock(Step.class));
assertFalse(com.issue().repo().stars().starred());
sr.perform(com, logger);
assertTrue(com.issue().repo().stars().starred());
}
开发者ID:opencharles,项目名称:charles-rest,代码行数:25,代码来源:StarRepoTestCase.java
示例5: starsRepoTwice
import com.jcabi.github.Github; //导入依赖的package包/类
/**
* StarRepo tries to star a repo twice.
* @throws Exception If something goes wrong.
*/
@Test
public void starsRepoTwice() throws Exception {
Logger logger = Mockito.mock(Logger.class);
Mockito.doNothing().when(logger).info(Mockito.anyString());
Mockito.doThrow(new IllegalStateException("Unexpected error; test failed")).when(logger).error(Mockito.anyString());
Github gh = new MkGithub("amihaiemil");
Repo repo = gh.repos().create(
new RepoCreate("amihaiemil.github.io", false)
);
Command com = Mockito.mock(Command.class);
Issue issue = Mockito.mock(Issue.class);
Mockito.when(issue.repo()).thenReturn(repo);
Mockito.when(com.issue()).thenReturn(issue);
Step sr = new StarRepo(Mockito.mock(Step.class));
assertFalse(com.issue().repo().stars().starred());
sr.perform(com, logger);
sr.perform(com, logger);
assertTrue(com.issue().repo().stars().starred());
}
开发者ID:opencharles,项目名称:charles-rest,代码行数:26,代码来源:StarRepoTestCase.java
示例6: mockCommand
import com.jcabi.github.Github; //导入依赖的package包/类
/**
* Mock a Github command where the agent is mentioned.
* @return The created Command.
* @throws IOException If something goes wrong.
*/
public Command mockCommand(String msg) throws IOException {
Github gh = new MkGithub("amihaiemil");
RepoCreate repoCreate = new RepoCreate("amihaiemil.github.io", false);
gh.repos().create(repoCreate);
Issue issue = gh.repos().get(
new Coordinates.Simple("amihaiemil", "amihaiemil.github.io")
).issues().create("Test issue for commands", "test body");
Comment c = issue.comments().post(msg);
Command com = Mockito.mock(Command.class);
Mockito.when(com.json()).thenReturn(c.json());
Mockito.when(com.issue()).thenReturn(issue);
return com;
}
开发者ID:opencharles,项目名称:charles-rest,代码行数:22,代码来源:TextReplyTestCase.java
示例7: agentRepliedAlreadyToTheLastComment
import com.jcabi.github.Github; //导入依赖的package包/类
/**
* Agent already replied once to the last comment.
* @throws Exception if something goes wrong.
*/
@Test
public void agentRepliedAlreadyToTheLastComment() throws Exception {
final MkStorage storage = new MkStorage.Synced(new MkStorage.InFile());
final Repo repoMihai = new MkGithub(storage, "amihaiemil").repos().create( new RepoCreate("amihaiemil.github.io", false));
final Issue issue = repoMihai.issues().create("test issue", "body");
issue.comments().post("@charlesmike hello!");
final Github charlesmike = new MkGithub(storage, "charlesmike");
Issue issueCharlesmike = charlesmike.repos().get(repoMihai.coordinates()).issues().get(issue.number());
issueCharlesmike.comments().post("@amihaiemil hi there, I can help you index... ");
issue.comments().post("@someoneelse, please check that...");
LastComment lastComment = new LastComment(issueCharlesmike);
JsonObject jsonComment = lastComment.json();
JsonObject emptyMentionComment = Json.createObjectBuilder().add("id", "-1").add("body", "").build();
assertTrue(emptyMentionComment.equals(jsonComment));
}
开发者ID:opencharles,项目名称:charles-rest,代码行数:23,代码来源:LastCommentTestCase.java
示例8: agentRepliedToPreviousMention
import com.jcabi.github.Github; //导入依赖的package包/类
/**
* There is more than 1 mention of the agent in the issue and it has already
* replied to others, but the last one is not replied to yet.
* @throws Exception if something goes wrong.
*/
@Test
public void agentRepliedToPreviousMention() throws Exception {
final MkStorage storage = new MkStorage.Synced(new MkStorage.InFile());
final Repo repoMihai = new MkGithub(storage, "amihaiemil").repos().create( new RepoCreate("amihaiemil.github.io", false));
final Issue issue = repoMihai.issues().create("test issue", "body");
issue.comments().post("@charlesmike hello!");//first mention
final Github charlesmike = new MkGithub(storage, "charlesmike");
Issue issueCharlesmike = charlesmike.repos().get(repoMihai.coordinates()).issues().get(issue.number());
issueCharlesmike.comments().post("@amihaiemil hi there, I can help you index... "); //first reply
Comment lastMention = issue.comments().post("@charlesmike hello again!!");//second mention
issue.comments().post("@someoneelse, please check that..."); //some other comment that is the last on the ticket.
LastComment lastComment = new LastComment(issueCharlesmike);
JsonObject jsonComment = lastComment.json();
assertTrue(lastMention.json().equals(jsonComment));
}
开发者ID:opencharles,项目名称:charles-rest,代码行数:24,代码来源:LastCommentTestCase.java
示例9: mockIssue
import com.jcabi.github.Github; //导入依赖的package包/类
/**
* Mock an issue on Github.
* @return 2 Issues: 1 from the commander's Github (where the comments
* are posted) and 1 from the agent's Github (where comments are checked)
* @throws IOException If something goes wrong.
*/
private Issue[] mockIssue() throws IOException {
MkStorage storage = new MkStorage.InFile();
Github commanderGithub = new MkGithub(storage, "amihaiemil");
commanderGithub.users().self().emails().add(Arrays.asList("[email protected]"));
Github agentGithub = new MkGithub(storage, "charlesmike");
RepoCreate repoCreate = new RepoCreate("amihaiemil.github.io", false);
commanderGithub.repos().create(repoCreate);
Issue[] issues = new Issue[2];
Coordinates repoCoordinates = new Coordinates.Simple("amihaiemil", "amihaiemil.github.io");
Issue authorsIssue = commanderGithub.repos().get(repoCoordinates).issues().create("Test issue for commands", "test body");
Issue agentsIssue = agentGithub.repos().get(repoCoordinates).issues().get(authorsIssue.number());
issues[0] = authorsIssue;
issues[1] = agentsIssue;
return issues;
}
开发者ID:opencharles,项目名称:charles-rest,代码行数:24,代码来源:LastCommentTestCase.java
示例10: main
import com.jcabi.github.Github; //导入依赖的package包/类
/**
* Main entry point.
* @param args Command line arguments
*/
public static void main(final String[] args) throws Exception {
final Github github = new RtGithub();
final JsonResponse resp = github.entry()
.uri().path("/search/repositories")
.queryParam("q", "java").back()
.fetch()
.as(JsonResponse.class);
final List<JsonObject> items = resp.json().readObject()
.getJsonArray("items")
.getValuesAs(JsonObject.class);
for (final JsonObject item : items) {
System.out.println(
String.format(
"repository found: %s",
item.get("full_name").toString()
)
);
}
}
开发者ID:cvrebert,项目名称:typed-github,代码行数:24,代码来源:Main.java
示例11: json
import com.jcabi.github.Github; //导入依赖的package包/类
@Override
public JsonObject json() {
return Json.createObjectBuilder()
.add(LOGIN_KEY, this.self)
.add("id", Integer.toString(RAND.nextInt()))
.add("name", "github")
.add("company", "GitHub")
.add("blog", "https://github.com/blog")
.add("location", "San Francisco")
.add("email", "[email protected]")
.add("public_repos", RAND.nextInt())
.add("public_gists", RAND.nextInt())
.add("total_private_repos", RAND.nextInt())
.add("owned_private_repos", RAND.nextInt())
.add("followers", RAND.nextInt())
.add("following", RAND.nextInt())
.add("url", "https://github.com/orgs/cat")
.add("repos_url", "https://github.com/orgs/cat/repos")
.add("events_url", "https://github.com/orgs/cat/events")
.add("html_url", "https://github.com/cat")
.add("created_at", new Github.Time().toString())
.add("type", "Organization")
.build();
}
开发者ID:cvrebert,项目名称:typed-github,代码行数:25,代码来源:MkOrganization.java
示例12: get
import com.jcabi.github.Github; //导入依赖的package包/类
@Override
@NotNull(message = "limit is never NULL")
public Limit get(@NotNull(message = "resource shouldn't be NULL")
final String resource) {
// @checkstyle AnonInnerLength (50 lines)
return new Limit() {
@Override
public Github github() {
return MkLimits.this.github();
}
@Override
public JsonObject json() {
return Json.createObjectBuilder()
// @checkstyle MagicNumber (2 lines)
.add("limit", 5000)
.add("remaining", 4999)
.add("reset", System.currentTimeMillis())
.build();
}
};
}
开发者ID:cvrebert,项目名称:typed-github,代码行数:22,代码来源:MkLimits.java
示例13: testCreatedAt
import com.jcabi.github.Github; //导入依赖的package包/类
/**
* Organization created_at field should be variable.
* @throws Exception If some problem inside
*/
@Test
public void testCreatedAt() throws Exception {
final String name = "testCreatedAt";
final MkOrganizations orgs = new MkOrganizations(
new MkStorage.InFile()
);
final String created = "created_at";
final Date early = new Github.Time(
orgs.get(name)
.json()
.getString(created)
).date();
TimeUnit.SECONDS.sleep(1L);
final Date later = new Github.Time(
orgs.get(name)
.json()
.getString(created)
).date();
MatcherAssert.assertThat(later, Matchers.greaterThanOrEqualTo(early));
}
开发者ID:cvrebert,项目名称:typed-github,代码行数:25,代码来源:MkOrganizationsTest.java
示例14: canRememberItsAuthor
import com.jcabi.github.Github; //导入依赖的package包/类
/**
* MkIssue can remember it's author.
* @throws Exception when a problem occurs.
*/
@Test
public void canRememberItsAuthor() throws Exception {
final MkGithub first = new MkGithub("first");
final Github second = first.relogin("second");
final Repo repo = first.randomRepo();
final int number = second.repos()
.get(repo.coordinates())
.issues()
.create("", "")
.number();
final Issue issue = first.repos()
.get(repo.coordinates())
.issues()
.get(number);
MatcherAssert.assertThat(
new Issue.Smart(issue).author().login(),
Matchers.is("second")
);
}
开发者ID:cvrebert,项目名称:typed-github,代码行数:24,代码来源:MkIssueTest.java
示例15: get
import com.jcabi.github.Github; //导入依赖的package包/类
@Override
public Limit get(final String resource) {
// @checkstyle AnonInnerLength (50 lines)
return new Limit() {
@Override
public Github github() {
return MkLimits.this.github();
}
@Override
public JsonObject json() {
return Json.createObjectBuilder()
// @checkstyle MagicNumber (2 lines)
.add("limit", 5000)
.add("remaining", 4999)
.add("reset", System.currentTimeMillis())
.build();
}
};
}
开发者ID:jcabi,项目名称:jcabi-github,代码行数:20,代码来源:MkLimits.java
示例16: handleNotifications
import com.jcabi.github.Github; //导入依赖的package包/类
/**
* Handles notifications, starts one action thread for each of them.
* @param notifications List of notifications.
* @return true if actions were started successfully; false otherwise.
*/
private boolean handleNotifications(final Notifications notifications) {
final String authToken = System.getProperty(GITHUB_API_TOKEN);
boolean handled;
if(authToken == null || authToken.isEmpty()) {
LOG.error(
"Missing comdor.auth.token; "
+ "Please specify the Github api access token!"
);
handled = false;
} else {
final Github github = new RtGithub(
new RtGithub(authToken).entry().through(RetryWire.class)
);
try {
for(final Notification notification : notifications) {
this.take(
new VigilantAction(
new Chat(
github.repos().get(
new Coordinates.Simple(
notification.repoFullName()
)
).issues().get(notification.issueNumber()),
new GithubSocialSteps()
),
github
)
);
}
handled = true;
} catch (final IOException ex) {
LOG.error("IOException when getting the Github Issue", ex);
handled = false;
}
}
return handled;
}
开发者ID:amihaiemil,项目名称:comdor,代码行数:43,代码来源:ChatResource.java
示例17: starsRepo
import com.jcabi.github.Github; //导入依赖的package包/类
/**
* StarRepo can successfully star a given repository.
* @throws Exception If something goes wrong.
*/
@Test
public void starsRepo() throws Exception {
final Log log = Mockito.mock(Log.class);
final Logger slf4j = Mockito.mock(Logger.class);
Mockito.doNothing().when(slf4j).info(Mockito.anyString());
Mockito.doThrow(
new IllegalStateException("Unexpected error; test failed")
).when(slf4j).error(Mockito.anyString());
Mockito.when(log.logger()).thenReturn(slf4j);
final Github gh = new MkGithub("amihaiemil");
final Repo repo = gh.repos().create(
new Repos.RepoCreate("amihaiemil.github.io", false)
);
final Command com = Mockito.mock(Command.class);
final Issue issue = Mockito.mock(Issue.class);
Mockito.when(issue.repo()).thenReturn(repo);
Mockito.when(com.issue()).thenReturn(issue);
final Step star = new StarRepo(Mockito.mock(Step.class));
MatcherAssert.assertThat(
com.issue().repo().stars().starred(),
Matchers.is(false)
);
star.perform(com, log);
MatcherAssert.assertThat(
com.issue().repo().stars().starred(),
Matchers.is(true)
);
}
开发者ID:amihaiemil,项目名称:comdor,代码行数:35,代码来源:StarRepoTestCase.java
示例18: starsRepoTwice
import com.jcabi.github.Github; //导入依赖的package包/类
/**
* StarRepo tries to star a repo twice.
* @throws Exception If something goes wrong.
*/
@Test
public void starsRepoTwice() throws Exception {
final Log log = Mockito.mock(Log.class);
final Logger slf4j = Mockito.mock(Logger.class);
Mockito.doNothing().when(slf4j).info(Mockito.anyString());
Mockito.doThrow(
new IllegalStateException("Unexpected error; test failed")
).when(slf4j).error(Mockito.anyString());
Mockito.when(log.logger()).thenReturn(slf4j);
final Github gh = new MkGithub("amihaiemil");
final Repo repo = gh.repos().create(
new Repos.RepoCreate("amihaiemil.github.io", false)
);
final Command com = Mockito.mock(Command.class);
final Issue issue = Mockito.mock(Issue.class);
Mockito.when(issue.repo()).thenReturn(repo);
Mockito.when(com.issue()).thenReturn(issue);
final Step star = new StarRepo(Mockito.mock(Step.class));
MatcherAssert.assertThat(
com.issue().repo().stars().starred(),
Matchers.is(false)
);
star.perform(com, log);
star.perform(com, log);
MatcherAssert.assertThat(
com.issue().repo().stars().starred(),
Matchers.is(true)
);
}
开发者ID:amihaiemil,项目名称:comdor,代码行数:36,代码来源:StarRepoTestCase.java
示例19: mockMention
import com.jcabi.github.Github; //导入依赖的package包/类
/**
* Mock a Mention, add issue, repo and github mocks into it.
* @return Mention.
*/
private Command mockMention() {
final Command com = Mockito.mock(Command.class);
Mockito.when(com.author()).thenReturn("amihaiemil");
final Issue issue = Mockito.mock(Issue.class);
final Repo repo = Mockito.mock(Repo.class);
Mockito.when(repo.github()).thenReturn(Mockito.mock(Github.class));
Mockito.when(issue.repo()).thenReturn(repo);
Mockito.when(com.issue()).thenReturn(issue);
return com;
}
开发者ID:amihaiemil,项目名称:comdor,代码行数:18,代码来源:FollowUserTestCase.java
示例20: opensIssueOnIOException
import com.jcabi.github.Github; //导入依赖的package包/类
/**
* VigilantAction can open a Github issue if the original Action throws
* an IOException.
* @throws Exception If something goes wrong.
*/
@Test
public void opensIssueOnIOException() throws Exception {
final Github github = this.mockGithub();
final Action original = this.mockAction();
Mockito.doThrow(new IOException("expected")).when(original).perform();
final Action vigilant = new VigilantAction(original, github);
vigilant.perform();
final Issues all = github.repos()
.get(new Coordinates.Simple("amihaiemil/comdor"))
.issues();
MatcherAssert.assertThat(
all.iterate(new HashMap<>()),
Matchers.iterableWithSize(1)
);
final Issue opened = all.get(1);
MatcherAssert.assertThat(
opened.json().getString("title"),
Matchers.equalTo("Exception occured while peforming an Action!")
);
MatcherAssert.assertThat(
opened.json().getString("body"),
Matchers.startsWith(
String.format(
"@amihaiemil Something went wrong, please have a look."
+ "\n\n[Here](%s) are the logs of the Action.",
original.log().location()
)
+ "\n\nHere is the exception:\n\n```\n\n"
)
);
}
开发者ID:amihaiemil,项目名称:comdor,代码行数:41,代码来源:VigilantActionTestCase.java
注:本文中的com.jcabi.github.Github类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论