1
2
3
4
5 package com.jcabi.github;
6
7 import com.jcabi.http.Request;
8 import com.jcabi.http.mock.MkAnswer;
9 import com.jcabi.http.mock.MkContainer;
10 import com.jcabi.http.mock.MkGrizzlyContainer;
11 import com.jcabi.http.mock.MkQuery;
12 import com.jcabi.http.request.ApacheRequest;
13 import java.io.IOException;
14 import java.net.HttpURLConnection;
15 import org.hamcrest.MatcherAssert;
16 import org.hamcrest.Matchers;
17 import org.junit.jupiter.api.Test;
18 import org.junit.jupiter.api.extension.ExtendWith;
19 import org.mockito.Mockito;
20
21
22
23
24
25 @ExtendWith(RandomPort.class)
26 final class RtDeployKeyTest {
27
28
29
30
31
32 @Test
33 void canDeleteDeployKey() throws IOException {
34 try (
35 MkContainer container = new MkGrizzlyContainer().next(
36 new MkAnswer.Simple(
37 HttpURLConnection.HTTP_NO_CONTENT,
38 ""
39 )
40 ).start(RandomPort.port())
41 ) {
42 final DeployKey key = new RtDeployKey(
43 new ApacheRequest(container.home()),
44 3,
45 RtDeployKeyTest.repo()
46 );
47 key.remove();
48 final MkQuery query = container.take();
49 MatcherAssert.assertThat(
50 "Values are not equal",
51 query.method(),
52 Matchers.equalTo(Request.DELETE)
53 );
54 }
55 }
56
57
58
59
60
61 private static Repo repo() {
62 final Repo repo = Mockito.mock(Repo.class);
63 Mockito.doReturn(new Coordinates.Simple("test", "keys"))
64 .when(repo).coordinates();
65 return repo;
66 }
67 }