本文整理汇总了Java中com.jcabi.http.mock.MkContainer.home方法的典型用法代码示例。如果您正苦于以下问题:Java MkContainer.home方法的具体用法?Java MkContainer.home怎么用?Java MkContainer.home使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jcabi.http.mock.MkContainer
的用法示例。
在下文中一共展示了MkContainer.home方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: iteratesOverFirstPage
import com.jcabi.http.mock.MkContainer; //导入方法依赖的package包/类
/**
* CommentsPage can return the first page of comments.
* @throws Exception If something goes wrong.
*/
@Test
public void iteratesOverFirstPage() throws Exception {
final MkContainer container = this.mockVersionEyeComments().start();
final VersionEye versionEye = new RtVersionEye(
new JdkRequest(container.home())
);
List<Comment> first = versionEye.users().user("amihaiemil").comments()
.paginated().fetch();
MatcherAssert.assertThat(first.size(), Matchers.is(2));
MatcherAssert.assertThat(
first.get(0).id(),
Matchers.equalTo("58f9b08ed797b2000e28d24e232323")
);
MatcherAssert.assertThat(
first.get(1).id(),
Matchers.equalTo("yurtuyrtuuyeprwiefwefpn")
);
MatcherAssert.assertThat(
container.take().uri().toString(),
Matchers.equalTo("/users/amihaiemil/comments?page=1")
);
}
示例2: knowsAbout
import com.jcabi.http.mock.MkContainer; //导入方法依赖的package包/类
/**
* RtUser can fetch data about a certain user.
* @throws IOException If something goes wrong.
*/
@Test
public void knowsAbout() throws IOException {
final MkContainer container = new MkGrizzlyContainer().next(
new MkAnswer.Simple(
HttpURLConnection.HTTP_OK,
"{\"fullname\": \"Jon Doe\", \"username\": \"jdoe\"}"
)
).start();
final User jon = new RtUser(
new JdkRequest(container.home()), "jdoe"
);
UserData about = jon.about();
MatcherAssert.assertThat(
about.fullName(), Matchers.equalTo("Jon Doe")
);
MatcherAssert.assertThat(
about.username(), Matchers.equalTo("jdoe")
);
MatcherAssert.assertThat(
container.take().uri().toString(),
Matchers.equalTo("/jdoe")
);
}
示例3: iteratesOverFirstPage
import com.jcabi.http.mock.MkContainer; //导入方法依赖的package包/类
/**
* RepositoriesPage can return the first page of repositories.
* @throws Exception If something goes wrong.
*/
@Test
public void iteratesOverFirstPage() throws Exception {
final MkContainer container =
this.mockVersionEyeRepositories().start();
final VersionEye versionEye = new RtVersionEye(
new JdkRequest(container.home())
);
List<Repository> first =
versionEye.github().repositories().paginated().fetch();
MatcherAssert.assertThat(first.size(), Matchers.is(14));
MatcherAssert.assertThat(
first.get(0).name(),
Matchers.equalTo("Compiler")
);
MatcherAssert.assertThat(
first.get(13).name(),
Matchers.equalTo("versioneye-api")
);
MatcherAssert.assertThat(
container.take().uri().toString(),
Matchers.equalTo("/github?page=1")
);
}
示例4: pingOk
import com.jcabi.http.mock.MkContainer; //导入方法依赖的package包/类
/**
* RtServices can ping the server successfully.
* @throws IOException if something goes wrong,
*/
@Test
public void pingOk() throws IOException {
final MkContainer container = new MkGrizzlyContainer().next(
new MkAnswer.Simple(
HttpURLConnection.HTTP_OK,
"{\"success\":true, \"message\":\"pong\"}"
)
).start();
final Services services = new RtServices(
new JdkRequest(container.home())
);
final JsonObject ping = services.ping();
MatcherAssert.assertThat(
ping.getBoolean("success"), Matchers.is(true)
);
MatcherAssert.assertThat(
ping.getString("message"), Matchers.is("pong")
);
MatcherAssert.assertThat(
container.take().uri().toString(),
Matchers.equalTo("/services/ping")
);
}
示例5: iteratesOverFirstPage
import com.jcabi.http.mock.MkContainer; //导入方法依赖的package包/类
/**
* VulnerabilitiesPage can return the first page of comments.
* @throws Exception If something goes wrong.
*/
@Test
public void iteratesOverFirstPage() throws Exception {
final MkContainer container = this.mockVersionEyeComments().start();
final VersionEye versionEye = new RtVersionEye(
new JdkRequest(container.home())
);
List<Vulnerability> first = versionEye.security("Java").paginated()
.fetch();
MatcherAssert.assertThat(first.size(), Matchers.is(2));
MatcherAssert.assertThat(
container.take().uri().toString(),
Matchers.equalTo("/security?language=Java&page=1")
);
}
示例6: iteratesOverFirstPage
import com.jcabi.http.mock.MkContainer; //导入方法依赖的package包/类
/**
* FavoritesPage can return the first page of favorites.
* @throws Exception If something goes wrong.
*/
@Test
public void iteratesOverFirstPage() throws Exception {
final MkContainer container = this.mockVersionEyeFavorites().start();
final VersionEye versionEye = new RtVersionEye(
new JdkRequest(container.home())
);
List<Favorite> first = versionEye.users().user("SherifWaly")
.favorites().paginated().fetch();
MatcherAssert.assertThat(first.size(), Matchers.is(2));
MatcherAssert.assertThat(
first.get(0).name(),
Matchers.equalTo("doctrine/common")
);
MatcherAssert.assertThat(
first.get(1).name(),
Matchers.equalTo("doctrine/doctrine-module")
);
MatcherAssert.assertThat(
container.take().uri().toString(),
Matchers.equalTo("/users/SherifWaly/favorites?page=1")
);
}
示例7: deletesProject
import com.jcabi.http.mock.MkContainer; //导入方法依赖的package包/类
/**
* RtProject can delete the project from the VersionEye server.
* @throws IOException If something goes wrong.
*/
@Test
public void deletesProject() throws IOException {
final MkContainer container = new MkGrizzlyContainer().next(
new MkAnswer.Simple(HttpURLConnection.HTTP_NO_CONTENT)
).start();
final Project project = new RtProject(
new JdkRequest(container.home()),
Mockito.mock(Team.class),
Json.createObjectBuilder().add("ids", "project123").build()
);
project.delete();
final MkQuery request = container.take();
MatcherAssert.assertThat(
request.method(), Matchers.equalTo("DELETE")
);
MatcherAssert.assertThat(
request.uri().toString(), Matchers.equalTo("/project123")
);
}
示例8: checkUserIsAssigneeForRepo
import com.jcabi.http.mock.MkContainer; //导入方法依赖的package包/类
/**
* RtAssignees can check if user is assignee for this repo.
* @throws Exception Exception If some problem inside
*/
@Test
public void checkUserIsAssigneeForRepo() throws Exception {
final MkContainer container = new MkGrizzlyContainer().next(
new MkAnswer.Simple(
HttpURLConnection.HTTP_NO_CONTENT,
Json.createArrayBuilder()
.add(RtAssigneesTest.json("octocat2"))
.add(RtAssigneesTest.json("dummy"))
.build().toString()
)
).start();
final Assignees users = new RtAssignees(
new JdkRequest(container.home()),
this.repo()
);
MatcherAssert.assertThat(
users.check("octocat2"),
Matchers.equalTo(true)
);
container.stop();
}
示例9: removeGistComment
import com.jcabi.http.mock.MkContainer; //导入方法依赖的package包/类
/**
* RtGistComment can remove comment.
* @throws IOException if has some problems with json parsing.
*/
@Test
public final void removeGistComment() throws IOException {
final int identifier = 1;
final MkContainer container = new MkGrizzlyContainer().next(
new MkAnswer.Simple(HttpURLConnection.HTTP_NO_CONTENT, "")
).start();
final RtGist gist = new RtGist(
new MkGithub(),
new FakeRequest().withStatus(HttpURLConnection.HTTP_NO_CONTENT),
"gistName"
);
final RtGistComment comment = new RtGistComment(
new ApacheRequest(container.home()), gist, identifier
);
comment.remove();
MatcherAssert.assertThat(
container.take().method(),
Matchers.equalTo(Request.DELETE)
);
container.stop();
}
示例10: canRetrieveSpecificGist
import com.jcabi.http.mock.MkContainer; //导入方法依赖的package包/类
/**
* RtGists can retrieve a specific Gist.
*
* @throws Exception if a problem occurs.
*/
@Test
public void canRetrieveSpecificGist() throws Exception {
final MkContainer container = new MkGrizzlyContainer().next(
new MkAnswer.Simple(HttpURLConnection.HTTP_OK, "testing")
).start();
final Gists gists = new RtGists(
new MkGithub(),
new ApacheRequest(container.home())
);
try {
MatcherAssert.assertThat(
gists.get("gist"),
Matchers.notNullValue()
);
} finally {
container.stop();
}
}
示例11: patchesComment
import com.jcabi.http.mock.MkContainer; //导入方法依赖的package包/类
/**
* RtComment can patch a comment.
* @throws Exception - if anything goes wrong.
*/
@Test
public void patchesComment() throws Exception {
final MkContainer container = new MkGrizzlyContainer().next(
new MkAnswer.Simple(HttpURLConnection.HTTP_OK, "")
).start();
final Repo repo = new MkGithub().randomRepo();
final Issue issue = repo.issues().create("testing5", "issue5");
final RtComment comment = new RtComment(
new ApacheRequest(container.home()), issue, 10
);
final JsonObject jsonPatch = Json.createObjectBuilder()
.add("title", "test comment").build();
try {
comment.patch(jsonPatch);
final MkQuery query = container.take();
MatcherAssert.assertThat(
query.method(), Matchers.equalTo(Request.PATCH)
);
} finally {
container.stop();
}
}
示例12: canFetchEmptyListOfHooks
import com.jcabi.http.mock.MkContainer; //导入方法依赖的package包/类
/**
* RtHooks can fetch empty list of hooks.
* @throws Exception if some problem inside
*/
@Test
public void canFetchEmptyListOfHooks() throws Exception {
final MkContainer container = new MkGrizzlyContainer().next(
new MkAnswer.Simple(HttpURLConnection.HTTP_OK, "[]")
).start();
final Hooks hooks = new RtHooks(
new JdkRequest(container.home()),
RtHooksTest.repo()
);
try {
MatcherAssert.assertThat(
hooks.iterate(),
Matchers.emptyIterable()
);
} finally {
container.stop();
}
}
示例13: iterateTemplateNames
import com.jcabi.http.mock.MkContainer; //导入方法依赖的package包/类
/**
* 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();
}
示例14: executePatchRequest
import com.jcabi.http.mock.MkContainer; //导入方法依赖的package包/类
/**
* RtJson can execute PATCH request.
*
* @throws Exception if there is any problem
*/
@Test
public void executePatchRequest() throws Exception {
final MkContainer container = new MkGrizzlyContainer().next(
new MkAnswer.Simple(HttpURLConnection.HTTP_OK, "{\"body\":\"hj\"}")
).start();
final RtJson json = new RtJson(new ApacheRequest(container.home()));
json.patch(
Json.createObjectBuilder()
.add("content", "hi you!")
.build()
);
MatcherAssert.assertThat(
container.take().method(),
Matchers.equalTo("PATCH")
);
container.stop();
}
示例15: fetchesContent
import com.jcabi.http.mock.MkContainer; //导入方法依赖的package包/类
/**
* RtReference should be able to fetch its json.
* @throws Exception - if something goes wrong.
*/
@Test
public void fetchesContent() throws Exception {
final MkContainer container = new MkGrizzlyContainer().next(
new MkAnswer.Simple(
HttpURLConnection.HTTP_OK,
"{\"ref\":\"refs/heads/featureB\"}"
)
).start();
final Reference reference = new RtReference(
new ApacheRequest(container.home()),
new MkGithub().randomRepo(),
"refs/heads/featureB"
);
try {
MatcherAssert.assertThat(
reference.json().getString("ref"),
Matchers.is("refs/heads/featureB")
);
} finally {
container.stop();
}
}