use of com.google.gerrit.server.git.meta.MetaDataUpdate in project gerrit by GerritCodeReview.
the class GroupConfigTest method nameCannotBeUpdatedToEmptyString.
@Test
public void nameCannotBeUpdatedToEmptyString() throws Exception {
createArbitraryGroup(groupUuid);
GroupConfig groupConfig = GroupConfig.loadForGroup(projectName, repository, groupUuid);
GroupDelta groupDelta = GroupDelta.builder().setName(AccountGroup.nameKey("")).build();
groupConfig.setGroupDelta(groupDelta, auditLogFormatter);
try (MetaDataUpdate metaDataUpdate = createMetaDataUpdate()) {
Throwable thrown = assertThrows(Throwable.class, () -> groupConfig.commit(metaDataUpdate));
assertThat(thrown.getCause(), instanceOf(ConfigInvalidException.class));
assertThat(thrown).hasMessageThat().contains("Name of the group " + groupUuid);
}
}
use of com.google.gerrit.server.git.meta.MetaDataUpdate in project gerrit by GerritCodeReview.
the class GroupConfigTest method timestampOfCommitterMatchesSpecifiedUpdatedOnOfUpdatedGroup.
@Test
// Instants
@SuppressWarnings("JdkObsolete")
public void timestampOfCommitterMatchesSpecifiedUpdatedOnOfUpdatedGroup() throws Exception {
Instant committerTimestamp = toInstant(LocalDate.of(2017, Month.DECEMBER, 13).atTime(15, 5, 27));
Instant updatedOn = toInstant(LocalDate.of(2016, Month.MARCH, 11).atTime(23, 49, 11));
createArbitraryGroup(groupUuid);
GroupDelta groupDelta = GroupDelta.builder().setName(AccountGroup.nameKey("Another name")).setUpdatedOn(updatedOn).build();
GroupConfig groupConfig = GroupConfig.loadForGroup(projectName, repository, groupUuid);
groupConfig.setGroupDelta(groupDelta, auditLogFormatter);
PersonIdent committerIdent = new PersonIdent("Jane", "Jane@gerritcodereview.com", Date.from(committerTimestamp), timeZone);
try (MetaDataUpdate metaDataUpdate = createMetaDataUpdate()) {
metaDataUpdate.getCommitBuilder().setCommitter(committerIdent);
groupConfig.commit(metaDataUpdate);
}
RevCommit revCommit = getLatestCommitForGroup(groupUuid);
assertThat(revCommit.getCommitterIdent().getWhen().getTime()).isEqualTo(updatedOn.toEpochMilli());
assertThat(revCommit.getCommitterIdent().getTimeZone().getRawOffset()).isEqualTo(timeZone.getRawOffset());
}
use of com.google.gerrit.server.git.meta.MetaDataUpdate in project gerrit by GerritCodeReview.
the class GroupConfigTest method ownerGroupUuidCannotBeUpdatedToEmptyString.
@Test
public void ownerGroupUuidCannotBeUpdatedToEmptyString() throws Exception {
createArbitraryGroup(groupUuid);
GroupConfig groupConfig = GroupConfig.loadForGroup(projectName, repository, groupUuid);
GroupDelta groupDelta = GroupDelta.builder().setOwnerGroupUUID(AccountGroup.uuid("")).build();
groupConfig.setGroupDelta(groupDelta, auditLogFormatter);
try (MetaDataUpdate metaDataUpdate = createMetaDataUpdate()) {
Throwable thrown = assertThrows(Throwable.class, () -> groupConfig.commit(metaDataUpdate));
assertThat(thrown.getCause(), instanceOf(ConfigInvalidException.class));
assertThat(thrown).hasMessageThat().contains("Owner UUID of the group " + groupUuid);
}
}
use of com.google.gerrit.server.git.meta.MetaDataUpdate in project gerrit by GerritCodeReview.
the class GroupConfigTest method timestampOfCommitterMatchesSpecifiedCreatedOnOfNewGroup.
// TODO(issue-15517): Fix the JdkObsolete issue with Date once JGit's PersonIdent class supports
// Instants
@SuppressWarnings("JdkObsolete")
@Test
public void timestampOfCommitterMatchesSpecifiedCreatedOnOfNewGroup() throws Exception {
Instant committerTimestamp = toInstant(LocalDate.of(2017, Month.DECEMBER, 13).atTime(15, 5, 27));
Instant createdOn = toInstant(LocalDate.of(2016, Month.MARCH, 11).atTime(23, 49, 11));
InternalGroupCreation groupCreation = InternalGroupCreation.builder().setGroupUUID(groupUuid).setNameKey(groupName).setId(groupId).build();
GroupDelta groupDelta = GroupDelta.builder().setName(AccountGroup.nameKey("Another name")).setUpdatedOn(createdOn).build();
GroupConfig groupConfig = GroupConfig.createForNewGroup(projectName, repository, groupCreation);
groupConfig.setGroupDelta(groupDelta, auditLogFormatter);
PersonIdent committerIdent = new PersonIdent("Jane", "Jane@gerritcodereview.com", Date.from(committerTimestamp), timeZone);
try (MetaDataUpdate metaDataUpdate = createMetaDataUpdate()) {
metaDataUpdate.getCommitBuilder().setCommitter(committerIdent);
groupConfig.commit(metaDataUpdate);
}
RevCommit revCommit = getLatestCommitForGroup(groupUuid);
assertThat(revCommit.getCommitterIdent().getWhen().getTime()).isEqualTo(createdOn.toEpochMilli());
assertThat(revCommit.getCommitterIdent().getTimeZone().getRawOffset()).isEqualTo(timeZone.getRawOffset());
}
use of com.google.gerrit.server.git.meta.MetaDataUpdate in project gerrit by GerritCodeReview.
the class GroupNameNotesTest method createMetaDataUpdate.
private MetaDataUpdate createMetaDataUpdate() {
PersonIdent serverIdent = newPersonIdent();
MetaDataUpdate metaDataUpdate = new MetaDataUpdate(GitReferenceUpdated.DISABLED, Project.nameKey("Test Repository"), repo);
metaDataUpdate.getCommitBuilder().setCommitter(serverIdent);
metaDataUpdate.getCommitBuilder().setAuthor(serverIdent);
return metaDataUpdate;
}
Aggregations