Search in sources :

Example 16 with LabelDefinitionInfo

use of com.google.gerrit.extensions.common.LabelDefinitionInfo 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 17 with LabelDefinitionInfo

use of com.google.gerrit.extensions.common.LabelDefinitionInfo 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 18 with LabelDefinitionInfo

use of com.google.gerrit.extensions.common.LabelDefinitionInfo 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)

Example 19 with LabelDefinitionInfo

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

the class SetLabelIT method unsetCopyAllScoresIfNoCodeChange.

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

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

the class SetLabelIT method unsetCopyMaxScore.

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

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