Search in sources :

Example 61 with LabelDefinitionInfo

use of com.google.gerrit.extensions.common.LabelDefinitionInfo in project gerrit by GerritCodeReview.

the class CreateLabelIT method createWithFunction.

@Test
public void createWithFunction() throws Exception {
    LabelDefinitionInput input = new LabelDefinitionInput();
    input.values = ImmutableMap.of("+1", "Looks Good", " 0", "Don't Know", "-1", "Looks Bad");
    input.function = LabelFunction.NO_OP.getFunctionName();
    LabelDefinitionInfo createdLabel = gApi.projects().name(project.get()).label("Foo").create(input).get();
    assertThat(createdLabel.function).isEqualTo(LabelFunction.NO_OP.getFunctionName());
}
Also used : LabelDefinitionInfo(com.google.gerrit.extensions.common.LabelDefinitionInfo) LabelDefinitionInput(com.google.gerrit.extensions.common.LabelDefinitionInput) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 62 with LabelDefinitionInfo

use of com.google.gerrit.extensions.common.LabelDefinitionInfo in project gerrit by GerritCodeReview.

the class CreateLabelIT method createWithCopyAllScoresOnTrivialRebase.

@Test
public void createWithCopyAllScoresOnTrivialRebase() throws Exception {
    LabelDefinitionInput input = new LabelDefinitionInput();
    input.values = ImmutableMap.of("+1", "Looks Good", " 0", "Don't Know", "-1", "Looks Bad");
    input.copyAllScoresOnTrivialRebase = true;
    LabelDefinitionInfo createdLabel = gApi.projects().name(project.get()).label("foo").create(input).get();
    assertThat(createdLabel.copyAllScoresOnTrivialRebase).isTrue();
}
Also used : LabelDefinitionInfo(com.google.gerrit.extensions.common.LabelDefinitionInfo) LabelDefinitionInput(com.google.gerrit.extensions.common.LabelDefinitionInput) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 63 with LabelDefinitionInfo

use of com.google.gerrit.extensions.common.LabelDefinitionInfo in project gerrit by GerritCodeReview.

the class CreateLabelIT method createCopyConditionPerformsGroupVisibilityCheckWhenUserInPredicateIsUsed.

@Test
public void createCopyConditionPerformsGroupVisibilityCheckWhenUserInPredicateIsUsed() throws Exception {
    String administratorsUUID = gApi.groups().query("name:Administrators").get().get(0).id;
    LabelDefinitionInput input = new LabelDefinitionInput();
    input.values = ImmutableMap.of("+1", "Looks Good", " 0", "Don't Know", "-1", "Looks Bad");
    input.copyCondition = "uploaderin:" + administratorsUUID;
    projectOperations.project(project).forUpdate().add(allow(Permission.OWNER).ref("refs/*").group(REGISTERED_USERS)).update();
    // User can't see admin group
    requestScopeOperations.setApiUser(user.id());
    BadRequestException thrown = assertThrows(BadRequestException.class, () -> gApi.projects().name(project.get()).label("foo").create(input));
    assertThat(thrown).hasMessageThat().contains("Group " + administratorsUUID + " not found");
    // Admin can see admin group
    requestScopeOperations.setApiUser(admin.id());
    LabelDefinitionInfo updatedLabel = gApi.projects().name(project.get()).label("foo").create(input).get();
    assertThat(updatedLabel.copyCondition).isEqualTo(input.copyCondition);
}
Also used : LabelDefinitionInfo(com.google.gerrit.extensions.common.LabelDefinitionInfo) BadRequestException(com.google.gerrit.extensions.restapi.BadRequestException) LabelDefinitionInput(com.google.gerrit.extensions.common.LabelDefinitionInput) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 64 with LabelDefinitionInfo

use of com.google.gerrit.extensions.common.LabelDefinitionInfo in project gerrit by GerritCodeReview.

the class CreateLabelIT method createWithoutIgnoreSelfApproval.

@Test
public void createWithoutIgnoreSelfApproval() throws Exception {
    LabelDefinitionInput input = new LabelDefinitionInput();
    input.values = ImmutableMap.of("+1", "Looks Good", " 0", "Don't Know", "-1", "Looks Bad");
    input.ignoreSelfApproval = false;
    LabelDefinitionInfo createdLabel = gApi.projects().name(project.get()).label("foo").create(input).get();
    assertThat(createdLabel.ignoreSelfApproval).isNull();
}
Also used : LabelDefinitionInfo(com.google.gerrit.extensions.common.LabelDefinitionInfo) LabelDefinitionInput(com.google.gerrit.extensions.common.LabelDefinitionInput) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 65 with LabelDefinitionInfo

use of com.google.gerrit.extensions.common.LabelDefinitionInfo in project gerrit by GerritCodeReview.

the class CreateLabelIT method createWithoutCopyAnyScore.

@Test
public void createWithoutCopyAnyScore() throws Exception {
    LabelDefinitionInput input = new LabelDefinitionInput();
    input.values = ImmutableMap.of("+1", "Looks Good", " 0", "Don't Know", "-1", "Looks Bad");
    input.copyAnyScore = false;
    LabelDefinitionInfo createdLabel = gApi.projects().name(project.get()).label("foo").create(input).get();
    assertThat(createdLabel.copyAnyScore).isNull();
}
Also used : LabelDefinitionInfo(com.google.gerrit.extensions.common.LabelDefinitionInfo) LabelDefinitionInput(com.google.gerrit.extensions.common.LabelDefinitionInput) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Aggregations

LabelDefinitionInfo (com.google.gerrit.extensions.common.LabelDefinitionInfo)93 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)91 Test (org.junit.Test)91 LabelDefinitionInput (com.google.gerrit.extensions.common.LabelDefinitionInput)79 BatchLabelInput (com.google.gerrit.extensions.common.BatchLabelInput)3 BadRequestException (com.google.gerrit.extensions.restapi.BadRequestException)2 LabelType (com.google.gerrit.entities.LabelType)1 LabelValue (com.google.gerrit.entities.LabelValue)1 AuthException (com.google.gerrit.extensions.restapi.AuthException)1 Response (com.google.gerrit.extensions.restapi.Response)1 RestReadView (com.google.gerrit.extensions.restapi.RestReadView)1 CurrentUser (com.google.gerrit.server.CurrentUser)1 PermissionBackend (com.google.gerrit.server.permissions.PermissionBackend)1 PermissionBackendException (com.google.gerrit.server.permissions.PermissionBackendException)1 ProjectPermission (com.google.gerrit.server.permissions.ProjectPermission)1 LabelDefinitionJson (com.google.gerrit.server.project.LabelDefinitionJson)1 ProjectResource (com.google.gerrit.server.project.ProjectResource)1 ProjectState (com.google.gerrit.server.project.ProjectState)1 Inject (com.google.inject.Inject)1 Provider (com.google.inject.Provider)1