当前位置: 首页>>代码示例>>Java>>正文


Java MkContainer类代码示例

本文整理汇总了Java中com.jcabi.http.mock.MkContainer的典型用法代码示例。如果您正苦于以下问题:Java MkContainer类的具体用法?Java MkContainer怎么用?Java MkContainer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MkContainer类属于com.jcabi.http.mock包,在下文中一共展示了MkContainer类的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")
    );
    
}
 
开发者ID:decorators-squad,项目名称:versioneye-api,代码行数:28,代码来源:CommentsPageTestCase.java

示例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")
    );
}
 
开发者ID:decorators-squad,项目名称:versioneye-api,代码行数:28,代码来源:RtUserTestCase.java

示例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")
    );   
}
 
开发者ID:decorators-squad,项目名称:versioneye-api,代码行数:28,代码来源:RepositoriesPageTestCase.java

示例4: mockVersionEyeRepositories

import com.jcabi.http.mock.MkContainer; //导入依赖的package包/类
/**
 * Mock the versioneye server for repositories.
 * @return MkContainer.
 * @throws IOException If something goes wrong.
 */
private MkContainer mockVersionEyeRepositories() throws IOException {
    return new MkGrizzlyContainer().next(
        new MkAnswer.Simple(
            HttpURLConnection.HTTP_OK,
            this.readResource("repositoriespage1.json")
        )
    ).next(
        new MkAnswer.Simple(
            HttpURLConnection.HTTP_OK,
            this.readResource("repositoriespage1.json")
        )
    ).next(
        new MkAnswer.Simple(
            HttpURLConnection.HTTP_OK,
            this.readResource("repositoriespage2.json")
        )
    );
}
 
开发者ID:decorators-squad,项目名称:versioneye-api,代码行数:24,代码来源:RepositoriesPageTestCase.java

示例5: 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")
    );
}
 
开发者ID:decorators-squad,项目名称:versioneye-api,代码行数:28,代码来源:RtServicesTestCase.java

示例6: fetchesComments

import com.jcabi.http.mock.MkContainer; //导入依赖的package包/类
/**
 * RtComments can fetch a user's comments.
 * @throws IOException If something goes wrong.
 */
@Test
public void fetchesComments() throws IOException {
    final MkContainer container = new MkGrizzlyContainer().next(
        new MkAnswer.Simple(
            HttpURLConnection.HTTP_OK,
            this.readResource("commentspage1.json")
        )
    ).start();
    final Comments comments = new RtVersionEye(
        new JdkRequest(container.home())
    ).me().comments();
    
    final List<Comment> fetched = comments.fetch(1);
    MatcherAssert.assertThat(fetched.size(), Matchers.is(2));
    MatcherAssert.assertThat(
        fetched.get(0).id(),
        Matchers.equalTo("58f9b08ed797b2000e28d24e232323")
    );
    MatcherAssert.assertThat(
        container.take().uri().toString(),
        Matchers.equalTo("/me/comments?page=1")
    );
}
 
开发者ID:decorators-squad,项目名称:versioneye-api,代码行数:28,代码来源:RtCommentsTestCase.java

示例7: returnsAuthenticatedUser

import com.jcabi.http.mock.MkContainer; //导入依赖的package包/类
/**
 * RtMe can return Authenticated user.
 * @throws IOException If something goes wrong.
 */
@Test
public void returnsAuthenticatedUser() throws IOException {
    final MkContainer container = new MkGrizzlyContainer().next(
        new MkAnswer.Simple(
            HttpURLConnection.HTTP_OK,
            this.readResource("authenticated.json")
        )
    ).start();
    
    final Authenticated authenticated = new RtVersionEye(
        new JdkRequest(container.home())
    ).me().about();
    
    MatcherAssert.assertThat(
        authenticated.username(), Matchers.is("SherifWaly")
    );
    MatcherAssert.assertThat(
        container.take().uri().toString(),
        Matchers.equalTo("/me")
    );
}
 
开发者ID:decorators-squad,项目名称:versioneye-api,代码行数:26,代码来源:RtMeTestCase.java

示例8: returnsUserData

import com.jcabi.http.mock.MkContainer; //导入依赖的package包/类
/**
 * RtFavorites can return user data.
 * @throws IOException If something goes wrong.
 */
@Test
public void returnsUserData() throws IOException {
    final MkContainer container = new MkGrizzlyContainer().next(
        new MkAnswer.Simple(
            HttpURLConnection.HTTP_OK,
            this.readResource("favoritespage1.json")
        )
    ).start();
    final Favorites favorites = new RtVersionEye(
        new JdkRequest(container.home())
    ).me().favorites();
   
    UserData userData = favorites.userData();
    MatcherAssert.assertThat(
        userData.fullName(),
        Matchers.is("Sherif Waly")
    );
    MatcherAssert.assertThat(
        userData.username(),
        Matchers.is("SherifWaly")
    );
}
 
开发者ID:decorators-squad,项目名称:versioneye-api,代码行数:27,代码来源:RtFavoritesTestCase.java

示例9: syncsGithub

import com.jcabi.http.mock.MkContainer; //导入依赖的package包/类
/**
 * RtGithub can sync the user's Github repos.
 * @throws IOException If something goes wrong.
 */
@Test
@SuppressWarnings("resource")
public void syncsGithub() throws IOException {
    final MkContainer container = new MkGrizzlyContainer().next(
        new MkAnswer.Simple(
            HttpURLConnection.HTTP_OK, "{\"status\": \"running\"}"
        )
    ).start();
    
    final String status = new RtVersionEye(
        new JdkRequest(container.home())
    ).github().sync();
    
    MatcherAssert.assertThat(status, Matchers.is("running"));
    MatcherAssert.assertThat(
        container.take().uri().toString(), Matchers.equalTo("/github/sync")
    );
}
 
开发者ID:decorators-squad,项目名称:versioneye-api,代码行数:23,代码来源:RtGithubTestCase.java

示例10: 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")
    );
    
}
 
开发者ID:decorators-squad,项目名称:versioneye-api,代码行数:20,代码来源:VulnerabilitiesPageTestCase.java

示例11: mockVersionEyeComments

import com.jcabi.http.mock.MkContainer; //导入依赖的package包/类
/**
 * Mock the versioneye server for comments.
 * @return MkContainer.
 * @throws IOException If something goes wrong.
 */
private MkContainer mockVersionEyeComments() throws IOException {
    final String firstPage = this.readResource(
        "vulnerabilities/vulnerabilitiespage1.json"
    );
    final String secondPage = this.readResource(
        "vulnerabilities/vulnerabilitiespage2.json"
    );
    final String thirdPage = this.readResource(
        "vulnerabilities/vulnerabilitiespage3.json"
    );
    
    return new MkGrizzlyContainer().next(
        new MkAnswer.Simple(HttpURLConnection.HTTP_OK, firstPage)
    ).next(
        new MkAnswer.Simple(HttpURLConnection.HTTP_OK, firstPage)
    ).next(
        new MkAnswer.Simple(HttpURLConnection.HTTP_OK, secondPage)
    ).next(
        new MkAnswer.Simple(HttpURLConnection.HTTP_OK, secondPage)
    ).next(
        new MkAnswer.Simple(HttpURLConnection.HTTP_OK, thirdPage)
    );
}
 
开发者ID:decorators-squad,项目名称:versioneye-api,代码行数:29,代码来源:VulnerabilitiesPageTestCase.java

示例12: returnsOrganizationWithName

import com.jcabi.http.mock.MkContainer; //导入依赖的package包/类
/**
 * RtOrganizations can return an organization with given name.
 * @throws IOException If something goes wrong.
 */
@Test
public void returnsOrganizationWithName() throws IOException {
    final MkContainer container = new MkGrizzlyContainer().next(
        new MkAnswer.Simple(
            HttpURLConnection.HTTP_OK,
            this.readResource("organizations.json")
        )
    ).start(); 
    final Organizations organizations = new RtVersionEye(
        new JdkRequest(container.home())
    ).organizations();
    
    MatcherAssert.assertThat(
        organizations.organization("sherifwaly_orga").apiKey(),
        Matchers.equalTo("88870f2710dba853a326")
    );
}
 
开发者ID:decorators-squad,项目名称:versioneye-api,代码行数:22,代码来源:RtOrganizationsTestCase.java

示例13: throwsIoExceptionForInvalidOrganizationName

import com.jcabi.http.mock.MkContainer; //导入依赖的package包/类
/**
 * RtOrganizations throws IOException with invalid organization name.
 * @throws IOException If something goes wrong.
 */
@Test(expected=IOException.class)
public void throwsIoExceptionForInvalidOrganizationName()
    throws IOException {
    final MkContainer container = new MkGrizzlyContainer().next(
        new MkAnswer.Simple(
            HttpURLConnection.HTTP_OK,
            this.readResource("organizations.json")
        )
    ).start(); 
    final Organizations organizations = new RtVersionEye(
        new JdkRequest(container.home())
    ).organizations();
        
    organizations.organization("invalid_orga");
}
 
开发者ID:decorators-squad,项目名称:versioneye-api,代码行数:20,代码来源:RtOrganizationsTestCase.java

示例14: 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")
    );
    
}
 
开发者ID:decorators-squad,项目名称:versioneye-api,代码行数:28,代码来源:FavoritesPageTestCase.java

示例15: deletesProjectBranchAndModifiesRepositoryName

import com.jcabi.http.mock.MkContainer; //导入依赖的package包/类
/**
 * RtRepository can delete the repository branch from
 * the VersionEye server and modifies repository name by replacing
 * '/' to ':' and '.' to '~'.
 * @throws IOException If something goes wrong.
 */
@Test
public void deletesProjectBranchAndModifiesRepositoryName()
    throws IOException {
    final MkContainer container = new MkGrizzlyContainer().next(
        new MkAnswer.Simple(HttpURLConnection.HTTP_OK)
    ).start();
    final Repository repository = new RtRepository(
        Json.createObjectBuilder().add("fullname", "repo/repo").build(),
        new JdkRequest(container.home())
    );
    repository.delete("master");
    final MkQuery request = container.take();
    MatcherAssert.assertThat(
        request.method(), Matchers.equalTo("DELETE")
    );
    MatcherAssert.assertThat(
        request.uri().toString(),
        Matchers.equalTo("/repo:repo?branch=master")
    );
}
 
开发者ID:decorators-squad,项目名称:versioneye-api,代码行数:27,代码来源:RtRepositoryTestCase.java


注:本文中的com.jcabi.http.mock.MkContainer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。