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
0189b872
Commit
0189b872
authored
Jun 15, 2019
by
Greg Messner
Browse files
Added testing of sub groups.
parent
85631bbb
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/test/java/org/gitlab4j/api/AbstractIntegrationTest.java
View file @
0189b872
...
...
@@ -28,6 +28,7 @@ public class AbstractIntegrationTest implements PropertyConstants {
protected
static
final
String
TEST_GROUP_PROJECT_NAME
=
HelperUtils
.
getProperty
(
GROUP_PROJECT_KEY
);
protected
static
final
String
TEST_NAMESPACE
=
HelperUtils
.
getProperty
(
NAMESPACE_KEY
,
TEST_LOGIN_USERNAME
);
protected
static
final
String
TEST_PRIVATE_TOKEN
=
HelperUtils
.
getProperty
(
PRIVATE_TOKEN_KEY
);
protected
static
final
String
TEST_SUB_GROUP
=
HelperUtils
.
getProperty
(
SUB_GROUP_KEY
);
protected
static
class
BaseTestResources
{
protected
GitLabApi
gitLabApi
;
...
...
src/test/java/org/gitlab4j/api/IntegrationTestSuite.java
View file @
0189b872
...
...
@@ -5,6 +5,7 @@ import static org.junit.Assert.assertNotNull;
import
static
org
.
junit
.
Assert
.
fail
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.Optional
;
import
org.gitlab4j.api.models.Group
;
...
...
@@ -42,6 +43,7 @@ public class IntegrationTestSuite implements PropertyConstants {
private
static
final
String
TEST_PROJECT_NAME
=
HelperUtils
.
getProperty
(
PROJECT_NAME_KEY
);
private
static
final
String
TEST_GROUP
=
HelperUtils
.
getProperty
(
GROUP_KEY
);
private
static
final
String
TEST_GROUP_PROJECT_NAME
=
HelperUtils
.
getProperty
(
GROUP_PROJECT_KEY
);
private
static
final
String
TEST_SUB_GROUP
=
HelperUtils
.
getProperty
(
SUB_GROUP_KEY
);
protected
static
final
String
TEST_PRIVATE_TOKEN_NAME
=
"GitLab4J Test Private Token - "
+
HelperUtils
.
getRandomInt
(
1000
);
protected
static
String
TEST_PRIVATE_TOKEN
=
HelperUtils
.
getProperty
(
PRIVATE_TOKEN_KEY
);
...
...
@@ -283,5 +285,19 @@ public class IntegrationTestSuite implements PropertyConstants {
gitLabApi
.
getRepositoryFileApi
().
updateFile
(
testProject
,
repoFile
,
"master"
,
"Updated contents"
);
System
.
out
.
format
(
"Updated %s repository file in %s%n"
,
repoFile
.
getFilePath
(),
TEST_GROUP_PROJECT_NAME
);
}
// Create a subgroup
List
<
Group
>
subGroups
=
gitLabApi
.
getGroupApi
().
getSubGroups
(
TEST_GROUP
,
null
,
null
,
TEST_SUB_GROUP
,
null
,
null
,
null
,
null
);
if
(
subGroups
.
isEmpty
())
{
Group
groupSettings
=
new
Group
()
.
withName
(
TEST_SUB_GROUP
)
.
withPath
(
TEST_SUB_GROUP
)
.
withDescription
(
"Test Sub-Group"
)
.
withVisibility
(
Visibility
.
PUBLIC
)
.
withRequestAccessEnabled
(
true
)
.
withParentId
(
testGroup
.
getId
());
Group
testSubGroup
=
gitLabApi
.
getGroupApi
().
addGroup
(
groupSettings
);
System
.
out
.
format
(
"Created %s sub-group (%s)%n"
,
testSubGroup
.
getName
(),
testSubGroup
.
getPath
());
}
}
}
src/test/java/org/gitlab4j/api/PropertyConstants.java
View file @
0189b872
...
...
@@ -23,8 +23,9 @@ public interface PropertyConstants {
public
static
final
String
PROXY_PASSWORD_KEY
=
"TEST_PROXY_PASSWORD"
;
public
static
final
String
PROXY_URI_KEY
=
"TEST_PROXY_URI"
;
public
static
final
String
PROXY_USERNAME_KEY
=
"TEST_PROXY_USERNAME"
;
public
static
final
String
TEST_REQUEST_ACCESS_USERNAME_KEY
=
"TEST_REQUEST_ACCESS_USERNAME
"
;
public
static
final
String
SUB_GROUP_KEY
=
"TEST_SUB_GROUP
"
;
public
static
final
String
SUDO_AS_USERNAME_KEY
=
"TEST_SUDO_AS_USERNAME"
;
public
static
final
String
TEST_REQUEST_ACCESS_USERNAME_KEY
=
"TEST_REQUEST_ACCESS_USERNAME"
;
public
static
final
String
USERNAME_KEY
=
"TEST_USERNAME"
;
public
static
final
String
XFER_NAMESPACE_KEY
=
"TEST_XFER_NAMESPACE"
;
}
src/test/java/org/gitlab4j/api/TestNamespaceApi.java
View file @
0189b872
...
...
@@ -90,6 +90,13 @@ public class TestNamespaceApi extends AbstractIntegrationTest {
assertEquals
(
TEST_NAMESPACE
,
namespaces
.
get
(
0
).
getName
());
}
@Test
public
void
testFindSubgroupNamespaces
()
throws
GitLabApiException
{
List
<
Namespace
>
namespaces
=
gitLabApi
.
getNamespaceApi
().
findNamespaces
(
TEST_SUB_GROUP
);
assertNotNull
(
namespaces
);
assertEquals
(
TEST_SUB_GROUP
,
namespaces
.
get
(
0
).
getName
());
}
@Test
public
void
testFindNamespacesByPage
()
throws
GitLabApiException
{
List
<
Namespace
>
namespaces
=
gitLabApi
.
getNamespaceApi
().
findNamespaces
(
TEST_NAMESPACE
,
1
,
10
);
...
...
src/test/resources/test-gitlab4j.properties
View file @
0189b872
...
...
@@ -36,11 +36,12 @@ TEST_BLOCK_USERNAME=user1
TEST_XFER_NAMESPACE
=
user1
TEST_REQUEST_ACCESS_USERNAME
=
user1
# This specifies the group, a project owned by the specified group,
and
a username to
# This specifies the group, a project owned by the specified group, a username
, and a sub-group
to
# test group membership functionality
TEST_GROUP
=
test-group
TEST_GROUP_PROJECT
=
test-group-project
TEST_GROUP_MEMBER_USERNAME
=
user1
TEST_SUB_GROUP
=
subgroup
# OPTIONAL: To test using GitLab4J-API with a proxy, set the following properties
TEST_PROXY_URI
=
...
...
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