Java Code Examples for com.jcabi.github.Coordinates#Simple

The following examples show how to use com.jcabi.github.Coordinates#Simple . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CachingGithubTests.java    From spring-cloud-release-tools with Apache License 2.0 6 votes vote down vote up
@Test
void should_not_cache_calls_for_different_coordinates() {
	Repos repos = mock(Repos.class);
	CachingRepos cachingRepos = new CachingRepos(repos);
	Coordinates.Simple simple1 = new Coordinates.Simple("foo", "bar1");
	Coordinates.Simple simple2 = new Coordinates.Simple("foo", "bar2");
	Coordinates.Simple simple3 = new Coordinates.Simple("foo", "bar3");

	cachingRepos.get(simple1);
	cachingRepos.get(simple2);
	cachingRepos.get(simple3);

	verify(repos).get(simple1);
	verify(repos).get(simple2);
	verify(repos).get(simple3);
}
 
Example 2
Source File: LastCommentTestCase.java    From charles-rest with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * 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;
}
 
Example 3
Source File: CachingGithubTests.java    From spring-cloud-release-tools with Apache License 2.0 5 votes vote down vote up
@Test
void should_get_repo_only_once_for_same_coordinates() {
	Repos repos = mock(Repos.class);
	CachingRepos cachingRepos = new CachingRepos(repos);
	Coordinates.Simple simple = new Coordinates.Simple("foo", "bar");

	cachingRepos.get(simple);
	cachingRepos.get(simple);
	cachingRepos.get(simple);

	verify(repos, only()).get(simple);
}
 
Example 4
Source File: ActionTestCase.java    From charles-rest with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Creates an Issue with the given command.
 * @param commander Author of the comment;
 * @param command The comment's body;
 * @return Github issue
 */
public Issue githubIssue(String commander, String command) throws Exception {
    MkStorage storage = new MkStorage.InFile();
    Github commanderGh = new MkGithub(storage, commander);
    RepoCreate repoCreate = new RepoCreate(commander + ".github.io", false);
    commanderGh.repos().create(repoCreate);
    Coordinates repoCoordinates = new Coordinates.Simple(commander, commander + ".github.io");
    Issue issue = commanderGh.repos().get(repoCoordinates).issues().create("Test issue for commands", "test body");
    issue.comments().post(command);
    Github agentGh = new MkGithub(storage, "charlesmike");
    return agentGh.repos().get(repoCoordinates).issues().get(issue.number());
    
}