Esempio n. 1
0
 /**
  * GithubProfile should throw a ConfigException if some asset file doesn't exist.
  *
  * @throws Exception In case of error.
  */
 @Test(expected = Profile.ConfigException.class)
 public void testAssetNotFound() throws Exception {
   final Repo repo =
       GithubProfileTest.repo(
           Joiner.on('\n')
               .join("assets:", "  test.xml: jeff/test1#test.xmls", "merge:", "  script: hello!"));
   final String yaml = "friends:\n  - jeff/test2";
   repo.github()
       .repos()
       .get(new Coordinates.Simple("jeff/test1"))
       .contents()
       .create(
           Json.createObjectBuilder()
               .add("path", ".rultor.yml")
               .add("message", "rultor config")
               .add("content", Base64.encodeBase64String(yaml.getBytes()))
               .build());
   final Profile profile = new GithubProfile(repo);
   profile.assets();
 }
Esempio n. 2
0
 /**
  * GithubProfile can fetch a YAML config.
  *
  * @throws Exception In case of error.
  */
 @Test
 public void fetchesYamlConfig() throws Exception {
   final Repo repo =
       GithubProfileTest.repo(
           Joiner.on('\n')
               .join(
                   "assets:",
                   "  test.xml: jeff/test1#test.xml",
                   "  beta: jeff/test1#test.xml",
                   "architect:",
                   " - jeff",
                   " - donald",
                   "merge:",
                   "  script: hello!"));
   final String yaml = "friends:\n  - jeff/test2";
   repo.github()
       .repos()
       .get(new Coordinates.Simple("jeff/test1"))
       .contents()
       .create(
           Json.createObjectBuilder()
               .add("path", ".rultor.yml")
               .add("message", "rultor config")
               .add("content", Base64.encodeBase64String(yaml.getBytes()))
               .build());
   final Profile profile = new GithubProfile(repo);
   MatcherAssert.assertThat(
       profile.read(),
       XhtmlMatchers.hasXPaths(
           "/p/entry[@key='merge']/entry[@key='script']",
           "/p/entry[@key='assets']/entry[@key='test.xml']",
           "/p/entry[@key='assets']/entry[@key='beta']"));
   MatcherAssert.assertThat(
       profile.read().xpath("/p/entry[@key='architect']/item/text()"),
       Matchers.contains("jeff", "donald"));
   MatcherAssert.assertThat(
       profile.assets(), Matchers.hasEntry(Matchers.equalTo("test.xml"), Matchers.notNullValue()));
 }