Skip to content

Commit

Permalink
jcabi#863 - RtContents#iterate test
Browse files Browse the repository at this point in the history
  • Loading branch information
maurezen committed Jan 21, 2015
1 parent 1f58809 commit f940eb3
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions src/test/java/com/jcabi/github/RtContentsITCase.java
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,51 @@ public void getContent() throws Exception {
}
}

/**
* RtContents can iterate content.
* @throws Exception If some problem inside
*/
@Test
public void iteratesContent() throws Exception {
final Repos repos = github().repos();
final Repo repo = this.rule.repo(repos);
try {
final String path1 = RandomStringUtils.randomAlphanumeric(Tv.TEN);
final String path2 = RandomStringUtils.randomAlphanumeric(Tv.TEN);
final String message1 = String.format("testMessage1");
final String message2 = String.format("testMessage2");
final String cont1 = new String(
Base64.encodeBase64(
String.format("content1:%d", System.currentTimeMillis())
.getBytes()
)
);
final String cont2 = new String(
Base64.encodeBase64(
String.format("content2:%d", System.currentTimeMillis())
.getBytes()
)
);
final Contents contents = repos.get(repo.coordinates()).contents();
contents.create(this.jsonObject(path1, cont1, message1));
contents.create(this.jsonObject(path2, cont2, message2));
final Content content1 = contents.get(path1);
final Content content2 = contents.get(path2);
final Iterable<Content> iterated = contents.iterate("", "master");
MatcherAssert.assertThat(
iterated,
Matchers.allOf(
Matchers.contains(content1, content2),
Matchers.<Content>iterableWithSize(2)
));
for (Content content : contents.iterate("", "master")) {
System.out.println(content.toString());
}
} finally {
repos.remove(repo.coordinates());
}
}

/**
* RtContents can check whether content exists or not.
* @throws Exception if any problem inside.
Expand Down

0 comments on commit f940eb3

Please sign in to comment.