mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-09-03 14:13:06 +00:00
Fix #329: Add more tests to Dashboard and Topic
This commit is contained in:
parent
21c87ad46d
commit
b2237e54f3
@ -334,10 +334,19 @@ public abstract class DashboardRepository {
|
||||
applyTags(dashboard);
|
||||
}
|
||||
|
||||
private void updateChartRelationships(Dashboard dashboard) {
|
||||
// Add relationship from dashboard to chart
|
||||
private void updateChartRelationships(Dashboard dashboard) throws IOException {
|
||||
String dashboardId = dashboard.getId().toString();
|
||||
|
||||
// Add relationship from dashboard to chart
|
||||
if (dashboard.getCharts() != null) {
|
||||
// Remove any existing charts associated with this dashboard
|
||||
List<Chart> existingCharts = getCharts(dashboard);
|
||||
if (existingCharts != null) {
|
||||
for (Chart chart: existingCharts) {
|
||||
relationshipDAO().delete(dashboardId, chart.getId().toString(), Relationship.CONTAINS.ordinal());
|
||||
}
|
||||
}
|
||||
|
||||
for (EntityReference chart : dashboard.getCharts()) {
|
||||
relationshipDAO().insert(dashboardId, chart.getId().toString(), Entity.DASHBOARD, Entity.CHART,
|
||||
Relationship.CONTAINS.ordinal());
|
||||
|
@ -384,6 +384,23 @@ public class DashboardResourceTest extends CatalogApplicationTest {
|
||||
assertEquals("newDescription", dashboard.getDescription());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void put_AddRemoveDashboardChartsUpdate_200(TestInfo test) throws HttpResponseException {
|
||||
CreateDashboard request = create(test).withService(SUPERSET_REFERENCE).withDescription(null);
|
||||
createAndCheckDashboard(request, adminAuthHeaders());
|
||||
|
||||
Dashboard dashboard = updateAndCheckDashboard(request
|
||||
.withDescription("newDescription").withCharts(CHART_REFERENCES),
|
||||
OK, adminAuthHeaders());
|
||||
validateDashboardCharts(dashboard, CHART_REFERENCES);
|
||||
// remove a chart
|
||||
CHART_REFERENCES.remove(0);
|
||||
dashboard = updateAndCheckDashboard(request
|
||||
.withDescription("newDescription").withCharts(CHART_REFERENCES),
|
||||
OK, adminAuthHeaders());
|
||||
validateDashboardCharts(dashboard, CHART_REFERENCES);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void get_nonExistentDashboard_404_notFound() {
|
||||
HttpResponseException exception = assertThrows(HttpResponseException.class, () ->
|
||||
|
Loading…
x
Reference in New Issue
Block a user