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
a1b28ea1
Unverified
Commit
a1b28ea1
authored
Aug 30, 2021
by
Gautier de Saint Martin Lacaze
Browse files
Migrate from JUnit 4 to JUnit 5
parent
73817d15
Changes
67
Hide whitespace changes
Inline
Side-by-side
src/test/java/org/gitlab4j/api/TestTagsApi.java
View file @
a1b28ea1
package
org.gitlab4j.api
;
package
org.gitlab4j.api
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
jupiter
.
api
.
Assert
ions
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertFalse
;
import
static
org
.
junit
.
jupiter
.
api
.
Assert
ions
.
assertFalse
;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
import
static
org
.
junit
.
jupiter
.
api
.
Assert
ions
.
assertNotNull
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
static
org
.
junit
.
jupiter
.
api
.
Assert
ions
.
assertTrue
;
import
static
org
.
junit
.
Assume
.
assumeTrue
;
import
static
org
.
junit
.
jupiter
.
api
.
Assumptions
.
assumeTrue
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Optional
;
import
java.util.Optional
;
...
@@ -15,13 +15,12 @@ import org.gitlab4j.api.models.Project;
...
@@ -15,13 +15,12 @@ import org.gitlab4j.api.models.Project;
import
org.gitlab4j.api.models.ProtectedTag
;
import
org.gitlab4j.api.models.ProtectedTag
;
import
org.gitlab4j.api.models.Release
;
import
org.gitlab4j.api.models.Release
;
import
org.gitlab4j.api.models.Tag
;
import
org.gitlab4j.api.models.Tag
;
import
org.junit.AfterClass
;
import
org.junit.jupiter.api.AfterAll
;
import
org.junit.Before
;
import
org.junit.jupiter.api.BeforeAll
;
import
org.junit.BeforeClass
;
import
org.junit.jupiter.api.BeforeEach
;
import
org.junit.Test
;
import
org.junit.jupiter.api.Test
;
import
org.junit.experimental.categories.Category
;
@
Category
(
IntegrationTest
.
class
)
@
org
.
junit
.
jupiter
.
api
.
Tag
(
"integration"
)
public
class
TestTagsApi
extends
AbstractIntegrationTest
{
public
class
TestTagsApi
extends
AbstractIntegrationTest
{
private
static
final
String
TEST_TAG_NAME_1
=
"test-tag-1"
;
private
static
final
String
TEST_TAG_NAME_1
=
"test-tag-1"
;
...
@@ -36,7 +35,7 @@ public class TestTagsApi extends AbstractIntegrationTest {
...
@@ -36,7 +35,7 @@ public class TestTagsApi extends AbstractIntegrationTest {
super
();
super
();
}
}
@Before
Class
@Before
All
public
static
void
testSetup
()
{
public
static
void
testSetup
()
{
// 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 instance
...
@@ -52,7 +51,7 @@ public class TestTagsApi extends AbstractIntegrationTest {
...
@@ -52,7 +51,7 @@ public class TestTagsApi extends AbstractIntegrationTest {
}
}
}
}
@After
Class
@After
All
public
static
void
tearDown
()
{
public
static
void
tearDown
()
{
deleteTestTags
();
deleteTestTags
();
}
}
...
@@ -82,7 +81,7 @@ public class TestTagsApi extends AbstractIntegrationTest {
...
@@ -82,7 +81,7 @@ public class TestTagsApi extends AbstractIntegrationTest {
}
}
}
}
@Before
@Before
Each
public
void
beforeMethod
()
{
public
void
beforeMethod
()
{
assumeTrue
(
testProject
!=
null
);
assumeTrue
(
testProject
!=
null
);
}
}
...
...
src/test/java/org/gitlab4j/api/TestTodosApi.java
View file @
a1b28ea1
package
org.gitlab4j.api
;
package
org.gitlab4j.api
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertEquals
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertNotNull
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertTrue
;
import
static
org
.
junit
.
jupiter
.
api
.
Assumptions
.
assumeTrue
;
import
java.util.List
;
import
java.util.Random
;
import
org.gitlab4j.api.Constants.TodoState
;
import
org.gitlab4j.api.Constants.TodoState
;
import
org.gitlab4j.api.models.Issue
;
import
org.gitlab4j.api.models.Issue
;
import
org.gitlab4j.api.models.Project
;
import
org.gitlab4j.api.models.Project
;
import
org.gitlab4j.api.models.Todo
;
import
org.gitlab4j.api.models.Todo
;
import
org.gitlab4j.api.models.User
;
import
org.gitlab4j.api.models.User
;
import
org.junit.AfterClass
;
import
org.junit.jupiter.api.AfterAll
;
import
org.junit.Before
;
import
org.junit.jupiter.api.BeforeAll
;
import
org.junit.BeforeClass
;
import
org.junit.jupiter.api.BeforeEach
;
import
org.junit.Test
;
import
org.junit.jupiter.api.Tag
;
import
org.junit.experimental.categories.Category
;
import
org.junit.jupiter.api.Test
;
import
org.junit.jupiter.api.extension.ExtendWith
;
import
java.util.List
;
import
java.util.Random
;
import
static
org
.
junit
.
Assert
.*;
import
static
org
.
junit
.
Assume
.
assumeNotNull
;
/**
/**
* 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
...
@@ -25,7 +28,8 @@ import static org.junit.Assume.assumeNotNull;
...
@@ -25,7 +28,8 @@ import static org.junit.Assume.assumeNotNull;
* <p>
* <p>
* 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
)
@Tag
(
"integration"
)
@ExtendWith
(
SetupIntegrationTestExtension
.
class
)
public
class
TestTodosApi
extends
AbstractIntegrationTest
{
public
class
TestTodosApi
extends
AbstractIntegrationTest
{
private
static
GitLabApi
gitLabApi
;
private
static
GitLabApi
gitLabApi
;
...
@@ -39,7 +43,7 @@ public class TestTodosApi extends AbstractIntegrationTest {
...
@@ -39,7 +43,7 @@ public class TestTodosApi extends AbstractIntegrationTest {
super
();
super
();
}
}
@Before
Class
@Before
All
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 instance
...
@@ -49,7 +53,7 @@ public class TestTodosApi extends AbstractIntegrationTest {
...
@@ -49,7 +53,7 @@ public class TestTodosApi extends AbstractIntegrationTest {
deleteAllTestIssues
();
deleteAllTestIssues
();
}
}
@After
Class
@After
All
public
static
void
teardown
()
throws
GitLabApiException
{
public
static
void
teardown
()
throws
GitLabApiException
{
deleteAllTestIssues
();
deleteAllTestIssues
();
}
}
...
@@ -72,9 +76,9 @@ public class TestTodosApi extends AbstractIntegrationTest {
...
@@ -72,9 +76,9 @@ public class TestTodosApi extends AbstractIntegrationTest {
}
}
}
}
@Before
@Before
Each
public
void
beforeMethod
()
{
public
void
beforeMethod
()
{
assume
NotNull
(
gitLabApi
);
assume
True
(
gitLabApi
!=
null
);
}
}
private
static
String
getUniqueTitle
()
{
private
static
String
getUniqueTitle
()
{
...
...
src/test/java/org/gitlab4j/api/TestUnitMergeRequestApi.java
View file @
a1b28ea1
...
@@ -2,18 +2,18 @@ package org.gitlab4j.api;
...
@@ -2,18 +2,18 @@ package org.gitlab4j.api;
import
static
org
.
hamcrest
.
MatcherAssert
.
assertThat
;
import
static
org
.
hamcrest
.
MatcherAssert
.
assertThat
;
import
static
org
.
hamcrest
.
Matchers
.
hasEntry
;
import
static
org
.
hamcrest
.
Matchers
.
hasEntry
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
jupiter
.
api
.
Assert
ions
.
assertEquals
;
import
static
org
.
mockito
.
ArgumentMatchers
.
any
;
import
static
org
.
mockito
.
ArgumentMatchers
.
any
;
import
static
org
.
mockito
.
Mockito
.
when
;
import
static
org
.
mockito
.
Mockito
.
when
;
import
static
org
.
mockito
.
MockitoAnnotations
.
init
Mocks
;
import
static
org
.
mockito
.
MockitoAnnotations
.
open
Mocks
;
import
java.util.Collections
;
import
java.util.Collections
;
import
javax.ws.rs.core.MultivaluedMap
;
import
javax.ws.rs.core.MultivaluedMap
;
import
org.gitlab4j.api.models.MergeRequest
;
import
org.gitlab4j.api.models.MergeRequest
;
import
org.junit.Before
;
import
org.junit.
jupiter.api.
Before
Each
;
import
org.junit.Test
;
import
org.junit.
jupiter.api.
Test
;
import
org.mockito.ArgumentCaptor
;
import
org.mockito.ArgumentCaptor
;
import
org.mockito.Captor
;
import
org.mockito.Captor
;
import
org.mockito.Mock
;
import
org.mockito.Mock
;
...
@@ -26,9 +26,9 @@ public class TestUnitMergeRequestApi {
...
@@ -26,9 +26,9 @@ public class TestUnitMergeRequestApi {
@Captor
private
ArgumentCaptor
<
MultivaluedMap
<
String
,
String
>>
attributeCaptor
;
@Captor
private
ArgumentCaptor
<
MultivaluedMap
<
String
,
String
>>
attributeCaptor
;
private
MockResponse
mockedResponse
;
private
MockResponse
mockedResponse
;
@Before
@Before
Each
public
void
setUp
()
throws
Exception
{
public
void
setUp
()
throws
Exception
{
init
Mocks
(
this
);
open
Mocks
(
this
);
mockedResponse
=
new
MockResponse
(
MergeRequest
.
class
,
"merge-request.json"
,
null
);
mockedResponse
=
new
MockResponse
(
MergeRequest
.
class
,
"merge-request.json"
,
null
);
when
(
mockGitLabApi
.
getApiClient
()).
thenReturn
(
mockedGitLabApiClient
);
when
(
mockGitLabApi
.
getApiClient
()).
thenReturn
(
mockedGitLabApiClient
);
...
...
src/test/java/org/gitlab4j/api/TestUpload.java
View file @
a1b28ea1
...
@@ -3,9 +3,8 @@ package org.gitlab4j.api;
...
@@ -3,9 +3,8 @@ package org.gitlab4j.api;
import
static
org
.
hamcrest
.
MatcherAssert
.
assertThat
;
import
static
org
.
hamcrest
.
MatcherAssert
.
assertThat
;
import
static
org
.
hamcrest
.
Matchers
.
endsWith
;
import
static
org
.
hamcrest
.
Matchers
.
endsWith
;
import
static
org
.
hamcrest
.
Matchers
.
equalTo
;
import
static
org
.
hamcrest
.
Matchers
.
equalTo
;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertNotNull
;
import
static
org
.
junit
.
Assume
.
assumeNotNull
;
import
static
org
.
junit
.
jupiter
.
api
.
Assumptions
.
assumeTrue
;
import
static
org
.
junit
.
Assume
.
assumeTrue
;
import
java.io.File
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileInputStream
;
...
@@ -13,12 +12,13 @@ import java.io.FileNotFoundException;
...
@@ -13,12 +12,13 @@ import java.io.FileNotFoundException;
import
java.util.Map
;
import
java.util.Map
;
import
org.gitlab4j.api.models.FileUpload
;
import
org.gitlab4j.api.models.FileUpload
;
import
org.gitlab4j.api.models.Project
;
import
org.gitlab4j.api.models.Project
;
import
org.junit.Before
;
import
org.junit.jupiter.api.BeforeAll
;
import
org.junit.BeforeClass
;
import
org.junit.jupiter.api.BeforeEach
;
import
org.junit.FixMethodOrder
;
import
org.junit.jupiter.api.MethodOrderer
;
import
org.junit.Test
;
import
org.junit.jupiter.api.Tag
;
import
org.junit.experimental.categories.Category
;
import
org.junit.jupiter.api.Test
;
import
org.junit.runners.MethodSorters
;
import
org.junit.jupiter.api.TestMethodOrder
;
import
org.junit.jupiter.api.extension.ExtendWith
;
/**
/**
* 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
...
@@ -30,8 +30,10 @@ import org.junit.runners.MethodSorters;
...
@@ -30,8 +30,10 @@ import org.junit.runners.MethodSorters;
*
*
* 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
)
@FixMethodOrder
(
MethodSorters
.
NAME_ASCENDING
)
@Tag
(
"integration"
)
@ExtendWith
(
SetupIntegrationTestExtension
.
class
)
@TestMethodOrder
(
MethodOrderer
.
MethodName
.
class
)
public
class
TestUpload
extends
AbstractIntegrationTest
{
public
class
TestUpload
extends
AbstractIntegrationTest
{
// The following needs to be set to your test repository
// The following needs to be set to your test repository
...
@@ -45,15 +47,15 @@ public class TestUpload extends AbstractIntegrationTest {
...
@@ -45,15 +47,15 @@ public class TestUpload extends AbstractIntegrationTest {
super
();
super
();
}
}
@Before
Class
@Before
All
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 instance
gitLabApi
=
baseTestSetup
();
gitLabApi
=
baseTestSetup
();
}
}
@Before
@Before
Each
public
void
beforeMethod
()
{
public
void
beforeMethod
()
{
assume
NotNull
(
gitLabApi
);
assume
True
(
gitLabApi
!=
null
);
}
}
@Test
@Test
...
...
src/test/java/org/gitlab4j/api/TestUserApi.java
View file @
a1b28ea1
...
@@ -2,14 +2,13 @@ package org.gitlab4j.api;
...
@@ -2,14 +2,13 @@ package org.gitlab4j.api;
import
static
org
.
hamcrest
.
MatcherAssert
.
assertThat
;
import
static
org
.
hamcrest
.
MatcherAssert
.
assertThat
;
import
static
org
.
hamcrest
.
Matchers
.
contains
;
import
static
org
.
hamcrest
.
Matchers
.
contains
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertFalse
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertFalse
;
import
static
org
.
junit
.
Assert
.
assertNotEquals
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertNotEquals
;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertNotNull
;
import
static
org
.
junit
.
Assert
.
assertNull
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertNull
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertTrue
;
import
static
org
.
junit
.
Assume
.
assumeNotNull
;
import
static
org
.
junit
.
jupiter
.
api
.
Assumptions
.
assumeTrue
;
import
static
org
.
junit
.
Assume
.
assumeTrue
;
import
java.text.ParseException
;
import
java.text.ParseException
;
import
java.util.Date
;
import
java.util.Date
;
...
@@ -29,10 +28,11 @@ import org.gitlab4j.api.models.SshKey;
...
@@ -29,10 +28,11 @@ import org.gitlab4j.api.models.SshKey;
import
org.gitlab4j.api.models.User
;
import
org.gitlab4j.api.models.User
;
import
org.gitlab4j.api.models.Version
;
import
org.gitlab4j.api.models.Version
;
import
org.gitlab4j.api.utils.ISO8601
;
import
org.gitlab4j.api.utils.ISO8601
;
import
org.junit.Before
;
import
org.junit.jupiter.api.BeforeAll
;
import
org.junit.BeforeClass
;
import
org.junit.jupiter.api.BeforeEach
;
import
org.junit.Test
;
import
org.junit.jupiter.api.Tag
;
import
org.junit.experimental.categories.Category
;
import
org.junit.jupiter.api.Test
;
import
org.junit.jupiter.api.extension.ExtendWith
;
/**
/**
* 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
...
@@ -52,7 +52,8 @@ import org.junit.experimental.categories.Category;
...
@@ -52,7 +52,8 @@ import org.junit.experimental.categories.Category;
* If this is null the SSH key tests will be skipped.
* If this is null the SSH key tests will be skipped.
*
*
*/
*/
@Category
(
IntegrationTest
.
class
)
@Tag
(
"integration"
)
@ExtendWith
(
SetupIntegrationTestExtension
.
class
)
public
class
TestUserApi
extends
AbstractIntegrationTest
{
public
class
TestUserApi
extends
AbstractIntegrationTest
{
// The following needs to be set to your test repository
// The following needs to be set to your test repository
...
@@ -132,7 +133,7 @@ public class TestUserApi extends AbstractIntegrationTest {
...
@@ -132,7 +133,7 @@ public class TestUserApi extends AbstractIntegrationTest {
super
();
super
();
}
}
@Before
Class
@Before
All
public
static
void
setup
()
{
public
static
void
setup
()
{
String
problems
=
""
;
String
problems
=
""
;
...
@@ -193,9 +194,9 @@ public class TestUserApi extends AbstractIntegrationTest {
...
@@ -193,9 +194,9 @@ public class TestUserApi extends AbstractIntegrationTest {
}
}
}
}
@Before
@Before
Each
public
void
beforeMethod
()
{
public
void
beforeMethod
()
{
assume
NotNull
(
gitLabApi
);
assume
True
(
gitLabApi
!=
null
);
}
}
@Test
@Test
...
@@ -223,7 +224,7 @@ public class TestUserApi extends AbstractIntegrationTest {
...
@@ -223,7 +224,7 @@ public class TestUserApi extends AbstractIntegrationTest {
@Test
@Test
public
void
testBlockUnblockUser
()
throws
GitLabApiException
{
public
void
testBlockUnblockUser
()
throws
GitLabApiException
{
assume
NotNull
(
blockUser
);
assume
True
(
blockUser
!=
null
);
assertNotEquals
(
"blocked"
,
blockUser
.
getState
());
assertNotEquals
(
"blocked"
,
blockUser
.
getState
());
gitLabApi
.
getUserApi
().
blockUser
(
blockUser
.
getId
());
gitLabApi
.
getUserApi
().
blockUser
(
blockUser
.
getId
());
...
@@ -251,9 +252,9 @@ public class TestUserApi extends AbstractIntegrationTest {
...
@@ -251,9 +252,9 @@ public class TestUserApi extends AbstractIntegrationTest {
@Test
@Test
public
void
testExternalUid
()
throws
GitLabApiException
{
public
void
testExternalUid
()
throws
GitLabApiException
{
assume
NotNull
(
TEST_EXTERNAL_USERNAME
);
assume
True
(
TEST_EXTERNAL_USERNAME
!=
null
);
assume
NotNull
(
TEST_EXTERNAL_PROVIDER
);
assume
True
(
TEST_EXTERNAL_PROVIDER
!=
null
);
assume
NotNull
(
TEST_EXTERNAL_UID
);
assume
True
(
TEST_EXTERNAL_UID
!=
null
);
User
externalUser
=
null
;
User
externalUser
=
null
;
try
{
try
{
...
@@ -423,18 +424,18 @@ public class TestUserApi extends AbstractIntegrationTest {
...
@@ -423,18 +424,18 @@ public class TestUserApi extends AbstractIntegrationTest {
assumeTrue
(
TEST_SSH_KEY
!=
null
);
assumeTrue
(
TEST_SSH_KEY
!=
null
);
SshKey
sshKey
=
gitLabApi
.
getUserApi
().
addSshKey
(
"Test-Key"
,
TEST_SSH_KEY
);
SshKey
sshKey
=
gitLabApi
.
getUserApi
().
addSshKey
(
"Test-Key"
,
TEST_SSH_KEY
);
assertNotNull
(
sshKey
);
assertNotNull
(
sshKey
);
assertTrue
(
TEST_SSH_KEY
,
sshKey
.
getKey
().
startsWith
(
TEST_SSH_KEY
));
assertTrue
(
sshKey
.
getKey
().
startsWith
(
TEST_SSH_KEY
)
,
TEST_SSH_KEY
);
gitLabApi
.
getUserApi
().
deleteSshKey
(
sshKey
.
getId
());
gitLabApi
.
getUserApi
().
deleteSshKey
(
sshKey
.
getId
());
User
user
=
gitLabApi
.
getUserApi
().
getCurrentUser
();
User
user
=
gitLabApi
.
getUserApi
().
getCurrentUser
();
sshKey
=
gitLabApi
.
getUserApi
().
addSshKey
(
user
.
getId
(),
"Test-Key1"
,
TEST_SSH_KEY
);
sshKey
=
gitLabApi
.
getUserApi
().
addSshKey
(
user
.
getId
(),
"Test-Key1"
,
TEST_SSH_KEY
);
assertNotNull
(
sshKey
);
assertNotNull
(
sshKey
);
assertTrue
(
TEST_SSH_KEY
,
sshKey
.
getKey
().
startsWith
(
TEST_SSH_KEY
));
assertTrue
(
sshKey
.
getKey
().
startsWith
(
TEST_SSH_KEY
)
,
TEST_SSH_KEY
);
assertEquals
(
user
.
getId
(),
sshKey
.
getUserId
());
assertEquals
(
user
.
getId
(),
sshKey
.
getUserId
());
Optional
<
SshKey
>
optional
=
gitLabApi
.
getUserApi
().
getOptionalSshKey
(
sshKey
.
getId
());
Optional
<
SshKey
>
optional
=
gitLabApi
.
getUserApi
().
getOptionalSshKey
(
sshKey
.
getId
());
assertNotNull
(
optional
.
isPresent
());
assertNotNull
(
optional
.
isPresent
());
assertTrue
(
TEST_SSH_KEY
,
sshKey
.
getKey
().
startsWith
(
TEST_SSH_KEY
));
assertTrue
(
sshKey
.
getKey
().
startsWith
(
TEST_SSH_KEY
)
,
TEST_SSH_KEY
);
gitLabApi
.
getUserApi
().
deleteSshKey
(
sshKey
.
getId
());
gitLabApi
.
getUserApi
().
deleteSshKey
(
sshKey
.
getId
());
}
}
...
...
src/test/java/org/gitlab4j/api/TestWikisApi.java
View file @
a1b28ea1
...
@@ -23,10 +23,10 @@
...
@@ -23,10 +23,10 @@
package
org.gitlab4j.api
;
package
org.gitlab4j.api
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
jupiter
.
api
.
Assert
ions
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
import
static
org
.
junit
.
jupiter
.
api
.
Assert
ions
.
assertNotNull
;
import
static
org
.
junit
.
Assert
.
fail
;
import
static
org
.
junit
.
jupiter
.
api
.
Assert
ions
.
fail
;
import
static
org
.
junit
.
Assume
.
assumeNotNull
;
import
static
org
.
junit
.
jupiter
.
api
.
Assumptions
.
assumeTrue
;
import
java.io.File
;
import
java.io.File
;
import
java.util.List
;
import
java.util.List
;
...
@@ -34,11 +34,12 @@ import java.util.List;
...
@@ -34,11 +34,12 @@ import java.util.List;
import
org.gitlab4j.api.models.Project
;
import
org.gitlab4j.api.models.Project
;
import
org.gitlab4j.api.models.WikiAttachment
;
import
org.gitlab4j.api.models.WikiAttachment
;
import
org.gitlab4j.api.models.WikiPage
;
import
org.gitlab4j.api.models.WikiPage
;
import
org.junit.AfterClass
;
import
org.junit.jupiter.api.AfterAll
;
import
org.junit.Before
;
import
org.junit.jupiter.api.BeforeAll
;
import
org.junit.BeforeClass
;
import
org.junit.jupiter.api.BeforeEach
;
import
org.junit.Test
;
import
org.junit.jupiter.api.Tag
;
import
org.junit.experimental.categories.Category
;
import
org.junit.jupiter.api.Test
;
import
org.junit.jupiter.api.extension.ExtendWith
;
/**
/**
* 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
...
@@ -50,7 +51,8 @@ import org.junit.experimental.categories.Category;
...
@@ -50,7 +51,8 @@ import org.junit.experimental.categories.Category;
* <p>
* <p>
* 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
)
@Tag
(
"integration"
)
@ExtendWith
(
SetupIntegrationTestExtension
.
class
)
public
class
TestWikisApi
extends
AbstractIntegrationTest
{
public
class
TestWikisApi
extends
AbstractIntegrationTest
{
private
static
final
String
TEST_WIKI_TITLE_PREFIX
=
"Test Wiki: "
;
private
static
final
String
TEST_WIKI_TITLE_PREFIX
=
"Test Wiki: "
;
...
@@ -62,7 +64,7 @@ public class TestWikisApi extends AbstractIntegrationTest {
...
@@ -62,7 +64,7 @@ public class TestWikisApi extends AbstractIntegrationTest {
super
();
super
();
}
}
@Before
Class
@Before
All
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 instance
...
@@ -73,7 +75,7 @@ public class TestWikisApi extends AbstractIntegrationTest {
...
@@ -73,7 +75,7 @@ public class TestWikisApi extends AbstractIntegrationTest {
deleteAllTestWikiPages
();
deleteAllTestWikiPages
();
}
}
@After
Class
@After
All
public
static
void
teardown
()
throws
GitLabApiException
{
public
static
void
teardown
()
throws
GitLabApiException
{
deleteAllTestWikiPages
();
deleteAllTestWikiPages
();
}
}
...
@@ -94,9 +96,9 @@ public class TestWikisApi extends AbstractIntegrationTest {
...
@@ -94,9 +96,9 @@ public class TestWikisApi extends AbstractIntegrationTest {
}
}
}
}
@Before
@Before
Each
public
void
beforeMethod
()
{
public
void
beforeMethod
()
{
assume
NotNull
(
testProject
);
assume
True
(
testProject
!=
null
);
}
}
private
WikiPage
createWikiPage
(
String
title
,
String
content
)
throws
GitLabApiException
{
private
WikiPage
createWikiPage
(
String
title
,
String
content
)
throws
GitLabApiException
{
...
...
src/test/java/org/gitlab4j/api/models/MembershipSourceTypeTest.java
View file @
a1b28ea1
package
org.gitlab4j.api.models
;
package
org.gitlab4j.api.models
;
import
org.junit.Assert
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertEquals
;
import
org.junit.Test
;
import
static
org
.
junit
.
Assert
.*
;
import
org.junit.
jupiter.api.Test
;
public
class
MembershipSourceTypeTest
{
public
class
MembershipSourceTypeTest
{
@Test
@Test
public
void
forValue
()
{
public
void
forValue
()
{
final
MembershipSourceType
namespace
=
MembershipSourceType
.
forValue
(
"Namespace"
);
final
MembershipSourceType
namespace
=
MembershipSourceType
.
forValue
(
"Namespace"
);
Assert
.
assertEquals
(
MembershipSourceType
.
NAMESPACE
,
namespace
);
assertEquals
(
MembershipSourceType
.
NAMESPACE
,
namespace
);
Assert
.
assertEquals
(
"Namespace"
,
namespace
.
toValue
());
assertEquals
(
"Namespace"
,
namespace
.
toValue
());
Assert
.
assertEquals
(
"Namespace"
,
namespace
.
toString
());
assertEquals
(
"Namespace"
,
namespace
.
toString
());
final
MembershipSourceType
project
=
MembershipSourceType
.
forValue
(
"Project"
);
final
MembershipSourceType
project
=
MembershipSourceType
.
forValue
(
"Project"
);
Assert
.
assertEquals
(
MembershipSourceType
.
PROJECT
,
project
);
assertEquals
(
MembershipSourceType
.
PROJECT
,
project
);
Assert
.
assertEquals
(
"Project"
,
project
.
toValue
());
assertEquals
(
"Project"
,
project
.
toValue
());
Assert
.
assertEquals
(
"Project"
,
project
.
toString
());
assertEquals
(
"Project"
,
project
.
toString
());
}
}
}
}
Prev
1
2
3
4
Next
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