use of com.google.gerrit.extensions.common.LegacySubmitRequirementInfo in project gerrit by GerritCodeReview.
the class SubmitRequirementIT method submitRecords.
@Test
public void submitRecords() throws Exception {
PushOneCommit.Result r = createChange();
TestSubmitRule testSubmitRule = new TestSubmitRule();
try (Registration registration = extensionRegistry.newRegistration().add(testSubmitRule)) {
String changeId = r.getChangeId();
ChangeInfo change = gApi.changes().id(changeId).get();
assertThat(change.submitRecords).hasSize(2);
// Check the default submit record for the code-review label
SubmitRecordInfo codeReviewRecord = Iterables.get(change.submitRecords, 0);
assertThat(codeReviewRecord.ruleName).isEqualTo("gerrit~DefaultSubmitRule");
assertThat(codeReviewRecord.status).isEqualTo(SubmitRecordInfo.Status.NOT_READY);
assertThat(codeReviewRecord.labels).hasSize(1);
SubmitRecordInfo.Label label = Iterables.getOnlyElement(codeReviewRecord.labels);
assertThat(label.label).isEqualTo("Code-Review");
assertThat(label.status).isEqualTo(SubmitRecordInfo.Label.Status.NEED);
assertThat(label.appliedBy).isNull();
// Check the custom test record created by the TestSubmitRule
SubmitRecordInfo testRecord = Iterables.get(change.submitRecords, 1);
assertThat(testRecord.ruleName).isEqualTo("testSubmitRule");
assertThat(testRecord.status).isEqualTo(SubmitRecordInfo.Status.OK);
assertThat(testRecord.requirements).containsExactly(new LegacySubmitRequirementInfo("OK", "fallback text", "type"));
assertThat(testRecord.labels).hasSize(1);
SubmitRecordInfo.Label testLabel = Iterables.getOnlyElement(testRecord.labels);
assertThat(testLabel.label).isEqualTo("label");
assertThat(testLabel.status).isEqualTo(SubmitRecordInfo.Label.Status.OK);
assertThat(testLabel.appliedBy).isNull();
voteLabel(changeId, "Code-Review", 2);
// Code review record is satisfied after voting +2
change = gApi.changes().id(changeId).get();
assertThat(change.submitRecords).hasSize(2);
codeReviewRecord = Iterables.get(change.submitRecords, 0);
assertThat(codeReviewRecord.ruleName).isEqualTo("gerrit~DefaultSubmitRule");
assertThat(codeReviewRecord.status).isEqualTo(SubmitRecordInfo.Status.OK);
assertThat(codeReviewRecord.labels).hasSize(1);
label = Iterables.getOnlyElement(codeReviewRecord.labels);
assertThat(label.label).isEqualTo("Code-Review");
assertThat(label.status).isEqualTo(SubmitRecordInfo.Label.Status.OK);
assertThat(label.appliedBy._accountId).isEqualTo(admin.id().get());
}
}
Aggregations