-
Notifications
You must be signed in to change notification settings - Fork 457
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
122 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package org.gitlab4j.api; | ||
|
||
import static org.gitlab4j.api.JsonUtils.compareJson; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
import static org.mockito.ArgumentMatchers.any; | ||
import static org.mockito.Mockito.when; | ||
import static org.mockito.MockitoAnnotations.openMocks; | ||
|
||
import java.io.IOException; | ||
|
||
import javax.ws.rs.core.MultivaluedMap; | ||
|
||
import org.gitlab4j.api.models.Topic; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.mockito.ArgumentCaptor; | ||
import org.mockito.Captor; | ||
import org.mockito.Mock; | ||
import org.mockito.Mockito; | ||
|
||
public class TestTopicsApi implements Constants { | ||
|
||
@Mock private GitLabApi gitLabApi; | ||
@Mock private GitLabApiClient gitLabApiClient; | ||
@Captor private ArgumentCaptor<MultivaluedMap<String, String>> attributeCaptor; | ||
private MockResponse response; | ||
|
||
@BeforeEach | ||
public void setUp() throws Exception { | ||
openMocks(this); | ||
} | ||
|
||
@Test | ||
public void testGetTopic() throws Exception { | ||
initGetTopic(); | ||
Topic result = new TopicsApi(gitLabApi).getTopic(1); | ||
assertNotNull(result); | ||
assertTrue(compareJson(result, "topic.json")); | ||
} | ||
|
||
private void initGetTopic() throws Exception, IOException { | ||
response = new MockResponse(Topic.class, "topic.json", null); | ||
when(gitLabApi.getApiClient()).thenReturn(gitLabApiClient); | ||
when(gitLabApiClient.validateSecretToken(any())).thenReturn(true); | ||
when(gitLabApiClient.get(attributeCaptor.capture(), Mockito.<Object>any())).thenReturn(response); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"id": 1, | ||
"name": "gitlab", | ||
"title": "GitLab", | ||
"description": "GitLab is an open source end-to-end software development platform with built-in version control, issue tracking, code review, CI/CD, and more.", | ||
"total_projects_count": 1000, | ||
"avatar_url": "http://www.gravatar.com/avatar/a0d477b3ea21970ce6ffcbb817b0b435?s=80&d=identicon" | ||
} |