Test that creation/last-updated timestamps for checks/checkers are reasonable

To verify timestamps we use a test clock with a clock step of 1 second.
Before creation/updating a check/checker we save the current timestamp
which will be handed out next. This is the timestamp that is expected to
be used for the creation/update.

This approach was already used to verify the creation timestamp for
checks in CreateCheckIT#createCheck(). This change adds similar tests
for getting/updating checks, and for checkers.

It turned out that the creation/update operation for checkers consumed
more than one timestamp:
- 1 timestamp for creating the CheckersUpdate instance (injection of
  GerritPersonIdent into NoteDbCheckersUpdate)
- 1 timestamp which was explictly retrieved when CheckerUpdate didn't
  specify an update timestamp to use (this was done in 2 places, in
  NoteDbCheckersUpdate#updateChecker(CheckerUuid, CheckerUpdate) and
  in CheckerConfig#onSave(CommitBuilder), since doing this once in
  CheckerConfig#onSave(CommitBuilder) covers both, checker creation and
  update, the code for this in
  NoteDbCheckersUpdate#updateChecker(CheckerUuid, CheckerUpdate) was
  removed)

Instead of explicitly retrieving a timestamp when CheckerUpdate didn't
specify an update timestamp we now use the timestamp from the
CommitBuilder which was populated from the timestamp of the injected
GerritPersonIdent (propagated via MetaDataUpdate).

In addition checks/checkers created by the test API didn't respect the
time settings that were done through TestTimeUtil at test
initialization. This was because CheckOperationsImpl and
CheckerOperationsImpl got CheckUpdate/CheckerUpdate directly injected
instead of injecting Provider<CheckUpdate>/Provider<CheckerUpdate>. This
way the timestamp got fixed when CheckOperationsImpl and
CheckerOperationsImpl got created.

Signed-off-by: Edwin Kempin <ekempin@google.com>
Change-Id: I6c6c58cd35bf96adbde1f3f599215aff02467fef
9 files changed
tree: dc563149e501477417e26297e213892ecf89764c
  1. java/
  2. javatests/
  3. src/
  4. BUILD
  5. LICENSE
  6. README.md
README.md

Gerrit Code Review Checks Plugin

This plugin provides a unified experience for checkers (CI systems, static analyzers, etc.) to integrate with Gerrit Code Review.