use of com.jcabi.http.request.JdkRequest in project jcabi-github by jcabi.
the class RtIssuesTest method searchIssues.
/**
* RtIssues can search issues within a repository.
* @throws Exception if there is any error
*/
@Test
public void searchIssues() throws Exception {
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, Json.createArrayBuilder().add(issue("some issue")).add(issue("some other issue")).build().toString())).start(this.resource.port());
final RtIssues issues = new RtIssues(new JdkRequest(container.home()), repo());
MatcherAssert.assertThat(issues.search(Issues.Sort.UPDATED, Search.Order.ASC, new EnumMap<Issues.Qualifier, String>(Issues.Qualifier.class)), Matchers.<Issue>iterableWithSize(2));
container.stop();
}
use of com.jcabi.http.request.JdkRequest in project jcabi-github by jcabi.
the class RtIssuesTest method createIssue.
/**
* RtIssues can create an issue.
*
* @throws Exception if some problem inside
*/
@Test
public void createIssue() throws Exception {
final String title = "Found a bug";
final String body = issue(title).toString();
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_CREATED, body)).next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, body)).start(this.resource.port());
final RtIssues issues = new RtIssues(new JdkRequest(container.home()), repo());
final Issue issue = issues.create(title, "having a problem with it.");
MatcherAssert.assertThat(container.take().method(), Matchers.equalTo(Request.POST));
MatcherAssert.assertThat(new Issue.Smart(issue).title(), Matchers.equalTo(title));
container.stop();
}
use of com.jcabi.http.request.JdkRequest in project jcabi-github by jcabi.
the class RtGitignoresTest method iterateTemplateNames.
/**
* RtGitignores can iterate template names.
* @throws Exception if there is any error
*/
@Test
public void iterateTemplateNames() throws Exception {
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, Json.createArrayBuilder().add("C").add("Java").build().toString())).start();
final RtGitignores gitignores = new RtGitignores(new RtGithub(new JdkRequest(container.home())));
MatcherAssert.assertThat(gitignores.iterate(), Matchers.<String>iterableWithSize(2));
container.stop();
}
use of com.jcabi.http.request.JdkRequest in project jcabi-github by jcabi.
the class RtCollaboratorsTest method userCanBeAddedAsCollaborator.
/**
* User can be added to a repo as a collaborator.
* @throws Exception if any error occurs.
*/
@Test
public void userCanBeAddedAsCollaborator() throws Exception {
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_NO_CONTENT, Json.createArrayBuilder().add(RtCollaboratorsTest.json("octocat2")).add(RtCollaboratorsTest.json("dummy")).build().toString())).start(this.resource.port());
final Collaborators users = new RtCollaborators(new JdkRequest(container.home()), this.repo());
try {
users.add("dummy1");
final MkQuery query = container.take();
MatcherAssert.assertThat(query.method(), Matchers.equalTo(Request.PUT));
} finally {
container.stop();
}
}
use of com.jcabi.http.request.JdkRequest in project jcabi-github by jcabi.
the class RtCommitTest method readsMessage.
/**
* Commit.Smart can read message.
* @throws Exception when an error occurs
*/
@Test
public final void readsMessage() throws Exception {
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, "{\"sha\":\"a0b1c3\",\"commit\":{\"message\":\"hello\"}}")).start(this.resource.port());
try {
final Commit.Smart commit = new Commit.Smart(new RtCommit(new JdkRequest(container.home()), new MkGithub().randomRepo(), "sha"));
MatcherAssert.assertThat(commit.message(), Matchers.equalTo("hello"));
} finally {
container.stop();
}
}
Aggregations