Search in sources :

Example 86 with LabelDefinitionInfo

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

the class SetLabelIT method setCopyMaxScore.

@Test
public void setCopyMaxScore() throws Exception {
    configLabel("foo", LabelFunction.NO_OP);
    assertThat(gApi.projects().name(project.get()).label("foo").get().copyMaxScore).isNull();
    LabelDefinitionInput input = new LabelDefinitionInput();
    input.copyMaxScore = true;
    LabelDefinitionInfo updatedLabel = gApi.projects().name(project.get()).label("foo").update(input);
    assertThat(updatedLabel.copyMaxScore).isTrue();
    assertThat(gApi.projects().name(project.get()).label("foo").get().copyMaxScore).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 87 with LabelDefinitionInfo

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

the class SetLabelIT method setCopyAllScoresOnTrivialRebase.

@Test
public void setCopyAllScoresOnTrivialRebase() throws Exception {
    configLabel("foo", LabelFunction.NO_OP);
    assertThat(gApi.projects().name(project.get()).label("foo").get().copyAllScoresOnTrivialRebase).isNull();
    LabelDefinitionInput input = new LabelDefinitionInput();
    input.copyAllScoresOnTrivialRebase = true;
    LabelDefinitionInfo updatedLabel = gApi.projects().name(project.get()).label("foo").update(input);
    assertThat(updatedLabel.copyAllScoresOnTrivialRebase).isTrue();
    assertThat(gApi.projects().name(project.get()).label("foo").get().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 88 with LabelDefinitionInfo

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

the class SetLabelIT method unsetCopyValues.

@Test
public void unsetCopyValues() throws Exception {
    configLabel("foo", LabelFunction.NO_OP);
    try (ProjectConfigUpdate u = updateProject(project)) {
        u.getConfig().updateLabelType("foo", lt -> lt.setCopyValues(ImmutableList.of((short) -1, (short) 1)));
        u.save();
    }
    assertThat(gApi.projects().name(project.get()).label("foo").get().copyValues).isNotEmpty();
    LabelDefinitionInput input = new LabelDefinitionInput();
    input.copyValues = ImmutableList.of();
    LabelDefinitionInfo updatedLabel = gApi.projects().name(project.get()).label("foo").update(input);
    assertThat(updatedLabel.copyValues).isNull();
    assertThat(gApi.projects().name(project.get()).label("foo").get().copyValues).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 89 with LabelDefinitionInfo

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

the class SetLabelIT method updateBranches.

@Test
public void updateBranches() throws Exception {
    LabelDefinitionInput input = new LabelDefinitionInput();
    // Branches can be full ref, ref pattern or regular expression.
    input.branches = ImmutableList.of("refs/heads/master", "refs/heads/foo/*", "^refs/heads/stable-.*");
    LabelDefinitionInfo updatedLabel = gApi.projects().name(allProjects.get()).label(LabelId.CODE_REVIEW).update(input);
    assertThat(updatedLabel.branches).containsExactlyElementsIn(input.branches);
    assertThat(gApi.projects().name(allProjects.get()).label(LabelId.CODE_REVIEW).get().branches).containsExactlyElementsIn(input.branches);
}
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 90 with LabelDefinitionInfo

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

the class SetLabelIT method updateFunction.

@Test
public void updateFunction() throws Exception {
    LabelDefinitionInput input = new LabelDefinitionInput();
    input.function = LabelFunction.NO_OP.getFunctionName();
    LabelDefinitionInfo updatedLabel = gApi.projects().name(allProjects.get()).label(LabelId.CODE_REVIEW).update(input);
    assertThat(updatedLabel.function).isEqualTo(input.function);
    assertThat(gApi.projects().name(allProjects.get()).label(LabelId.CODE_REVIEW).get().function).isEqualTo(input.function);
}
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