use of com.jcabi.http.request.JdkRequest in project jcabi-github by jcabi.
the class RtAssigneesTest method checkUserIsNotAssigneeForRepo.
/**
* RtAssignees can check if user is NOT assignee for this repo.
* @throws Exception Exception If some problem inside
*/
@Test
public void checkUserIsNotAssigneeForRepo() throws Exception {
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_NOT_FOUND, Json.createArrayBuilder().add(RtAssigneesTest.json("octocat3")).add(RtAssigneesTest.json("dummy")).build().toString())).start(this.resource.port());
final Assignees users = new RtAssignees(new JdkRequest(container.home()), this.repo());
MatcherAssert.assertThat(users.check("octocat33"), Matchers.equalTo(false));
container.stop();
}
use of com.jcabi.http.request.JdkRequest in project jcabi-github by jcabi.
the class RtAssigneesTest method iteratesAssignees.
/**
* RtAssignees can iterate over assignees.
* @throws Exception Exception If some problem inside
*/
@Test
public void iteratesAssignees() throws Exception {
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, Json.createArrayBuilder().add(RtAssigneesTest.json("octocat")).add(RtAssigneesTest.json("dummy")).build().toString())).start(this.resource.port());
final Assignees users = new RtAssignees(new JdkRequest(container.home()), this.repo());
MatcherAssert.assertThat(users.iterate(), Matchers.<User>iterableWithSize(2));
container.stop();
}
use of com.jcabi.http.request.JdkRequest in project jcabi-github by jcabi.
the class RtForksTest method createsFork.
/**
* RtForks should be able to create a new fork.
*
* @throws Exception if a problem occurs.
*/
@Test
public void createsFork() throws Exception {
final String organization = RandomStringUtils.randomAlphanumeric(10);
final MkAnswer answer = new MkAnswer.Simple(HttpURLConnection.HTTP_OK, fork(organization).toString());
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_ACCEPTED, fork(organization).toString())).next(answer).start(this.resource.port());
final Repo owner = Mockito.mock(Repo.class);
final Coordinates coordinates = new Coordinates.Simple("test_user", "test_repo");
Mockito.doReturn(coordinates).when(owner).coordinates();
final RtForks forks = new RtForks(new JdkRequest(container.home()), owner);
final Fork fork = forks.create(organization);
MatcherAssert.assertThat(container.take().method(), Matchers.equalTo(Request.POST));
MatcherAssert.assertThat(fork.json().getString(ORGANIZATION), Matchers.equalTo(organization));
container.stop();
}
use of com.jcabi.http.request.JdkRequest in project jcabi-github by jcabi.
the class RtLabelsTest method deleteLabel.
/**
* RtLabels can delete a label.
* @throws Exception if some problem inside
*/
@Test
public void deleteLabel() throws Exception {
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_NO_CONTENT, "")).start();
final RtLabels issues = new RtLabels(new JdkRequest(container.home()), repo());
issues.delete("issue");
final MkQuery query = container.take();
MatcherAssert.assertThat(query.method(), Matchers.equalTo(Request.DELETE));
MatcherAssert.assertThat(query.body(), Matchers.isEmptyOrNullString());
container.stop();
}
use of com.jcabi.http.request.JdkRequest in project jcabi-github by jcabi.
the class RtLabelsTest method getSingleLabel.
/**
* RtLabels can get a single label.
*
* @throws Exception if some problem inside
*/
@Test
public void getSingleLabel() throws Exception {
final String name = "bug";
final String color = "f29513";
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, label(name, color).toString())).start();
final RtLabels issues = new RtLabels(new JdkRequest(container.home()), repo());
final Label label = issues.get(name);
MatcherAssert.assertThat(new Label.Smart(label).color(), Matchers.equalTo(color));
container.stop();
}
Aggregations