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
b5e8e839
Unverified
Commit
b5e8e839
authored
Mar 22, 2021
by
Gautier de Saint Martin Lacaze
Committed by
GitHub
Mar 22, 2021
Browse files
Merge pull request #673 from gitlab4j/pr-662-add-tests
test: Add tests for EmailOnPushService
parents
d1556748
2b8bdcf0
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/gitlab4j/api/services/EmailOnPushService.java
View file @
b5e8e839
...
@@ -32,7 +32,7 @@ public class EmailOnPushService extends NotificationService {
...
@@ -32,7 +32,7 @@ public class EmailOnPushService extends NotificationService {
@JsonIgnore
@JsonIgnore
public
String
getRecipients
()
{
public
String
getRecipients
()
{
return
(
(
String
)
getProperty
(
RECIPIENT_PROP
));
return
(
getProperty
(
RECIPIENT_PROP
));
}
}
public
void
setRecipients
(
String
recipients
)
{
public
void
setRecipients
(
String
recipients
)
{
setProperty
(
RECIPIENT_PROP
,
recipients
);
setProperty
(
RECIPIENT_PROP
,
recipients
);
...
@@ -45,7 +45,7 @@ public class EmailOnPushService extends NotificationService {
...
@@ -45,7 +45,7 @@ public class EmailOnPushService extends NotificationService {
@JsonIgnore
@JsonIgnore
public
Boolean
getDisableDiffs
()
{
public
Boolean
getDisableDiffs
()
{
return
Boolean
.
valueOf
(
getProperty
(
DISABLE_DIFFS_PROP
,
"
false
"
));
return
Boolean
.
valueOf
(
getProperty
(
DISABLE_DIFFS_PROP
,
false
));
}
}
public
void
setDisableDiffs
(
Boolean
disableDiffs
)
{
public
void
setDisableDiffs
(
Boolean
disableDiffs
)
{
setProperty
(
DISABLE_DIFFS_PROP
,
disableDiffs
);
setProperty
(
DISABLE_DIFFS_PROP
,
disableDiffs
);
...
@@ -54,10 +54,10 @@ public class EmailOnPushService extends NotificationService {
...
@@ -54,10 +54,10 @@ public class EmailOnPushService extends NotificationService {
setDisableDiffs
(
disableDiffs
);
setDisableDiffs
(
disableDiffs
);
return
this
;
return
this
;
}
}
@JsonIgnore
@JsonIgnore
public
Boolean
getSendFromCommitterEmail
()
{
public
Boolean
getSendFromCommitterEmail
()
{
return
Boolean
.
valueOf
(
getProperty
(
SEND_FROM_COMMITTER_EMAIL_PROP
,
"
false
"
));
return
Boolean
.
valueOf
(
getProperty
(
SEND_FROM_COMMITTER_EMAIL_PROP
,
false
));
}
}
public
void
setSendFromCommitterEmail
(
Boolean
sendFromCommitterEmail
)
{
public
void
setSendFromCommitterEmail
(
Boolean
sendFromCommitterEmail
)
{
setProperty
(
SEND_FROM_COMMITTER_EMAIL_PROP
,
sendFromCommitterEmail
);
setProperty
(
SEND_FROM_COMMITTER_EMAIL_PROP
,
sendFromCommitterEmail
);
...
@@ -68,16 +68,20 @@ public class EmailOnPushService extends NotificationService {
...
@@ -68,16 +68,20 @@ public class EmailOnPushService extends NotificationService {
}
}
@JsonIgnore
@JsonIgnore
public
String
getBranchesToBeNotified
()
{
public
BranchesToBeNotified
getBranchesToBeNotified
()
{
return
((
String
)
getProperty
(
BRANCHES_TO_BE_NOTIFIED_PROP
));
String
branchesToBeNotified
=
getProperty
(
BRANCHES_TO_BE_NOTIFIED_PROP
);
if
(
branchesToBeNotified
==
null
||
branchesToBeNotified
.
isEmpty
())
{
return
null
;
}
return
(
BranchesToBeNotified
.
valueOf
(
branchesToBeNotified
.
toUpperCase
()));
}
}
public
void
setBranchesToBeNotified
(
String
branchesToBeNotified
)
{
public
void
setBranchesToBeNotified
(
BranchesToBeNotified
branchesToBeNotified
)
{
setProperty
(
BRANCHES_TO_BE_NOTIFIED_PROP
,
branchesToBeNotified
);
setProperty
(
BRANCHES_TO_BE_NOTIFIED_PROP
,
branchesToBeNotified
.
toString
()
);
}
}
public
EmailOnPushService
withBranchesToBeNotified
(
String
branchesToBeNotified
)
{
public
EmailOnPushService
withBranchesToBeNotified
(
BranchesToBeNotified
branchesToBeNotified
)
{
setBranchesToBeNotified
(
branchesToBeNotified
);
setBranchesToBeNotified
(
branchesToBeNotified
);
return
this
;
return
this
;
}
}
}
}
src/main/java/org/gitlab4j/api/services/NotificationService.java
View file @
b5e8e839
...
@@ -34,10 +34,12 @@ public abstract class NotificationService {
...
@@ -34,10 +34,12 @@ public abstract class NotificationService {
private
Integer
id
;
private
Integer
id
;
private
String
title
;
private
String
title
;
private
String
slug
;
private
Date
createdAt
;
private
Date
createdAt
;
private
Date
updatedAt
;
private
Date
updatedAt
;
private
Boolean
active
;
private
Boolean
active
;
private
Boolean
commitEvents
;
private
Boolean
pushEvents
;
private
Boolean
pushEvents
;
private
Boolean
issuesEvents
;
private
Boolean
issuesEvents
;
private
Boolean
confidentialIssuesEvents
;
private
Boolean
confidentialIssuesEvents
;
...
@@ -61,6 +63,14 @@ public abstract class NotificationService {
...
@@ -61,6 +63,14 @@ public abstract class NotificationService {
this
.
id
=
id
;
this
.
id
=
id
;
}
}
public
String
getSlug
()
{
return
slug
;
}
public
void
setSlug
(
String
slug
)
{
this
.
slug
=
slug
;
}
public
String
getTitle
()
{
public
String
getTitle
()
{
return
title
;
return
title
;
}
}
...
@@ -97,6 +107,19 @@ public abstract class NotificationService {
...
@@ -97,6 +107,19 @@ public abstract class NotificationService {
// The following methods can be used to configure the notification service
// The following methods can be used to configure the notification service
// *******************************************************************************
// *******************************************************************************
public
Boolean
getCommitEvents
()
{
return
commitEvents
;
}
public
void
setCommitEvents
(
Boolean
commitEvents
)
{
this
.
commitEvents
=
commitEvents
;
}
protected
<
T
>
T
withCommitEvents
(
Boolean
commitEvents
,
T
derivedInstance
)
{
this
.
commitEvents
=
commitEvents
;
return
(
derivedInstance
);
}
public
Boolean
getPushEvents
()
{
public
Boolean
getPushEvents
()
{
return
pushEvents
;
return
pushEvents
;
}
}
...
@@ -237,7 +260,7 @@ public abstract class NotificationService {
...
@@ -237,7 +260,7 @@ public abstract class NotificationService {
@JsonIgnore
@JsonIgnore
protected
String
getProperty
(
String
prop
)
{
protected
String
getProperty
(
String
prop
)
{
return
(
(
String
)
getProperty
(
prop
,
""
));
return
(
getProperty
(
prop
,
""
));
}
}
@JsonIgnore
@JsonIgnore
...
@@ -270,4 +293,13 @@ public abstract class NotificationService {
...
@@ -270,4 +293,13 @@ public abstract class NotificationService {
public
String
toString
()
{
public
String
toString
()
{
return
(
JacksonJson
.
toJsonString
(
this
));
return
(
JacksonJson
.
toJsonString
(
this
));
}
}
public
enum
BranchesToBeNotified
{
ALL
,
DEFAULT
,
PROTECTED
,
DEFAULT_AND_PROTECTED
;
@Override
public
String
toString
()
{
return
(
name
().
toLowerCase
());
}
}
}
}
src/test/java/org/gitlab4j/api/TestServicesApi.java
View file @
b5e8e839
...
@@ -9,9 +9,11 @@ import static org.junit.Assume.assumeNotNull;
...
@@ -9,9 +9,11 @@ import static org.junit.Assume.assumeNotNull;
import
org.gitlab4j.api.models.Project
;
import
org.gitlab4j.api.models.Project
;
import
org.gitlab4j.api.services.BugzillaService
;
import
org.gitlab4j.api.services.BugzillaService
;
import
org.gitlab4j.api.services.CustomIssueTrackerService
;
import
org.gitlab4j.api.services.CustomIssueTrackerService
;
import
org.gitlab4j.api.services.EmailOnPushService
;
import
org.gitlab4j.api.services.ExternalWikiService
;
import
org.gitlab4j.api.services.ExternalWikiService
;
import
org.gitlab4j.api.services.JiraService
;
import
org.gitlab4j.api.services.JiraService
;
import
org.gitlab4j.api.services.MattermostService
;
import
org.gitlab4j.api.services.MattermostService
;
import
org.gitlab4j.api.services.NotificationService.BranchesToBeNotified
;
import
org.gitlab4j.api.services.SlackService
;
import
org.gitlab4j.api.services.SlackService
;
import
org.junit.Before
;
import
org.junit.Before
;
import
org.junit.BeforeClass
;
import
org.junit.BeforeClass
;
...
@@ -21,300 +23,378 @@ import org.junit.experimental.categories.Category;
...
@@ -21,300 +23,378 @@ import org.junit.experimental.categories.Category;
import
org.junit.runners.MethodSorters
;
import
org.junit.runners.MethodSorters
;
/**
/**
* In order for these tests to run you must set the following properties in test-gitlab4j.properties
* In order for these tests to run you must set the following properties in
*
* test-gitlab4j.properties
* TEST_NAMESPACE
*
* TEST_PROJECT_NAME
* TEST_NAMESPACE TEST_PROJECT_NAME TEST_HOST_URL TEST_PRIVATE_TOKEN
* TEST_HOST_URL
*
* TEST_PRIVATE_TOKEN
*
* If any of the above are NULL, all tests in this class will be skipped.
* If any of the above are NULL, all tests in this class will be skipped.
*/
*/
@Category
(
IntegrationTest
.
class
)
@Category
(
IntegrationTest
.
class
)
@FixMethodOrder
(
MethodSorters
.
NAME_ASCENDING
)
@FixMethodOrder
(
MethodSorters
.
NAME_ASCENDING
)
public
class
TestServicesApi
extends
AbstractIntegrationTest
{
public
class
TestServicesApi
extends
AbstractIntegrationTest
{
private
static
final
String
TEST_ENDPOINT
=
"https://foobar.com/gitlab_service/webhooks/"
;
private
static
final
String
TEST_ENDPOINT
=
"https://foobar.com/gitlab_service/webhooks/"
;
private
static
GitLabApi
gitLabApi
;
private
static
GitLabApi
gitLabApi
;
private
static
Project
testProject
;
private
static
Project
testProject
;
public
TestServicesApi
()
{
public
TestServicesApi
()
{
super
();
super
();
}
}
@BeforeClass
@BeforeClass
public
static
void
setup
()
{
public
static
void
setup
()
{
// Must setup the connection to the GitLab test server and get the test Project instance
// Must setup the connection to the GitLab test server and get the test Project
gitLabApi
=
baseTestSetup
();
// instance
testProject
=
getTestProject
();
gitLabApi
=
baseTestSetup
();
testProject
=
getTestProject
();
if
(
testProject
!=
null
)
{
try
{
gitLabApi
.
getServicesApi
().
deleteJiraService
(
testProject
);
}
catch
(
Exception
ignore
)
{}
if
(
testProject
!=
null
)
{
try
{
gitLabApi
.
getServicesApi
().
deleteSlackService
(
testProject
);
}
catch
(
Exception
ignore
)
{}
try
{
}
gitLabApi
.
getServicesApi
().
deleteJiraService
(
testProject
);
}
}
catch
(
Exception
ignore
)
{
}
@Before
try
{
public
void
beforeMethod
()
{
gitLabApi
.
getServicesApi
().
deleteSlackService
(
testProject
);
assumeNotNull
(
testProject
);
}
catch
(
Exception
ignore
)
{
}
}
}
@Test
}
public
void
testProjectIdOrPath
()
throws
GitLabApiException
{
Integer
projectId
=
testProject
.
getId
();
@Before
JiraService
jiraServiceById
=
gitLabApi
.
getServicesApi
().
getJiraService
(
projectId
);
public
void
beforeMethod
()
{
assertNotNull
(
jiraServiceById
);
assumeNotNull
(
testProject
);
JiraService
jiraServiceByPath
=
gitLabApi
.
getServicesApi
().
getJiraService
(
testProject
.
getPathWithNamespace
());
}
assertNotNull
(
jiraServiceByPath
);
JiraService
jiraServiceByProject
=
gitLabApi
.
getServicesApi
().
getJiraService
(
testProject
);
@Test
assertNotNull
(
jiraServiceByProject
);
public
void
testProjectIdOrPath
()
throws
GitLabApiException
{
Integer
projectId
=
testProject
.
getId
();
assertEquals
(
jiraServiceById
.
getTitle
(),
jiraServiceByPath
.
getTitle
());
JiraService
jiraServiceById
=
gitLabApi
.
getServicesApi
().
getJiraService
(
projectId
);
assertEquals
(
jiraServiceById
.
getTitle
(),
jiraServiceByProject
.
getTitle
());
assertNotNull
(
jiraServiceById
);
}
JiraService
jiraServiceByPath
=
gitLabApi
.
getServicesApi
().
getJiraService
(
testProject
.
getPathWithNamespace
());
assertNotNull
(
jiraServiceByPath
);
@Test
JiraService
jiraServiceByProject
=
gitLabApi
.
getServicesApi
().
getJiraService
(
testProject
);
public
void
testGetJiraService
()
throws
GitLabApiException
{
assertNotNull
(
jiraServiceByProject
);
JiraService
jiraService
=
gitLabApi
.
getServicesApi
().
getJiraService
(
testProject
);
assertEquals
(
jiraServiceById
.
getSlug
(),
jiraServiceByPath
.
getSlug
());
assertNotNull
(
jiraService
);
assertEquals
(
jiraServiceById
.
getSlug
(),
jiraServiceByProject
.
getSlug
());
}
// Make sure the jira_issue_transition_id is retrievable.
// This is testing that a class cast exception is not thrown.
@Test
Integer
jiraIssueTransitionId
=
jiraService
.
getJiraIssueTransitionId
();
public
void
testGetJiraService
()
throws
GitLabApiException
{
assertTrue
(
jiraIssueTransitionId
==
null
||
jiraIssueTransitionId
!=
null
);
}
JiraService
jiraService
=
gitLabApi
.
getServicesApi
().
getJiraService
(
testProject
);
assertNotNull
(
jiraService
);
@Test
public
void
testUpdateJiraService
()
throws
GitLabApiException
{
// Make sure the jira_issue_transition_id is retrievable.
// This is testing that a class cast exception is not thrown.
try
{
Integer
jiraIssueTransitionId
=
jiraService
.
getJiraIssueTransitionId
();
JiraService
jiraService
=
new
JiraService
()
assertTrue
(
jiraIssueTransitionId
==
null
||
jiraIssueTransitionId
!=
null
);
.
withCommitEvents
(
true
)
}
.
withMergeRequestsEvents
(
true
)
.
withUrl
(
"http://jira.example.com"
)
@Test
.
withUsername
(
"GitLab4J"
)
public
void
testUpdateJiraService
()
throws
GitLabApiException
{
.
withPassword
(
"test"
)
.
withProjectKey
(
"GL4J"
);
try
{
JiraService
updatedJiraService
=
gitLabApi
.
getServicesApi
().
updateJiraService
(
testProject
,
jiraService
);
JiraService
jiraService
=
new
JiraService
()
assertNotNull
(
updatedJiraService
);
.
withCommitEvents
(
true
)
}
finally
{
.
withMergeRequestsEvents
(
true
)
try
{
gitLabApi
.
getServicesApi
().
deleteJiraService
(
testProject
);
}
catch
(
Exception
ignore
)
{}
.
withUrl
(
"http://jira.example.com"
)
}
.
withUsername
(
"GitLab4J"
)
}
.
withPassword
(
"test"
)
.
withProjectKey
(
"GL4J"
);
@Test
JiraService
updatedJiraService
=
gitLabApi
.
getServicesApi
().
updateJiraService
(
testProject
,
jiraService
);
public
void
testDeleteJiraService
()
throws
GitLabApiException
{
assertNotNull
(
updatedJiraService
);
}
finally
{
JiraService
jiraService
=
new
JiraService
()
try
{
.
withCommitEvents
(
true
)
gitLabApi
.
getServicesApi
().
deleteJiraService
(
testProject
);
.
withMergeRequestsEvents
(
true
)
}
catch
(
Exception
ignore
)
{
.
withUrl
(
"http://jira.example.com"
)
}
.
withUsername
(
"GitLab4J"
)
}
.
withPassword
(
"test"
)
}
.
withProjectKey
(
"GL4J"
);
JiraService
updatedJiraService
=
gitLabApi
.
getServicesApi
().
updateJiraService
(
testProject
,
jiraService
);
@Test
assertNotNull
(
updatedJiraService
);
public
void
testDeleteJiraService
()
throws
GitLabApiException
{
assertTrue
(
updatedJiraService
.
getActive
());
JiraService
jiraService
=
new
JiraService
()
gitLabApi
.
getServicesApi
().
deleteJiraService
(
testProject
);
.
withCommitEvents
(
true
)
JiraService
deleteJiraService
=
gitLabApi
.
getServicesApi
().
getJiraService
(
testProject
);
.
withMergeRequestsEvents
(
true
)
assertNotNull
(
deleteJiraService
);
.
withUrl
(
"http://jira.example.com"
)
assertFalse
(
deleteJiraService
.
getActive
());
.
withUsername
(
"GitLab4J"
)
}
.
withPassword
(
"test"
)
.
withProjectKey
(
"GL4J"
);
@Test
JiraService
updatedJiraService
=
gitLabApi
.
getServicesApi
().
updateJiraService
(
testProject
,
jiraService
);
public
void
testGetSlackService
()
throws
GitLabApiException
{
assertNotNull
(
updatedJiraService
);
SlackService
slackService
=
gitLabApi
.
getServicesApi
().
getSlackService
(
testProject
);
assertTrue
(
updatedJiraService
.
getActive
());
assertNotNull
(
slackService
);
}
gitLabApi
.
getServicesApi
().
deleteJiraService
(
testProject
);
JiraService
deleteJiraService
=
gitLabApi
.
getServicesApi
().
getJiraService
(
testProject
);
@Test
assertNotNull
(
deleteJiraService
);
public
void
testUpdateSlackService
()
throws
GitLabApiException
{
assertFalse
(
deleteJiraService
.
getActive
());
}
try
{
SlackService
slackService
=
new
SlackService
()
@Test
.
withMergeRequestsEvents
(
true
)
public
void
testGetSlackService
()
throws
GitLabApiException
{
.
withWebhook
(
"https://hooks.slack.com/services/ABCDEFGHI/KJLMNOPQR/wetrewq7897HKLH8998wfjjj"
)
SlackService
slackService
=
gitLabApi
.
getServicesApi
().
getSlackService
(
testProject
);
.
withUsername
(
"GitLab4J"
);
assertNotNull
(
slackService
);
SlackService
updatedSlackService
=
gitLabApi
.
getServicesApi
().
updateSlackService
(
testProject
,
slackService
);
}
assertNotNull
(
updatedSlackService
);
}
finally
{
@Test
try
{
gitLabApi
.
getServicesApi
().
deleteSlackService
(
testProject
);
}
catch
(
Exception
ignore
)
{}
public
void
testUpdateSlackService
()
throws
GitLabApiException
{
}
}
try
{
SlackService
slackService
=
new
SlackService
()
@Test
.
withMergeRequestsEvents
(
true
)
public
void
testDeleteSlackService
()
throws
GitLabApiException
{
.
withWebhook
(
"https://hooks.slack.com/services/ABCDEFGHI/KJLMNOPQR/wetrewq7897HKLH8998wfjjj"
)
SlackService
slackService
=
new
SlackService
()
.
withUsername
(
"GitLab4J"
);
.
withMergeRequestsEvents
(
true
)
SlackService
updatedSlackService
=
gitLabApi
.
getServicesApi
().
updateSlackService
(
testProject
,
slackService
);
.
withWebhook
(
"https://hooks.slack.com/services/ABCDEFGHI/KJLMNOPQR/wetrewq7897HKLH8998wfjjj"
)
assertNotNull
(
updatedSlackService
);
.
withUsername
(
"GitLab4J"
);
}
finally
{
SlackService
updatedSlackService
=
gitLabApi
.
getServicesApi
().
updateSlackService
(
testProject
,
slackService
);
try
{
assertNotNull
(
updatedSlackService
);
gitLabApi
.
getServicesApi
().
deleteSlackService
(
testProject
);
assertTrue
(
updatedSlackService
.
getActive
());
}
catch
(
Exception
ignore
)
{
}
gitLabApi
.
getServicesApi
().
deleteSlackService
(
testProject
);
}
SlackService
deleteSlackService
=
gitLabApi
.
getServicesApi
().
getSlackService
(
testProject
);
}
assertNotNull
(
deleteSlackService
);
assertFalse
(
deleteSlackService
.
getActive
());
@Test
}
public
void
testDeleteSlackService
()
throws
GitLabApiException
{
SlackService
slackService
=
new
SlackService
()
@Test
.
withMergeRequestsEvents
(
true
)
public
void
testGetExternalWiki
()
throws
GitLabApiException
{
.
withWebhook
(
"https://hooks.slack.com/services/ABCDEFGHI/KJLMNOPQR/wetrewq7897HKLH8998wfjjj"
)
ExternalWikiService
wikiService
=
gitLabApi
.
getServicesApi
().
getExternalWikiService
(
testProject
);
.
withUsername
(
"GitLab4J"
);
assertNotNull
(
wikiService
);
SlackService
updatedSlackService
=
gitLabApi
.
getServicesApi
().
updateSlackService
(
testProject
,
slackService
);
}
assertNotNull
(
updatedSlackService
);
assertTrue
(
updatedSlackService
.
getActive
());
@Test
public
void
testUpdateExternalWiki
()
throws
GitLabApiException
{
gitLabApi
.
getServicesApi
().
deleteSlackService
(
testProject
);
try
{
SlackService
deleteSlackService
=
gitLabApi
.
getServicesApi
().
getSlackService
(
testProject
);
ExternalWikiService
wikiService
=
new
ExternalWikiService
()
assertNotNull
(
deleteSlackService
);
.
withExternalWikiUrl
(
"http://wiki.io"
);
assertFalse
(
deleteSlackService
.
getActive
());
ExternalWikiService
updatedExternalWikiService
=
gitLabApi
.
getServicesApi
().
updateExternalWikiService
(
testProject
,
wikiService
);
}
assertNotNull
(
updatedExternalWikiService
);
}
finally
{
@Test
try
{
gitLabApi
.
getServicesApi
().
deleteExternalWikiService
(
testProject
);
}
catch
(
Exception
ignore
)
{}
public
void
testGetExternalWiki
()
throws
GitLabApiException
{
}
ExternalWikiService
wikiService
=
gitLabApi
.
getServicesApi
().
getExternalWikiService
(
testProject
);
}
assertNotNull
(
wikiService
);
}
@Test
public
void
testDeleteExternalWikiService
()
throws
GitLabApiException
{
@Test
ExternalWikiService
wikiService
=
new
ExternalWikiService
()
public
void
testUpdateExternalWiki
()
throws
GitLabApiException
{
.
withExternalWikiUrl
(
"http://wiki.io"
);
try
{
ExternalWikiService
updatedExternalWikiService
=
gitLabApi
.
getServicesApi
().
updateExternalWikiService
(
testProject
,
wikiService
);
ExternalWikiService
wikiService
=
new
ExternalWikiService
()
assertNotNull
(
updatedExternalWikiService
);
.
withExternalWikiUrl
(
"http://wiki.io"
);
assertTrue
(
updatedExternalWikiService
.
getActive
());
ExternalWikiService
updatedExternalWikiService
=
gitLabApi
.
getServicesApi
()
.
updateExternalWikiService
(
testProject
,
wikiService
);
gitLabApi
.
getServicesApi
().
deleteExternalWikiService
(
testProject
);
assertNotNull
(
updatedExternalWikiService
);
ExternalWikiService
deleteExternalWikiService
=
gitLabApi
.
getServicesApi
().
getExternalWikiService
(
testProject
);
}
finally
{
assertNotNull
(
deleteExternalWikiService
);
try
{
assertFalse
(
deleteExternalWikiService
.
getActive
());
gitLabApi
.
getServicesApi
().
deleteExternalWikiService
(
testProject
);
}
}
catch
(
Exception
ignore
)
{
}
@Test
}
public
void
testGetMattermostService
()
throws
GitLabApiException
{
}
MattermostService
service
=
gitLabApi
.
getServicesApi
().
getMattermostService
(
testProject
);
assertNotNull
(
service
);
@Test
}
public
void
testDeleteExternalWikiService
()
throws
GitLabApiException
{
ExternalWikiService
wikiService
=
new
ExternalWikiService
()
@Test
.
withExternalWikiUrl
(
"http://wiki.io"
);
public
void
testUpdateMattermostService
()
throws
GitLabApiException
{
ExternalWikiService
updatedExternalWikiService
=
gitLabApi
.
getServicesApi
()
.
updateExternalWikiService
(
testProject
,
wikiService
);
try
{
assertNotNull
(
updatedExternalWikiService
);
MattermostService
service
=
new
MattermostService
()
assertTrue
(
updatedExternalWikiService
.
getActive
());
.
withMergeRequestsEvents
(
true
)
.
withWebhook
(
"https://hooks.mattermost.com/services/ABCDEFGHI/KJLMNOPQR/wetrewq7897HKLH8998wfjjj"
)
gitLabApi
.
getServicesApi
().
deleteExternalWikiService
(
testProject
);
.
withUsername
(
"GitLab4J"
);
ExternalWikiService
deleteExternalWikiService
=
gitLabApi
.
getServicesApi
().
getExternalWikiService
(
testProject
);
MattermostService
updatedService
=
gitLabApi
.
getServicesApi
().
updateMattermostService
(
testProject
,
service
);
assertNotNull
(
deleteExternalWikiService
);
assertNotNull
(
updatedService
);
assertFalse
(
deleteExternalWikiService
.
getActive
());
assertEquals
(
service
.
getWebhook
(),
updatedService
.
getWebhook
());
}
}
finally
{
try
{
gitLabApi
.
getServicesApi
().
deleteMattermostService
(
testProject
);
}
catch
(
Exception
ignore
)
{}
@Test
}
public
void
testGetMattermostService
()
throws
GitLabApiException
{
}
MattermostService
service
=
gitLabApi
.
getServicesApi
().
getMattermostService
(
testProject
);
assertNotNull
(
service
);
@Test
}
public
void
testDeleteMattermostService
()
throws
GitLabApiException
{
MattermostService
service
=
new
MattermostService
()
@Test
.
withMergeRequestsEvents
(
true
)
public
void
testUpdateMattermostService
()
throws
GitLabApiException
{
.
withWebhook
(
"https://hooks.mattermost.com/services/ABCDEFGHI/KJLMNOPQR/wetrewq7897HKLH8998wfjjj"
)
.
withUsername
(
"GitLab4J"
);
try
{
MattermostService
updatedService
=
gitLabApi
.
getServicesApi
().
updateMattermostService
(
testProject
,
service
);
MattermostService
service
=
new
MattermostService
()
assertNotNull
(
updatedService
);
.
withMergeRequestsEvents
(
true
)
assertTrue
(
updatedService
.
getActive
());
.
withWebhook
(
"https://hooks.mattermost.com/services/ABCDEFGHI/KJLMNOPQR/wetrewq7897HKLH8998wfjjj"
)
.
withUsername
(
"GitLab4J"
);
gitLabApi
.
getServicesApi
().
deleteMattermostService
(
testProject
);
MattermostService
updatedService
=
gitLabApi
.
getServicesApi
().
updateMattermostService
(
testProject
,
service
);
MattermostService
deleteMattermostService
=
gitLabApi
.
getServicesApi
().
getMattermostService
(
testProject
);
assertNotNull
(
updatedService
);
assertNotNull
(
deleteMattermostService
);
assertEquals
(
service
.
getWebhook
(),
updatedService
.
getWebhook
());
assertFalse
(
deleteMattermostService
.
getActive
());
}
finally
{
}
try
{
gitLabApi
.
getServicesApi
().
deleteMattermostService
(
testProject
);
@Test
}
catch
(
Exception
ignore
)
{
public
void
testGetBugzillaService
()
throws
GitLabApiException
{
}
BugzillaService
service
=
gitLabApi
.
getServicesApi
().
getBugzillaService
(
testProject
);
}
assertNotNull
(
service
);
}
}
@Test
@Test
public
void
testDeleteMattermostService
()
throws
GitLabApiException
{
public
void
testUpdateBugzillaService
()
throws
GitLabApiException
{
MattermostService
service
=
new
MattermostService
()
.
withMergeRequestsEvents
(
true
)
try
{
.
withWebhook
(
"https://hooks.mattermost.com/services/ABCDEFGHI/KJLMNOPQR/wetrewq7897HKLH8998wfjjj"
)
.
withUsername
(
"GitLab4J"
);
BugzillaService
service
=
new
BugzillaService
()
MattermostService
updatedService
=
gitLabApi
.
getServicesApi
().
updateMattermostService
(
testProject
,
service
);
.
withIssuesUrl
(
TEST_ENDPOINT
+
"issues"
)
assertNotNull
(
updatedService
);
.
withNewIssueUrl
(
TEST_ENDPOINT
+
"new_issue"
)
assertTrue
(
updatedService
.
getActive
());
.
withProjectUrl
(
TEST_ENDPOINT
+
"project"
);
BugzillaService
updatedService
=
gitLabApi
.
getServicesApi
().
updateBugzillaService
(
testProject
,
service
);
gitLabApi
.
getServicesApi
().
deleteMattermostService
(
testProject
);
assertNotNull
(
updatedService
);
MattermostService
deleteMattermostService
=
gitLabApi
.
getServicesApi
().
getMattermostService
(
testProject
);
assertEquals
(
service
.
getIssuesUrl
(),
updatedService
.
getIssuesUrl
());
assertNotNull
(
deleteMattermostService
);
assertEquals
(
service
.
getNewIssueUrl
(),
updatedService
.
getNewIssueUrl
());
assertFalse
(
deleteMattermostService
.
getActive
());
assertEquals
(
service
.
getProjectUrl
(),
updatedService
.
getProjectUrl
());
}
}
finally
{
@Test
try
{
gitLabApi
.
getServicesApi
().
deleteBugzillaService
(
testProject
);
}
catch
(
Exception
ignore
)
{}
public
void
testGetBugzillaService
()
throws
GitLabApiException
{
}
BugzillaService
service
=
gitLabApi
.
getServicesApi
().
getBugzillaService
(
testProject
);
}
assertNotNull
(
service
);
}
@Test
public
void
testDeleteBugzillaService
()
throws
GitLabApiException
{
@Test
public
void
testUpdateBugzillaService
()
throws
GitLabApiException
{
BugzillaService
service
=
new
BugzillaService
()
.
withIssuesUrl
(
TEST_ENDPOINT
+
"issues"
)
try
{
.
withNewIssueUrl
(
TEST_ENDPOINT
+
"new_issue"
)
.
withProjectUrl
(
TEST_ENDPOINT
+
"project"
);
BugzillaService
service
=
new
BugzillaService
()
BugzillaService
updatedService
=
gitLabApi
.
getServicesApi
().
updateBugzillaService
(
testProject
,
service
);
.
withIssuesUrl
(
TEST_ENDPOINT
+
"issues"
)
assertNotNull
(
updatedService
);
.
withNewIssueUrl
(
TEST_ENDPOINT
+
"new_issue"
)
assertTrue
(
updatedService
.
getActive
());
.
withProjectUrl
(
TEST_ENDPOINT
+
"project"
);
BugzillaService
updatedService
=
gitLabApi
.
getServicesApi
().
updateBugzillaService
(
testProject
,
service
);
gitLabApi
.
getServicesApi
().
deleteBugzillaService
(
testProject
);
assertNotNull
(
updatedService
);
BugzillaService
deletedService
=
gitLabApi
.
getServicesApi
().
getBugzillaService
(
testProject
);
assertEquals
(
service
.
getIssuesUrl
(),
updatedService
.
getIssuesUrl
());
assertNotNull
(
deletedService
);
assertEquals
(
service
.
getNewIssueUrl
(),
updatedService
.
getNewIssueUrl
());
assertFalse
(
deletedService
.
getActive
());
assertEquals
(
service
.
getProjectUrl
(),
updatedService
.
getProjectUrl
());
}
}
finally
{
@Test
try
{
public
void
testGetCustomIssueTrackerService
()
throws
GitLabApiException
{
gitLabApi
.
getServicesApi
().
deleteBugzillaService
(
testProject
);
CustomIssueTrackerService
service
=
gitLabApi
.
getServicesApi
().
getCustomIssueTrackerService
(
testProject
);
}
catch
(
Exception
ignore
)
{
assertNotNull
(
service
);
}
}
}
}
@Test
public
void
testUpdateCustomIssueTrackerService
()
throws
GitLabApiException
{
@Test
public
void
testDeleteBugzillaService
()
throws
GitLabApiException
{
try
{
BugzillaService
service
=
new
BugzillaService
()
CustomIssueTrackerService
service
=
new
CustomIssueTrackerService
()
.
withIssuesUrl
(
TEST_ENDPOINT
+
"issues"
)
.
withIssuesUrl
(
TEST_ENDPOINT
+
"issues"
)
.
withNewIssueUrl
(
TEST_ENDPOINT
+
"new_issue"
)
.
withNewIssueUrl
(
TEST_ENDPOINT
+
"new_issue"
)
.
withProjectUrl
(
TEST_ENDPOINT
+
"project"
);
.
withProjectUrl
(
TEST_ENDPOINT
+
"project"
);
BugzillaService
updatedService
=
gitLabApi
.
getServicesApi
().
updateBugzillaService
(
testProject
,
service
);
CustomIssueTrackerService
updatedService
=
gitLabApi
.
getServicesApi
().
updateCustomIssueTrackerService
(
testProject
,
service
);
assertNotNull
(
updatedService
);
assertNotNull
(
updatedService
);
assertTrue
(
updatedService
.
getActive
());
assertEquals
(
service
.
getIssuesUrl
(),
updatedService
.
getIssuesUrl
());
assertEquals
(
service
.
getNewIssueUrl
(),
updatedService
.
getNewIssueUrl
());
gitLabApi
.
getServicesApi
().
deleteBugzillaService
(
testProject
);
assertEquals
(
service
.
getProjectUrl
(),
updatedService
.
getProjectUrl
());
BugzillaService
deletedService
=
gitLabApi
.
getServicesApi
().
getBugzillaService
(
testProject
);
assertNotNull
(
deletedService
);
}
finally
{
assertFalse
(
deletedService
.
getActive
());
try
{
gitLabApi
.
getServicesApi
().
deleteCustomIssueTrackerService
(
testProject
);
}
catch
(
Exception
ignore
)
{}
}
}
}
@Test
public
void
testGetCustomIssueTrackerService
()
throws
GitLabApiException
{
@Test
CustomIssueTrackerService
service
=
gitLabApi
.
getServicesApi
().
getCustomIssueTrackerService
(
testProject
);
public
void
testDeleteCustomIssueTrackerService
()
throws
GitLabApiException
{
assertNotNull
(
service
);
}
CustomIssueTrackerService
service
=
new
CustomIssueTrackerService
()
.
withIssuesUrl
(
TEST_ENDPOINT
+
"issues"
)
@Test
.
withNewIssueUrl
(
TEST_ENDPOINT
+
"new_issue"
)
public
void
testUpdateCustomIssueTrackerService
()
throws
GitLabApiException
{
.
withProjectUrl
(
TEST_ENDPOINT
+
"project"
);
CustomIssueTrackerService
updatedService
=
gitLabApi
.
getServicesApi
().
updateCustomIssueTrackerService
(
testProject
,
service
);
try
{
assertNotNull
(
updatedService
);
assertTrue
(
updatedService
.
getActive
());
CustomIssueTrackerService
service
=
new
CustomIssueTrackerService
()
.
withIssuesUrl
(
TEST_ENDPOINT
+
"issues"
)
gitLabApi
.
getServicesApi
().
deleteCustomIssueTrackerService
(
testProject
);
.
withNewIssueUrl
(
TEST_ENDPOINT
+
"new_issue"
)
CustomIssueTrackerService
deletedService
=
gitLabApi
.
getServicesApi
().
getCustomIssueTrackerService
(
testProject
);
.
withProjectUrl
(
TEST_ENDPOINT
+
"project"
);
assertNotNull
(
deletedService
);
CustomIssueTrackerService
updatedService
=
gitLabApi
.
getServicesApi
()
assertFalse
(
deletedService
.
getActive
());
.
updateCustomIssueTrackerService
(
testProject
,
service
);
}
assertNotNull
(
updatedService
);
assertEquals
(
service
.
getIssuesUrl
(),
updatedService
.
getIssuesUrl
());
assertEquals
(
service
.
getNewIssueUrl
(),
updatedService
.
getNewIssueUrl
());
assertEquals
(
service
.
getProjectUrl
(),
updatedService
.
getProjectUrl
());
}
finally
{
try
{
gitLabApi
.
getServicesApi
().
deleteCustomIssueTrackerService
(
testProject
);
}
catch
(
Exception
ignore
)
{
}
}
}
@Test
public
void
testDeleteCustomIssueTrackerService
()
throws
GitLabApiException
{
CustomIssueTrackerService
service
=
new
CustomIssueTrackerService
()
.
withIssuesUrl
(
TEST_ENDPOINT
+
"issues"
)
.
withNewIssueUrl
(
TEST_ENDPOINT
+
"new_issue"
)
.
withProjectUrl
(
TEST_ENDPOINT
+
"project"
);
CustomIssueTrackerService
updatedService
=
gitLabApi
.
getServicesApi
()
.
updateCustomIssueTrackerService
(
testProject
,
service
);
assertNotNull
(
updatedService
);
assertTrue
(
updatedService
.
getActive
());
gitLabApi
.
getServicesApi
().
deleteCustomIssueTrackerService
(
testProject
);
CustomIssueTrackerService
deletedService
=
gitLabApi
.
getServicesApi
().
getCustomIssueTrackerService
(
testProject
);
assertNotNull
(
deletedService
);
assertFalse
(
deletedService
.
getActive
());
}
@Test
public
void
testGetEmailOnPushService
()
throws
GitLabApiException
{
EmailOnPushService
emailOnPushService
=
gitLabApi
.
getServicesApi
().
getEmailOnPushService
(
testProject
);
assertNotNull
(
emailOnPushService
);
// This is testing that a class cast exception is not thrown.
Boolean
commitEvents
=
emailOnPushService
.
getCommitEvents
();
assertTrue
(
commitEvents
||
!
commitEvents
);
}
@Test
public
void
testUpdateEmailOnPushService
()
throws
GitLabApiException
{
try
{
EmailOnPushService
emailOnPushService
=
new
EmailOnPushService
()
.
withRecipients
(
"email@gitlab4j.localhost"
)
.
withBranchesToBeNotified
(
BranchesToBeNotified
.
ALL
)
.
withDisableDiffs
(
false
)
.
withPushEvents
(
false
)
.
withSendFromCommitterEmail
(
true
)
.
withTagPushEvents
(
false
);
EmailOnPushService
updatedEmailOnPushService
=
gitLabApi
.
getServicesApi
()
.
updateEmailOnPushService
(
testProject
,
emailOnPushService
);
assertNotNull
(
updatedEmailOnPushService
);
assertTrue
(
updatedEmailOnPushService
.
getActive
());
}
finally
{
try
{
gitLabApi
.
getServicesApi
().
deleteEmailonPushService
(
testProject
);
}
catch
(
Exception
ignore
)
{
}
}
}
@Test
public
void
testDeleteEmailOnPushService
()
throws
GitLabApiException
{
EmailOnPushService
emailOnPushService
=
new
EmailOnPushService
()
.
withRecipients
(
"email@gitlab4j.localhost"
)
.
withPushEvents
(
false
);
EmailOnPushService
updatedEmailOnPushService
=
gitLabApi
.
getServicesApi
().
updateEmailOnPushService
(
testProject
,
emailOnPushService
);
assertNotNull
(
updatedEmailOnPushService
);
assertTrue
(
updatedEmailOnPushService
.
getActive
());
gitLabApi
.
getServicesApi
().
deleteEmailonPushService
(
testProject
);
EmailOnPushService
deleteEmailOnPushService
=
gitLabApi
.
getServicesApi
().
getEmailOnPushService
(
testProject
);
assertNotNull
(
deleteEmailOnPushService
);
assertFalse
(
deleteEmailOnPushService
.
getActive
());
}
}
}
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