Search in sources :

Example 26 with LabelDefinitionInfo

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

the class SetLabelIT method emptyBranchesAreIgnored.

@Test
public void emptyBranchesAreIgnored() throws Exception {
    LabelDefinitionInput input = new LabelDefinitionInput();
    input.branches = ImmutableList.of("refs/heads/master", "", " ");
    LabelDefinitionInfo updatedLabel = gApi.projects().name(allProjects.get()).label(LabelId.CODE_REVIEW).update(input);
    assertThat(updatedLabel.branches).containsExactly("refs/heads/master");
    assertThat(gApi.projects().name(allProjects.get()).label(LabelId.CODE_REVIEW).get().branches).containsExactly("refs/heads/master");
}
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 27 with LabelDefinitionInfo

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

the class SetLabelIT method setCopyValues.

@Test
public void setCopyValues() throws Exception {
    configLabel("foo", LabelFunction.NO_OP);
    assertThat(gApi.projects().name(project.get()).label("foo").get().copyValues).isNull();
    LabelDefinitionInput input = new LabelDefinitionInput();
    input.copyValues = ImmutableList.of((short) -1, (short) 1);
    LabelDefinitionInfo updatedLabel = gApi.projects().name(project.get()).label("foo").update(input);
    assertThat(updatedLabel.copyValues).containsExactly((short) -1, (short) 1).inOrder();
    assertThat(gApi.projects().name(project.get()).label("foo").get().copyValues).containsExactly((short) -1, (short) 1).inOrder();
}
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 28 with LabelDefinitionInfo

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

the class SetLabelIT method updateValues.

@Test
public void updateValues() throws Exception {
    LabelDefinitionInput input = new LabelDefinitionInput();
    // Positive values can be specified as '<value>' or '+<value>'.
    input.values = ImmutableMap.of("2", "Looks Very Good", "+1", "Looks Good", "0", "Don't Know", "-1", "Looks Bad", "-2", "Looks Very Bad");
    LabelDefinitionInfo updatedLabel = gApi.projects().name(allProjects.get()).label(LabelId.CODE_REVIEW).update(input);
    assertThat(updatedLabel.values).containsExactly("+2", "Looks Very Good", "+1", "Looks Good", " 0", "Don't Know", "-1", "Looks Bad", "-2", "Looks Very Bad");
    assertThat(gApi.projects().name(allProjects.get()).label(LabelId.CODE_REVIEW).get().values).containsExactly("+2", "Looks Very Good", "+1", "Looks Good", " 0", "Don't Know", "-1", "Looks Bad", "-2", "Looks Very Bad");
}
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 29 with LabelDefinitionInfo

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

the class GetLabelIT method allProjectsCodeReviewLabel.

@Test
public void allProjectsCodeReviewLabel() throws Exception {
    LabelDefinitionInfo codeReviewLabel = gApi.projects().name(allProjects.get()).label(LabelId.CODE_REVIEW).get();
    LabelAssert.assertCodeReviewLabel(codeReviewLabel);
}
Also used : LabelDefinitionInfo(com.google.gerrit.extensions.common.LabelDefinitionInfo) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 30 with LabelDefinitionInfo

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

the class GetLabelIT method labelWithoutRules.

@Test
public void labelWithoutRules() throws Exception {
    configLabel("foo", LabelFunction.NO_OP);
    // unset rules which are enabled by default
    try (ProjectConfigUpdate u = updateProject(project)) {
        u.getConfig().updateLabelType("foo", labelType -> {
            labelType.setCanOverride(false);
            labelType.setCopyAllScoresIfNoChange(false);
            labelType.setAllowPostSubmit(false);
        });
        u.save();
    }
    LabelDefinitionInfo fooLabel = gApi.projects().name(project.get()).label("foo").get();
    assertThat(fooLabel.canOverride).isNull();
    assertThat(fooLabel.copyAnyScore).isNull();
    assertThat(fooLabel.copyMinScore).isNull();
    assertThat(fooLabel.copyMaxScore).isNull();
    assertThat(fooLabel.copyAllScoresIfListOfFilesDidNotChange).isNull();
    assertThat(fooLabel.copyAllScoresIfNoChange).isNull();
    assertThat(fooLabel.copyAllScoresIfNoCodeChange).isNull();
    assertThat(fooLabel.copyAllScoresOnTrivialRebase).isNull();
    assertThat(fooLabel.copyAllScoresOnMergeFirstParentUpdate).isNull();
    assertThat(fooLabel.copyValues).isNull();
    assertThat(fooLabel.allowPostSubmit).isNull();
    assertThat(fooLabel.ignoreSelfApproval).isNull();
}
Also used : LabelDefinitionInfo(com.google.gerrit.extensions.common.LabelDefinitionInfo) 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