Search in sources :

Example 71 with LabelDefinitionInfo

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

the class PostLabelsIT method deleteRecreateAndUpdateLabel.

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

Example 72 with LabelDefinitionInfo

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

the class SetLabelIT method setCopyCondition.

@Test
public void setCopyCondition() throws Exception {
    configLabel("foo", LabelFunction.NO_OP);
    assertThat(gApi.projects().name(project.get()).label("foo").get().copyCondition).isNull();
    LabelDefinitionInput input = new LabelDefinitionInput();
    input.copyCondition = "is:MAX";
    LabelDefinitionInfo updatedLabel = gApi.projects().name(project.get()).label("foo").update(input);
    assertThat(updatedLabel.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 73 with LabelDefinitionInfo

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

the class SetLabelIT method unsetCopyCondition.

@Test
public void unsetCopyCondition() throws Exception {
    configLabel("foo", LabelFunction.NO_OP);
    try (ProjectConfigUpdate u = updateProject(project)) {
        u.getConfig().updateLabelType("foo", lt -> lt.setCopyCondition("is:MAX"));
        u.save();
    }
    assertThat(gApi.projects().name(project.get()).label("foo").get().copyCondition).isEqualTo("is:MAX");
    LabelDefinitionInput input = new LabelDefinitionInput();
    input.unsetCopyCondition = true;
    LabelDefinitionInfo updatedLabel = gApi.projects().name(project.get()).label("foo").update(input);
    assertThat(updatedLabel.copyCondition).isNull();
    assertThat(gApi.projects().name(project.get()).label("foo").get().copyCondition).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 74 with LabelDefinitionInfo

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

the class GetLabelIT method labelWithDefaultValue.

@Test
public void labelWithDefaultValue() throws Exception {
    configLabel("foo", LabelFunction.NO_OP);
    // set default value
    try (ProjectConfigUpdate u = updateProject(project)) {
        u.getConfig().updateLabelType("foo", labelType -> labelType.setDefaultValue((short) 1));
        u.save();
    }
    LabelDefinitionInfo fooLabel = gApi.projects().name(project.get()).label("foo").get();
    assertThat(fooLabel.defaultValue).isEqualTo(1);
}
Also used : LabelDefinitionInfo(com.google.gerrit.extensions.common.LabelDefinitionInfo) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 75 with LabelDefinitionInfo

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

the class GetLabelIT method labelLimitedToBranches.

@Test
public void labelLimitedToBranches() throws Exception {
    configLabel("foo", LabelFunction.NO_OP, ImmutableList.of("refs/heads/master", "^refs/heads/stable-.*"));
    LabelDefinitionInfo fooLabel = gApi.projects().name(project.get()).label("foo").get();
    assertThat(fooLabel.branches).containsExactly("refs/heads/master", "^refs/heads/stable-.*");
}
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