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
2e2c67fc
Commit
2e2c67fc
authored
Aug 08, 2017
by
Greg Messner
Browse files
Initial check-in.
parent
eb829861
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/test/java/org/gitlab4j/api/TestUserApi.java
0 → 100644
View file @
2e2c67fc
package
org.gitlab4j.api
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
import
static
org
.
junit
.
Assume
.
assumeTrue
;
import
org.gitlab4j.api.GitLabApi.ApiVersion
;
import
org.gitlab4j.api.models.User
;
import
org.gitlab4j.api.models.Version
;
import
org.junit.Before
;
import
org.junit.BeforeClass
;
import
org.junit.Test
;
/**
* In order for these tests to run you must set the following properties in test-gitlab4j.properties
*
* TEST_HOST_URL
* TEST_PRIVATE_TOKEN
* TEST_USERNAME
*
* If any of the above are NULL, all tests in this class will be skipped.
*
*/
public
class
TestUserApi
{
// The following needs to be set to your test repository
private
static
final
String
TEST_HOST_URL
;
private
static
final
String
TEST_PRIVATE_TOKEN
;
private
static
final
String
TEST_USERNAME
;
static
{
TEST_HOST_URL
=
TestUtils
.
getProperty
(
"TEST_HOST_URL"
);
TEST_PRIVATE_TOKEN
=
TestUtils
.
getProperty
(
"TEST_PRIVATE_TOKEN"
);
TEST_USERNAME
=
TestUtils
.
getProperty
(
"TEST_USERNAME"
);
}
private
static
GitLabApi
gitLabApi
;
public
TestUserApi
()
{
super
();
}
@BeforeClass
public
static
void
setup
()
{
String
problems
=
""
;
if
(
TEST_HOST_URL
==
null
||
TEST_HOST_URL
.
trim
().
length
()
==
0
)
{
problems
+=
"TEST_HOST_URL cannot be empty\n"
;
}
if
(
TEST_PRIVATE_TOKEN
==
null
||
TEST_PRIVATE_TOKEN
.
trim
().
length
()
==
0
)
{
problems
+=
"TEST_PRIVATE_TOKEN cannot be empty\n"
;
}
if
(
TEST_USERNAME
==
null
||
TEST_USERNAME
.
trim
().
length
()
==
0
)
{
problems
+=
"TEST_USER_NAME cannot be empty\n"
;
}
if
(
problems
.
isEmpty
())
{
gitLabApi
=
new
GitLabApi
(
ApiVersion
.
V4
,
TEST_HOST_URL
,
TEST_PRIVATE_TOKEN
);
}
else
{
System
.
err
.
print
(
problems
);
}
}
@Before
public
void
beforeMethod
()
{
assumeTrue
(
gitLabApi
!=
null
);
}
@Test
public
void
testGetVersion
()
throws
GitLabApiException
{
Version
version
=
gitLabApi
.
getVersion
();
assertNotNull
(
version
);
System
.
out
.
format
(
"version=%s, revision=%s%n"
,
version
.
getVersion
(),
version
.
getRevision
());
assertNotNull
(
version
.
getVersion
());
assertNotNull
(
version
.
getRevision
());
}
@Test
public
void
testGetCurrentUser
()
throws
GitLabApiException
{
User
currentUser
=
gitLabApi
.
getUserApi
().
getCurrentUser
();
assertNotNull
(
currentUser
);
assertEquals
(
TEST_USERNAME
,
currentUser
.
getUsername
());
}
}
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