View Javadoc
1   /*
2    * SPDX-FileCopyrightText: Copyright (c) 2013-2025 Yegor Bugayenko
3    * SPDX-License-Identifier: MIT
4    */
5   package com.jcabi.github;
6   
7   import com.jcabi.http.Request;
8   import com.jcabi.http.request.FakeRequest;
9   import java.io.IOException;
10  import org.hamcrest.MatcherAssert;
11  import org.hamcrest.Matchers;
12  import org.junit.jupiter.api.Test;
13  import org.mockito.Mockito;
14  
15  /**
16   * Test case for {@link Bulk}.
17   * @since 0.17
18   */
19  final class BulkTest {
20  
21      @Test
22      void cachesJsonData() throws IOException {
23          final Comment origin = Mockito.mock(Comment.class);
24          final Request request = new FakeRequest()
25              .withBody("[{\"body\": \"hey you\"}]");
26          final Iterable<Comment> comments = new Bulk<>(
27              new RtPagination<>(
28                  request,
29                  object -> origin
30              )
31          );
32          final Comment comment = comments.iterator().next();
33          MatcherAssert.assertThat(
34              "Values are not equal",
35              new Comment.Smart(comment).body(),
36              Matchers.equalTo("hey you")
37          );
38          comment.number();
39          Mockito.verify(origin).number();
40          Mockito.verify(origin, Mockito.never()).json();
41      }
42  
43  }