Search in sources :

Example 26 with LabelDefinitionInput

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

the class SetLabelIT method commitMessageIsTrimmed.

@Test
public void commitMessageIsTrimmed() throws Exception {
    LabelDefinitionInput input = new LabelDefinitionInput();
    input.function = LabelFunction.NO_OP.getFunctionName();
    input.commitMessage = " Set NoOp function ";
    gApi.projects().name(allProjects.get()).label(LabelId.CODE_REVIEW).update(input);
    assertThat(projectOperations.project(allProjects).getHead(RefNames.REFS_CONFIG).getShortMessage()).isEqualTo("Set NoOp function");
}
Also used : LabelDefinitionInput(com.google.gerrit.extensions.common.LabelDefinitionInput) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 27 with LabelDefinitionInput

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

the class SetLabelIT method unsetCanOverride.

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

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

the class SetLabelIT method unsetCopyAnyScore.

@Test
public void unsetCopyAnyScore() throws Exception {
    configLabel("foo", LabelFunction.NO_OP);
    try (ProjectConfigUpdate u = updateProject(project)) {
        u.getConfig().updateLabelType("foo", lt -> lt.setCopyAnyScore(true));
        u.save();
    }
    assertThat(gApi.projects().name(project.get()).label("foo").get().copyAnyScore).isTrue();
    LabelDefinitionInput input = new LabelDefinitionInput();
    input.copyAnyScore = false;
    LabelDefinitionInfo updatedLabel = gApi.projects().name(project.get()).label("foo").update(input);
    assertThat(updatedLabel.copyAnyScore).isNull();
    assertThat(gApi.projects().name(project.get()).label("foo").get().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)

Example 29 with LabelDefinitionInput

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

the class SetLabelIT method cannotSetNameIfNameClashes.

@Test
public void cannotSetNameIfNameClashes() throws Exception {
    configLabel("Foo-Review", LabelFunction.NO_OP);
    configLabel("Bar-Review", LabelFunction.NO_OP);
    LabelDefinitionInput input = new LabelDefinitionInput();
    input.name = "Bar-Review";
    ResourceConflictException thrown = assertThrows(ResourceConflictException.class, () -> gApi.projects().name(project.get()).label("Foo-Review").update(input));
    assertThat(thrown).hasMessageThat().contains("name " + input.name + " already in use");
}
Also used : ResourceConflictException(com.google.gerrit.extensions.restapi.ResourceConflictException) LabelDefinitionInput(com.google.gerrit.extensions.common.LabelDefinitionInput) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 30 with LabelDefinitionInput

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

the class SetLabelIT method unsetCopyAllScoresIfNoChange.

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

LabelDefinitionInput (com.google.gerrit.extensions.common.LabelDefinitionInput)132 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)129 Test (org.junit.Test)129 LabelDefinitionInfo (com.google.gerrit.extensions.common.LabelDefinitionInfo)79 BadRequestException (com.google.gerrit.extensions.restapi.BadRequestException)28 BatchLabelInput (com.google.gerrit.extensions.common.BatchLabelInput)17 ResourceConflictException (com.google.gerrit.extensions.restapi.ResourceConflictException)8 AuthException (com.google.gerrit.extensions.restapi.AuthException)7 LabelType (com.google.gerrit.entities.LabelType)4 ProjectConfig (com.google.gerrit.server.project.ProjectConfig)4 UnprocessableEntityException (com.google.gerrit.extensions.restapi.UnprocessableEntityException)3 MetaDataUpdate (com.google.gerrit.server.git.meta.MetaDataUpdate)3 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)2 Map (java.util.Map)2 RevCommit (org.eclipse.jgit.revwalk.RevCommit)2 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Iterables (com.google.common.collect.Iterables)1