Example #1
0
 /**
  * Convert address to input stream.
  *
  * @param path Path of the asset, e.g. "yegor/rultor#pom.xml"
  * @return Stream with content
  * @throws IOException If fails
  */
 private InputStream asset(final String path) throws IOException {
   final Matcher matcher = GithubProfile.PATH.matcher(path);
   if (!matcher.matches()) {
     throw new IllegalArgumentException(String.format("invalid path of asset: %s", path));
   }
   final Repo rpo = this.repo.github().repos().get(new Coordinates.Simple(matcher.group(1)));
   return new ByteArrayInputStream(
       Base64.decodeBase64(new Content.Smart(rpo.contents().get(matcher.group(2))).content()));
 }
Example #2
0
 /**
  * Make a repo with YAML inside.
  *
  * @param yaml YAML config
  * @return Repo
  * @throws IOException If fails
  */
 private static Repo repo(final String yaml) throws IOException {
   final Github github = new MkGithub("jeff");
   github
       .repos()
       .create(new Repos.RepoCreate("test1", false))
       .contents()
       .create(
           Json.createObjectBuilder()
               .add("path", "test.xml")
               .add("message", "just test msg")
               .add("content", Base64.encodeBase64String("hey".getBytes()))
               .build());
   final Repo repo = github.repos().create(new Repos.RepoCreate("test2", false));
   repo.contents()
       .create(
           Json.createObjectBuilder()
               .add("path", ".rultor.yml")
               .add("message", "just test")
               .add("content", Base64.encodeBase64String(yaml.getBytes()))
               .build());
   return repo;
 }
Example #3
0
 /**
  * GithubProfile can accept asset from repo name that contains a dot.
  *
  * @throws Exception In case of error.
  */
 @Test
 public void acceptsAssetsFromDotRepo() throws Exception {
   final Github github = new MkGithub("jeff");
   final String name = "te.st";
   final Repo repo = github.repos().create(new Repos.RepoCreate(name, false));
   repo.contents()
       .create(
           Json.createObjectBuilder()
               .add("path", ".rultor.yml")
               .add("message", "just test")
               .add(
                   "content",
                   Base64.encodeBase64String(
                       Joiner.on('\n')
                           .join(
                               "assets: ",
                               String.format("  something.xml: jeff/%s#.rultor.yml", name),
                               "friends:",
                               String.format("  - jeff/%s", name))
                           .getBytes()))
               .build());
   MatcherAssert.assertThat(
       new GithubProfile(repo).assets().entrySet(), Matchers.not(Matchers.emptyIterable()));
 }