Search in sources :

Example 51 with LabelDefinitionInput

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

the class CreateLabelIT method createWithCopyCondition.

@Test
public void createWithCopyCondition() throws Exception {
    LabelDefinitionInput input = new LabelDefinitionInput();
    input.values = ImmutableMap.of("+1", "Looks Good", " 0", "Don't Know", "-1", "Looks Bad");
    input.copyCondition = "is:MAX";
    LabelDefinitionInfo createdLabel = gApi.projects().name(project.get()).label("foo").create(input).get();
    assertThat(createdLabel.copyCondition).isEqualTo("is:MAX");
}
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 52 with LabelDefinitionInput

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

the class CreateLabelIT method branchesAreTrimmed.

@Test
public void branchesAreTrimmed() throws Exception {
    LabelDefinitionInput input = new LabelDefinitionInput();
    input.values = ImmutableMap.of("+1", "Looks Good", " 0", "Don't Know", "-1", "Looks Bad");
    input.branches = ImmutableList.of(" refs/heads/master ", " refs/heads/foo/* ", " ^refs/heads/stable-.* ");
    LabelDefinitionInfo createdLabel = gApi.projects().name(project.get()).label("Foo").create(input).get();
    assertThat(createdLabel.branches).containsExactly("refs/heads/master", "refs/heads/foo/*", "^refs/heads/stable-.*");
}
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 53 with LabelDefinitionInput

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

the class CreateLabelIT method cannotCreateLabelWithDuplicateValues.

@Test
public void cannotCreateLabelWithDuplicateValues() throws Exception {
    LabelDefinitionInput input = new LabelDefinitionInput();
    // Positive values can be specified as '<value>' or '+<value>'.
    input.values = ImmutableMap.of("+1", "Looks Good", "1", "Looks Good", "0", "Don't Know", "-1", "Looks Bad");
    BadRequestException thrown = assertThrows(BadRequestException.class, () -> gApi.projects().name(allProjects.get()).label("Foo").create(input));
    assertThat(thrown).hasMessageThat().contains("duplicate value: 1");
}
Also used : 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 54 with LabelDefinitionInput

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

the class CreateLabelIT method createWithDefaultValue.

@Test
public void createWithDefaultValue() throws Exception {
    LabelDefinitionInput input = new LabelDefinitionInput();
    input.values = ImmutableMap.of("+1", "Looks Good", " 0", "Don't Know", "-1", "Looks Bad");
    input.defaultValue = 1;
    LabelDefinitionInfo createdLabel = gApi.projects().name(project.get()).label("Foo").create(input).get();
    assertThat(createdLabel.defaultValue).isEqualTo(input.defaultValue);
}
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 55 with LabelDefinitionInput

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

the class CreateLabelIT method createWithInvalidCopyCondition.

@Test
public void createWithInvalidCopyCondition() throws Exception {
    LabelDefinitionInput input = new LabelDefinitionInput();
    input.values = ImmutableMap.of("+1", "Looks Good", " 0", "Don't Know", "-1", "Looks Bad");
    input.copyCondition = "blarg::asd";
    BadRequestException thrown = assertThrows(BadRequestException.class, () -> gApi.projects().name(project.get()).label("Bar").create(input));
    assertThat(thrown).hasMessageThat().contains("unable to parse copy condition");
}
Also used : BadRequestException(com.google.gerrit.extensions.restapi.BadRequestException) 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