本文整理汇总了Java中com.jcabi.github.Repos类的典型用法代码示例。如果您正苦于以下问题:Java Repos类的具体用法?Java Repos怎么用?Java Repos使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Repos类属于com.jcabi.github包,在下文中一共展示了Repos类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: returnsMissingComdorYaml
import com.jcabi.github.Repos; //导入依赖的package包/类
/**
* JsonMention can return the .comdor.yml
* if it is missing from the repository.
* @throws Exception If something goes wrong.
*/
@Test
public void returnsMissingComdorYaml() throws Exception {
final MkGithub gh = new MkGithub("amihaiemil");
final Repo repo = gh.repos().create(
new Repos.RepoCreate("charlesrepo", false)
);
final Command mention = new MockConcrete(
Json.createObjectBuilder().build(),
repo.issues().create("for test", "body")
);
final ComdorYaml yaml = mention.comdorYaml();
MatcherAssert.assertThat(yaml, Matchers.notNullValue());
MatcherAssert.assertThat(
yaml instanceof ComdorYaml.Missing,
Matchers.is(true)
);
}
示例2: canGetAbsentLabel
import com.jcabi.github.Repos; //导入依赖的package包/类
/**
* MkEvent can get absent label value from json object.
* @throws Exception If some problem inside
*/
@Test
public void canGetAbsentLabel() throws Exception {
final MkStorage storage = new MkStorage.InFile();
final String user = "barbie";
final Repo repo = new MkGithub(storage, user).repos().create(
new Repos.RepoCreate("bar", false)
);
final int num = ((MkIssueEvents) (repo.issueEvents())).create(
Event.LABELED,
1,
user,
Optional.<String>absent()
).number();
MatcherAssert.assertThat(
new Event.Smart(
new MkEvent(
storage,
user,
repo.coordinates(),
num
)
).label(),
Matchers.equalTo(Optional.<Label>absent())
);
}
示例3: canSearchForIssues
import com.jcabi.github.Repos; //导入依赖的package包/类
/**
* MkSearch can search for issues.
*
* @throws Exception if a problem occurs
*/
@Test
public void canSearchForIssues() throws Exception {
final MkGithub github = new MkGithub();
final Repo repo = github.repos().create(
new Repos.RepoCreate("TestIssues", false)
);
repo.issues().create("test issue", "TheTest");
MatcherAssert.assertThat(
github.search().issues(
"TheTest",
"updated",
Search.Order.DESC,
new EnumMap<Search.Qualifier, String>(Search.Qualifier.class)
),
Matchers.not(Matchers.emptyIterable())
);
}
示例4: returnsExistingComdorYaml
import com.jcabi.github.Repos; //导入依赖的package包/类
/**
* JsonMention can return the .comdor.yml if it exists in the repository.
* @throws Exception If something goes wrong.
*/
@Test
public void returnsExistingComdorYaml() throws Exception {
final MkGithub gh = new MkGithub("amihaiemil");
final Repo repo = gh.repos().create(
new Repos.RepoCreate("charlesrepo", false)
);
repo.contents()
.create(
Json.createObjectBuilder()
.add("path", ".comdor.yml")
.add("message", "just a test")
.add(
"content",
Base64.encodeBase64String(
"docker: test".getBytes()
)
).build()
);
final Command mention = new MockConcrete(
Json.createObjectBuilder().build(),
repo.issues().create("for test", "body")
);
MatcherAssert.assertThat(mention.comdorYaml(), Matchers.notNullValue());
MatcherAssert.assertThat(
mention.comdorYaml() instanceof ComdorYamlRules,
Matchers.is(true)
);
}
示例5: starsRepo
import com.jcabi.github.Repos; //导入依赖的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)
);
}
示例6: starsRepoTwice
import com.jcabi.github.Repos; //导入依赖的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)
);
}
示例7: repos
import com.jcabi.github.Repos; //导入依赖的package包/类
@Override
@NotNull(message = "repos is never NULL")
public Repos repos() {
try {
return new MkRepos(this.storage, this.self);
} catch (final IOException ex) {
throw new IllegalStateException(ex);
}
}
示例8: randomRepo
import com.jcabi.github.Repos; //导入依赖的package包/类
/**
* Create repo with random name.
* @return Repo
* @throws IOException If fails
*/
@NotNull(message = "Repo is never NULL")
public Repo randomRepo() throws IOException {
return this.repos().create(
new Repos.RepoCreate(
RandomStringUtils.randomAlphanumeric(Tv.TWENTY),
true
)
);
}
示例9: canGetPresentLabel
import com.jcabi.github.Repos; //导入依赖的package包/类
/**
* MkEvent can get present label value from json object.
* @throws Exception If some problem inside
*/
@Test
public void canGetPresentLabel() throws Exception {
final MkStorage storage = new MkStorage.InFile();
final String user = "ken";
final Repo repo = new MkGithub(storage, user).repos().create(
new Repos.RepoCreate("foo", false)
);
final MkIssueEvents events = (MkIssueEvents) (repo.issueEvents());
final String label = "problem";
final int num = events.create(
Event.LABELED,
1,
user,
Optional.of(label)
).number();
MatcherAssert.assertThat(
new Event.Smart(
new MkEvent(
storage,
user,
repo.coordinates(),
num
)
).label().get().name(),
Matchers.equalTo(label)
);
}
示例10: canSearchForRepos
import com.jcabi.github.Repos; //导入依赖的package包/类
/**
* MkSearch can search for repos.
*
* @throws Exception if a problem occurs
*/
@Test
public void canSearchForRepos() throws Exception {
final MkGithub github = new MkGithub();
github.repos().create(
new Repos.RepoCreate("TestRepo", false)
);
MatcherAssert.assertThat(
github.search().repos("TestRepo", "updated", Search.Order.ASC),
Matchers.not(Matchers.emptyIterable())
);
}
示例11: canSearchForCodes
import com.jcabi.github.Repos; //导入依赖的package包/类
/**
* MkSearch can search for codes.
*
* @throws Exception if a problem occurs
*/
@Test
public void canSearchForCodes() throws Exception {
final MkGithub github = new MkGithub("jeff");
github.repos().create(
new Repos.RepoCreate("TestCode", false)
);
MatcherAssert.assertThat(
github.search().codes("jeff", "repositories", Search.Order.DESC),
Matchers.not(Matchers.emptyIterable())
);
}
示例12: postsPullComment
import com.jcabi.github.Repos; //导入依赖的package包/类
/**
* MkPullComments can create a pull comment.
*
* @throws Exception If something goes wrong.
*/
@Test
public void postsPullComment() throws Exception {
final MkStorage storage = new MkStorage.InFile();
final String commit = "commit_id";
final String path = "path";
final String bodytext = "some text as a body";
final String login = "jamie";
final String reponame = "incredible";
final Repo repo = new MkGithub(storage, login).repos().create(
new Repos.RepoCreate(reponame, false)
);
repo.pulls()
.create("pullrequest1", "head", "base").comments()
.post(bodytext, commit, path, 1);
final String[] fields = {commit, path};
for (final String element : fields) {
MkPullCommentsTest.assertFieldContains(storage, repo, element);
}
final List<String> position = storage.xml().xpath(
String.format(
// @checkstyle LineLength (1 line)
"/github/repos/repo[@coords='%s/%s']/pulls/pull/comments/comment/position/text()",
repo.coordinates().user(),
repo.coordinates().repo()
)
);
MatcherAssert.assertThat(
position.get(0), Matchers.notNullValue()
);
final List<String> body = storage.xml().xpath(
String.format(
// @checkstyle LineLength (1 line)
"/github/repos/repo[@coords='%s/%s']/pulls/pull/comments/comment/body/text()",
repo.coordinates().user(),
repo.coordinates().repo()
)
);
MatcherAssert.assertThat(body.get(0), Matchers.equalTo(bodytext));
}
示例13: createsRepository
import com.jcabi.github.Repos; //导入依赖的package包/类
/**
* MkRepos can create a repo.
* @throws Exception If some problem inside
*/
@Test
public void createsRepository() throws Exception {
final Repos repos = new MkRepos(new MkStorage.InFile(), "jeff");
final Repo repo = MkReposTest.repo(repos, "test", "test repo");
MatcherAssert.assertThat(
repo.coordinates(),
Matchers.hasToString("jeff/test")
);
}
示例14: createsRepositoryWithDetails
import com.jcabi.github.Repos; //导入依赖的package包/类
/**
* MkRepos can create a repo with details.
* @throws Exception If some problem inside
*/
@Test
public void createsRepositoryWithDetails() throws Exception {
final Repos repos = new MkRepos(new MkStorage.InFile(), "jeff");
final Repo repo = MkReposTest.repo(repos, "hello", "my test repo");
MatcherAssert.assertThat(
new Repo.Smart(repo).description(),
Matchers.startsWith("my test")
);
}
示例15: removesRepo
import com.jcabi.github.Repos; //导入依赖的package包/类
/**
* MkRepos can remove an existing repo.
* @throws Exception If some problem inside
*/
@Test
public void removesRepo() throws Exception {
final Repos repos = new MkRepos(new MkStorage.InFile(), "jeff");
final Repo repo = MkReposTest.repo(repos, "remove-me", "remove repo");
MatcherAssert.assertThat(
repos.get(repo.coordinates()),
Matchers.notNullValue()
);
repos.remove(repo.coordinates());
this.thrown.expect(IllegalArgumentException.class);
this.thrown.expectMessage("repository jeff/remove-me doesn't exist");
repos.get(repo.coordinates());
}