Include all fields in toString() for group audit log entries

As 'addedOn' is neither returned as part of Key#members nor the parent
key, it isn't included in the toString() representation of
AccountGroup{Member|ById}Aud{it}.Key. Hence, it isn't included in the
toString() representation of AccountGroup{Member|ById}Aud{it} either.

This poses a problem in the context of consistency checks between groups
in ReviewDb and the ones in NoteDb. If audit entries differ because of
the 'addedOn' field, we won't see this inconsistency in the logged
consistency violations. As that is very impractical, we now provide
an explicit toString() representation for Key which covers all fields.

Change-Id: I6a86b76698b173676337a0ceccb9794e3d240605
This commit is contained in:
Alice Kober-Sotzek
2017-11-28 11:17:29 +01:00
parent c17e94ccfc
commit ed69c9882f
3 changed files with 28 additions and 2 deletions

View File

@@ -61,6 +61,18 @@ public final class AccountGroupByIdAud {
public com.google.gwtorm.client.Key<?>[] members() {
return new com.google.gwtorm.client.Key<?>[] {includeUUID};
}
@Override
public String toString() {
return "Key{"
+ "groupId="
+ groupId
+ ", includeUUID="
+ includeUUID
+ ", addedOn="
+ addedOn
+ '}';
}
}
@Column(id = 1, name = Column.NONE)

View File

@@ -61,6 +61,18 @@ public final class AccountGroupMemberAudit {
public com.google.gwtorm.client.Key<?>[] members() {
return new com.google.gwtorm.client.Key<?>[] {groupId};
}
@Override
public String toString() {
return "Key{"
+ "groupId="
+ groupId
+ ", accountId="
+ accountId
+ ", addedOn="
+ addedOn
+ '}';
}
}
@Column(id = 1, name = Column.NONE)

View File

@@ -79,14 +79,16 @@ public class GroupBundleTest extends GerritBaseTests {
+ "ReviewDb: [AccountGroupMember{key=1000,1}]\n"
+ "NoteDb : []",
"AccountGroupMemberAudits differ\n"
+ ("ReviewDb: [AccountGroupMemberAudit{key=1000,1, addedBy=2000, removedBy=null,"
+ ("ReviewDb: [AccountGroupMemberAudit{key=Key{groupId=1, accountId=1000,"
+ " addedOn=2009-09-30 17:00:00.0}, addedBy=2000, removedBy=null,"
+ " removedOn=null}]\n")
+ "NoteDb : []",
"AccountGroupByIds differ\n"
+ "ReviewDb: [AccountGroupById{key=1,subgroup}]\n"
+ "NoteDb : []",
"AccountGroupByIdAudits differ\n"
+ ("ReviewDb: [AccountGroupByIdAud{key=1,subgroup, addedBy=3000, removedBy=null,"
+ ("ReviewDb: [AccountGroupByIdAud{key=Key{groupId=1, includeUUID=subgroup,"
+ " addedOn=2009-09-30 17:00:00.0}, addedBy=3000, removedBy=null,"
+ " removedOn=null}]\n")
+ "NoteDb : []");
}