Search in sources :

Example 1 with DashboardInfo

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

the class DashboardIT method replaceDefaultDashboard.

@Test
public void replaceDefaultDashboard() throws Exception {
    DashboardInfo d1 = createTestDashboard(DashboardsCollection.DEFAULT_DASHBOARD_NAME, "test1");
    DashboardInfo d2 = createTestDashboard(DashboardsCollection.DEFAULT_DASHBOARD_NAME, "test2");
    assertThat(d1.isDefault).isNull();
    assertThat(d2.isDefault).isNull();
    project().dashboard(d1.id).setDefault();
    assertThat(project().dashboard(d1.id).get().isDefault).isTrue();
    assertThat(project().dashboard(d2.id).get().isDefault).isNull();
    assertThat(project().defaultDashboard().get().id).isEqualTo(d1.id);
    project().dashboard(d2.id).setDefault();
    assertThat(project().defaultDashboard().get().id).isEqualTo(d2.id);
    assertThat(project().dashboard(d1.id).get().isDefault).isNull();
    assertThat(project().dashboard(d2.id).get().isDefault).isTrue();
}
Also used : DashboardInfo(com.google.gerrit.extensions.api.projects.DashboardInfo) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 2 with DashboardInfo

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

the class DashboardIT method getDashboardWithNoDescription.

@Test
public void getDashboardWithNoDescription() throws Exception {
    DashboardInfo info = newDashboardInfo(DashboardsCollection.DEFAULT_DASHBOARD_NAME, "test");
    info.description = null;
    DashboardInfo created = createDashboard(info);
    assertThat(created.description).isNull();
    DashboardInfo result = project().dashboard(created.id).get();
    assertThat(result.description).isNull();
}
Also used : DashboardInfo(com.google.gerrit.extensions.api.projects.DashboardInfo) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 3 with DashboardInfo

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

the class DashboardIT method getDashboardNonDefault.

@Test
public void getDashboardNonDefault() throws Exception {
    DashboardInfo info = createTestDashboard("my", "test");
    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)

Example 4 with DashboardInfo

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

the class DashboardIT method cannotGetDashboardWithInheritedForNonDefault.

@Test
public void cannotGetDashboardWithInheritedForNonDefault() throws Exception {
    DashboardInfo info = createTestDashboard();
    BadRequestException thrown = assertThrows(BadRequestException.class, () -> project().dashboard(info.id).get(true));
    assertThat(thrown).hasMessageThat().contains("inherited flag can only be used with default");
}
Also used : BadRequestException(com.google.gerrit.extensions.restapi.BadRequestException) DashboardInfo(com.google.gerrit.extensions.api.projects.DashboardInfo) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 5 with DashboardInfo

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

the class ListDashboards method apply.

@Override
public Response<List<?>> apply(ProjectResource rsrc) throws ResourceNotFoundException, IOException, PermissionBackendException {
    String project = rsrc.getName();
    if (!inherited) {
        return Response.ok(scan(rsrc.getProjectState(), project, true));
    }
    List<List<DashboardInfo>> all = new ArrayList<>();
    boolean setDefault = true;
    for (ProjectState ps : tree(rsrc)) {
        List<DashboardInfo> list = scan(ps, project, setDefault);
        for (DashboardInfo d : list) {
            if (d.isDefault != null && Boolean.TRUE.equals(d.isDefault)) {
                setDefault = false;
            }
        }
        if (!list.isEmpty()) {
            all.add(list);
        }
    }
    return Response.ok(all);
}
Also used : ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) ImmutableList(com.google.common.collect.ImmutableList) List(java.util.List) ProjectState(com.google.gerrit.server.project.ProjectState) DashboardInfo(com.google.gerrit.extensions.api.projects.DashboardInfo)

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