1
2
3
4
5 package com.jcabi.github;
6
7 import com.jcabi.http.request.FakeRequest;
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
16
17
18 final class RtPublicKeyTest {
19
20 @Test
21 void canRepresentAsJson() throws IOException {
22 final RtPublicKey key = new RtPublicKey(
23 new FakeRequest().withBody("{}"),
24 Mockito.mock(User.class),
25 1
26 );
27 MatcherAssert.assertThat(
28 "Value is null",
29 key.json(),
30 Matchers.notNullValue()
31 );
32 }
33
34 @Test
35 void canObtainUser() {
36 final User user = Mockito.mock(User.class);
37 final RtPublicKey key = new RtPublicKey(new FakeRequest(), user, 2);
38 MatcherAssert.assertThat(
39 "Assertion failed",
40 key.user(),
41 Matchers.sameInstance(user)
42 );
43 }
44
45 @Test
46 void canObtainNumber() {
47 final int number = 39;
48 final RtPublicKey key = new RtPublicKey(
49 new FakeRequest(),
50 Mockito.mock(User.class),
51 number
52 );
53 MatcherAssert.assertThat(
54 "Values are not equal",
55 key.number(),
56 Matchers.equalTo(number)
57 );
58 }
59
60 }