Commit ba0a4ef7 authored by unknown's avatar unknown
Browse files

Initial check-in.

parents
package com.messners.gitlab.api;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.List;
import org.codehaus.jackson.JsonParseException;
import org.codehaus.jackson.map.JsonMappingException;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.type.TypeReference;
import org.junit.BeforeClass;
import org.junit.Test;
public class TestGitLabApiBeans {
private static JacksonJsonConfig jacksonJsonConfig;
public TestGitLabApiBeans () {
super();
}
@BeforeClass
public static void setup () {
jacksonJsonConfig = new JacksonJsonConfig();
}
@Test
public void testBranch () {
try {
Branch branch = makeFakeApiCall(Branch.class, "branch");
assertTrue(branch != null);
} catch (Exception e) {
e.printStackTrace();
}
}
@Test
public void testDiff () {
try {
Diff diff = makeFakeApiCall(Diff.class, "diff");
assertTrue(diff != null);
} catch (Exception e) {
e.printStackTrace();
}
}
@Test
public void testEvent () {
try {
Event event = makeFakeApiCall(Event.class, "event");
assertTrue(event != null);
} catch (Exception e) {
e.printStackTrace();
}
}
@Test
public void testGroup () {
try {
Group group = makeFakeApiCall(Group.class, "group");
assertTrue(group != null);
} catch (Exception e) {
e.printStackTrace();
}
}
@Test
public void testIssue () {
try {
Issue issue = makeFakeApiCall(Issue.class, "issue");
assertTrue(issue != null);
} catch (Exception e) {
e.printStackTrace();
}
}
@Test
public void testKey () {
try {
Key key = makeFakeApiCall(Key.class, "key");
assertTrue(key != null);
} catch (Exception e) {
e.printStackTrace();
}
}
@Test
public void testMember () {
try {
Member member = makeFakeApiCall(Member.class, "member");
assertTrue(member != null);
} catch (Exception e) {
e.printStackTrace();
}
}
@Test
public void testMergeRequestComment () {
try {
MergeRequestComment mergeRequestComment = makeFakeApiCall(MergeRequestComment.class, "merge-request-comment");
assertTrue(mergeRequestComment != null);
} catch (Exception e) {
e.printStackTrace();
}
}
@Test
public void testMergeRequest () {
try {
MergeRequest mergeRequest = makeFakeApiCall(MergeRequest.class, "merge-request");
assertTrue(mergeRequest != null);
} catch (Exception e) {
e.printStackTrace();
}
}
@Test
public void testMilestone () {
try {
Milestone milestone = makeFakeApiCall(Milestone.class, "milestone");
assertTrue(milestone != null);
} catch (Exception e) {
e.printStackTrace();
}
}
@Test
public void testNote () {
try {
Note note = makeFakeApiCall(Note.class, "note");
assertTrue(note != null);
} catch (Exception e) {
e.printStackTrace();
}
}
@Test
public void testProject () {
try {
Project project = makeFakeApiCall(Project.class, "project");
assertTrue(project != null);
} catch (Exception e) {
e.printStackTrace();
}
}
@Test
public void testProjectSnippet () {
try {
ProjectSnippet projectSnippet = makeFakeApiCall(ProjectSnippet.class, "project-snippet");
assertTrue(projectSnippet != null);
} catch (Exception e) {
e.printStackTrace();
}
}
@Test
public void testSession () {
try {
Session session = makeFakeApiCall(Session.class, "session");
assertTrue(session != null);
} catch (Exception e) {
e.printStackTrace();
}
}
@Test
public void testSystemHook () {
try {
SystemHook systemHook = makeFakeApiCall(SystemHook.class, "SystemHook");
assertTrue(systemHook != null);
} catch (Exception e) {
e.printStackTrace();
}
}
@Test
public void testTag () {
try {
Tag tag = makeFakeApiCall(Tag.class, "tag");
assertTrue(tag != null);
} catch (Exception e) {
e.printStackTrace();
}
}
@Test
public void testTree () {
try {
InputStreamReader reader = new InputStreamReader(GitLabApi.class.getResourceAsStream("tree.json"));
ObjectMapper objectMapper = jacksonJsonConfig.getContext(null);
List<TreeItem> tree = objectMapper.readValue(reader, new TypeReference<List<TreeItem>>(){});
assertTrue(tree != null);
} catch (Exception e) {
e.printStackTrace();
}
}
@Test
public void testUser () {
try {
User user = makeFakeApiCall(User.class, "user");
assertTrue(user != null);
} catch (Exception e) {
e.printStackTrace();
}
}
private <T> T makeFakeApiCall (Class<T> returnType, String file) throws JsonParseException, JsonMappingException, IOException {
InputStreamReader reader = new InputStreamReader(GitLabApi.class.getResourceAsStream(file + ".json"));
ObjectMapper objectMapper = jacksonJsonConfig.getContext(returnType);
return (objectMapper.readValue(reader, returnType));
}
}
package com.messners.gitlab.api;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
import java.io.InputStreamReader;
import org.codehaus.jackson.JsonParseException;
import org.codehaus.jackson.map.JsonMappingException;
import org.codehaus.jackson.map.ObjectMapper;
import org.junit.BeforeClass;
import org.junit.Test;
import com.messners.gitlab.api.event.EventObject;
import com.messners.gitlab.api.event.PushEvent;
public class TestGitLabApiEvents {
private static JacksonJsonConfig jacksonJsonConfig;
public TestGitLabApiEvents () {
super();
}
@BeforeClass
public static void setup () {
jacksonJsonConfig = new JacksonJsonConfig();
}
@Test
public void testIssueEvent () {
try {
EventObject issueEvent = makeFakeApiCall(EventObject.class, "issue-event");
assertTrue(issueEvent != null);
} catch (Exception e) {
e.printStackTrace();
}
}
@Test
public void testMergeRequestEvent () {
try {
EventObject mergeRequestEvent = makeFakeApiCall(EventObject.class, "merge-request-event");
assertTrue(mergeRequestEvent != null);
} catch (Exception e) {
e.printStackTrace();
}
}
@Test
public void testPushEvent () {
try {
PushEvent pushEvent = makeFakeApiCall(PushEvent.class, "push-event");
assertTrue(pushEvent != null);
} catch (Exception e) {
e.printStackTrace();
}
}
private <T> T makeFakeApiCall (Class<T> returnType, String file) throws JsonParseException, JsonMappingException, IOException {
InputStreamReader reader = new InputStreamReader(GitLabApi.class.getResourceAsStream(file + ".json"));
ObjectMapper objectMapper = jacksonJsonConfig.getContext(returnType);
return (objectMapper.readValue(reader, returnType));
}
}
{
"event_name":"project_create",
"name":"Ruby",
"path":"ruby",
"project_id":1,
"owner_name":"Someone",
"owner_email":"example@gitlabhq.com"
}
{
"name": "master",
"commit": {
"id": "7b5c3cc8be40ee161ae89a06bba6229da1032a0c",
"parents": [
{
"id": "4ad91d3c1144c406e50c7b33bae684bd6837faf8"
}
],
"tree": "46e82de44b1061621357f24c05515327f2795a95",
"message": "add projects API",
"author": {
"name": "John Smith",
"email": "john@example.com"
},
"committer": {
"name": "John Smith",
"email": "john@example.com"
},
"authored_date": "2012-06-27T05:51:39-07:00",
"committed_date": "2012-06-28T03:44:20-07:00"
},
"protected": true
}
{
"id": "ed899a2f4b50b4370feeea94676502b42383c746",
"short_id": "ed899a2f4b5",
"title": "Replace sanitize with escape once",
"author_name": "Dmitriy Zaporozhets",
"author_email": "dzaporozhets@sphereconsultinginc.com",
"created_at": "2012-09-20T11:50:22+03:00"
}
{
"diff": "--- a/doc/update/5.4-to-6.0.html\n+++ b/doc/update/5.4-to-6.0.html\n@@ -71,6 +71,8 @@\n sudo -u git -H bundle exec rake migrate_keys RAILS_ENV=production\n sudo -u git -H bundle exec rake migrate_inline_notes RAILS_ENV=production\n \n+sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=production\n+\n ```\n \n ### 6. Update config files",
"new_path": "doc/update/5.4-to-6.0.html",
"old_path": "doc/update/5.4-to-6.0.html",
"a_mode": null,
"b_mode": "100644",
"new_file": false,
"renamed_file": false,
"deleted_file": false
}
{
"object_kind":"issue",
"object_attributes":{
"id":301,
"target_branch":"master",
"source_branch":"ms-viewport",
"source_project_id":14,
"title":"New API: create/update/delete file",
"assignee_id":51,
"author_id":51,
"project_id":14,
"created_at":"2013-12-03T17:15:43Z",
"updated_at":"2013-12-03T17:15:43Z",
"st_commits":null,
"st_diffs":null,
"position":0,
"branch_name":null,
"description":"Create new API for manipulations with repository",
"milestone_id":null,
"state":"opened",
"iid":23,
"merge_status":"unchecked",
"target_project_id":14,
}
}
{
"title": null,
"project_id": 15,
"action_name": "opened",
"target_id": null,
"target_type": null,
"author_id": 1,
"data": {
"before": "50d4420237a9de7be1304607147aec22e4a14af7",
"after": "c5feabde2d8cd023215af4d2ceeb7a64839fc428",
"ref": "refs/heads/master",
"user_id": 1,
"user_name": "Dmitriy Zaporozhets",
"repository": {
"name": "gitlabhq",
"url": "git@dev.gitlab.org:gitlab/gitlabhq.git",
"description": "GitLab: self hosted Git management software. \r\nDistributed under the MIT License.",
"homepage": "https://dev.gitlab.org/gitlab/gitlabhq"
},
"commits": [{
"id": "c5feabde2d8cd023215af4d2ceeb7a64839fc428",
"message": "Add simple search to projects in public area",
"timestamp": "2013-05-13T18:18:08+00:00",
"url": "https://dev.gitlab.org/gitlab/gitlabhq/commit/c5feabde2d8cd023215af4d2ceeb7a64839fc428",
"author": {
"name": "Dmitriy Zaporozhets",
"email": "dmitriy.zaporozhets@gmail.com"
}
}],
"total_commits_count": 1
},
"target_title": null
}
{
"id": 1,
"name": "Foobar Group",
"path": "foo-bar",
"owner_id": 18
}
{
"object_kind":"issue",
"object_attributes":{
"id":301,
"title":"New API - create/update/delete file",
"assignee_id":51,
"author_id":51,
"project_id":14,
"created_at":"2013-12-03T17:15:43Z",
"updated_at":"2013-12-03T17:15:43Z",
"position":0,
"branch_name":null,
"description":"Create new API for manipulations with repository",
"milestone_id":null,
"state":"opened",
"iid":23
}
}
{
"id": 42,
"iid": 4,
"project_id": 8,
"title": "Add user settings",
"description": "",
"labels": [
"feature"
],
"milestone": {
"id": 1,
"title": "v1.0",
"description": "",
"due_date": "2012-07-20",
"state": "reopenend",
"updated_at": "2012-07-04T13:42:48Z",
"created_at": "2012-07-04T13:42:48Z"
},
"assignee": {
"id": 2,
"username": "jack_smith",
"email": "jack@example.com",
"name": "Jack Smith",
"state": "active",
"created_at": "2012-05-23T08:01:01Z"
},
"author": {
"id": 1,
"username": "john_smith",
"email": "john@example.com",
"name": "John Smith",
"state": "active",
"created_at": "2012-05-23T08:00:58Z"
},
"state": "opened",
"updated_at": "2012-07-12T13:43:19Z",
"created_at": "2012-06-28T12:58:06Z"
}
{
"id": 1,
"title" : "Public key",
"key": "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt4596k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9wa++Oi7Qkr8prgHc4soW6NUlfDzpvZK2H5E7eQaSeP3SAwGmQKUFHCddNaP0L+hM7zhFNzjFvpaMgJw0=",
"created_at":"2013-10-02T11:12:29Z"
}
{
"id": 1,
"username": "raymond_smith",
"email": "ray@smith.org",
"name": "Raymond Smith",
"state": "active",
"created_at": "2012-10-22T14:13:35Z",
"access_level": 30
}
{
"author":{
"id":1,
"username": "admin",
"email":"admin@local.host",
"name":"Administrator",
"blocked":false,
"created_at":"2012-04-29T08:46:00Z"
},
"note":"text1"
}
{
"object_kind":"merge_request",
"object_attributes":{
"id":99,
"target_branch":"master",
"source_branch":"ms-viewport",
"source_project_id":14,
"author_id":51,
"assignee_id":6,
"title":"MS-Viewport",
"created_at":"2013-12-03T17:23:34Z",
"updated_at":"2013-12-03T17:23:34Z",
"st_commits":null,
"st_diffs":null,
"milestone_id":null,
"state":"opened",
"merge_status":"unchecked",
"target_project_id":14,
"iid":1,
"description":""
}
}
{
"id":1,
"iid":1,
"target_branch":"master",
"source_branch":"test1",
"project_id":3,
"title":"test1",
"state":"merged",
"upvotes":0,
"downvotes":0,
"author":{
"id":1,
"username": "admin",
"email":"admin@local.host",
"name":"Administrator",
"state":"active",
"created_at":"2012-04-29T08:46:00Z"
},
"assignee":{
"id":1,
"username": "admin",
"email":"admin@local.host",
"name":"Administrator",
"state":"active",
"created_at":"2012-04-29T08:46:00Z"
}
}
{
"id":12,
"iid":3,
"project_id":16,
"title":"10.0",
"description":"Version",
"due_date":"2013-11-29",
"state":"active",
"updated_at":"2013-10-02T09:24:18Z",
"created_at":"2013-10-02T09:24:18Z"
}
{
"id":52,
"title":"Snippet",
"attachment":null,
"file_name":"snippet.rb",
"author":{
"id":1,
"username":"pipin",
"email":"admin@example.com",
"name":"Pip",
"state":"active",
"created_at":"2013-09-30T13:46:01Z"
},
"expires_at":null,
"updated_at":"2013-10-02T07:34:20Z",
"created_at":"2013-10-02T07:34:20Z"
}
{
"id": 1,
"title": "test",
"file_name": "add.rb",
"author": {
"id": 1,
"username": "john_smith",
"email": "john@example.com",
"name": "John Smith",
"state": "active",
"created_at": "2012-05-23T08:00:58Z"
},
"expires_at": null,
"updated_at": "2012-06-28T10:52:04Z",
"created_at": "2012-06-28T10:52:04Z"
}
{
"id": 6,
"description": null,
"default_branch": "master",
"public": false,
"visibility_level": 0,
"ssh_url_to_repo": "git@example.com:brightbox/puppet.git",
"http_url_to_repo": "http://example.com/brightbox/puppet.git",
"web_url": "http://example.com/brightbox/puppet",
"owner": {
"id": 4,
"name": "Brightbox",
"created_at": "2013-09-30T13:46:02Z"
},
"name": "Puppet",
"name_with_namespace": "Brightbox / Puppet",
"path": "puppet",
"path_with_namespace": "brightbox/puppet",
"issues_enabled": true,
"merge_requests_enabled": true,
"wall_enabled": false,
"wiki_enabled": true,
"snippets_enabled": false,
"created_at": "2013-09-30T13:46:02Z",
"last_activity_at": "2013-09-30T13:46:02Z",
"namespace": {
"created_at": "2013-09-30T13:46:02Z",
"description": "",
"id": 4,
"name": "Brightbox",
"owner_id": 1,
"path": "brightbox",
"updated_at": "2013-09-30T13:46:02Z"
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment