Search in sources :

Example 11 with DashboardInfo

use of com.google.gerrit.extensions.api.projects.DashboardInfo in project gerrit by GerritCodeReview.

the class DashboardsCollection method newDashboardInfo.

static DashboardInfo newDashboardInfo(String id) throws InvalidDashboardId {
    DashboardInfo info = new DashboardInfo();
    List<String> parts = Lists.newArrayList(Splitter.on(':').limit(2).split(id));
    if (parts.size() != 2) {
        throw new InvalidDashboardId(id);
    }
    info.id = id;
    info.ref = parts.get(0);
    info.path = parts.get(1);
    return info;
}
Also used : IdString(com.google.gerrit.extensions.restapi.IdString) DashboardInfo(com.google.gerrit.extensions.api.projects.DashboardInfo)

Example 12 with DashboardInfo

use of com.google.gerrit.extensions.api.projects.DashboardInfo in project gerrit by GerritCodeReview.

the class DashboardIT method setDefaultDashboardByProject.

@Test
public void setDefaultDashboardByProject() throws Exception {
    DashboardInfo info = createTestDashboard();
    assertThat(info.isDefault).isNull();
    project().defaultDashboard(info.id);
    assertThat(project().dashboard(info.id).get().isDefault).isTrue();
    assertThat(project().defaultDashboard().get().id).isEqualTo(info.id);
    project().removeDefaultDashboard();
    assertThat(project().dashboard(info.id).get().isDefault).isNull();
    assertThrows(ResourceNotFoundException.class, () -> project().defaultDashboard().get());
}
Also used : DashboardInfo(com.google.gerrit.extensions.api.projects.DashboardInfo) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 13 with DashboardInfo

use of com.google.gerrit.extensions.api.projects.DashboardInfo in project gerrit by GerritCodeReview.

the class DashboardIT method listDashboards.

@Test
public void listDashboards() throws Exception {
    assertThat(dashboards()).isEmpty();
    DashboardInfo info1 = createTestDashboard(DashboardsCollection.DEFAULT_DASHBOARD_NAME, "test1");
    DashboardInfo info2 = createTestDashboard(DashboardsCollection.DEFAULT_DASHBOARD_NAME, "test2");
    assertThat(dashboards().stream().map(d -> d.id).collect(toList())).containsExactly(info1.id, info2.id);
}
Also used : ResourceNotFoundException(com.google.gerrit.extensions.restapi.ResourceNotFoundException) BranchInput(com.google.gerrit.extensions.api.projects.BranchInput) DashboardsCollection(com.google.gerrit.server.restapi.project.DashboardsCollection) RevCommit(org.eclipse.jgit.revwalk.RevCommit) Inject(com.google.inject.Inject) ProjectApi(com.google.gerrit.extensions.api.projects.ProjectApi) REGISTERED_USERS(com.google.gerrit.server.group.SystemGroupBackend.REGISTERED_USERS) BadRequestException(com.google.gerrit.extensions.restapi.BadRequestException) ImmutableList(com.google.common.collect.ImmutableList) RestApiException(com.google.gerrit.extensions.restapi.RestApiException) TestProjectUpdate.allow(com.google.gerrit.acceptance.testsuite.project.TestProjectUpdate.allow) Before(org.junit.Before) TestRepository(org.eclipse.jgit.junit.TestRepository) DashboardSectionInfo(com.google.gerrit.extensions.api.projects.DashboardSectionInfo) Permission(com.google.gerrit.entities.Permission) Test(org.junit.Test) Truth.assertThat(com.google.common.truth.Truth.assertThat) NoHttpd(com.google.gerrit.acceptance.NoHttpd) DashboardInfo(com.google.gerrit.extensions.api.projects.DashboardInfo) Collectors.toList(java.util.stream.Collectors.toList) List(java.util.List) ProjectOperations(com.google.gerrit.acceptance.testsuite.project.ProjectOperations) ResourceConflictException(com.google.gerrit.extensions.restapi.ResourceConflictException) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) GerritJUnit.assertThrows(com.google.gerrit.testing.GerritJUnit.assertThrows) Repository(org.eclipse.jgit.lib.Repository) DashboardInfo(com.google.gerrit.extensions.api.projects.DashboardInfo) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 14 with DashboardInfo

use of com.google.gerrit.extensions.api.projects.DashboardInfo in project gerrit by GerritCodeReview.

the class DashboardIT method newDashboardInfo.

private DashboardInfo newDashboardInfo(String ref, String path) {
    DashboardInfo info = DashboardsCollection.newDashboardInfo(ref, path);
    info.title = "Reviewer";
    info.description = "Own review requests";
    info.foreach = "owner:self";
    DashboardSectionInfo section = new DashboardSectionInfo();
    section.name = "Open";
    section.query = "is:open";
    info.sections = ImmutableList.of(section);
    return info;
}
Also used : DashboardSectionInfo(com.google.gerrit.extensions.api.projects.DashboardSectionInfo) DashboardInfo(com.google.gerrit.extensions.api.projects.DashboardInfo)

Example 15 with DashboardInfo

use of com.google.gerrit.extensions.api.projects.DashboardInfo in project gerrit by GerritCodeReview.

the class DashboardIT method getDashboard.

@Test
public void getDashboard() throws Exception {
    DashboardInfo info = createTestDashboard();
    DashboardInfo result = project().dashboard(info.id).get();
    assertDashboardInfo(result, info);
}
Also used : DashboardInfo(com.google.gerrit.extensions.api.projects.DashboardInfo) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Aggregations

DashboardInfo (com.google.gerrit.extensions.api.projects.DashboardInfo)16 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)8 Test (org.junit.Test)8 ImmutableList (com.google.common.collect.ImmutableList)4 ResourceNotFoundException (com.google.gerrit.extensions.restapi.ResourceNotFoundException)4 DashboardSectionInfo (com.google.gerrit.extensions.api.projects.DashboardSectionInfo)3 BadRequestException (com.google.gerrit.extensions.restapi.BadRequestException)3 IdString (com.google.gerrit.extensions.restapi.IdString)3 ConfigInvalidException (org.eclipse.jgit.errors.ConfigInvalidException)3 ResourceConflictException (com.google.gerrit.extensions.restapi.ResourceConflictException)2 ProjectState (com.google.gerrit.server.project.ProjectState)2 List (java.util.List)2 RepositoryNotFoundException (org.eclipse.jgit.errors.RepositoryNotFoundException)2 Repository (org.eclipse.jgit.lib.Repository)2 Truth.assertThat (com.google.common.truth.Truth.assertThat)1 NoHttpd (com.google.gerrit.acceptance.NoHttpd)1 ProjectOperations (com.google.gerrit.acceptance.testsuite.project.ProjectOperations)1 TestProjectUpdate.allow (com.google.gerrit.acceptance.testsuite.project.TestProjectUpdate.allow)1 Permission (com.google.gerrit.entities.Permission)1 BranchInput (com.google.gerrit.extensions.api.projects.BranchInput)1