Add 'created on' field of groups to Java and REST API
Change-Id: I236ceae7bbe49c173ac9f9fbb3a3f0a69fdd235c
This commit is contained in:
@@ -42,7 +42,8 @@ by group name.
|
||||
"description": "Gerrit Site Administrators",
|
||||
"group_id": 1,
|
||||
"owner": "Administrators",
|
||||
"owner_id": "6a1e70e1a88782771a91808c8af9bbb7a9871389"
|
||||
"owner_id": "6a1e70e1a88782771a91808c8af9bbb7a9871389",
|
||||
"created_on": "2013-02-01 09:59:32.126000000"
|
||||
},
|
||||
"Anonymous Users": {
|
||||
"id": "global%3AAnonymous-Users",
|
||||
@@ -52,7 +53,8 @@ by group name.
|
||||
"description": "Any user, signed-in or not",
|
||||
"group_id": 2,
|
||||
"owner": "Administrators",
|
||||
"owner_id": "6a1e70e1a88782771a91808c8af9bbb7a9871389"
|
||||
"owner_id": "6a1e70e1a88782771a91808c8af9bbb7a9871389",
|
||||
"created_on": "2013-02-01 09:59:32.126000000"
|
||||
},
|
||||
"MyProject_Committers": {
|
||||
"id": "834ec36dd5e0ed21a2ff5d7e2255da082d63bbd7",
|
||||
@@ -62,7 +64,8 @@ by group name.
|
||||
},
|
||||
"group_id": 6,
|
||||
"owner": "MyProject_Committers",
|
||||
"owner_id": "834ec36dd5e0ed21a2ff5d7e2255da082d63bbd7"
|
||||
"owner_id": "834ec36dd5e0ed21a2ff5d7e2255da082d63bbd7",
|
||||
"created_on": "2013-02-01 09:59:32.126000000"
|
||||
},
|
||||
"Non-Interactive Users": {
|
||||
"id": "5057f3cbd3519d6ab69364429a89ffdffba50f73",
|
||||
@@ -72,7 +75,8 @@ by group name.
|
||||
"description": "Users who perform batch actions on Gerrit",
|
||||
"group_id": 4,
|
||||
"owner": "Administrators",
|
||||
"owner_id": "6a1e70e1a88782771a91808c8af9bbb7a9871389"
|
||||
"owner_id": "6a1e70e1a88782771a91808c8af9bbb7a9871389",
|
||||
"created_on": "2013-02-01 09:59:32.126000000"
|
||||
},
|
||||
"Project Owners": {
|
||||
"id": "global%3AProject-Owners",
|
||||
@@ -82,7 +86,8 @@ by group name.
|
||||
"description": "Any owner of the project",
|
||||
"group_id": 5,
|
||||
"owner": "Administrators",
|
||||
"owner_id": "6a1e70e1a88782771a91808c8af9bbb7a9871389"
|
||||
"owner_id": "6a1e70e1a88782771a91808c8af9bbb7a9871389",
|
||||
"created_on": "2013-02-01 09:59:32.126000000"
|
||||
},
|
||||
"Registered Users": {
|
||||
"id": "global%3ARegistered-Users",
|
||||
@@ -92,7 +97,8 @@ by group name.
|
||||
"description": "Any signed-in user",
|
||||
"group_id": 3,
|
||||
"owner": "Administrators",
|
||||
"owner_id": "6a1e70e1a88782771a91808c8af9bbb7a9871389"
|
||||
"owner_id": "6a1e70e1a88782771a91808c8af9bbb7a9871389",
|
||||
"created_on": "2013-02-01 09:59:32.126000000"
|
||||
}
|
||||
}
|
||||
----
|
||||
@@ -154,7 +160,8 @@ returned.
|
||||
"description":"contains all committers for MyProject",
|
||||
"group_id": 551,
|
||||
"owner": "MyProject-Owners",
|
||||
"owner_id": "7ca042f4d5847936fcb90ca91057673157fd06fc"
|
||||
"owner_id": "7ca042f4d5847936fcb90ca91057673157fd06fc",
|
||||
"created_on": "2013-02-01 09:59:32.126000000"
|
||||
}
|
||||
}
|
||||
----
|
||||
@@ -211,6 +218,7 @@ error out.)
|
||||
"group_id": 1,
|
||||
"owner": "Administrators",
|
||||
"owner_id": "59b92f35489e62c80d1ab1bf0c2d17843038df8b",
|
||||
"created_on": "2013-02-01 09:59:32.126000000",
|
||||
"id": "59b92f35489e62c80d1ab1bf0c2d17843038df8b"
|
||||
}
|
||||
}
|
||||
@@ -254,6 +262,7 @@ link:#list-groups[List Groups] endpoint.
|
||||
"group_id": 20,
|
||||
"owner": "MyProject-Test-Group",
|
||||
"owner_id": "59b92f35489e62c80d1ab1bf0c2d17843038df8b",
|
||||
"created_on": "2013-02-01 09:59:32.126000000",
|
||||
"id": "68236a40ca78de8be630312d8ba50250bc5638ae"
|
||||
},
|
||||
{
|
||||
@@ -263,6 +272,7 @@ link:#list-groups[List Groups] endpoint.
|
||||
"group_id": 17,
|
||||
"owner": "ProjectX-Testers",
|
||||
"owner_id": "59b92f35489e62c80d1ab1bf0c2d17843038df8b",
|
||||
"created_on": "2013-02-01 09:59:32.126000000",
|
||||
"id": "99a534526313324a2667025c3f4e089199b736aa"
|
||||
}
|
||||
]
|
||||
@@ -330,7 +340,8 @@ describes the group.
|
||||
"description": "Gerrit Site Administrators",
|
||||
"group_id": 1,
|
||||
"owner": "Administrators",
|
||||
"owner_id": "6a1e70e1a88782771a91808c8af9bbb7a9871389"
|
||||
"owner_id": "6a1e70e1a88782771a91808c8af9bbb7a9871389",
|
||||
"created_on": "2013-02-01 09:59:32.126000000"
|
||||
}
|
||||
----
|
||||
|
||||
@@ -378,7 +389,8 @@ describes the created group.
|
||||
"description":"contains all committers for MyProject",
|
||||
"group_id": 551,
|
||||
"owner": "MyProject-Owners",
|
||||
"owner_id": "7ca042f4d5847936fcb90ca91057673157fd06fc"
|
||||
"owner_id": "7ca042f4d5847936fcb90ca91057673157fd06fc",
|
||||
"created_on": "2013-02-01 09:59:32.126000000"
|
||||
}
|
||||
----
|
||||
|
||||
@@ -419,6 +431,7 @@ describes the group.
|
||||
"group_id": 1,
|
||||
"owner": "Administrators",
|
||||
"owner_id": "6a1e70e1a88782771a91808c8af9bbb7a9871389",
|
||||
"created_on": "2013-02-01 09:59:32.126000000",
|
||||
"members": [
|
||||
{
|
||||
"_account_id": 1000097,
|
||||
@@ -668,7 +681,8 @@ describes the owner group.
|
||||
"description": "Gerrit Site Administrators",
|
||||
"group_id": 1,
|
||||
"owner": "Administrators",
|
||||
"owner_id": "6a1e70e1a88782771a91808c8af9bbb7a9871389"
|
||||
"owner_id": "6a1e70e1a88782771a91808c8af9bbb7a9871389",
|
||||
"created_on": "2013-02-01 09:59:32.126000000"
|
||||
}
|
||||
----
|
||||
|
||||
@@ -714,7 +728,8 @@ describes the new owner group.
|
||||
"description": "Gerrit Site Administrators",
|
||||
"group_id": 1,
|
||||
"owner": "Administrators",
|
||||
"owner_id": "6a1e70e1a88782771a91808c8af9bbb7a9871389"
|
||||
"owner_id": "6a1e70e1a88782771a91808c8af9bbb7a9871389",
|
||||
"created_on": "2013-02-01 09:59:32.126000000"
|
||||
}
|
||||
----
|
||||
|
||||
@@ -751,6 +766,7 @@ newest audit event comes first.
|
||||
"group_id": 3,
|
||||
"owner": "Administrators",
|
||||
"owner_id": "e56678641565e7f59dd5c6878f5bcbc842bf150a",
|
||||
"created_on": "2013-02-01 09:59:32.126000000",
|
||||
"id": "fdda826a0815859ab48d22a05a43472f0f55f89a",
|
||||
"name": "MyGroup"
|
||||
},
|
||||
@@ -770,6 +786,7 @@ newest audit event comes first.
|
||||
"group_id": 3,
|
||||
"owner": "Administrators",
|
||||
"owner_id": "e56678641565e7f59dd5c6878f5bcbc842bf150a",
|
||||
"created_on": "2013-02-01 09:59:32.126000000",
|
||||
"id": "fdda826a0815859ab48d22a05a43472f0f55f89a",
|
||||
"name": "MyGroup"
|
||||
},
|
||||
@@ -1114,7 +1131,8 @@ The entries in the list are sorted by group name and UUID.
|
||||
},
|
||||
"group_id": 38,
|
||||
"owner": "MyProject-Verifiers",
|
||||
"owner_id": "7ca042f4d5847936fcb90ca91057673157fd06fc"
|
||||
"owner_id": "7ca042f4d5847936fcb90ca91057673157fd06fc",
|
||||
"created_on": "2013-02-01 09:59:32.126000000"
|
||||
}
|
||||
]
|
||||
----
|
||||
@@ -1150,7 +1168,8 @@ describes the included group.
|
||||
},
|
||||
"group_id": 38,
|
||||
"owner": "Administrators",
|
||||
"owner_id": "6a1e70e1a88782771a91808c8af9bbb7a9871389"
|
||||
"owner_id": "6a1e70e1a88782771a91808c8af9bbb7a9871389",
|
||||
"created_on": "2013-02-01 09:59:32.126000000"
|
||||
}
|
||||
----
|
||||
|
||||
@@ -1186,7 +1205,8 @@ describes the included group.
|
||||
},
|
||||
"group_id": 8,
|
||||
"owner": "Administrators",
|
||||
"owner_id": "6a1e70e1a88782771a91808c8af9bbb7a9871389"
|
||||
"owner_id": "6a1e70e1a88782771a91808c8af9bbb7a9871389",
|
||||
"created_on": "2013-02-01 09:59:32.126000000"
|
||||
}
|
||||
----
|
||||
|
||||
@@ -1246,7 +1266,8 @@ group was already included in the group.
|
||||
},
|
||||
"group_id": 8,
|
||||
"owner": "Administrators",
|
||||
"owner_id": "6a1e70e1a88782771a91808c8af9bbb7a9871389"
|
||||
"owner_id": "6a1e70e1a88782771a91808c8af9bbb7a9871389",
|
||||
"created_on": "2013-02-01 09:59:32.126000000"
|
||||
},
|
||||
{
|
||||
"id": "5057f3cbd3519d6ab69364429a89ffdffba50f73",
|
||||
@@ -1256,7 +1277,8 @@ group was already included in the group.
|
||||
},
|
||||
"group_id": 10,
|
||||
"owner": "MyOtherGroup",
|
||||
"owner_id": "5057f3cbd3519d6ab69364429a89ffdffba50f73"
|
||||
"owner_id": "5057f3cbd3519d6ab69364429a89ffdffba50f73",
|
||||
"created_on": "2013-02-01 09:59:32.126000000"
|
||||
}
|
||||
]
|
||||
----
|
||||
@@ -1382,6 +1404,8 @@ permits users to apply to join the group, or manage their membership.
|
||||
|`group_id` |only for internal groups|The numeric ID of the group.
|
||||
|`owner` |only for internal groups|The name of the owner group.
|
||||
|`owner_id` |only for internal groups|The URL encoded UUID of the owner group.
|
||||
|`created_on` |only for internal groups|The
|
||||
link:rest-api.html#timestamp[timestamp] of when the group was created.
|
||||
|`_more_groups`|optional, only for internal groups, not set if `false`|
|
||||
Whether the query would deliver more results if not limited. +
|
||||
Only set on the last group that is returned by a
|
||||
|
||||
@@ -42,6 +42,7 @@ public class GroupAssert {
|
||||
assertThat(toBoolean(info.options.visibleToAll)).isEqualTo(group.isVisibleToAll());
|
||||
assertThat(info.description).isEqualTo(group.getDescription());
|
||||
assertThat(Url.decode(info.ownerId)).isEqualTo(group.getOwnerGroupUUID().get());
|
||||
assertThat(info.createdOn).isEqualTo(group.getCreatedOn());
|
||||
}
|
||||
|
||||
public static boolean toBoolean(Boolean b) {
|
||||
|
||||
@@ -20,11 +20,13 @@ import static com.google.gerrit.acceptance.rest.account.AccountAssert.assertAcco
|
||||
import static com.google.gerrit.server.group.SystemGroupBackend.ANONYMOUS_USERS;
|
||||
import static java.util.stream.Collectors.toList;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||
import com.google.gerrit.acceptance.GerritConfig;
|
||||
import com.google.gerrit.acceptance.NoHttpd;
|
||||
import com.google.gerrit.acceptance.TestAccount;
|
||||
import com.google.gerrit.common.TimeUtil;
|
||||
import com.google.gerrit.common.data.GroupReference;
|
||||
import com.google.gerrit.extensions.api.groups.GroupApi;
|
||||
import com.google.gerrit.extensions.api.groups.GroupInput;
|
||||
@@ -220,6 +222,25 @@ public class GroupsIT extends AbstractDaemonTest {
|
||||
gApi.groups().create(name("newGroup"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createdOnFieldIsPopulatedForNewGroup() throws Exception {
|
||||
Timestamp testStartTime = TimeUtil.nowTs();
|
||||
String newGroupName = name("newGroup");
|
||||
GroupInfo group = gApi.groups().create(newGroupName).get();
|
||||
|
||||
assertThat(group.createdOn).isAtLeast(testStartTime);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createdOnFieldDefaultsToAuditCreationInstantBeforeSchemaUpgrade() throws Exception {
|
||||
String newGroupName = name("newGroup");
|
||||
GroupInfo newGroup = gApi.groups().create(newGroupName).get();
|
||||
setCreatedOnToNull(new AccountGroup.Id(newGroup.groupId));
|
||||
|
||||
GroupInfo updatedGroup = gApi.groups().id(newGroup.id).get();
|
||||
assertThat(updatedGroup.createdOn).isEqualTo(AccountGroup.auditCreationInstantTs());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getGroup() throws Exception {
|
||||
AccountGroup adminGroup = groupCache.get(new AccountGroup.NameKey("Administrators"));
|
||||
@@ -614,4 +635,11 @@ public class GroupsIT extends AbstractDaemonTest {
|
||||
accountCreator.create(name, group);
|
||||
return name;
|
||||
}
|
||||
|
||||
private void setCreatedOnToNull(AccountGroup.Id groupId) throws Exception {
|
||||
AccountGroup group = db.accountGroups().get(groupId);
|
||||
group.setCreatedOn(null);
|
||||
db.accountGroups().update(ImmutableList.of(group));
|
||||
groupCache.evict(group);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
package com.google.gerrit.extensions.common;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.List;
|
||||
|
||||
public class GroupInfo extends GroupBaseInfo {
|
||||
@@ -25,6 +26,7 @@ public class GroupInfo extends GroupBaseInfo {
|
||||
public Integer groupId;
|
||||
public String owner;
|
||||
public String ownerId;
|
||||
public Timestamp createdOn;
|
||||
public Boolean _moreGroups;
|
||||
|
||||
// These fields are only supplied for internal groups, and only if requested.
|
||||
|
||||
@@ -107,6 +107,7 @@ public class GroupJson {
|
||||
info.owner = o.getName();
|
||||
}
|
||||
}
|
||||
info.createdOn = g.getCreatedOn();
|
||||
}
|
||||
|
||||
return info;
|
||||
|
||||
Reference in New Issue
Block a user