Search in sources :

Example 1 with ArrayMap

use of com.jcabi.immutable.ArrayMap in project jcabi-github by jcabi.

the class MkIssuesTest method iteratesIssues.

/**
 * MkIssues can list issues.
 * @throws Exception If some problem inside
 */
@Test
public void iteratesIssues() throws Exception {
    final Repo repo = new MkGithub().randomRepo();
    repo.issues().create("hey, you", "body of issue");
    repo.issues().create("hey", "body of 2nd issue");
    repo.issues().create("hey again", "body of 3rd issue");
    MatcherAssert.assertThat(repo.issues().iterate(new ArrayMap<String, String>()), Matchers.<Issue>iterableWithSize(Tv.THREE));
}
Also used : Repo(com.jcabi.github.Repo) ArrayMap(com.jcabi.immutable.ArrayMap) Test(org.junit.Test)

Example 2 with ArrayMap

use of com.jcabi.immutable.ArrayMap in project jcabi-github by jcabi.

the class MkMilestonesTest method iteratesMilestones.

/**
 * This tests that the iterate(Map<String, String> params)
 * method in MkMilestones works fine.
 * @throws Exception - if something goes wrong.
 */
@Test
public void iteratesMilestones() throws Exception {
    final Milestones milestones = new MkGithub().randomRepo().milestones();
    milestones.create("testMilestone");
    MatcherAssert.assertThat(milestones.iterate(new ArrayMap<String, String>()), Matchers.<Milestone>iterableWithSize(1));
}
Also used : Milestones(com.jcabi.github.Milestones) ArrayMap(com.jcabi.immutable.ArrayMap) Test(org.junit.Test)

Example 3 with ArrayMap

use of com.jcabi.immutable.ArrayMap in project jcabi-github by jcabi.

the class MkMilestonesTest method removesMilestone.

/**
 * This tests that MkMilestones can remove a certain MkMilestone, by number.
 * @throws Exception - if something goes wrong.
 */
@Test
public void removesMilestone() throws Exception {
    final Milestones milestones = new MkGithub().randomRepo().milestones();
    final Milestone created = milestones.create("testTitle");
    MatcherAssert.assertThat(milestones.iterate(new ArrayMap<String, String>()), Matchers.<Milestone>iterableWithSize(1));
    milestones.remove(created.number());
    MatcherAssert.assertThat(milestones.iterate(new ArrayMap<String, String>()), Matchers.<Milestone>iterableWithSize(0));
}
Also used : Milestones(com.jcabi.github.Milestones) Milestone(com.jcabi.github.Milestone) ArrayMap(com.jcabi.immutable.ArrayMap) Test(org.junit.Test)

Example 4 with ArrayMap

use of com.jcabi.immutable.ArrayMap 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 5 with ArrayMap

use of com.jcabi.immutable.ArrayMap in project jcabi-github by jcabi.

the class RtIssuesTest method iterateIssues.

/**
 * RtIssues can iterate issues.
 * @throws Exception if there is any error
 */
@Test
public void iterateIssues() throws Exception {
    final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, Json.createArrayBuilder().add(issue("new issue")).add(issue("code issue")).build().toString())).start(this.resource.port());
    final RtIssues issues = new RtIssues(new JdkRequest(container.home()), repo());
    MatcherAssert.assertThat(issues.iterate(new ArrayMap<String, String>()), Matchers.<Issue>iterableWithSize(2));
    container.stop();
}
Also used : MkGrizzlyContainer(com.jcabi.http.mock.MkGrizzlyContainer) JdkRequest(com.jcabi.http.request.JdkRequest) ArrayMap(com.jcabi.immutable.ArrayMap) MkContainer(com.jcabi.http.mock.MkContainer) Test(org.junit.Test)

Aggregations

ArrayMap (com.jcabi.immutable.ArrayMap)6 Test (org.junit.Test)6 Milestones (com.jcabi.github.Milestones)2 Repo (com.jcabi.github.Repo)2 MkContainer (com.jcabi.http.mock.MkContainer)2 MkGrizzlyContainer (com.jcabi.http.mock.MkGrizzlyContainer)2 Milestone (com.jcabi.github.Milestone)1 ApacheRequest (com.jcabi.http.request.ApacheRequest)1 JdkRequest (com.jcabi.http.request.JdkRequest)1 VerboseCallable (com.jcabi.log.VerboseCallable)1 ArrayList (java.util.ArrayList)1 Callable (java.util.concurrent.Callable)1 ExecutorService (java.util.concurrent.ExecutorService)1