Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
佳 邓
Gitlab4j Api
Commits
80d32ac6
Commit
80d32ac6
authored
Apr 09, 2017
by
Greg Messner
Browse files
Mods for webhook support.
parent
e9f806a4
Changes
13
Hide whitespace changes
Inline
Side-by-side
pom.xml
View file @
80d32ac6
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
>
<modelVersion>
4.0.0
</modelVersion>
<modelVersion>
4.0.0
</modelVersion>
<groupId>
org.gitlab4j
</groupId>
<groupId>
org.gitlab4j
</groupId>
...
@@ -193,6 +194,11 @@
...
@@ -193,6 +194,11 @@
<artifactId>
jersey-client
</artifactId>
<artifactId>
jersey-client
</artifactId>
<version>
${jersey.version}
</version>
<version>
${jersey.version}
</version>
</dependency>
</dependency>
<dependency>
<groupId>
javax.servlet
</groupId>
<artifactId>
javax.servlet-api
</artifactId>
<version>
3.1.0
</version>
</dependency>
<dependency>
<dependency>
<groupId>
junit
</groupId>
<groupId>
junit
</groupId>
<artifactId>
junit
</artifactId>
<artifactId>
junit
</artifactId>
...
...
src/main/java/org/gitlab4j/api/GitLabApiClient.java
View file @
80d32ac6
package
org.gitlab4j.api
;
package
org.gitlab4j.api
;
import
org.gitlab4j.api.utils.JacksonJson
;
import
org.glassfish.jersey.client.ClientConfig
;
import
org.glassfish.jersey.client.ClientConfig
;
import
org.glassfish.jersey.client.ClientProperties
;
import
org.glassfish.jersey.client.ClientProperties
;
...
...
src/main/java/org/gitlab4j/api/GitLabApiException.java
View file @
80d32ac6
...
@@ -15,6 +15,16 @@ public class GitLabApiException extends Exception {
...
@@ -15,6 +15,16 @@ public class GitLabApiException extends Exception {
private
StatusType
statusInfo
;
private
StatusType
statusInfo
;
private
int
httpStatus
;
private
int
httpStatus
;
private
String
message
;
private
String
message
;
/**
* Create a GitLabApiException instance with the specified message.
*
* @param message the message for the exception
*/
public
GitLabApiException
(
String
message
)
{
super
(
message
);
this
.
message
=
message
;
}
/**
/**
* Create a GitLabApiException instance based on the ClientResponse.
* Create a GitLabApiException instance based on the ClientResponse.
...
...
src/main/java/org/gitlab4j/api/RepositoryApi.java
View file @
80d32ac6
...
@@ -14,6 +14,7 @@ import javax.ws.rs.core.Response;
...
@@ -14,6 +14,7 @@ import javax.ws.rs.core.Response;
import
org.gitlab4j.api.models.Branch
;
import
org.gitlab4j.api.models.Branch
;
import
org.gitlab4j.api.models.Tag
;
import
org.gitlab4j.api.models.Tag
;
import
org.gitlab4j.api.models.TreeItem
;
import
org.gitlab4j.api.models.TreeItem
;
import
org.gitlab4j.api.utils.FileUtils
;
/**
/**
* This class provides an entry point to all the GitLab API repository calls.
* This class provides an entry point to all the GitLab API repository calls.
...
@@ -180,7 +181,7 @@ public class RepositoryApi extends AbstractApi {
...
@@ -180,7 +181,7 @@ public class RepositoryApi extends AbstractApi {
String
releaseNotes
;
String
releaseNotes
;
if
(
releaseNotesFile
!=
null
)
{
if
(
releaseNotesFile
!=
null
)
{
try
{
try
{
releaseNotes
=
Utils
.
readFileContents
(
releaseNotesFile
);
releaseNotes
=
File
Utils
.
readFileContents
(
releaseNotesFile
);
}
catch
(
IOException
ioe
)
{
}
catch
(
IOException
ioe
)
{
throw
(
new
GitLabApiException
(
ioe
));
throw
(
new
GitLabApiException
(
ioe
));
}
}
...
@@ -335,7 +336,7 @@ public class RepositoryApi extends AbstractApi {
...
@@ -335,7 +336,7 @@ public class RepositoryApi extends AbstractApi {
if
(
directory
==
null
)
if
(
directory
==
null
)
directory
=
new
File
(
System
.
getProperty
(
"java.io.tmpdir"
));
directory
=
new
File
(
System
.
getProperty
(
"java.io.tmpdir"
));
String
filename
=
Utils
.
getFilenameFromContentDisposition
(
response
);
String
filename
=
File
Utils
.
getFilenameFromContentDisposition
(
response
);
File
file
=
new
File
(
directory
,
filename
);
File
file
=
new
File
(
directory
,
filename
);
InputStream
in
=
response
.
readEntity
(
InputStream
.
class
);
InputStream
in
=
response
.
readEntity
(
InputStream
.
class
);
...
...
src/main/java/org/gitlab4j/api/utils/FileUtils.java
View file @
80d32ac6
package
org.gitlab4j.api
;
package
org.gitlab4j.api
.utils
;
import
java.io.File
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.IOException
;
...
@@ -9,7 +9,7 @@ import javax.ws.rs.core.Response;
...
@@ -9,7 +9,7 @@ import javax.ws.rs.core.Response;
/**
/**
* This class provides static utility methods used throughout GitLab4J.
* This class provides static utility methods used throughout GitLab4J.
*/
*/
public
class
Utils
{
public
class
File
Utils
{
/**
/**
* Creates a File that is unique in the specified directory. If the specified
* Creates a File that is unique in the specified directory. If the specified
...
...
src/main/java/org/gitlab4j/api/utils/ISO8601.java
View file @
80d32ac6
package
org.gitlab4j.api
;
package
org.gitlab4j.api
.utils
;
import
java.text.ParseException
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.text.SimpleDateFormat
;
...
...
src/main/java/org/gitlab4j/api/utils/JacksonJson.java
View file @
80d32ac6
package
org.gitlab4j.api
;
package
org.gitlab4j.api
.utils
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.Reader
;
import
java.io.Reader
;
...
...
src/main/java/org/gitlab4j/api/webhook/Event.java
View file @
80d32ac6
package
org.gitlab4j.api.webhook
;
package
org.gitlab4j.api.webhook
;
import
com.fasterxml.jackson.annotation.JsonSubTypes
;
import
com.fasterxml.jackson.annotation.JsonTypeInfo
;
@JsonTypeInfo
(
use
=
JsonTypeInfo
.
Id
.
NAME
,
include
=
JsonTypeInfo
.
As
.
PROPERTY
,
property
=
"object_kind"
)
@JsonSubTypes
({
@JsonSubTypes
.
Type
(
value
=
IssueEvent
.
class
,
name
=
IssueEvent
.
OBJECT_KIND
),
@JsonSubTypes
.
Type
(
value
=
MergeRequestEvent
.
class
,
name
=
MergeRequestEvent
.
OBJECT_KIND
),
@JsonSubTypes
.
Type
(
value
=
NoteEvent
.
class
,
name
=
NoteEvent
.
OBJECT_KIND
),
@JsonSubTypes
.
Type
(
value
=
PushEvent
.
class
,
name
=
PushEvent
.
OBJECT_KIND
),
@JsonSubTypes
.
Type
(
value
=
TagPushEvent
.
class
,
name
=
TagPushEvent
.
OBJECT_KIND
)
})
public
interface
Event
{
public
interface
Event
{
public
String
getObjectKind
();
public
String
getObjectKind
();
}
}
src/main/java/org/gitlab4j/api/webhook/EventCommit.java
View file @
80d32ac6
...
@@ -3,8 +3,12 @@ package org.gitlab4j.api.webhook;
...
@@ -3,8 +3,12 @@ package org.gitlab4j.api.webhook;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
import
javax.xml.bind.annotation.XmlAccessType
;
import
javax.xml.bind.annotation.XmlAccessorType
;
import
org.gitlab4j.api.models.Author
;
import
org.gitlab4j.api.models.Author
;
@XmlAccessorType
(
XmlAccessType
.
FIELD
)
public
class
EventCommit
{
public
class
EventCommit
{
private
String
id
;
private
String
id
;
...
...
src/main/java/org/gitlab4j/api/webhook/IssueEvent.java
View file @
80d32ac6
package
org.gitlab4j.api.webhook
;
package
org.gitlab4j.api.webhook
;
import
java.util.Date
;
import
javax.xml.bind.annotation.XmlAccessType
;
import
javax.xml.bind.annotation.XmlAccessType
;
import
javax.xml.bind.annotation.XmlAccessorType
;
import
javax.xml.bind.annotation.XmlAccessorType
;
...
@@ -19,12 +17,12 @@ public class IssueEvent implements Event {
...
@@ -19,12 +17,12 @@ public class IssueEvent implements Event {
private
EventRepository
repository
;
private
EventRepository
repository
;
private
ObjectAttributes
objectAttributes
;
private
ObjectAttributes
objectAttributes
;
private
Assignee
assignee
;
private
Assignee
assignee
;
public
String
getObjectKind
()
{
public
String
getObjectKind
()
{
return
(
OBJECT_KIND
);
return
(
OBJECT_KIND
);
}
}
public
void
setObjectKind
(
String
objectKind
)
{
public
void
setObjectKind
(
String
objectKind
)
{
if
(!
OBJECT_KIND
.
equals
(
objectKind
))
if
(!
OBJECT_KIND
.
equals
(
objectKind
))
throw
new
RuntimeException
(
"Invalid object_kind ("
+
objectKind
+
"), must be '"
+
OBJECT_KIND
+
"'"
);
throw
new
RuntimeException
(
"Invalid object_kind ("
+
objectKind
+
"), must be '"
+
OBJECT_KIND
+
"'"
);
}
}
...
@@ -69,147 +67,6 @@ public class IssueEvent implements Event {
...
@@ -69,147 +67,6 @@ public class IssueEvent implements Event {
this
.
objectAttributes
=
objectAttributes
;
this
.
objectAttributes
=
objectAttributes
;
}
}
@XmlAccessorType
(
XmlAccessType
.
FIELD
)
public
static
class
ObjectAttributes
extends
EventIssue
{
public
static
class
ObjectAttributes
{
private
Integer
assigneeId
;
private
Integer
authorId
;
private
String
branchName
;
private
Date
createdAt
;
private
String
description
;
private
Integer
id
;
private
Integer
iid
;
private
String
milestoneId
;
private
Integer
position
;
private
Integer
projectId
;
private
String
state
;
private
String
title
;
private
Date
updatedAt
;
private
String
url
;
private
String
action
;
public
Integer
getAssigneeId
()
{
return
this
.
assigneeId
;
}
public
void
setAssigneeId
(
Integer
assigneeId
)
{
this
.
assigneeId
=
assigneeId
;
}
public
Integer
getAuthorId
()
{
return
this
.
authorId
;
}
public
void
setAuthorId
(
Integer
authorId
)
{
this
.
authorId
=
authorId
;
}
public
String
getBranchName
()
{
return
this
.
branchName
;
}
public
void
setBranchName
(
String
branchName
)
{
this
.
branchName
=
branchName
;
}
public
Date
getCreatedAt
()
{
return
this
.
createdAt
;
}
public
void
setCreatedAt
(
Date
createdAt
)
{
this
.
createdAt
=
createdAt
;
}
public
String
getDescription
()
{
return
this
.
description
;
}
public
void
setDescription
(
String
description
)
{
this
.
description
=
description
;
}
public
Integer
getId
()
{
return
this
.
id
;
}
public
void
setId
(
Integer
id
)
{
this
.
id
=
id
;
}
public
Integer
getIid
()
{
return
this
.
iid
;
}
public
void
setIid
(
Integer
iid
)
{
this
.
iid
=
iid
;
}
public
String
getMilestoneId
()
{
return
this
.
milestoneId
;
}
public
void
setMilestoneId
(
String
milestoneId
)
{
this
.
milestoneId
=
milestoneId
;
}
public
Integer
getPosition
()
{
return
this
.
position
;
}
public
void
setPosition
(
Integer
position
)
{
this
.
position
=
position
;
}
public
Integer
getProjectId
()
{
return
this
.
projectId
;
}
public
void
setProjectId
(
Integer
projectId
)
{
this
.
projectId
=
projectId
;
}
public
String
getState
()
{
return
this
.
state
;
}
public
void
setState
(
String
state
)
{
this
.
state
=
state
;
}
public
String
getTitle
()
{
return
this
.
title
;
}
public
void
setTitle
(
String
title
)
{
this
.
title
=
title
;
}
public
Date
getUpdatedAt
()
{
return
this
.
updatedAt
;
}
public
void
setUpdatedAt
(
Date
updatedAt
)
{
this
.
updatedAt
=
updatedAt
;
}
public
String
getUrl
()
{
return
url
;
}
public
void
setUrl
(
String
url
)
{
this
.
url
=
url
;
}
public
String
getAction
()
{
return
action
;
}
public
void
setAction
(
String
action
)
{
this
.
action
=
action
;
}
}
}
}
}
src/main/java/org/gitlab4j/api/webhook/MergeRequestEvent.java
View file @
80d32ac6
package
org.gitlab4j.api.webhook
;
package
org.gitlab4j.api.webhook
;
import
java.util.Date
;
import
javax.xml.bind.annotation.XmlAccessType
;
import
javax.xml.bind.annotation.XmlAccessType
;
import
javax.xml.bind.annotation.XmlAccessorType
;
import
javax.xml.bind.annotation.XmlAccessorType
;
import
org.gitlab4j.api.models.Assignee
;
import
org.gitlab4j.api.models.User
;
import
org.gitlab4j.api.models.User
;
@XmlAccessorType
(
XmlAccessType
.
FIELD
)
@XmlAccessorType
(
XmlAccessType
.
FIELD
)
...
@@ -43,251 +40,6 @@ public class MergeRequestEvent implements Event {
...
@@ -43,251 +40,6 @@ public class MergeRequestEvent implements Event {
}
}
@XmlAccessorType
(
XmlAccessType
.
FIELD
)
@XmlAccessorType
(
XmlAccessType
.
FIELD
)
public
static
class
ObjectAttributes
{
public
static
class
ObjectAttributes
extends
EventMergeRequest
{
private
Integer
assigneeId
;
private
Integer
authorId
;
private
String
branchName
;
private
Date
createdAt
;
private
String
description
;
private
Integer
id
;
private
Integer
iid
;
private
String
mergeStatus
;
private
String
milestoneId
;
private
Integer
position
;
private
Integer
projectId
;
private
String
sourceBranch
;
private
Integer
sourceProjectId
;
private
String
stCommits
;
private
String
stDiffs
;
private
String
state
;
private
String
targetBranch
;
private
Integer
targetProjectId
;
private
String
title
;
private
Date
updatedAt
;
private
EventProject
source
;
private
EventProject
target
;
private
EventCommit
lastCommit
;
private
Boolean
workInProgress
;
private
String
url
;
private
String
action
;
private
Assignee
assignee
;
public
Integer
getAssigneeId
()
{
return
this
.
assigneeId
;
}
public
void
setAssigneeId
(
Integer
assigneeId
)
{
this
.
assigneeId
=
assigneeId
;
}
public
Integer
getAuthorId
()
{
return
this
.
authorId
;
}
public
void
setAuthorId
(
Integer
authorId
)
{
this
.
authorId
=
authorId
;
}
public
String
getBranchName
()
{
return
this
.
branchName
;
}
public
void
setBranchName
(
String
branchName
)
{
this
.
branchName
=
branchName
;
}
public
Date
getCreatedAt
()
{
return
this
.
createdAt
;
}
public
void
setCreatedAt
(
Date
createdAt
)
{
this
.
createdAt
=
createdAt
;
}
public
String
getDescription
()
{
return
this
.
description
;
}
public
void
setDescription
(
String
description
)
{
this
.
description
=
description
;
}
public
Integer
getId
()
{
return
this
.
id
;
}
public
void
setId
(
Integer
id
)
{
this
.
id
=
id
;
}
public
Integer
getIid
()
{
return
this
.
iid
;
}
public
void
setIid
(
Integer
iid
)
{
this
.
iid
=
iid
;
}
public
String
getMergeStatus
()
{
return
this
.
mergeStatus
;
}
public
void
setMergeStatus
(
String
mergeStatus
)
{
this
.
mergeStatus
=
mergeStatus
;
}
public
String
getMilestoneId
()
{
return
this
.
milestoneId
;
}
public
void
setMilestoneId
(
String
milestoneId
)
{
this
.
milestoneId
=
milestoneId
;
}
public
Integer
getPosition
()
{
return
this
.
position
;
}
public
void
setPosition
(
Integer
position
)
{
this
.
position
=
position
;
}
public
Integer
getProjectId
()
{
return
this
.
projectId
;
}
public
void
setProjectId
(
Integer
projectId
)
{
this
.
projectId
=
projectId
;
}
public
String
getSourceBranch
()
{
return
this
.
sourceBranch
;
}
public
void
setSourceBranch
(
String
sourceBranch
)
{
this
.
sourceBranch
=
sourceBranch
;
}
public
Integer
getSourceProjectId
()
{
return
this
.
sourceProjectId
;
}
public
void
setSourceProjectId
(
Integer
sourceProjectId
)
{
this
.
sourceProjectId
=
sourceProjectId
;
}
public
String
getStCommits
()
{
return
this
.
stCommits
;
}
public
void
setStCommits
(
String
stCommits
)
{
this
.
stCommits
=
stCommits
;
}
public
String
getStDiffs
()
{
return
this
.
stDiffs
;
}
public
void
setStDiffs
(
String
stDiffs
)
{
this
.
stDiffs
=
stDiffs
;
}
public
String
getState
()
{
return
this
.
state
;
}
public
void
setState
(
String
state
)
{
this
.
state
=
state
;
}
public
String
getTargetBranch
()
{
return
this
.
targetBranch
;
}
public
void
setTargetBranch
(
String
targetBranch
)
{
this
.
targetBranch
=
targetBranch
;
}
public
Integer
getTargetProjectId
()
{
return
this
.
targetProjectId
;
}
public
void
setTargetProjectId
(
Integer
targetProjectId
)
{
this
.
targetProjectId
=
targetProjectId
;
}
public
String
getTitle
()
{
return
this
.
title
;
}
public
void
setTitle
(
String
title
)
{
this
.
title
=
title
;
}
public
Date
getUpdatedAt
()
{
return
this
.
updatedAt
;
}
public
void
setUpdatedAt
(
Date
updatedAt
)
{
this
.
updatedAt
=
updatedAt
;
}
public
EventProject
getSource
()
{
return
source
;
}
public
void
setSource
(
EventProject
source
)
{
this
.
source
=
source
;
}
public
EventProject
getTarget
()
{
return
target
;
}
public
void
setTarget
(
EventProject
target
)
{
this
.
target
=
target
;
}
public
EventCommit
getLastCommit
()
{
return
lastCommit
;
}
public
void
setLastCommit
(
EventCommit
lastCommit
)
{
this
.
lastCommit
=
lastCommit
;
}
public
Boolean
getWorkInProgress
()
{
return
workInProgress
;
}
public
void
setWorkInProgress
(
Boolean
workInProgress
)
{
this
.
workInProgress
=
workInProgress
;
}
public
String
getUrl
()
{
return
url
;
}
public
void
setUrl
(
String
url
)
{
this
.
url
=
url
;
}
public
String
getAction
()
{
return
action
;
}
public
void
setAction
(
String
action
)
{
this
.
action
=
action
;
}
public
Assignee
getAssignee
()
{
return
assignee
;
}
public
void
setAssignee
(
Assignee
assignee
)
{
this
.
assignee
=
assignee
;
}
}
}
}
}
src/test/java/org/gitlab4j/api/TestGitLabApiBeans.java
View file @
80d32ac6
...
@@ -7,7 +7,6 @@ import java.io.InputStreamReader;
...
@@ -7,7 +7,6 @@ import java.io.InputStreamReader;
import
java.util.List
;
import
java.util.List
;
import
org.gitlab4j.api.GitLabApi
;
import
org.gitlab4j.api.GitLabApi
;
import
org.gitlab4j.api.JacksonJson
;
import
org.gitlab4j.api.models.Branch
;
import
org.gitlab4j.api.models.Branch
;
import
org.gitlab4j.api.models.Commit
;
import
org.gitlab4j.api.models.Commit
;
import
org.gitlab4j.api.models.Diff
;
import
org.gitlab4j.api.models.Diff
;
...
@@ -27,6 +26,7 @@ import org.gitlab4j.api.models.SystemHook;
...
@@ -27,6 +26,7 @@ import org.gitlab4j.api.models.SystemHook;
import
org.gitlab4j.api.models.Tag
;
import
org.gitlab4j.api.models.Tag
;
import
org.gitlab4j.api.models.TreeItem
;
import
org.gitlab4j.api.models.TreeItem
;
import
org.gitlab4j.api.models.User
;
import
org.gitlab4j.api.models.User
;
import
org.gitlab4j.api.utils.JacksonJson
;
import
org.junit.BeforeClass
;
import
org.junit.BeforeClass
;
import
org.junit.Test
;
import
org.junit.Test
;
...
...
src/test/java/org/gitlab4j/api/TestGitLabApiEvents.java
View file @
80d32ac6
...
@@ -5,12 +5,13 @@ import static org.junit.Assert.assertTrue;
...
@@ -5,12 +5,13 @@ import static org.junit.Assert.assertTrue;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.io.InputStreamReader
;
import
org.gitlab4j.api.GitLabApi
;
import
org.gitlab4j.api.utils.JacksonJson
;
import
org.gitlab4j.api.JacksonJson
;
import
org.gitlab4j.api.webhook.Event
;
import
org.gitlab4j.api.webhook.Event
;
import
org.gitlab4j.api.webhook.IssueEvent
;
import
org.gitlab4j.api.webhook.IssueEvent
;
import
org.gitlab4j.api.webhook.MergeRequestEvent
;
import
org.gitlab4j.api.webhook.MergeRequestEvent
;
import
org.gitlab4j.api.webhook.NoteEvent
;
import
org.gitlab4j.api.webhook.PushEvent
;
import
org.gitlab4j.api.webhook.PushEvent
;
import
org.gitlab4j.api.webhook.TagPushEvent
;
import
org.junit.BeforeClass
;
import
org.junit.BeforeClass
;
import
org.junit.Test
;
import
org.junit.Test
;
...
@@ -36,36 +37,84 @@ public class TestGitLabApiEvents {
...
@@ -36,36 +37,84 @@ public class TestGitLabApiEvents {
}
}
@Test
@Test
public
void
testIssueEvent
()
{
public
void
testIssueEvent
()
throws
Exception
{
try
{
Event
issueEvent
=
makeFakeApiCall
(
IssueEvent
.
class
,
"issue-event"
);
Event
issueEvent
=
makeFakeApiCall
(
IssueEvent
.
class
,
"issue-event"
);
assertTrue
(
compareJson
(
issueEvent
,
"issue-event"
));
assertTrue
(
compareJson
(
issueEvent
,
"issue-event"
));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
}
@Test
@Test
public
void
testMergeRequestEvent
()
{
public
void
testMergeRequestEvent
()
throws
Exception
{
try
{
Event
mergeRequestEvent
=
makeFakeApiCall
(
MergeRequestEvent
.
class
,
"merge-request-event"
);
Event
mergeRequestEvent
=
makeFakeApiCall
(
MergeRequestEvent
.
class
,
"merge-request-event"
);
assertTrue
(
compareJson
(
mergeRequestEvent
,
"merge-request-event"
));
assertTrue
(
compareJson
(
mergeRequestEvent
,
"merge-request-event"
));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
}
@Test
@Test
public
void
testPushEvent
()
{
public
void
testPushEvent
()
throws
Exception
{
try
{
Event
pushEvent
=
makeFakeApiCall
(
PushEvent
.
class
,
"push-event"
);
PushEvent
pushEvent
=
makeFakeApiCall
(
PushEvent
.
class
,
"push-event"
);
assertTrue
(
compareJson
(
pushEvent
,
"push-event"
));
assertTrue
(
compareJson
(
pushEvent
,
"push-event"
));
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
@Test
}
public
void
testTagPushEvent
()
throws
Exception
{
Event
pushEvent
=
makeFakeApiCall
(
TagPushEvent
.
class
,
"tag-push-event"
);
assertTrue
(
compareJson
(
pushEvent
,
"tag-push-event"
));
}
@Test
public
void
testNoteCommitEvent
()
throws
Exception
{
Event
noteEvent
=
makeFakeApiCall
(
NoteEvent
.
class
,
"note-commit-event"
);
assertTrue
(
compareJson
(
noteEvent
,
"note-commit-event"
));
}
@Test
public
void
testNoteMergeRequestEvent
()
throws
Exception
{
Event
noteEvent
=
makeFakeApiCall
(
NoteEvent
.
class
,
"note-merge-request-event"
);
assertTrue
(
compareJson
(
noteEvent
,
"note-merge-request-event"
));
}
@Test
public
void
testNoteIssueEvent
()
throws
Exception
{
Event
noteEvent
=
makeFakeApiCall
(
NoteEvent
.
class
,
"note-issue-event"
);
assertTrue
(
compareJson
(
noteEvent
,
"note-issue-event"
));
}
@Test
public
void
testNoteSnippetEvent
()
throws
Exception
{
Event
noteEvent
=
makeFakeApiCall
(
NoteEvent
.
class
,
"note-snippet-event"
);
assertTrue
(
compareJson
(
noteEvent
,
"note-snippet-event"
));
}
@Test
public
void
testPolymorphicEvent
()
throws
Exception
{
Event
event
=
makeFakeApiCall
(
Event
.
class
,
"issue-event"
);
assertTrue
(
compareJson
(
event
,
"issue-event"
));
event
=
makeFakeApiCall
(
Event
.
class
,
"merge-request-event"
);
assertTrue
(
compareJson
(
event
,
"merge-request-event"
));
event
=
makeFakeApiCall
(
Event
.
class
,
"note-commit-event"
);
assertTrue
(
compareJson
(
event
,
"note-commit-event"
));
event
=
makeFakeApiCall
(
Event
.
class
,
"note-issue-event"
);
assertTrue
(
compareJson
(
event
,
"note-issue-event"
));
event
=
makeFakeApiCall
(
Event
.
class
,
"note-merge-request-event"
);
assertTrue
(
compareJson
(
event
,
"note-merge-request-event"
));
event
=
makeFakeApiCall
(
Event
.
class
,
"note-snippet-event"
);
assertTrue
(
compareJson
(
event
,
"note-snippet-event"
));
event
=
makeFakeApiCall
(
Event
.
class
,
"tag-push-event"
);
assertTrue
(
compareJson
(
event
,
"tag-push-event"
));
}
}
private
<
T
>
T
makeFakeApiCall
(
Class
<
T
>
returnType
,
String
file
)
throws
JsonParseException
,
JsonMappingException
,
IOException
{
private
<
T
>
T
makeFakeApiCall
(
Class
<
T
>
returnType
,
String
file
)
throws
JsonParseException
,
JsonMappingException
,
IOException
{
...
@@ -90,8 +139,8 @@ public class TestGitLabApiEvents {
...
@@ -90,8 +139,8 @@ public class TestGitLabApiEvents {
}
}
return
(
sameJson
);
return
(
sameJson
);
}
}
private
void
sortedDump
(
final
JsonNode
node
)
throws
JsonProcessingException
{
private
void
sortedDump
(
final
JsonNode
node
)
throws
JsonProcessingException
{
final
Object
obj
=
jacksonJson
.
getObjectMapper
().
treeToValue
(
node
,
Object
.
class
);
final
Object
obj
=
jacksonJson
.
getObjectMapper
().
treeToValue
(
node
,
Object
.
class
);
System
.
out
.
println
(
jacksonJson
.
getObjectMapper
().
writeValueAsString
(
obj
));
System
.
out
.
println
(
jacksonJson
.
getObjectMapper
().
writeValueAsString
(
obj
));
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment