Search in sources :

Example 26 with PatchSetApproval

use of com.google.gerrit.entities.PatchSetApproval in project gerrit by GerritCodeReview.

the class LabelNormalizerTest method noNormalizeByPermission.

@Test
public void noNormalizeByPermission() throws Exception {
    projectOperations.allProjectsForUpdate().add(allowLabel(LabelId.CODE_REVIEW).ref("refs/heads/*").group(REGISTERED_USERS).range(-1, 1)).add(allowLabel(LabelId.VERIFIED).ref("refs/heads/*").group(REGISTERED_USERS).range(-1, 1)).update();
    PatchSetApproval cr = psa(userId, LabelId.CODE_REVIEW, 2);
    PatchSetApproval v = psa(userId, LabelId.VERIFIED, 1);
    assertEquals(Result.create(list(cr, v), list(), list()), norm.normalize(notes, list(cr, v)));
}
Also used : PatchSetApproval(com.google.gerrit.entities.PatchSetApproval) Test(org.junit.Test)

Example 27 with PatchSetApproval

use of com.google.gerrit.entities.PatchSetApproval in project gerrit by GerritCodeReview.

the class LabelNormalizerTest method emptyPermissionRangeKeepsResult.

@Test
public void emptyPermissionRangeKeepsResult() throws Exception {
    PatchSetApproval cr = psa(userId, LabelId.CODE_REVIEW, 1);
    PatchSetApproval v = psa(userId, LabelId.VERIFIED, 1);
    assertEquals(Result.create(list(cr, v), list(), list()), norm.normalize(notes, list(cr, v)));
}
Also used : PatchSetApproval(com.google.gerrit.entities.PatchSetApproval) Test(org.junit.Test)

Example 28 with PatchSetApproval

use of com.google.gerrit.entities.PatchSetApproval in project gerrit by GerritCodeReview.

the class LabelNormalizerTest method normalizeByType.

@Test
public void normalizeByType() throws Exception {
    projectOperations.allProjectsForUpdate().add(allowLabel(LabelId.CODE_REVIEW).ref("refs/heads/*").group(REGISTERED_USERS).range(-5, 5)).add(allowLabel(LabelId.VERIFIED).ref("refs/heads/*").group(REGISTERED_USERS).range(-5, 5)).update();
    PatchSetApproval cr = psa(userId, LabelId.CODE_REVIEW, 5);
    PatchSetApproval v = psa(userId, LabelId.VERIFIED, 5);
    assertEquals(Result.create(list(), list(copy(cr, 2), copy(v, 1)), list()), norm.normalize(notes, list(cr, v)));
}
Also used : PatchSetApproval(com.google.gerrit.entities.PatchSetApproval) Test(org.junit.Test)

Example 29 with PatchSetApproval

use of com.google.gerrit.entities.PatchSetApproval in project gerrit by GerritCodeReview.

the class LabelNormalizerTest method explicitZeroVoteOnNonEmptyRangeIsPresent.

@Test
public void explicitZeroVoteOnNonEmptyRangeIsPresent() throws Exception {
    projectOperations.allProjectsForUpdate().add(allowLabel(LabelId.CODE_REVIEW).ref("refs/heads/*").group(REGISTERED_USERS).range(-1, 1)).update();
    PatchSetApproval cr = psa(userId, LabelId.CODE_REVIEW, 0);
    PatchSetApproval v = psa(userId, LabelId.VERIFIED, 0);
    assertEquals(Result.create(list(cr, v), list(), list()), norm.normalize(notes, list(cr, v)));
}
Also used : PatchSetApproval(com.google.gerrit.entities.PatchSetApproval) Test(org.junit.Test)

Example 30 with PatchSetApproval

use of com.google.gerrit.entities.PatchSetApproval in project gerrit by GerritCodeReview.

the class PatchSetApprovalProtoConverterTest method mandatoryValuesConvertedToProtoAndBackAgain.

@Test
public void mandatoryValuesConvertedToProtoAndBackAgain() {
    PatchSetApproval patchSetApproval = PatchSetApproval.builder().key(PatchSetApproval.key(PatchSet.id(Change.id(42), 14), Account.id(100013), LabelId.create("label-8"))).value(456).granted(Instant.ofEpochMilli(987654L)).build();
    PatchSetApproval convertedPatchSetApproval = protoConverter.fromProto(protoConverter.toProto(patchSetApproval));
    assertThat(convertedPatchSetApproval).isEqualTo(patchSetApproval);
}
Also used : PatchSetApproval(com.google.gerrit.entities.PatchSetApproval) Test(org.junit.Test)

Aggregations

PatchSetApproval (com.google.gerrit.entities.PatchSetApproval)93 Test (org.junit.Test)57 Change (com.google.gerrit.entities.Change)41 LabelType (com.google.gerrit.entities.LabelType)22 Account (com.google.gerrit.entities.Account)20 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)14 Map (java.util.Map)14 ObjectId (org.eclipse.jgit.lib.ObjectId)14 LabelId (com.google.gerrit.entities.LabelId)13 PatchSet (com.google.gerrit.entities.PatchSet)12 SubmitRecord (com.google.gerrit.entities.SubmitRecord)12 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)11 ReviewInput (com.google.gerrit.extensions.api.changes.ReviewInput)10 SubmissionId (com.google.gerrit.entities.SubmissionId)9 ChangeData (com.google.gerrit.server.query.change.ChangeData)9 Inject (com.google.inject.Inject)9 Instant (java.time.Instant)9 HashMap (java.util.HashMap)9 List (java.util.List)9 ChangeMessage (com.google.gerrit.entities.ChangeMessage)8