Search in sources :

Example 31 with Repo

use of com.jcabi.github.Repo in project jcabi-github by jcabi.

the class MkGithubTest method canHandleMultipleThreads.

/**
 * MkGithub can handle multiple threads in parallel.
 * @throws Exception if some problem inside
 */
@Test
public void canHandleMultipleThreads() throws Exception {
    final Repo repo = new MkGithub().randomRepo();
    final int threads = Tv.HUNDRED;
    final ExecutorService svc = Executors.newFixedThreadPool(threads);
    final Callable<Void> task = new VerboseCallable<Void>(new Callable<Void>() {

        @Override
        public Void call() throws Exception {
            repo.issues().create("", "");
            return null;
        }
    });
    final Collection<Callable<Void>> tasks = new ArrayList<Callable<Void>>(threads);
    for (int idx = 0; idx < threads; ++idx) {
        tasks.add(task);
    }
    svc.invokeAll(tasks);
    MatcherAssert.assertThat(repo.issues().iterate(new ArrayMap<String, String>()), Matchers.<Issue>iterableWithSize(threads));
}
Also used : ArrayList(java.util.ArrayList) ArrayMap(com.jcabi.immutable.ArrayMap) Callable(java.util.concurrent.Callable) VerboseCallable(com.jcabi.log.VerboseCallable) Repo(com.jcabi.github.Repo) VerboseCallable(com.jcabi.log.VerboseCallable) ExecutorService(java.util.concurrent.ExecutorService) Test(org.junit.Test)

Example 32 with Repo

use of com.jcabi.github.Repo in project jcabi-github by jcabi.

the class SampleTest method fetchesLabelsFromGithub.

/**
 * Fetches labels from Github.
 * @throws Exception If fails
 */
@Test
public void fetchesLabelsFromGithub() throws Exception {
    final Github github = new RtGithub();
    final Repo repo = github.repos().get(new Coordinates.Simple("jcabi/jcabi-github"));
    MatcherAssert.assertThat(repo.labels().iterate().iterator().hasNext(), Matchers.equalTo(true));
}
Also used : Repo(com.jcabi.github.Repo) RtGithub(com.jcabi.github.RtGithub) Github(com.jcabi.github.Github) Coordinates(com.jcabi.github.Coordinates) RtGithub(com.jcabi.github.RtGithub) Test(org.junit.Test)

Example 33 with Repo

use of com.jcabi.github.Repo in project jcabi-github by jcabi.

the class MkRepos method create.

@Override
public Repo create(final RepoCreate settings) throws IOException {
    final Coordinates coords = new Coordinates.Simple(this.self, settings.name());
    this.storage.apply(new Directives().xpath(this.xpath()).add("repo").attr("coords", coords.toString()).add("name").set(settings.name()).up().add("description").set("test repository").up().add("private").set("false").up());
    final Repo repo = this.get(coords);
    repo.patch(settings.json());
    Logger.info(this, "repository %s created by %s", coords, this.self);
    return repo;
}
Also used : Repo(com.jcabi.github.Repo) Directives(org.xembly.Directives) Coordinates(com.jcabi.github.Coordinates)

Example 34 with Repo

use of com.jcabi.github.Repo in project jcabi-github by jcabi.

the class MkAssigneesTest method checkCollaboratorIsAssigneeForRepo.

/**
 * MkAssignees can check if a collaborator is an assignee for this repo.
 * @throws Exception Exception If some problem inside
 */
@Test
public void checkCollaboratorIsAssigneeForRepo() throws Exception {
    final Repo repo = repo();
    repo.collaborators().add("Vladimir");
    MatcherAssert.assertThat(repo.assignees().check("Vladimir"), Matchers.is(true));
}
Also used : Repo(com.jcabi.github.Repo) Test(org.junit.Test)

Example 35 with Repo

use of com.jcabi.github.Repo in project jcabi-github by jcabi.

the class MkBranchTest method fetchesRepo.

/**
 * MkBranch can fetch its repo.
 * @throws IOException If an I/O problem occurs
 */
@Test
public void fetchesRepo() throws IOException {
    final Repo repo = new MkGithub().randomRepo();
    final Coordinates coords = MkBranchTest.branches(repo).create("test", "sha").repo().coordinates();
    MatcherAssert.assertThat(coords.user(), Matchers.equalTo(repo.coordinates().user()));
    MatcherAssert.assertThat(coords.repo(), Matchers.equalTo(repo.coordinates().repo()));
}
Also used : Repo(com.jcabi.github.Repo) Coordinates(com.jcabi.github.Coordinates) Test(org.junit.Test)

Aggregations

Repo (com.jcabi.github.Repo)57 Test (org.junit.Test)55 Coordinates (com.jcabi.github.Coordinates)11 Issue (com.jcabi.github.Issue)10 Repos (com.jcabi.github.Repos)10 References (com.jcabi.github.References)5 Github (com.jcabi.github.Github)3 JsonObject (javax.json.JsonObject)3 Comment (com.jcabi.github.Comment)2 Content (com.jcabi.github.Content)2 Event (com.jcabi.github.Event)2 RepoCommit (com.jcabi.github.RepoCommit)2 ArrayMap (com.jcabi.immutable.ArrayMap)2 Branch (com.jcabi.github.Branch)1 Contents (com.jcabi.github.Contents)1 Fork (com.jcabi.github.Fork)1 IssueLabels (com.jcabi.github.IssueLabels)1 Label (com.jcabi.github.Label)1 Labels (com.jcabi.github.Labels)1 Language (com.jcabi.github.Language)1