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
44d556bb
Commit
44d556bb
authored
Jun 24, 2017
by
Greg Messner
Browse files
Improved test coverage.
parent
4f003111
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/test/java/org/gitlab4j/api/TestNamespaceApi.java
View file @
44d556bb
...
@@ -73,12 +73,41 @@ public class TestNamespaceApi {
...
@@ -73,12 +73,41 @@ public class TestNamespaceApi {
public
void
testGetNamespaces
()
throws
GitLabApiException
{
public
void
testGetNamespaces
()
throws
GitLabApiException
{
List
<
Namespace
>
namespaces
=
gitLabApi
.
getNamespaceApi
().
getNamespaces
();
List
<
Namespace
>
namespaces
=
gitLabApi
.
getNamespaceApi
().
getNamespaces
();
assertNotNull
(
namespaces
);
assertNotNull
(
namespaces
);
assertEquals
(
TEST_NAMESPACE
,
namespaces
.
get
(
0
).
getName
());
}
@Test
public
void
testGetNamespacesViaPager
()
throws
GitLabApiException
{
Pager
<
Namespace
>
pager
=
gitLabApi
.
getNamespaceApi
().
getNamespaces
(
10
);
assertNotNull
(
pager
);
assertEquals
(
TEST_NAMESPACE
,
pager
.
next
().
get
(
0
).
getName
());
}
@Test
public
void
testGetNamespacesByPage
()
throws
GitLabApiException
{
List
<
Namespace
>
namespaces
=
gitLabApi
.
getNamespaceApi
().
getNamespaces
(
1
,
10
);
assertNotNull
(
namespaces
);
assertEquals
(
TEST_NAMESPACE
,
namespaces
.
get
(
0
).
getName
());
}
}
@Test
@Test
public
void
testFindNamespaces
()
throws
GitLabApiException
{
public
void
testFindNamespaces
()
throws
GitLabApiException
{
List
<
Namespace
>
namespaces
=
gitLabApi
.
getNamespaceApi
().
findNamespaces
(
TEST_NAMESPACE
);
List
<
Namespace
>
namespaces
=
gitLabApi
.
getNamespaceApi
().
findNamespaces
(
TEST_NAMESPACE
);
assertNotNull
(
namespaces
);
assertNotNull
(
namespaces
);
assertEquals
(
TEST_NAMESPACE
,
namespaces
.
get
(
0
).
getName
());
assertEquals
(
TEST_NAMESPACE
,
namespaces
.
get
(
0
).
getName
());
}
}
@Test
public
void
testFindNamespacesByPage
()
throws
GitLabApiException
{
List
<
Namespace
>
namespaces
=
gitLabApi
.
getNamespaceApi
().
findNamespaces
(
TEST_NAMESPACE
,
1
,
10
);
assertNotNull
(
namespaces
);
assertEquals
(
TEST_NAMESPACE
,
namespaces
.
get
(
0
).
getName
());
}
@Test
public
void
testFindNamespacesViaPager
()
throws
GitLabApiException
{
Pager
<
Namespace
>
pager
=
gitLabApi
.
getNamespaceApi
().
findNamespaces
(
TEST_NAMESPACE
,
10
);
assertNotNull
(
pager
);
assertEquals
(
TEST_NAMESPACE
,
pager
.
next
().
get
(
0
).
getName
());
}
}
}
src/test/java/org/gitlab4j/api/TestProjectApi.java
View file @
44d556bb
...
@@ -148,6 +148,99 @@ public class TestProjectApi {
...
@@ -148,6 +148,99 @@ public class TestProjectApi {
assertEquals
(
TEST_PROJECT_NAME
,
projects
.
get
(
1
).
getName
());
assertEquals
(
TEST_PROJECT_NAME
,
projects
.
get
(
1
).
getName
());
}
}
@Test
public
void
testListProjectsWithParams
()
throws
GitLabApiException
{
List
<
Project
>
projects
=
gitLabApi
.
getProjectApi
().
getProjects
(
false
,
Visibility
.
PUBLIC
,
Constants
.
ProjectOrderBy
.
NAME
,
Constants
.
SortOrder
.
DESC
,
null
,
true
,
true
,
true
,
false
,
true
);
assertNotNull
(
projects
);
assertTrue
(
projects
.
size
()
>=
2
);
int
matchCount
=
0
;
for
(
Project
project
:
projects
)
{
if
(
TEST_PROJECT_NAME
.
equals
(
project
.
getName
()))
matchCount
++;
else
if
(
TEST_PROJECT_NAME_2
.
equals
(
project
.
getName
()))
matchCount
++;
}
assertEquals
(
2
,
matchCount
);
projects
=
gitLabApi
.
getProjectApi
().
getProjects
(
TEST_PROJECT_NAME
);
assertNotNull
(
projects
);
assertEquals
(
2
,
projects
.
size
());
assertEquals
(
TEST_PROJECT_NAME_2
,
projects
.
get
(
0
).
getName
());
assertEquals
(
TEST_PROJECT_NAME
,
projects
.
get
(
1
).
getName
());
}
@Test
public
void
testListProjectsWithParamsViaPager
()
throws
GitLabApiException
{
Pager
<
Project
>
pager
=
gitLabApi
.
getProjectApi
().
getProjects
(
false
,
Visibility
.
PUBLIC
,
Constants
.
ProjectOrderBy
.
NAME
,
Constants
.
SortOrder
.
DESC
,
null
,
true
,
true
,
true
,
false
,
true
,
10
);
assertNotNull
(
pager
);
assertTrue
(
pager
.
getTotalItems
()
>=
2
);
List
<
Project
>
projects
=
pager
.
next
();
int
matchCount
=
0
;
for
(
Project
project
:
projects
)
{
if
(
TEST_PROJECT_NAME
.
equals
(
project
.
getName
()))
matchCount
++;
else
if
(
TEST_PROJECT_NAME_2
.
equals
(
project
.
getName
()))
matchCount
++;
}
assertEquals
(
2
,
matchCount
);
projects
=
gitLabApi
.
getProjectApi
().
getProjects
(
TEST_PROJECT_NAME
);
assertNotNull
(
projects
);
assertEquals
(
2
,
projects
.
size
());
assertEquals
(
TEST_PROJECT_NAME_2
,
projects
.
get
(
0
).
getName
());
assertEquals
(
TEST_PROJECT_NAME
,
projects
.
get
(
1
).
getName
());
}
@Test
public
void
testListProjectsWithParamByPage
()
throws
GitLabApiException
{
List
<
Project
>
projects
=
gitLabApi
.
getProjectApi
().
getProjects
(
false
,
Visibility
.
PUBLIC
,
Constants
.
ProjectOrderBy
.
NAME
,
Constants
.
SortOrder
.
DESC
,
null
,
true
,
true
,
true
,
false
,
true
,
1
,
10
);
assertNotNull
(
projects
);
assertTrue
(
projects
.
size
()
>=
2
);
int
matchCount
=
0
;
for
(
Project
project
:
projects
)
{
if
(
TEST_PROJECT_NAME
.
equals
(
project
.
getName
()))
matchCount
++;
else
if
(
TEST_PROJECT_NAME_2
.
equals
(
project
.
getName
()))
matchCount
++;
}
assertEquals
(
2
,
matchCount
);
projects
=
gitLabApi
.
getProjectApi
().
getProjects
(
TEST_PROJECT_NAME
);
assertNotNull
(
projects
);
assertEquals
(
2
,
projects
.
size
());
assertEquals
(
TEST_PROJECT_NAME_2
,
projects
.
get
(
0
).
getName
());
assertEquals
(
TEST_PROJECT_NAME
,
projects
.
get
(
1
).
getName
());
}
@Test
public
void
testListStarredProjects
()
throws
GitLabApiException
{
List
<
Project
>
projects
=
gitLabApi
.
getProjectApi
().
getStarredProjects
();
assertNotNull
(
projects
);
assertTrue
(
projects
.
isEmpty
());
}
@Test
public
void
testListStarredProjectsWithParams
()
throws
GitLabApiException
{
List
<
Project
>
projects
=
gitLabApi
.
getProjectApi
().
getProjects
(
false
,
Visibility
.
PUBLIC
,
Constants
.
ProjectOrderBy
.
NAME
,
Constants
.
SortOrder
.
DESC
,
null
,
true
,
true
,
true
,
true
,
true
);
assertNotNull
(
projects
);
assertTrue
(
projects
.
isEmpty
());
}
@Test
@Test
public
void
testRemoveByDelete
()
throws
GitLabApiException
{
public
void
testRemoveByDelete
()
throws
GitLabApiException
{
Project
project
=
gitLabApi
.
getProjectApi
().
getProject
(
TEST_NAMESPACE
,
TEST_PROJECT_NAME
);
Project
project
=
gitLabApi
.
getProjectApi
().
getProject
(
TEST_NAMESPACE
,
TEST_PROJECT_NAME
);
...
...
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