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


Java Comments类代码示例

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


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

示例1: comments

import com.jcabi.github.Comments; //导入依赖的package包/类
@Override
@NotNull(message = "comments is never NULL")
public Comments comments() {
    try {
        return new MkComments(
            this.storage, this.self, this.coords, this.num
        );
    } catch (final IOException ex) {
        throw new IllegalStateException(ex);
    }
}
 
开发者ID:cvrebert,项目名称:typed-github,代码行数:12,代码来源:MkIssue.java

示例2: iteratesComments

import com.jcabi.github.Comments; //导入依赖的package包/类
/**
 * MkComments can iterate comments.
 * @throws Exception If some problem inside
 */
@Test
public void iteratesComments() throws Exception {
    final Comments comments = this.comments();
    comments.post("hello, dude!");
    comments.post("hello again");
    MatcherAssert.assertThat(
        comments.iterate(),
        Matchers.<Comment>iterableWithSize(2)
    );
}
 
开发者ID:cvrebert,项目名称:typed-github,代码行数:15,代码来源:MkCommentsTest.java

示例3: comments

import com.jcabi.github.Comments; //导入依赖的package包/类
@Override
public Comments comments() {
    try {
        return new MkComments(
            this.storage, this.self, this.coords, this.num
        );
    } catch (final IOException ex) {
        throw new IllegalStateException(ex);
    }
}
 
开发者ID:jcabi,项目名称:jcabi-github,代码行数:11,代码来源:MkIssue.java

示例4: iteratesComments

import com.jcabi.github.Comments; //导入依赖的package包/类
/**
 * MkComments can iterate comments.
 * @throws Exception If some problem inside
 */
@Test
public void iteratesComments() throws Exception {
    final Comments comments = this.comments();
    comments.post("hello, dude!");
    comments.post("hello again");
    MatcherAssert.assertThat(
        comments.iterate(new Date(0L)),
        Matchers.<Comment>iterableWithSize(2)
    );
}
 
开发者ID:jcabi,项目名称:jcabi-github,代码行数:15,代码来源:MkCommentsTest.java

示例5: actionsFail

import com.jcabi.github.Comments; //导入依赖的package包/类
/**
 * Start 2 actions but each of them fail with IOException
 * when the comments are first listed (within LastComment(...))
 * @throws Exception If something goes wrong
 */
@Test
public void actionsFail() throws Exception {
    Language english = (Language)new English();
    Issue issue1 = this.githubIssue("amihaiemil", "@charlesmike index");
    Issue issue2 = this.githubIssue("jeff", "@charlesmike index");
    
    Comments comments = Mockito.mock(Comments.class);
    Comment com = Mockito.mock(Comment.class);
    Mockito.when(com.json()).thenThrow(new IOException("expected IOException..."));
    Mockito.when(comments.iterate()).thenReturn(Arrays.asList(com));
    
    Issue mockedIssue1 = Mockito.mock(Issue.class);
    Mockito.when(mockedIssue1.comments())
        .thenReturn(comments)
        .thenReturn(issue1.comments());

    Issue mockedIssue2 = Mockito.mock(Issue.class);
    Mockito.when(mockedIssue2.comments())
        .thenReturn(comments)
        .thenReturn(issue2.comments());
    
    final Action ac1 = new Action(mockedIssue1);
    final Action ac2 = new Action(mockedIssue2);
    
    final ExecutorService executorService = Executors.newFixedThreadPool(5);
    List<Future> futures = new ArrayList<Future>();
    futures.add(executorService.submit(new Runnable() {
        @Override
        public void run() {
            ac1.perform();;
        }
    }));
    futures.add(executorService.submit(new Runnable() {
        @Override
        public void run() {
            ac2.perform();
        }
    }));

    for(Future f : futures) {
        assertTrue(f.get()==null);
    }
    
    List<Comment> commentsWithReply1 = Lists.newArrayList(issue1.comments().iterate());
    List<Comment> commentsWithReply2 = Lists.newArrayList(issue2.comments().iterate());

    String expectedStartsWith = "There was an error when processing your command. [Here](/";
    assertTrue(commentsWithReply1.get(1).json().getString("body")
            .startsWith(expectedStartsWith)); //there should be only 2 comments - the command and the reply.
    
    assertTrue(commentsWithReply2.get(1).json().getString("body")
            .startsWith(expectedStartsWith)); //there should be only 2 comments - the command and the reply.
    
}
 
开发者ID:opencharles,项目名称:charles-rest,代码行数:60,代码来源:ActionTestCase.java

示例6: getsOrganizationMembership

import com.jcabi.github.Comments; //导入依赖的package包/类
/**
 * Command can fetch the author's organization membership.
 * @throws Exception if something goes wrong.
 */
@Test
public void getsOrganizationMembership() throws Exception {
    int port = this.port();
    MkContainer server = new MkGrizzlyContainer()
        .next(
            new MkAnswer.Simple(
                Json.createObjectBuilder()
                    .add("state", "snowflake")
                    .add("role", "special_test_admin")
                    .build().toString()
            )
        ).start(port);
    try {
        Github gh = Mockito.mock(Github.class);
        Mockito.when(gh.entry()).thenReturn(
            new ApacheRequest("http://localhost:" + port + "/")        
        );
        Repo repo = Mockito.mock(Repo.class);
        Mockito.when(repo.json()).thenReturn(
            Json.createObjectBuilder().add(
                "owner",
                Json.createObjectBuilder().add(
                    "type", "organization"        
                ).add(
                    "login", "someorganization"
                ).build()
            ).build()
        );
        Mockito.when(repo.github()).thenReturn(gh);
        
        Comments comments = Mockito.mock(Comments.class);
        Mockito.when(comments.iterate()).thenReturn(new ArrayList<Comment>());
        
        Issue issue = Mockito.mock(Issue.class);
        Mockito.when(issue.repo()).thenReturn(repo);
        Mockito.when(issue.comments()).thenReturn(comments);

        LastComment lastComment = new LastComment(issue);
        lastComment.comment(
            Json.createObjectBuilder().add(
                "user",
                Json.createObjectBuilder()
                    .add("login", "amihaiemil")
                    .build()
            ).build()
        );
        JsonObject mem = lastComment.authorOrgMembership();
        assertTrue(mem.getString("state").equals("snowflake"));
        assertTrue(mem.getString("role").equals("special_test_admin"));
        MkQuery request = server.take();
        String uri = request.uri().toString();
        assertTrue(
            uri.equals(
                "/orgs/someorganization/memberships/amihaiemil"
            )
        );
    } finally {
        server.stop();
    }
}
 
开发者ID:opencharles,项目名称:charles-rest,代码行数:65,代码来源:LastCommentTestCase.java

示例7: comments

import com.jcabi.github.Comments; //导入依赖的package包/类
/**
 * Create a comments to work with.
 * @return Comments just created
 * @throws Exception If some problem inside
 */
private Comments comments() throws Exception {
    return new MkGithub().randomRepo()
        .issues().create("hey", "how are you?")
        .comments();
}
 
开发者ID:cvrebert,项目名称:typed-github,代码行数:11,代码来源:MkCommentsTest.java


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