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
d27c6b18
Commit
d27c6b18
authored
Jan 25, 2020
by
Greg Messner
Browse files
Added tests for getting merge request pipelines (#500)
parent
1ee18e9a
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/test/java/org/gitlab4j/api/TestMergeRequestApi.java
View file @
d27c6b18
...
...
@@ -8,10 +8,12 @@ import static org.junit.Assume.assumeNotNull;
import
java.util.List
;
import
java.util.Optional
;
import
java.util.stream.Stream
;
import
org.gitlab4j.api.models.Branch
;
import
org.gitlab4j.api.models.MergeRequest
;
import
org.gitlab4j.api.models.MergeRequestParams
;
import
org.gitlab4j.api.models.Pipeline
;
import
org.gitlab4j.api.models.Project
;
import
org.gitlab4j.api.models.RepositoryFile
;
import
org.gitlab4j.api.models.User
;
...
...
@@ -226,4 +228,47 @@ public class TestMergeRequestApi extends AbstractIntegrationTest {
}
}
}
@Test
public
void
testGetMergeRequestPipelines
()
throws
GitLabApiException
{
// Create a test branch
Branch
branch
=
gitLabApi
.
getRepositoryApi
().
createBranch
(
testProject
,
TEST_BRANCH_NAME
,
"master"
);
assertNotNull
(
branch
);
// Create a new file in the test branch
RepositoryFile
repoFile
=
new
RepositoryFile
();
repoFile
.
setFilePath
(
"README-FOR-TESTING-MERGE-REQUEST-PIPELINES.md"
);
repoFile
.
setContent
(
"This is content"
);
gitLabApi
.
getRepositoryFileApi
().
createFile
(
testProject
,
repoFile
,
TEST_BRANCH_NAME
,
"Initial commit."
);
MergeRequest
mr
=
null
;
try
{
MergeRequestParams
params
=
new
MergeRequestParams
()
.
withSourceBranch
(
TEST_BRANCH_NAME
)
.
withTargetBranch
(
"master"
)
.
withTitle
(
TEST_MR_TITLE
);
mr
=
gitLabApi
.
getMergeRequestApi
().
createMergeRequest
(
testProject
,
params
);
assertNotNull
(
mr
);
List
<
Pipeline
>
pipelines
=
gitLabApi
.
getMergeRequestApi
().
getMergeRequestPipelines
(
testProject
,
mr
.
getIid
());
assertNotNull
(
pipelines
);
Stream
<
Pipeline
>
pipelineStream
=
gitLabApi
.
getMergeRequestApi
().
getMergeRequestPipelinesStream
(
testProject
,
mr
.
getIid
());
assertNotNull
(
pipelineStream
);
}
finally
{
if
(
mr
!=
null
)
{
try
{
gitLabApi
.
getMergeRequestApi
().
deleteMergeRequest
(
testProject
,
mr
.
getIid
());
}
catch
(
Exception
ignore
)
{}
}
try
{
gitLabApi
.
getRepositoryApi
().
deleteBranch
(
testProject
,
TEST_BRANCH_NAME
);
}
catch
(
GitLabApiException
ignore
)
{}
}
}
}
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