Search in sources :

Example 81 with LabelDefinitionInfo

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

the class SetLabelIT method updateName.

@Test
public void updateName() throws Exception {
    LabelDefinitionInput input = new LabelDefinitionInput();
    input.name = "Foo-Review";
    LabelDefinitionInfo updatedLabel = gApi.projects().name(allProjects.get()).label(LabelId.CODE_REVIEW).update(input);
    assertThat(updatedLabel.name).isEqualTo(input.name);
    assertThat(gApi.projects().name(allProjects.get()).label("Foo-Review").get()).isNotNull();
    assertThrows(ResourceNotFoundException.class, () -> gApi.projects().name(allProjects.get()).label(LabelId.CODE_REVIEW).get());
}
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 82 with LabelDefinitionInfo

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

the class SetLabelIT method unsetCopyMinScore.

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

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

the class SetLabelIT method unsetCopyAllScoresOnTrivialRebase.

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

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

the class SetLabelIT method branchesAreTrimmed.

@Test
public void branchesAreTrimmed() throws Exception {
    LabelDefinitionInput input = new LabelDefinitionInput();
    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).containsExactly("refs/heads/master", "refs/heads/foo/*", "^refs/heads/stable-.*");
    assertThat(gApi.projects().name(allProjects.get()).label(LabelId.CODE_REVIEW).get().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 85 with LabelDefinitionInfo

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

the class SetLabelIT method setCanOverride.

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

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