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


Java MkAnswer类代码示例

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


MkAnswer类属于com.jcabi.http.mock包,在下文中一共展示了MkAnswer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: knowsAbout

import com.jcabi.http.mock.MkAnswer; //导入依赖的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

示例2: mockVersionEyeRepositories

import com.jcabi.http.mock.MkAnswer; //导入依赖的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

示例3: pingOk

import com.jcabi.http.mock.MkAnswer; //导入依赖的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

示例4: fetchesComments

import com.jcabi.http.mock.MkAnswer; //导入依赖的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

示例5: returnsAuthenticatedUser

import com.jcabi.http.mock.MkAnswer; //导入依赖的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

示例6: returnsUserData

import com.jcabi.http.mock.MkAnswer; //导入依赖的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

示例7: syncsGithub

import com.jcabi.http.mock.MkAnswer; //导入依赖的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

示例8: mockVersionEyeComments

import com.jcabi.http.mock.MkAnswer; //导入依赖的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

示例9: returnsOrganizationWithName

import com.jcabi.http.mock.MkAnswer; //导入依赖的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

示例10: throwsIoExceptionForInvalidOrganizationName

import com.jcabi.http.mock.MkAnswer; //导入依赖的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

示例11: deletesProjectBranchAndModifiesRepositoryName

import com.jcabi.http.mock.MkAnswer; //导入依赖的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

示例12: deletesProject

import com.jcabi.http.mock.MkAnswer; //导入依赖的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")
    );
}
 
开发者ID:decorators-squad,项目名称:versioneye-api,代码行数:24,代码来源:RtProjectTestCase.java

示例13: hooksOnGithub

import com.jcabi.http.mock.MkAnswer; //导入依赖的package包/类
/**
 * RtProject can hook itself to Github.
 * @throws IOException If something goes wrong.
 */
@Test
public void hooksOnGithub() throws IOException {
    final MkContainer container = new MkGrizzlyContainer().next(
        new MkAnswer.Simple(HttpURLConnection.HTTP_CREATED)
    ).start();
    Team team = Mockito.mock(Team.class);
    Mockito.when(team.versionEye())
        .thenReturn(
            new RtVersionEye(
                new JdkRequest(container.home())
            )
        );
    final Project project = new RtProject(
        new FakeRequest(), team,
        Json.createObjectBuilder().add("ids", "id123").build()
    );
    MatcherAssert.assertThat(project.hook(), Matchers.is(project));
    final MkQuery request = container.take();
    MatcherAssert.assertThat(
        request.method(), Matchers.equalTo("POST")
    );
    MatcherAssert.assertThat(
        request.uri().toString(), Matchers.equalTo("/github/hook/id123")
    );
}
 
开发者ID:decorators-squad,项目名称:versioneye-api,代码行数:30,代码来源:RtProjectTestCase.java

示例14: pathFromUsers

import com.jcabi.http.mock.MkAnswer; //导入依赖的package包/类
/**
 * RtUser return Request with path.
 * @throws Exception If fails
 */
@Test
public void pathFromUsers() throws Exception {
    final MkContainer container = new MkGrizzlyContainer()
        .next(
            new MkAnswer.Simple(
                HttpURLConnection.HTTP_OK,
                "{\"body\":\"hi\"}"
            )
        ).start();
    new RtHub(
        container.home()
    ).users().self().json();
    container.stop();
    MatcherAssert.assertThat(
        container.take().uri(),
        CoreMatchers.equalTo(
            new URI("/hub/api/rest/users/me")
        )
    );
}
 
开发者ID:smallcreep,项目名称:jb-hub-client,代码行数:25,代码来源:RtUserTest.java

示例15: userAgent

import com.jcabi.http.mock.MkAnswer; //导入依赖的package包/类
/**
 * RtHub return Request with UserAgent.
 * @throws Exception If fails
 */
@Test
public void userAgent() throws Exception {
    final MkContainer container = new MkGrizzlyContainer()
        .next(
            new MkAnswer.Simple("hello, world!")
        ).start();
    new RtHub(
        container.home()
    ).entry().fetch();
    container.stop();
    MatcherAssert.assertThat(
        container.take().headers(),
        Matchers.hasEntry(
            Matchers.equalTo(HttpHeaders.USER_AGENT),
            Matchers.hasItem(
                String.format(
                    "jb-hub-api-client %s %s %s",
                    Manifests.read("Hub-Version"),
                    Manifests.read("Hub-Build"),
                    Manifests.read("Hub-Date")
                )
            )
        )
    );
}
 
开发者ID:smallcreep,项目名称:jb-hub-client,代码行数:30,代码来源:RtHubTest.java


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