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 org.hamcrest.MatcherAssert;
8   import org.hamcrest.Matchers;
9   import org.junit.jupiter.api.Test;
10  import org.mockito.Mockito;
11  
12  /**
13   * Tests for {@link Label}.
14   * @since 0.1
15   * @checkstyle MultipleStringLiterals (500 lines)
16   */
17  final class LabelTest {
18  
19      @Test
20      void canBeComparedProperly() {
21          final Label.Unmodified one = new Label.Unmodified(
22              LabelTest.repo("jef", "jef_repo"),
23              "{\"name\":\"paul\"}"
24          );
25          final Label.Unmodified other = new Label.Unmodified(
26              LabelTest.repo("stan", "stan_repo"),
27              "{\"name\":\"paul\"}"
28          );
29          MatcherAssert.assertThat(
30              "Values are not equal",
31              one.equals(other),
32              Matchers.is(false)
33          );
34          MatcherAssert.assertThat(
35              "Assertion failed",
36              one.compareTo(other),
37              Matchers.not(0)
38          );
39      }
40  
41      /**
42       * Create and return repo for testing.
43       * @param user User name
44       * @param rpo Repo name
45       * @return Repo
46       */
47      private static Repo repo(final String user, final String rpo) {
48          final Repo repo = Mockito.mock(Repo.class);
49          Mockito.doReturn(new Coordinates.Simple(user, rpo))
50              .when(repo).coordinates();
51          return repo;
52      }
53  }