Search in sources :

Example 1 with Coordinates

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

the class MkMilestoneTest method returnsSameCoordinatesRepo.

/**
 * MkMilestone returns a repo with same coordinates.
 * @throws Exception if test fails
 */
@Test
public final void returnsSameCoordinatesRepo() throws Exception {
    final Coordinates coordinates = new Coordinates.Simple("user", "repo");
    final MkMilestone milestone = new MkMilestone(new MkStorage.InFile(), "login", coordinates, 1);
    final Repo repo = milestone.repo();
    MatcherAssert.assertThat(repo.coordinates(), Matchers.equalTo(coordinates));
}
Also used : Repo(com.jcabi.github.Repo) Coordinates(com.jcabi.github.Coordinates) Test(org.junit.Test)

Example 2 with Coordinates

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

the class MkBranchesTest method createsBranch.

/**
 * MkBranches can create a new branch.
 * @throws IOException if there is any I/O problem
 */
@Test
public void createsBranch() throws IOException {
    final String name = "my-new-feature";
    final String sha = "590e188e3d52a8da38cf51d3f9bf598bb46911af";
    final Repo repo = new MkGithub().randomRepo();
    final Branch branch = ((MkBranches) (repo.branches())).create(name, sha);
    MatcherAssert.assertThat(branch.name(), Matchers.equalTo(name));
    MatcherAssert.assertThat(branch.commit().sha(), Matchers.equalTo(sha));
    final Coordinates coords = branch.commit().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) Branch(com.jcabi.github.Branch) Coordinates(com.jcabi.github.Coordinates) Test(org.junit.Test)

Example 3 with Coordinates

use of com.jcabi.github.Coordinates 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 4 with Coordinates

use of com.jcabi.github.Coordinates 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)

Example 5 with Coordinates

use of com.jcabi.github.Coordinates in project wring by yegor256.

the class BoCommit method push.

@Override
public void push(final Events events) throws IOException {
    final Coordinates coords = this.commit.repo().coordinates();
    final String body = this.text(coords);
    if (body.isEmpty()) {
        Logger.info(this, "%s %s ignored", coords, this.commit.sha());
    } else {
        events.post(String.format("[%s] %s", coords, this.commit.sha()), body);
        Logger.info(this, "New event in %s#%s", coords, this.commit.sha());
    }
}
Also used : Coordinates(com.jcabi.github.Coordinates)

Aggregations

Coordinates (com.jcabi.github.Coordinates)7 Repo (com.jcabi.github.Repo)4 Test (org.junit.Test)3 Branch (com.jcabi.github.Branch)1 RepoCommit (com.jcabi.github.RepoCommit)1 RtPagination (com.jcabi.github.RtPagination)1 Logger (com.jcabi.log.Logger)1 Printable (io.wring.agents.Printable)1 Base (io.wring.model.Base)1 Events (io.wring.model.Events)1 IOException (java.io.IOException)1 Iterator (java.util.Iterator)1 Optional (java.util.Optional)1 Pattern (java.util.regex.Pattern)1 JsonObject (javax.json.JsonObject)1 StringEscapeUtils (org.apache.commons.text.StringEscapeUtils)1 Directives (org.xembly.Directives)1