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();
}
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();
}
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);
}
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");
}
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);
}
Aggregations