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 org.hamcrest.MatcherAssert;
10  import org.hamcrest.Matchers;
11  import org.junit.jupiter.api.Test;
12  import org.mockito.Mockito;
13  
14  /**
15   * Test case for {@link Milestone}.
16   * @since 0.7
17   * @checkstyle MultipleStringLiterals (500 lines)
18   */
19  final class MilestoneTest {
20      @Test
21      void fetchesTitle() throws IOException {
22          final Milestone milestone = Mockito.mock(Milestone.class);
23          Mockito.doReturn(
24              Json.createObjectBuilder()
25                  .add("title", "this is some title")
26                  .build()
27          ).when(milestone).json();
28          MatcherAssert.assertThat(
29              "Value is null",
30              new Milestone.Smart(milestone).title(),
31              Matchers.notNullValue()
32          );
33      }
34  
35      @Test
36      void fetchesDescription() throws IOException {
37          final Milestone milestone = Mockito.mock(Milestone.class);
38          Mockito.doReturn(
39              Json.createObjectBuilder()
40                  .add("description", "description of the milestone")
41                  .build()
42          ).when(milestone).json();
43          MatcherAssert.assertThat(
44              "Value is null",
45              new Milestone.Smart(milestone).description(),
46              Matchers.notNullValue()
47          );
48      }
49  
50      @Test
51      void fetchesState() throws IOException {
52          final Milestone milestone = Mockito.mock(Milestone.class);
53          Mockito.doReturn(
54              Json.createObjectBuilder()
55                  .add("state", "state of the milestone")
56                  .build()
57          ).when(milestone).json();
58          MatcherAssert.assertThat(
59              "Value is null",
60              new Milestone.Smart(milestone).state(),
61              Matchers.notNullValue()
62          );
63      }
64  
65      @Test
66      void fetchesDueOn() throws IOException {
67          final Milestone milestone = Mockito.mock(Milestone.class);
68          Mockito.doReturn(
69              Json.createObjectBuilder()
70                  .add("due_on", "2011-04-10T20:09:31Z")
71                  .build()
72          ).when(milestone).json();
73          MatcherAssert.assertThat(
74              "Value is null",
75              new Milestone.Smart(milestone).dueOn(),
76              Matchers.notNullValue()
77          );
78      }
79  }