|
|
|
@ -257,6 +257,7 @@ public class ExportImportServiceSqlTest extends BaseExportImportServiceTest { |
|
|
|
Asset asset1 = createAsset(tenantId1, null, assetProfile.getId(), "Asset 1"); |
|
|
|
Asset asset2 = createAsset(tenantId1, null, assetProfile.getId(), "Asset 2"); |
|
|
|
Dashboard dashboard = createDashboard(tenantId1, null, "Dashboard 1"); |
|
|
|
Dashboard otherDashboard = createDashboard(tenantId1, null, "Dashboard 2"); |
|
|
|
DeviceProfile existingDeviceProfile = createDeviceProfile(tenantId2, null, null, "Existing"); |
|
|
|
|
|
|
|
String aliasId = "23c4185d-1497-9457-30b2-6d91e69a5b2c"; |
|
|
|
@ -265,20 +266,43 @@ public class ExportImportServiceSqlTest extends BaseExportImportServiceTest { |
|
|
|
"\"" + aliasId + "\": {\n" + |
|
|
|
"\"alias\": \"assets\",\n" + |
|
|
|
"\"filter\": {\n" + |
|
|
|
"\"entityList\": [\n" + |
|
|
|
"\"" + asset1.getId().toString() + "\",\n" + |
|
|
|
"\"" + asset2.getId().toString() + "\",\n" + |
|
|
|
"\"" + tenantId1.getId().toString() + "\",\n" + |
|
|
|
"\"" + existingDeviceProfile.getId().toString() + "\",\n" + |
|
|
|
"\"" + unknownUuid + "\"\n" + |
|
|
|
"],\n" + |
|
|
|
"\"resolveMultiple\": true\n" + |
|
|
|
" \"entityList\": [\n" + |
|
|
|
" \"" + asset1.getId() + "\",\n" + |
|
|
|
" \"" + asset2.getId() + "\",\n" + |
|
|
|
" \"" + tenantId1.getId() + "\",\n" + |
|
|
|
" \"" + existingDeviceProfile.getId() + "\",\n" + |
|
|
|
" \"" + unknownUuid + "\"\n" + |
|
|
|
" ],\n" + |
|
|
|
" \"id\":\"" + asset1.getId() + "\",\n" + |
|
|
|
" \"resolveMultiple\": true\n" + |
|
|
|
"},\n" + |
|
|
|
"\"id\": \"" + aliasId + "\"\n" + |
|
|
|
"}\n" + |
|
|
|
"}"; |
|
|
|
String widgetId = "ea8f34a0-264a-f11f-cde3-05201bb4ff4b"; |
|
|
|
String actionId = "4a8e6efa-3e68-fa59-7feb-d83366130cae"; |
|
|
|
String widgets = "{\n" + |
|
|
|
" \"" + widgetId + "\": {\n" + |
|
|
|
" \"config\": {\n" + |
|
|
|
" \"actions\": {\n" + |
|
|
|
" \"rowClick\": [\n" + |
|
|
|
" {\n" + |
|
|
|
" \"name\": \"go to dashboard\",\n" + |
|
|
|
" \"targetDashboardId\": \"" + otherDashboard.getId() + "\",\n" + |
|
|
|
" \"id\": \"" + actionId + "\"\n" + |
|
|
|
" }\n" + |
|
|
|
" ]\n" + |
|
|
|
" }\n" + |
|
|
|
" },\n" + |
|
|
|
" \"row\": 0,\n" + |
|
|
|
" \"col\": 0,\n" + |
|
|
|
" \"id\": \"" + widgetId + "\"\n" + |
|
|
|
" }\n" + |
|
|
|
"}"; |
|
|
|
|
|
|
|
ObjectNode dashboardConfiguration = JacksonUtil.newObjectNode(); |
|
|
|
dashboardConfiguration.set("entityAliases", JacksonUtil.toJsonNode(entityAliases)); |
|
|
|
dashboardConfiguration.set("widgets", JacksonUtil.toJsonNode(widgets)); |
|
|
|
dashboardConfiguration.set("description", new TextNode("hallo")); |
|
|
|
dashboard.setConfiguration(dashboardConfiguration); |
|
|
|
dashboard = dashboardService.saveDashboard(dashboard); |
|
|
|
@ -288,10 +312,12 @@ public class ExportImportServiceSqlTest extends BaseExportImportServiceTest { |
|
|
|
EntityExportData<Asset> asset1ExportData = exportEntity(tenantAdmin1, asset1.getId()); |
|
|
|
EntityExportData<Asset> asset2ExportData = exportEntity(tenantAdmin1, asset2.getId()); |
|
|
|
EntityExportData<Dashboard> dashboardExportData = exportEntity(tenantAdmin1, dashboard.getId()); |
|
|
|
EntityExportData<Dashboard> otherDashboardExportData = exportEntity(tenantAdmin1, otherDashboard.getId()); |
|
|
|
|
|
|
|
AssetProfile importedProfile = importEntity(tenantAdmin2, profileExportData).getSavedEntity(); |
|
|
|
Asset importedAsset1 = importEntity(tenantAdmin2, asset1ExportData).getSavedEntity(); |
|
|
|
Asset importedAsset2 = importEntity(tenantAdmin2, asset2ExportData).getSavedEntity(); |
|
|
|
Dashboard importedOtherDashboard = importEntity(tenantAdmin2, otherDashboardExportData).getSavedEntity(); |
|
|
|
Dashboard importedDashboard = importEntity(tenantAdmin2, dashboardExportData).getSavedEntity(); |
|
|
|
|
|
|
|
Map.Entry<String, JsonNode> entityAlias = importedDashboard.getConfiguration().get("entityAliases").fields().next(); |
|
|
|
@ -311,6 +337,17 @@ public class ExportImportServiceSqlTest extends BaseExportImportServiceTest { |
|
|
|
.isEqualTo(existingDeviceProfile.getId().toString()); |
|
|
|
assertThat(aliasEntitiesIds).element(4).as("unresolved uuid was replaced with tenant id") |
|
|
|
.isEqualTo(tenantId2.toString()); |
|
|
|
assertThat(entityAlias.getValue().get("filter").get("id").asText()).as("external asset 1 was replaced with imported one") |
|
|
|
.isEqualTo(importedAsset1.getId().toString()); |
|
|
|
|
|
|
|
ObjectNode widgetConfig = importedDashboard.getWidgetsConfig().get(0); |
|
|
|
assertThat(widgetConfig.get("id").asText()).as("widget id is not replaced") |
|
|
|
.isEqualTo(widgetId); |
|
|
|
JsonNode actionConfig = widgetConfig.get("config").get("actions").get("rowClick").get(0); |
|
|
|
assertThat(actionConfig.get("id").asText()).as("action id is not replaced") |
|
|
|
.isEqualTo(actionId); |
|
|
|
assertThat(actionConfig.get("targetDashboardId").asText()).as("dashboard id is replaced with imported one") |
|
|
|
.isEqualTo(importedOtherDashboard.getId().toString()); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|