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 jakarta.json.Json;
8   import java.io.IOException;
9   import java.util.Collections;
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 Smarts}.
17   * @since 0.5
18   */
19  final class SmartsTest {
20  
21      @Test
22      void decoratesObjectsOnFly() throws IOException {
23          final Comment origin = Mockito.mock(Comment.class);
24          Mockito.doReturn(
25              Json.createObjectBuilder().add("body", "hello, world!").build()
26          ).when(origin).json();
27          final Iterable<Comment.Smart> comments = new Smarts<>(
28              Collections.singletonList(origin)
29          );
30          MatcherAssert.assertThat(
31              "String does not end with expected value",
32              comments.iterator().next().body(),
33              Matchers.endsWith("world!")
34          );
35      }
36  
37  }