From 14dd37b61fcd22b78684151c04bc45b7ece54991 Mon Sep 17 00:00:00 2001 From: Viktor Date: Fri, 6 Dec 2024 15:59:08 +0700 Subject: [PATCH 01/12] Update Snowflake datasource / datasource item features, test and examples --- .../DashboardCreators/SnowFlakeDashboard.cs | 57 +++++++++++ e2e/Sandbox/MainWindow.xaml.cs | 4 +- e2e/Sandbox/Reveal/AuthenticationProvider.cs | 5 + .../SnowflakeDataSourceItemFixture.cs | 96 +++++++++++++++---- .../DataSources/SnowflakeDataSourceFixture.cs | 57 ++++++++++- .../Data/TableDataSourceltemFixture.cs | 20 ++++ .../Data/DataSources/SnowflakeDataSource.cs | 2 +- .../Data/TableDataSourceItem.cs | 7 ++ 8 files changed, 223 insertions(+), 25 deletions(-) create mode 100644 e2e/Sandbox/DashboardCreators/SnowFlakeDashboard.cs diff --git a/e2e/Sandbox/DashboardCreators/SnowFlakeDashboard.cs b/e2e/Sandbox/DashboardCreators/SnowFlakeDashboard.cs new file mode 100644 index 00000000..4c53e9fd --- /dev/null +++ b/e2e/Sandbox/DashboardCreators/SnowFlakeDashboard.cs @@ -0,0 +1,57 @@ +using Reveal.Sdk.Dom; +using Reveal.Sdk.Dom.Data; +using Reveal.Sdk.Dom.Visualizations; +using Sandbox.DashboardFactories; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Sandbox.DashboardCreators +{ + internal class SnowflakeDashboard : IDashboardCreator + { + public string Name => "Snowflake Dashboard"; + + public RdashDocument CreateDashboard() + { + var snowflakeDS = new SnowflakeDataSource() + { + Id = "SnowflakeDSId", + Title = "Snowflake Data source", + Subtitle = "Snowflake Subtitle", + Account = "pqwkobs-xb90908", + DefaultRefreshRate = "120", + Host = "gpiskyj-al16914.snowflakecomputing.com", + Database = "SNOWFLAKE_SAMPLE_DATA", + //Role + Warehouse = "COMPUTE_WH", + Schema = "TPCDS_SF100TCL" + }; + + var snowflakeDSI = new SnowflakeDataSourceItem("Snowflake DSI Title", snowflakeDS) + { + Id = "SnowflakeDSItemId", + Title = "Snowflake data source Item", + Subtitle = "Snowflake data source Item Subtitle", + CustomQuery = "Select O_ORDERKEY, O_ORDERPRIORITY, O_CUSTKEY from ORDERS", + Schema = "TPCH_SF10", + Table = "ORDERS", + Database = "SNOWFLAKE_SAMPLE_DATA", + Fields = new List + { + new NumberField("O_ORDERKEY"), + new NumberField("O_CUSTKEY"), + new TextField("O_ORDERPRIORITY"), + } + }; + + var document = new RdashDocument("Snowflake Dashboard"); + + document.Visualizations.Add(new PieChartVisualization("Snowflake Order Priorities", snowflakeDSI) + .SetLabel("O_ORDERPRIORITY").SetValues("O_CUSTKEY")); + return document; + } + } +} diff --git a/e2e/Sandbox/MainWindow.xaml.cs b/e2e/Sandbox/MainWindow.xaml.cs index 1992d24c..b1f73518 100644 --- a/e2e/Sandbox/MainWindow.xaml.cs +++ b/e2e/Sandbox/MainWindow.xaml.cs @@ -22,6 +22,7 @@ using Reveal.Sdk.Data.Rest; using Reveal.Sdk.Data.Snowflake; using Reveal.Sdk.Dom; +using Sandbox.DashboardCreators; using Sandbox.DashboardFactories; using Sandbox.RevealSDK; using System; @@ -51,6 +52,7 @@ public partial class MainWindow : Window new RestDataSourceDashboard(), new SalesDashboard(), new SqlServerDataSourceDashboards(), + new SnowflakeDashboard(), }; public MainWindow() @@ -59,7 +61,7 @@ public MainWindow() RevealSdkSettings.DataSourceProvider = new Sandbox.RevealSDK.DataSourceProvider(); RevealSdkSettings.AuthenticationProvider = new AuthenticationProvider(); - RevealSdkSettings.DataSources.RegisterMicrosoftSqlServer().RegisterMicrosoftAnalysisServices(); + RevealSdkSettings.DataSources.RegisterMicrosoftSqlServer().RegisterMicrosoftAnalysisServices().RegisterSnowflake(); LoadDashboards(); diff --git a/e2e/Sandbox/Reveal/AuthenticationProvider.cs b/e2e/Sandbox/Reveal/AuthenticationProvider.cs index 07e9fce2..6677250e 100644 --- a/e2e/Sandbox/Reveal/AuthenticationProvider.cs +++ b/e2e/Sandbox/Reveal/AuthenticationProvider.cs @@ -1,6 +1,7 @@ using Reveal.Sdk.Data; using Reveal.Sdk.Data.Microsoft.AnalysisServices; using Reveal.Sdk.Data.Microsoft.SqlServer; +using Reveal.Sdk.Data.Snowflake; using System.Threading.Tasks; namespace Sandbox.RevealSDK @@ -18,6 +19,10 @@ public Task ResolveCredentialsAsync(RVDashboardDataSour { userCredential = new RVUsernamePasswordDataSourceCredential("username", "password", "domain"); } + else if (dataSource is RVSnowflakeDataSource) + { + userCredential = new RVUsernamePasswordDataSourceCredential("snow-flake-username", "snow-flake-password"); + } return Task.FromResult(userCredential); } } diff --git a/src/Reveal.Sdk.Dom.Tests/Data/DataSourceItems/SnowflakeDataSourceItemFixture.cs b/src/Reveal.Sdk.Dom.Tests/Data/DataSourceItems/SnowflakeDataSourceItemFixture.cs index 20d8b767..971d0d0c 100644 --- a/src/Reveal.Sdk.Dom.Tests/Data/DataSourceItems/SnowflakeDataSourceItemFixture.cs +++ b/src/Reveal.Sdk.Dom.Tests/Data/DataSourceItems/SnowflakeDataSourceItemFixture.cs @@ -1,4 +1,6 @@ -using Reveal.Sdk.Dom.Core.Extensions; +using Newtonsoft.Json.Linq; +using Reveal.Sdk.Dom.Core.Constants; +using Reveal.Sdk.Dom.Core.Extensions; using Reveal.Sdk.Dom.Data; using Xunit; @@ -7,49 +9,107 @@ namespace Reveal.Sdk.Dom.Tests.Data.DataSourceItems public class SnowflakeDataSourceItemFixture { [Theory] - [InlineData("Test Item")] - [InlineData(null)] - public void Constructor_SetsTitleAndDataSource_WhenCalled(string title) + [InlineData("DS Title", "DS Title", "DSI Title", "DSI Title")] + [InlineData(null, "DSI Title", "DSI Title", "DSI Title")] + public void Constructor_CreateSnowFlakeDSI_WithTitleAndDataSource(string dsTitle, string expectedDSTitle, string dsiTitle, string expectedDSITitle) { // Arrange - var dataSource = new SnowflakeDataSource(); + var dataSource = new DataSource() { Title = dsTitle }; // Act - var item = new SnowflakeDataSourceItem(title, dataSource); + var item = new SnowflakeDataSourceItem(dsiTitle, dataSource); // Assert - Assert.Equal(title, item.Title); - Assert.Equal(dataSource, item.DataSource); + Assert.Equal(SchemaTypeNames.DataSourceItemType, item.SchemaTypeName); + Assert.Equal(expectedDSTitle, item.DataSource.Title); + Assert.Equal(dataSource.Id, item.DataSource.Id); + Assert.Equal(dataSource.Id, item.DataSourceId); + Assert.IsType(item.DataSource); + Assert.NotSame(dataSource, item.DataSource); + Assert.Equal(expectedDSITitle, item.Title); } [Theory] - [InlineData("Test Item")] - [InlineData(null)] - public void Constructor_SetsTitleAndDataSource_WhenConstructedWithGenericDataSource(string title) + [InlineData("DS Title", "DS Title", "DSI Title", "DSI Title")] + [InlineData(null, "DSI Title", "DSI Title", "DSI Title")] + public void Constructor_CreateSnowFlakeDSI_WithTitleAndSnowFlakeDataSource(string dsTitle, string expectedDSTitle, string dsiTitle, string expectedDSITitle) { // Arrange - var dataSource = new DataSource(); + var dataSource = new SnowflakeDataSource() { Title = dsTitle }; // Act - var item = new SnowflakeDataSourceItem(title, dataSource); + var item = new SnowflakeDataSourceItem(dsiTitle, dataSource); // Assert - Assert.Equal(title, item.Title); + Assert.Equal(SchemaTypeNames.DataSourceItemType, item.SchemaTypeName); + Assert.Equal(expectedDSTitle, item.DataSource.Title); + Assert.Equal(dataSource.Id, item.DataSource.Id); + Assert.Equal(dataSource.Id, item.DataSourceId); Assert.IsType(item.DataSource); + Assert.Same(dataSource, item.DataSource); + Assert.Equal(expectedDSITitle, item.Title); } [Fact] - public void ProcessDataOnServer_ShouldSetAndGetValue_WithInputs() + public void GetProcessDataOnServer_ReturnSameValue_AfterSet() { // Arrange var item = new SnowflakeDataSourceItem("Test Item", new SnowflakeDataSource()); + var expectedProcessDataOnServer = true; // Act - item.ProcessDataOnServer = true; + item.ProcessDataOnServer = expectedProcessDataOnServer; // Assert - Assert.True(item.ProcessDataOnServer); - Assert.True(item.Properties.GetValue("ServerAggregation")); + Assert.Equal(expectedProcessDataOnServer, item.ProcessDataOnServer); + Assert.Equal(expectedProcessDataOnServer, item.Properties.GetValue("ServerAggregation")); + } + + [Fact] + public void ToJsonString_CreatesFormattedJson_NoConditions() + { + // Arrange + var expectedJson = @"{ + ""_type"": ""DataSourceItemType"", + ""Id"": ""a60ab508-0ed4-46e4-8d90-c3a9c09c29b8"", + ""Title"": ""SnowFlake DSI"", + ""DataSourceId"": ""snowflake_ds"", + ""HasTabularData"": true, + ""HasAsset"": false, + ""Properties"": { + ""ServerAggregation"": true, + ""Table"": ""CALL_CENTER"", + ""Schema"": ""TPCDS_SF100TCL"" + }, + ""Parameters"": { + ""RPCustomQuery"": ""Select CC_CALL_CENTER_ID, CC_CALL_CENTER_SK from CALL_CENTER"" + } + }"; + + var dataSource = new SnowflakeDataSource() + { + Id = "snowflake_ds", + }; + var dataSourceItem = new SnowflakeDataSourceItem("SnowFlake DSI", dataSource) + { + Id = "a60ab508-0ed4-46e4-8d90-c3a9c09c29b8", + HasTabularData = true, + HasAsset = false, + ProcessDataOnServer = true, + Table = "CALL_CENTER", + Schema = "TPCDS_SF100TCL", + CustomQuery = "Select CC_CALL_CENTER_ID, CC_CALL_CENTER_SK from CALL_CENTER", + }; + + var expectedJObject = JObject.Parse(expectedJson); + + // Act + var json = dataSourceItem.ToJsonString(); + var actualJObject = JObject.Parse(json); + + // Assert + Assert.Equal(expectedJObject, actualJObject); + } } } diff --git a/src/Reveal.Sdk.Dom.Tests/Data/DataSources/SnowflakeDataSourceFixture.cs b/src/Reveal.Sdk.Dom.Tests/Data/DataSources/SnowflakeDataSourceFixture.cs index 1803b905..ff934fcd 100644 --- a/src/Reveal.Sdk.Dom.Tests/Data/DataSources/SnowflakeDataSourceFixture.cs +++ b/src/Reveal.Sdk.Dom.Tests/Data/DataSources/SnowflakeDataSourceFixture.cs @@ -1,4 +1,5 @@ -using Reveal.Sdk.Dom.Core.Extensions; +using Newtonsoft.Json.Linq; +using Reveal.Sdk.Dom.Core.Extensions; using Reveal.Sdk.Dom.Data; using Xunit; @@ -7,7 +8,7 @@ namespace Reveal.Sdk.Dom.Tests.Data.DataSources public class SnowflakeDataSourceFixture { [Fact] - public void SnowflakeDataSource_ShouldSetProviderToSnowflake() + public void Constructor_SetDefaultProvider_WithoutParameter() { // Act var dataSource = new SnowflakeDataSource(); @@ -19,7 +20,7 @@ public void SnowflakeDataSource_ShouldSetProviderToSnowflake() [Theory] [InlineData("testAccount")] [InlineData(null)] - public void Account_ShouldSetAndGetValue_WithDifferentInputs(string account) + public void GetAccount_ReturnSameValue_AfterSetAccount(string account) { // Arrange var dataSource = new SnowflakeDataSource(); @@ -35,7 +36,7 @@ public void Account_ShouldSetAndGetValue_WithDifferentInputs(string account) [Theory] [InlineData("testRole")] [InlineData(null)] - public void Role_ShouldSetAndGetValue_WithDifferentInputs(string role) + public void GetRole_ReturnSameValue_AfterSetRole(string role) { // Arrange var dataSource = new SnowflakeDataSource(); @@ -51,7 +52,7 @@ public void Role_ShouldSetAndGetValue_WithDifferentInputs(string role) [Theory] [InlineData("testWarehouse")] [InlineData(null)] - public void Warehouse_ShouldSetAndGetValue_WithDifferentInputs(string warehouse) + public void SetWarehouse_ReturnSameValue_AfterSetWarehouse(string warehouse) { // Arrange var dataSource = new SnowflakeDataSource(); @@ -63,5 +64,51 @@ public void Warehouse_ShouldSetAndGetValue_WithDifferentInputs(string warehouse) Assert.Equal(warehouse, dataSource.Warehouse); Assert.Equal(warehouse, dataSource.Properties.GetValue("Warehouse")); } + + [Fact] + public void ToJsonString_CreatesFormattedJson_NoConditions() + { + // Arrange + var expectedJson = @"{ + ""_type"": ""DataSourceType"", + ""Id"": ""snowflake_ds"", + ""Provider"": ""SNOWFLAKE"", + ""Description"": ""Snowflake TEST"", + ""Subtitle"": ""Snowflake TEST Subtitle"", + ""Properties"": { + ""ServerAggregationDefault"": true, + ""ServerAggregationReadOnly"": false, + ""Host"": ""gpiskyj-al16914.snowflakecomputing.com"", + ""Database"": ""SNOWFLAKE_SAMPLE_DATA"", + ""Account"": ""pqwkobs-xb90908"", + ""Warehouse"": ""COMPUTE_WH"", + ""Schema"": ""TPCDS_SF100TCL"" + }, + //""Settings"": {} // TODO: Update to check settings fields after Postgresql PR is merged + }"; + + var dataSource = new SnowflakeDataSource() + { + Id = "snowflake_ds", + Title = "Snowflake TEST", + Subtitle = "Snowflake TEST Subtitle", + ProcessDataOnServerDefaultValue = true, + ProcessDataOnServerReadOnly = false, + Host = "gpiskyj-al16914.snowflakecomputing.com", + Database = "SNOWFLAKE_SAMPLE_DATA", + Account = "pqwkobs-xb90908", + Warehouse = "COMPUTE_WH", + Schema = "TPCDS_SF100TCL", + }; + var expectedJObject = JObject.Parse(expectedJson); + + // Act + var json = dataSource.ToJsonString(); + var actualJObject = JObject.Parse(json); + + // Assert + Assert.Equal(expectedJObject, actualJObject); + + } } } diff --git a/src/Reveal.Sdk.Dom.Tests/Data/TableDataSourceltemFixture.cs b/src/Reveal.Sdk.Dom.Tests/Data/TableDataSourceltemFixture.cs index a357293e..e4c42087 100644 --- a/src/Reveal.Sdk.Dom.Tests/Data/TableDataSourceltemFixture.cs +++ b/src/Reveal.Sdk.Dom.Tests/Data/TableDataSourceltemFixture.cs @@ -1,4 +1,5 @@ using Moq; +using Reveal.Sdk.Dom.Core.Extensions; using Reveal.Sdk.Dom.Data; using Xunit; @@ -39,6 +40,25 @@ public void GetTable_ReturnSameValue_WithSetValue() // Assert Assert.Equal(expectedTable, tableDataSourceItem.Table); + Assert.Equal(expectedTable, tableDataSourceItem.Properties.GetValue("Table")); + } + + [Fact] + public void GetCustomQuery_ReturnSameValue_WithSetValue() + { + // Arrange + var title = "Title"; + var dataSource = new DataSource(); + var mock = new Mock(title, dataSource); + var tableDataSourceItem = mock.Object; + var expectedCustomQuery = "Select FieldA, FieldB from SampleTable;"; + + // Act + tableDataSourceItem.CustomQuery = expectedCustomQuery; + + // Assert + Assert.Equal(expectedCustomQuery, tableDataSourceItem.CustomQuery); + Assert.Equal(expectedCustomQuery, tableDataSourceItem.Parameters.GetValue("RPCustomQuery")); } } } diff --git a/src/Reveal.Sdk.Dom/Data/DataSources/SnowflakeDataSource.cs b/src/Reveal.Sdk.Dom/Data/DataSources/SnowflakeDataSource.cs index a9679506..b2857916 100644 --- a/src/Reveal.Sdk.Dom/Data/DataSources/SnowflakeDataSource.cs +++ b/src/Reveal.Sdk.Dom/Data/DataSources/SnowflakeDataSource.cs @@ -3,7 +3,7 @@ namespace Reveal.Sdk.Dom.Data { - public class SnowflakeDataSource : ProcessDataSource + public class SnowflakeDataSource : SchemaDataSource { public SnowflakeDataSource() { diff --git a/src/Reveal.Sdk.Dom/Data/TableDataSourceItem.cs b/src/Reveal.Sdk.Dom/Data/TableDataSourceItem.cs index c7f5ab61..4505a039 100644 --- a/src/Reveal.Sdk.Dom/Data/TableDataSourceItem.cs +++ b/src/Reveal.Sdk.Dom/Data/TableDataSourceItem.cs @@ -15,5 +15,12 @@ public string Table get => Properties.GetValue("Table"); set => Properties.SetItem("Table", value); } + + [JsonIgnore] + public string CustomQuery + { + get => Parameters.GetValue("RPCustomQuery"); + set => Parameters.SetItem("RPCustomQuery", value); + } } } From d38fa39beb75d113bcda87e8a6cbc72f1dcdf869 Mon Sep 17 00:00:00 2001 From: Viktor Date: Mon, 9 Dec 2024 14:14:32 +0700 Subject: [PATCH 02/12] Update Azure sql data source / data source item --- ...softAzureSqlServerDataSourceItemFixture.cs | 48 +++++++++++++++---- ...icrosoftAzureSqlServerDataSourceFixture.cs | 7 +-- .../MicrosoftAzureSqlServerDataSourceItem.cs | 15 +++++- .../MicrosoftAzureSqlServerDataSource.cs | 2 +- 4 files changed, 55 insertions(+), 17 deletions(-) diff --git a/src/Reveal.Sdk.Dom.Tests/Data/DataSourceItems/MicrosoftAzureSqlServerDataSourceItemFixture.cs b/src/Reveal.Sdk.Dom.Tests/Data/DataSourceItems/MicrosoftAzureSqlServerDataSourceItemFixture.cs index d8efdb23..5ee572e7 100644 --- a/src/Reveal.Sdk.Dom.Tests/Data/DataSourceItems/MicrosoftAzureSqlServerDataSourceItemFixture.cs +++ b/src/Reveal.Sdk.Dom.Tests/Data/DataSourceItems/MicrosoftAzureSqlServerDataSourceItemFixture.cs @@ -1,9 +1,4 @@ using Reveal.Sdk.Dom.Data; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using Xunit; namespace Reveal.Sdk.Dom.Tests.Data.DataSourceItems @@ -13,7 +8,7 @@ public class MicrosoftAzureSqlServerDataSourceItemFixture [Theory] [InlineData("DS Title", "DS Item Title", "DS Title", "DS Item Title")] [InlineData(null, "DS Item Title", "DS Item Title", "DS Item Title")] - public void Constructor_SetsTitleAndDatasource_AsProvided(string dSTitle, string dSItemTitle, string expectedDSTitle, string expectedDSItemTitle) + public void Constructor_CreateDSItemWithExpectedFields_WithTitleAndMSAzureSqlServerDataSource(string dSTitle, string dSItemTitle, string expectedDSTitle, string expectedDSItemTitle) { // Arrange var dataSource = new MicrosoftAzureSqlServerDataSource() { Title = dSTitle }; @@ -23,11 +18,46 @@ public void Constructor_SetsTitleAndDatasource_AsProvided(string dSTitle, string // Assert Assert.Equal(expectedDSItemTitle, dataSourceItem.Title); - Assert.Equal(dataSource, dataSourceItem.DataSource); + Assert.Equal(dataSource.Id, dataSourceItem.DataSource.Id); Assert.Equal(dataSource.Id, dataSourceItem.DataSourceId); Assert.Equal(expectedDSTitle, dataSourceItem.DataSource.Title); - Assert.Equal(dSItemTitle, dataSourceItem.Title); - Assert.Equal(dataSource, dataSourceItem.DataSource); + Assert.Same(dataSource, dataSourceItem.DataSource); + } + + [Fact] + public void Constructor_CreateDSItemWithExpectedFields_WithTitle() + { + // Arrange + var expectedDSItemTitle = "Azure SQL DS Item title"; + + // Act + var dataSourceItem = new MicrosoftAzureSqlServerDataSourceItem(expectedDSItemTitle); + + // Assert + Assert.Equal(expectedDSItemTitle, dataSourceItem.Title); + Assert.NotNull(dataSourceItem.DataSource); + Assert.IsType(dataSourceItem.DataSource); + Assert.Equal(expectedDSItemTitle, dataSourceItem.DataSource.Title); + } + + [Theory] + [InlineData("DS Title", "DS Item Title", "DS Title", "DS Item Title")] + [InlineData(null, "DS Item Title", "DS Item Title", "DS Item Title")] + public void Constructor_CreateDSItemWithExpectedFields_WithTitleAndDataSource(string dSTitle, string dSItemTitle, string expectedDSTitle, string expectedDSItemTitle) + { + // Arrange + var dataSource = new DataSource () { Title = dSTitle }; + + // Act + var dataSourceItem = new MicrosoftAzureSqlServerDataSourceItem(dSItemTitle, dataSource); + + // Assert + Assert.Equal(expectedDSItemTitle, dataSourceItem.Title); + Assert.Equal(dataSource.Id, dataSourceItem.DataSource.Id); + Assert.Equal(dataSource.Id, dataSourceItem.DataSourceId); + Assert.Equal(expectedDSTitle, dataSourceItem.DataSource.Title); + Assert.NotSame(dataSource, dataSourceItem.DataSource); + Assert.IsType(dataSourceItem.DataSource); } } } diff --git a/src/Reveal.Sdk.Dom.Tests/Data/DataSources/MicrosoftAzureSqlServerDataSourceFixture.cs b/src/Reveal.Sdk.Dom.Tests/Data/DataSources/MicrosoftAzureSqlServerDataSourceFixture.cs index 75e3f4d0..e700e89d 100644 --- a/src/Reveal.Sdk.Dom.Tests/Data/DataSources/MicrosoftAzureSqlServerDataSourceFixture.cs +++ b/src/Reveal.Sdk.Dom.Tests/Data/DataSources/MicrosoftAzureSqlServerDataSourceFixture.cs @@ -1,10 +1,5 @@ using Reveal.Sdk.Dom.Core.Extensions; using Reveal.Sdk.Dom.Data; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using Xunit; namespace Reveal.Sdk.Dom.Tests.Data.DataSources @@ -22,7 +17,7 @@ public void Constructor_SetProviderToMicrosoftAzureSqlServer_WhenConstructed() } [Fact] - public void TrustServerCertificate_SaveValueAndProperties_WhenSet() + public void GetTrustServerCertificate_ReturnSameValue_WhenSet() { // Arrange var dataSource = new MicrosoftAzureSqlServerDataSource(); diff --git a/src/Reveal.Sdk.Dom/Data/DataSourceItems/MicrosoftAzureSqlServerDataSourceItem.cs b/src/Reveal.Sdk.Dom/Data/DataSourceItems/MicrosoftAzureSqlServerDataSourceItem.cs index e9e8a927..d242c6eb 100644 --- a/src/Reveal.Sdk.Dom/Data/DataSourceItems/MicrosoftAzureSqlServerDataSourceItem.cs +++ b/src/Reveal.Sdk.Dom/Data/DataSourceItems/MicrosoftAzureSqlServerDataSourceItem.cs @@ -1,9 +1,22 @@ namespace Reveal.Sdk.Dom.Data { - internal class MicrosoftAzureSqlServerDataSourceItem : MicrosoftSqlServerDataSourceItem + public class MicrosoftAzureSqlServerDataSourceItem : MicrosoftSqlServerDataSourceItem { public MicrosoftAzureSqlServerDataSourceItem(string title, DataSource dataSource) : base(title, dataSource) { } + + public MicrosoftAzureSqlServerDataSourceItem(string title, MicrosoftAzureSqlServerDataSource dataSource) : + base(title, dataSource) + { } + + public MicrosoftAzureSqlServerDataSourceItem(string title) : + base(title, new MicrosoftAzureSqlServerDataSource()) + { } + + protected override DataSource CreateDataSourceInstance(DataSource dataSource) + { + return Create(dataSource); + } } } diff --git a/src/Reveal.Sdk.Dom/Data/DataSources/MicrosoftAzureSqlServerDataSource.cs b/src/Reveal.Sdk.Dom/Data/DataSources/MicrosoftAzureSqlServerDataSource.cs index 2c3d45d2..b94126f8 100644 --- a/src/Reveal.Sdk.Dom/Data/DataSources/MicrosoftAzureSqlServerDataSource.cs +++ b/src/Reveal.Sdk.Dom/Data/DataSources/MicrosoftAzureSqlServerDataSource.cs @@ -3,7 +3,7 @@ namespace Reveal.Sdk.Dom.Data { - internal class MicrosoftAzureSqlServerDataSource : MicrosoftSqlServerDataSource + public class MicrosoftAzureSqlServerDataSource : MicrosoftSqlServerDataSource { public MicrosoftAzureSqlServerDataSource() { From 0cc8f896e2f923d2f5039d6fef97a6bdd258ecb4 Mon Sep 17 00:00:00 2001 From: Viktor Date: Tue, 10 Dec 2024 14:46:00 +0700 Subject: [PATCH 03/12] Remove CustomQuery field --- .../DashboardCreators/SnowFlakeDashboard.cs | 6 ------ .../SnowflakeDataSourceItemFixture.cs | 5 +---- .../Data/TableDataSourceltemFixture.cs | 18 ------------------ src/Reveal.Sdk.Dom/Data/TableDataSourceItem.cs | 6 ------ 4 files changed, 1 insertion(+), 34 deletions(-) diff --git a/e2e/Sandbox/DashboardCreators/SnowFlakeDashboard.cs b/e2e/Sandbox/DashboardCreators/SnowFlakeDashboard.cs index 4c53e9fd..797bb736 100644 --- a/e2e/Sandbox/DashboardCreators/SnowFlakeDashboard.cs +++ b/e2e/Sandbox/DashboardCreators/SnowFlakeDashboard.cs @@ -2,11 +2,7 @@ using Reveal.Sdk.Dom.Data; using Reveal.Sdk.Dom.Visualizations; using Sandbox.DashboardFactories; -using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Sandbox.DashboardCreators { @@ -25,7 +21,6 @@ public RdashDocument CreateDashboard() DefaultRefreshRate = "120", Host = "gpiskyj-al16914.snowflakecomputing.com", Database = "SNOWFLAKE_SAMPLE_DATA", - //Role Warehouse = "COMPUTE_WH", Schema = "TPCDS_SF100TCL" }; @@ -35,7 +30,6 @@ public RdashDocument CreateDashboard() Id = "SnowflakeDSItemId", Title = "Snowflake data source Item", Subtitle = "Snowflake data source Item Subtitle", - CustomQuery = "Select O_ORDERKEY, O_ORDERPRIORITY, O_CUSTKEY from ORDERS", Schema = "TPCH_SF10", Table = "ORDERS", Database = "SNOWFLAKE_SAMPLE_DATA", diff --git a/src/Reveal.Sdk.Dom.Tests/Data/DataSourceItems/SnowflakeDataSourceItemFixture.cs b/src/Reveal.Sdk.Dom.Tests/Data/DataSourceItems/SnowflakeDataSourceItemFixture.cs index 971d0d0c..617074f5 100644 --- a/src/Reveal.Sdk.Dom.Tests/Data/DataSourceItems/SnowflakeDataSourceItemFixture.cs +++ b/src/Reveal.Sdk.Dom.Tests/Data/DataSourceItems/SnowflakeDataSourceItemFixture.cs @@ -81,9 +81,7 @@ public void ToJsonString_CreatesFormattedJson_NoConditions() ""Table"": ""CALL_CENTER"", ""Schema"": ""TPCDS_SF100TCL"" }, - ""Parameters"": { - ""RPCustomQuery"": ""Select CC_CALL_CENTER_ID, CC_CALL_CENTER_SK from CALL_CENTER"" - } + ""Parameters"": {} }"; var dataSource = new SnowflakeDataSource() @@ -98,7 +96,6 @@ public void ToJsonString_CreatesFormattedJson_NoConditions() ProcessDataOnServer = true, Table = "CALL_CENTER", Schema = "TPCDS_SF100TCL", - CustomQuery = "Select CC_CALL_CENTER_ID, CC_CALL_CENTER_SK from CALL_CENTER", }; var expectedJObject = JObject.Parse(expectedJson); diff --git a/src/Reveal.Sdk.Dom.Tests/Data/TableDataSourceltemFixture.cs b/src/Reveal.Sdk.Dom.Tests/Data/TableDataSourceltemFixture.cs index e4c42087..75654770 100644 --- a/src/Reveal.Sdk.Dom.Tests/Data/TableDataSourceltemFixture.cs +++ b/src/Reveal.Sdk.Dom.Tests/Data/TableDataSourceltemFixture.cs @@ -42,23 +42,5 @@ public void GetTable_ReturnSameValue_WithSetValue() Assert.Equal(expectedTable, tableDataSourceItem.Table); Assert.Equal(expectedTable, tableDataSourceItem.Properties.GetValue("Table")); } - - [Fact] - public void GetCustomQuery_ReturnSameValue_WithSetValue() - { - // Arrange - var title = "Title"; - var dataSource = new DataSource(); - var mock = new Mock(title, dataSource); - var tableDataSourceItem = mock.Object; - var expectedCustomQuery = "Select FieldA, FieldB from SampleTable;"; - - // Act - tableDataSourceItem.CustomQuery = expectedCustomQuery; - - // Assert - Assert.Equal(expectedCustomQuery, tableDataSourceItem.CustomQuery); - Assert.Equal(expectedCustomQuery, tableDataSourceItem.Parameters.GetValue("RPCustomQuery")); - } } } diff --git a/src/Reveal.Sdk.Dom/Data/TableDataSourceItem.cs b/src/Reveal.Sdk.Dom/Data/TableDataSourceItem.cs index 4505a039..63879125 100644 --- a/src/Reveal.Sdk.Dom/Data/TableDataSourceItem.cs +++ b/src/Reveal.Sdk.Dom/Data/TableDataSourceItem.cs @@ -16,11 +16,5 @@ public string Table set => Properties.SetItem("Table", value); } - [JsonIgnore] - public string CustomQuery - { - get => Parameters.GetValue("RPCustomQuery"); - set => Parameters.SetItem("RPCustomQuery", value); - } } } From e6afff28f7668197e63ffe71c73845db0bc3ca84 Mon Sep 17 00:00:00 2001 From: Viktor Date: Tue, 10 Dec 2024 15:01:04 +0700 Subject: [PATCH 04/12] Update namespace name --- e2e/Sandbox/DashboardCreators/SnowFlakeDashboard.cs | 5 ++--- e2e/Sandbox/MainWindow.xaml.cs | 3 +-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/e2e/Sandbox/DashboardCreators/SnowFlakeDashboard.cs b/e2e/Sandbox/DashboardCreators/SnowFlakeDashboard.cs index 797bb736..a54c8b70 100644 --- a/e2e/Sandbox/DashboardCreators/SnowFlakeDashboard.cs +++ b/e2e/Sandbox/DashboardCreators/SnowFlakeDashboard.cs @@ -1,14 +1,13 @@ using Reveal.Sdk.Dom; using Reveal.Sdk.Dom.Data; using Reveal.Sdk.Dom.Visualizations; -using Sandbox.DashboardFactories; using System.Collections.Generic; -namespace Sandbox.DashboardCreators +namespace Sandbox.DashboardFactories { internal class SnowflakeDashboard : IDashboardCreator { - public string Name => "Snowflake Dashboard"; + public string Name => "Snowflake Data Source"; public RdashDocument CreateDashboard() { diff --git a/e2e/Sandbox/MainWindow.xaml.cs b/e2e/Sandbox/MainWindow.xaml.cs index b1f73518..785a7055 100644 --- a/e2e/Sandbox/MainWindow.xaml.cs +++ b/e2e/Sandbox/MainWindow.xaml.cs @@ -22,7 +22,6 @@ using Reveal.Sdk.Data.Rest; using Reveal.Sdk.Data.Snowflake; using Reveal.Sdk.Dom; -using Sandbox.DashboardCreators; using Sandbox.DashboardFactories; using Sandbox.RevealSDK; using System; @@ -51,8 +50,8 @@ public partial class MainWindow : Window new MarketingDashboard(), new RestDataSourceDashboard(), new SalesDashboard(), - new SqlServerDataSourceDashboards(), new SnowflakeDashboard(), + new SqlServerDataSourceDashboards(), }; public MainWindow() From 5288c934132c955516e57ae07ece70132ff0f8ce Mon Sep 17 00:00:00 2001 From: Viktor Date: Tue, 10 Dec 2024 15:10:40 +0700 Subject: [PATCH 05/12] Create sandbox example for MS Azure Sql Data Source Item --- .../MSAzureSqlServerDSDashboard.cs | 49 +++++++++++++++++++ e2e/Sandbox/MainWindow.xaml.cs | 2 + e2e/Sandbox/Reveal/AuthenticationProvider.cs | 7 ++- 3 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 e2e/Sandbox/DashboardCreators/MSAzureSqlServerDSDashboard.cs diff --git a/e2e/Sandbox/DashboardCreators/MSAzureSqlServerDSDashboard.cs b/e2e/Sandbox/DashboardCreators/MSAzureSqlServerDSDashboard.cs new file mode 100644 index 00000000..e9865a32 --- /dev/null +++ b/e2e/Sandbox/DashboardCreators/MSAzureSqlServerDSDashboard.cs @@ -0,0 +1,49 @@ +using Reveal.Sdk.Dom; +using Reveal.Sdk.Dom.Data; +using Reveal.Sdk.Dom.Visualizations; +using Sandbox.DashboardFactories; +using System.Collections.Generic; + +namespace Sandbox.DashboardCreators +{ + public class MSAzureSqlServerDSDashboard : IDashboardCreator + { + public string Name => "MS Azure Sql Server"; + + public RdashDocument CreateDashboard() + { + var document = new RdashDocument("MS Azure Sql Dashboard"); + + var msAzureSqlDS = new MicrosoftAzureSqlServerDataSource() + { + Id = "MSAzureSqlId", + Title = "Microsoft Azure Sql Server Data Source", + Subtitle = "MS Azure Sql Server DS Subtitle", + Database = "reveal", + DefaultRefreshRate = "180", + Encrypt = false, + Host = "revealtesting.database.windows.net", + Port = 1433, + TrustServerCertificate = false + }; + + var msAzureSqlDSItem = new MicrosoftAzureSqlServerDataSourceItem("Microsoft Azure Sql Data Source Item", msAzureSqlDS) + { + Id = "MSAzureSqlItemId", + Title = "Microsoft Azure Sql Server Data Source Item", + Subtitle = "MS Azure Sql Server DSI Subtitle", + Table = "Customers", + Fields = new List() + { + new TextField("City"), + new TextField("CustomerID"), + } + }; + + document.Visualizations.Add(new GridVisualization("Customers in France", msAzureSqlDSItem) + .SetColumns("CustomerID", "City")); + + return document; + } + } +} diff --git a/e2e/Sandbox/MainWindow.xaml.cs b/e2e/Sandbox/MainWindow.xaml.cs index 1992d24c..869ae5b2 100644 --- a/e2e/Sandbox/MainWindow.xaml.cs +++ b/e2e/Sandbox/MainWindow.xaml.cs @@ -22,6 +22,7 @@ using Reveal.Sdk.Data.Rest; using Reveal.Sdk.Data.Snowflake; using Reveal.Sdk.Dom; +using Sandbox.DashboardCreators; using Sandbox.DashboardFactories; using Sandbox.RevealSDK; using System; @@ -48,6 +49,7 @@ public partial class MainWindow : Window new HealthcareDashboard(), new ManufacturingDashboard(), new MarketingDashboard(), + new MSAzureSqlServerDSDashboard(), new RestDataSourceDashboard(), new SalesDashboard(), new SqlServerDataSourceDashboards(), diff --git a/e2e/Sandbox/Reveal/AuthenticationProvider.cs b/e2e/Sandbox/Reveal/AuthenticationProvider.cs index 07e9fce2..d7cbc4af 100644 --- a/e2e/Sandbox/Reveal/AuthenticationProvider.cs +++ b/e2e/Sandbox/Reveal/AuthenticationProvider.cs @@ -10,7 +10,11 @@ internal class AuthenticationProvider : IRVAuthenticationProvider public Task ResolveCredentialsAsync(RVDashboardDataSource dataSource) { IRVDataSourceCredential userCredential = null; - if (dataSource is RVSqlServerDataSource) + if (dataSource is RVAzureSqlDataSource) + { + userCredential = new RVUsernamePasswordDataSourceCredential("azure-username", "password"); + } + else if (dataSource is RVSqlServerDataSource) { userCredential = new RVUsernamePasswordDataSourceCredential(); } @@ -18,6 +22,7 @@ public Task ResolveCredentialsAsync(RVDashboardDataSour { userCredential = new RVUsernamePasswordDataSourceCredential("username", "password", "domain"); } + return Task.FromResult(userCredential); } } From 0a819120ed0293e71e177c28beb66d282a17a140 Mon Sep 17 00:00:00 2001 From: Viktor Date: Mon, 9 Dec 2024 15:37:28 +0700 Subject: [PATCH 06/12] Update namspace for auzre sql example --- e2e/Sandbox/DashboardCreators/MSAzureSqlServerDSDashboard.cs | 3 +-- e2e/Sandbox/MainWindow.xaml.cs | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/e2e/Sandbox/DashboardCreators/MSAzureSqlServerDSDashboard.cs b/e2e/Sandbox/DashboardCreators/MSAzureSqlServerDSDashboard.cs index e9865a32..cd6cb8db 100644 --- a/e2e/Sandbox/DashboardCreators/MSAzureSqlServerDSDashboard.cs +++ b/e2e/Sandbox/DashboardCreators/MSAzureSqlServerDSDashboard.cs @@ -1,10 +1,9 @@ using Reveal.Sdk.Dom; using Reveal.Sdk.Dom.Data; using Reveal.Sdk.Dom.Visualizations; -using Sandbox.DashboardFactories; using System.Collections.Generic; -namespace Sandbox.DashboardCreators +namespace Sandbox.DashboardFactories { public class MSAzureSqlServerDSDashboard : IDashboardCreator { diff --git a/e2e/Sandbox/MainWindow.xaml.cs b/e2e/Sandbox/MainWindow.xaml.cs index 869ae5b2..1a288b18 100644 --- a/e2e/Sandbox/MainWindow.xaml.cs +++ b/e2e/Sandbox/MainWindow.xaml.cs @@ -22,7 +22,6 @@ using Reveal.Sdk.Data.Rest; using Reveal.Sdk.Data.Snowflake; using Reveal.Sdk.Dom; -using Sandbox.DashboardCreators; using Sandbox.DashboardFactories; using Sandbox.RevealSDK; using System; From 597afb79085b0010b2a12fd8bee648b9b77ad984 Mon Sep 17 00:00:00 2001 From: Viktor Date: Mon, 9 Dec 2024 16:43:15 +0700 Subject: [PATCH 07/12] Add unit tests for to JSON string --- ...softAzureSqlServerDataSourceItemFixture.cs | 47 ++++++++++++++++- ...icrosoftAzureSqlServerDataSourceFixture.cs | 51 ++++++++++++++++++- 2 files changed, 96 insertions(+), 2 deletions(-) diff --git a/src/Reveal.Sdk.Dom.Tests/Data/DataSourceItems/MicrosoftAzureSqlServerDataSourceItemFixture.cs b/src/Reveal.Sdk.Dom.Tests/Data/DataSourceItems/MicrosoftAzureSqlServerDataSourceItemFixture.cs index 5ee572e7..555717ae 100644 --- a/src/Reveal.Sdk.Dom.Tests/Data/DataSourceItems/MicrosoftAzureSqlServerDataSourceItemFixture.cs +++ b/src/Reveal.Sdk.Dom.Tests/Data/DataSourceItems/MicrosoftAzureSqlServerDataSourceItemFixture.cs @@ -1,4 +1,5 @@ -using Reveal.Sdk.Dom.Data; +using Newtonsoft.Json.Linq; +using Reveal.Sdk.Dom.Data; using Xunit; namespace Reveal.Sdk.Dom.Tests.Data.DataSourceItems @@ -59,5 +60,49 @@ public void Constructor_CreateDSItemWithExpectedFields_WithTitleAndDataSource(st Assert.NotSame(dataSource, dataSourceItem.DataSource); Assert.IsType(dataSourceItem.DataSource); } + + [Fact] + public void ToJsonString_CreateExpectedRevealJson_NoConditions() + { + // Arrange + var expectedJson = @"{ + ""_type"": ""DataSourceItemType"", + ""Id"": ""azureSqlDsItemId"", + ""Title"": ""Azure SQL DSItem"", + ""Subtitle"": ""Azure SQL DS Item SubTitle"", + ""DataSourceId"": ""azureSqlId"", + ""HasTabularData"": true, + ""HasAsset"": false, + ""Properties"": { + ""ServerAggregation"": true, + ""Database"": ""reveal"", + ""Table"": ""Categories"" + }, + ""Parameters"": {} + }"; + var dataSource = new MicrosoftAzureSqlServerDataSource() + { + Id = "azureSqlId" + }; + var dataSourceItem = new MicrosoftAzureSqlServerDataSourceItem("Azure SQL DSItem", dataSource) + { + Id = "azureSqlDsItemId", + Subtitle = "Azure SQL DS Item SubTitle", + HasTabularData = true, + HasAsset = false, + ProcessDataOnServer = true, + Database = "reveal", + Table = "Categories" + //DefaultRefreshRate = "161" // TODO: Check the DefaultRefreshRate when get Json, after DefaultRefreshRate is moved to Settings field + }; + + // Act + var json = dataSourceItem.ToJsonString(); + var expectedJObject = JObject.Parse(expectedJson); + var actualJObject = JObject.Parse(json); + + // Assert + Assert.Equal(expectedJObject, actualJObject); + } } } diff --git a/src/Reveal.Sdk.Dom.Tests/Data/DataSources/MicrosoftAzureSqlServerDataSourceFixture.cs b/src/Reveal.Sdk.Dom.Tests/Data/DataSources/MicrosoftAzureSqlServerDataSourceFixture.cs index e700e89d..16911a15 100644 --- a/src/Reveal.Sdk.Dom.Tests/Data/DataSources/MicrosoftAzureSqlServerDataSourceFixture.cs +++ b/src/Reveal.Sdk.Dom.Tests/Data/DataSources/MicrosoftAzureSqlServerDataSourceFixture.cs @@ -1,4 +1,5 @@ -using Reveal.Sdk.Dom.Core.Extensions; +using Newtonsoft.Json.Linq; +using Reveal.Sdk.Dom.Core.Extensions; using Reveal.Sdk.Dom.Data; using Xunit; @@ -30,5 +31,53 @@ public void GetTrustServerCertificate_ReturnSameValue_WhenSet() Assert.Equal(trustServerCertificate, dataSource.TrustServerCertificate); Assert.Equal(trustServerCertificate, dataSource.Properties.GetValue("TrustServerCertificate")); } + + [Fact] + public void ToJsonString_CreateExpectedRevealJson_NoConditions() + { + // Arrange + var expectedJson = @"{ + ""_type"": ""DataSourceType"", + ""Id"": ""azureSqlId"", + ""Provider"": ""AZURE_SQL"", + ""Description"": ""Azure SQL DS"", + ""Subtitle"": ""Azure SQL DS Item"", + ""Properties"": { + ""ServerAggregationDefault"": false, + ""ServerAggregationReadOnly"": true, + ""Host"": ""revealtesting.database.windows.net"", + ""Port"": 1433, + ""Database"": ""reveal"", + ""Schema"": ""azureSchema"", + ""TrustServerCertificate"": false, + ""Encrypt"": false + }, + + }"; + var dataSource = new MicrosoftAzureSqlServerDataSource() + { + Id = "azureSqlId", + Title = "Azure SQL DS", + Subtitle = "Azure SQL DS Item", + ProcessDataOnServerDefaultValue = false, + ProcessDataOnServerReadOnly = true, + Host = "revealtesting.database.windows.net", + Port = 1433, + Database = "reveal", + Schema = "azureSchema", + TrustServerCertificate = false, + Encrypt = false, + //DefaultRefreshRate = "161" // TODO: Check the DefaultRefreshRate when get Json, after DefaultRefreshRate is moved to Settings field + }; + + // Act + var json = dataSource.ToJsonString(); + var expectedJObject = JObject.Parse(expectedJson); + var actualJObject = JObject.Parse(json); + + // Assert + Assert.Equal(expectedJObject, actualJObject); + } } } + \ No newline at end of file From 8a08ebeabd047ce57ca7c08507c0bec4561c7786 Mon Sep 17 00:00:00 2001 From: Viktor Date: Tue, 10 Dec 2024 16:40:16 +0700 Subject: [PATCH 08/12] Remvove uneeded changes --- src/Reveal.Sdk.Dom/Data/TableDataSourceItem.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Reveal.Sdk.Dom/Data/TableDataSourceItem.cs b/src/Reveal.Sdk.Dom/Data/TableDataSourceItem.cs index 63879125..c7f5ab61 100644 --- a/src/Reveal.Sdk.Dom/Data/TableDataSourceItem.cs +++ b/src/Reveal.Sdk.Dom/Data/TableDataSourceItem.cs @@ -15,6 +15,5 @@ public string Table get => Properties.GetValue("Table"); set => Properties.SetItem("Table", value); } - } } From 12b0452df21da1a73445b5704dfe73c8094c31e7 Mon Sep 17 00:00:00 2001 From: Viktor Date: Wed, 11 Dec 2024 14:11:52 +0700 Subject: [PATCH 09/12] Fix failed unit tests --- ...softAzureSqlServerDataSourceItemFixture.cs | 3 +- ...icrosoftAzureSqlServerDataSourceFixture.cs | 43 ++++++++++--------- 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/src/Reveal.Sdk.Dom.Tests/Data/DataSourceItems/MicrosoftAzureSqlServerDataSourceItemFixture.cs b/src/Reveal.Sdk.Dom.Tests/Data/DataSourceItems/MicrosoftAzureSqlServerDataSourceItemFixture.cs index 555717ae..abcfdd08 100644 --- a/src/Reveal.Sdk.Dom.Tests/Data/DataSourceItems/MicrosoftAzureSqlServerDataSourceItemFixture.cs +++ b/src/Reveal.Sdk.Dom.Tests/Data/DataSourceItems/MicrosoftAzureSqlServerDataSourceItemFixture.cs @@ -92,8 +92,7 @@ public void ToJsonString_CreateExpectedRevealJson_NoConditions() HasAsset = false, ProcessDataOnServer = true, Database = "reveal", - Table = "Categories" - //DefaultRefreshRate = "161" // TODO: Check the DefaultRefreshRate when get Json, after DefaultRefreshRate is moved to Settings field + Table = "Categories", }; // Act diff --git a/src/Reveal.Sdk.Dom.Tests/Data/DataSources/MicrosoftAzureSqlServerDataSourceFixture.cs b/src/Reveal.Sdk.Dom.Tests/Data/DataSources/MicrosoftAzureSqlServerDataSourceFixture.cs index 16911a15..dd912ec6 100644 --- a/src/Reveal.Sdk.Dom.Tests/Data/DataSources/MicrosoftAzureSqlServerDataSourceFixture.cs +++ b/src/Reveal.Sdk.Dom.Tests/Data/DataSources/MicrosoftAzureSqlServerDataSourceFixture.cs @@ -36,24 +36,28 @@ public void GetTrustServerCertificate_ReturnSameValue_WhenSet() public void ToJsonString_CreateExpectedRevealJson_NoConditions() { // Arrange - var expectedJson = @"{ - ""_type"": ""DataSourceType"", - ""Id"": ""azureSqlId"", - ""Provider"": ""AZURE_SQL"", - ""Description"": ""Azure SQL DS"", - ""Subtitle"": ""Azure SQL DS Item"", - ""Properties"": { - ""ServerAggregationDefault"": false, - ""ServerAggregationReadOnly"": true, - ""Host"": ""revealtesting.database.windows.net"", - ""Port"": 1433, - ""Database"": ""reveal"", - ""Schema"": ""azureSchema"", - ""TrustServerCertificate"": false, - ""Encrypt"": false + var expectedJson = """ + { + "_type": "DataSourceType", + "Id": "azureSqlId", + "Provider": "AZURE_SQL", + "Description": "Azure SQL DS", + "Subtitle": "Azure SQL DS Item", + "Properties": { + "ServerAggregationDefault": false, + "ServerAggregationReadOnly": true, + "Host": "revealtesting.database.windows.net", + "Port": 1433, + "Database": "reveal", + "Schema": "azureSchema", + "TrustServerCertificate": false, + "Encrypt": false }, - - }"; + "Settings": { + "DefaultRefreshRate": 180 + } + } + """; var dataSource = new MicrosoftAzureSqlServerDataSource() { Id = "azureSqlId", @@ -67,7 +71,7 @@ public void ToJsonString_CreateExpectedRevealJson_NoConditions() Schema = "azureSchema", TrustServerCertificate = false, Encrypt = false, - //DefaultRefreshRate = "161" // TODO: Check the DefaultRefreshRate when get Json, after DefaultRefreshRate is moved to Settings field + DefaultRefreshRate = "180" }; // Act @@ -79,5 +83,4 @@ public void ToJsonString_CreateExpectedRevealJson_NoConditions() Assert.Equal(expectedJObject, actualJObject); } } -} - \ No newline at end of file +} From 8b92aff8ef8568ade53aafe9d134bea092002ff2 Mon Sep 17 00:00:00 2001 From: Viktor Date: Wed, 11 Dec 2024 14:32:05 +0700 Subject: [PATCH 10/12] Fix failed unit tests --- .../SnowflakeDataSourceItemFixture.cs | 31 +++++++-------- .../DataSources/SnowflakeDataSourceFixture.cs | 39 ++++++++++--------- 2 files changed, 36 insertions(+), 34 deletions(-) diff --git a/src/Reveal.Sdk.Dom.Tests/Data/DataSourceItems/SnowflakeDataSourceItemFixture.cs b/src/Reveal.Sdk.Dom.Tests/Data/DataSourceItems/SnowflakeDataSourceItemFixture.cs index 617074f5..9763900d 100644 --- a/src/Reveal.Sdk.Dom.Tests/Data/DataSourceItems/SnowflakeDataSourceItemFixture.cs +++ b/src/Reveal.Sdk.Dom.Tests/Data/DataSourceItems/SnowflakeDataSourceItemFixture.cs @@ -69,21 +69,22 @@ public void GetProcessDataOnServer_ReturnSameValue_AfterSet() public void ToJsonString_CreatesFormattedJson_NoConditions() { // Arrange - var expectedJson = @"{ - ""_type"": ""DataSourceItemType"", - ""Id"": ""a60ab508-0ed4-46e4-8d90-c3a9c09c29b8"", - ""Title"": ""SnowFlake DSI"", - ""DataSourceId"": ""snowflake_ds"", - ""HasTabularData"": true, - ""HasAsset"": false, - ""Properties"": { - ""ServerAggregation"": true, - ""Table"": ""CALL_CENTER"", - ""Schema"": ""TPCDS_SF100TCL"" + var expectedJson = """ + { + "_type": "DataSourceItemType", + "Id": "a60ab508-0ed4-46e4-8d90-c3a9c09c29b8", + "Title": "SnowFlake DSI", + "DataSourceId": "snowflake_ds", + "HasTabularData": true, + "HasAsset": false, + "Properties": { + "ServerAggregation": true, + "Table": "CALL_CENTER", + "Schema": "TPCDS_SF100TCL" }, - ""Parameters"": {} - }"; - + "Parameters": {} + } + """; var dataSource = new SnowflakeDataSource() { Id = "snowflake_ds", @@ -97,7 +98,6 @@ public void ToJsonString_CreatesFormattedJson_NoConditions() Table = "CALL_CENTER", Schema = "TPCDS_SF100TCL", }; - var expectedJObject = JObject.Parse(expectedJson); // Act @@ -106,7 +106,6 @@ public void ToJsonString_CreatesFormattedJson_NoConditions() // Assert Assert.Equal(expectedJObject, actualJObject); - } } } diff --git a/src/Reveal.Sdk.Dom.Tests/Data/DataSources/SnowflakeDataSourceFixture.cs b/src/Reveal.Sdk.Dom.Tests/Data/DataSources/SnowflakeDataSourceFixture.cs index ff934fcd..4680fd0a 100644 --- a/src/Reveal.Sdk.Dom.Tests/Data/DataSources/SnowflakeDataSourceFixture.cs +++ b/src/Reveal.Sdk.Dom.Tests/Data/DataSources/SnowflakeDataSourceFixture.cs @@ -69,24 +69,27 @@ public void SetWarehouse_ReturnSameValue_AfterSetWarehouse(string warehouse) public void ToJsonString_CreatesFormattedJson_NoConditions() { // Arrange - var expectedJson = @"{ - ""_type"": ""DataSourceType"", - ""Id"": ""snowflake_ds"", - ""Provider"": ""SNOWFLAKE"", - ""Description"": ""Snowflake TEST"", - ""Subtitle"": ""Snowflake TEST Subtitle"", - ""Properties"": { - ""ServerAggregationDefault"": true, - ""ServerAggregationReadOnly"": false, - ""Host"": ""gpiskyj-al16914.snowflakecomputing.com"", - ""Database"": ""SNOWFLAKE_SAMPLE_DATA"", - ""Account"": ""pqwkobs-xb90908"", - ""Warehouse"": ""COMPUTE_WH"", - ""Schema"": ""TPCDS_SF100TCL"" + var expectedJson = """ + { + "_type": "DataSourceType", + "Id": "snowflake_ds", + "Provider": "SNOWFLAKE", + "Description": "Snowflake TEST", + "Subtitle": "Snowflake TEST Subtitle", + "Properties": { + "ServerAggregationDefault": true, + "ServerAggregationReadOnly": false, + "Host": "gpiskyj-al16914.snowflakecomputing.com", + "Database": "SNOWFLAKE_SAMPLE_DATA", + "Account": "pqwkobs-xb90908", + "Warehouse": "COMPUTE_WH", + "Schema": "TPCDS_SF100TCL" }, - //""Settings"": {} // TODO: Update to check settings fields after Postgresql PR is merged - }"; - + "Settings": { + "DefaultRefreshRate": 180 + } + } + """; var dataSource = new SnowflakeDataSource() { Id = "snowflake_ds", @@ -99,6 +102,7 @@ public void ToJsonString_CreatesFormattedJson_NoConditions() Account = "pqwkobs-xb90908", Warehouse = "COMPUTE_WH", Schema = "TPCDS_SF100TCL", + DefaultRefreshRate = "180" }; var expectedJObject = JObject.Parse(expectedJson); @@ -108,7 +112,6 @@ public void ToJsonString_CreatesFormattedJson_NoConditions() // Assert Assert.Equal(expectedJObject, actualJObject); - } } } From 65096190ad173705ea9bb06dda20c9cc408be1ce Mon Sep 17 00:00:00 2001 From: Viktor Date: Wed, 11 Dec 2024 16:30:06 +0700 Subject: [PATCH 11/12] Keep sandbox example class internal --- e2e/Sandbox/DashboardCreators/MSAzureSqlServerDSDashboard.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/Sandbox/DashboardCreators/MSAzureSqlServerDSDashboard.cs b/e2e/Sandbox/DashboardCreators/MSAzureSqlServerDSDashboard.cs index cd6cb8db..b94cafa6 100644 --- a/e2e/Sandbox/DashboardCreators/MSAzureSqlServerDSDashboard.cs +++ b/e2e/Sandbox/DashboardCreators/MSAzureSqlServerDSDashboard.cs @@ -5,7 +5,7 @@ namespace Sandbox.DashboardFactories { - public class MSAzureSqlServerDSDashboard : IDashboardCreator + internal class MSAzureSqlServerDSDashboard : IDashboardCreator { public string Name => "MS Azure Sql Server"; From 202d428c7f581d5b4afa42e3b65c789937b9700e Mon Sep 17 00:00:00 2001 From: Brian Lagunas <835562+brianlagunas@users.noreply.github.com> Date: Wed, 11 Dec 2024 14:36:48 -0700 Subject: [PATCH 12/12] added default value to AutomaticLabelRotation --- .../Visualizations/Settings/SharedChartVisualizationSettings.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Reveal.Sdk.Dom/Visualizations/Settings/SharedChartVisualizationSettings.cs b/src/Reveal.Sdk.Dom/Visualizations/Settings/SharedChartVisualizationSettings.cs index 35f1240a..70b18b2a 100644 --- a/src/Reveal.Sdk.Dom/Visualizations/Settings/SharedChartVisualizationSettings.cs +++ b/src/Reveal.Sdk.Dom/Visualizations/Settings/SharedChartVisualizationSettings.cs @@ -12,7 +12,7 @@ protected SharedChartVisualizationSettings() : base() { } /// /// Gets or sets a value that determines if the chart will automatcially rotate labels /// - public bool AutomaticLabelRotation { get; set; } + public bool AutomaticLabelRotation { get; set; } = true; /// /// Gets or sets a values that will sync the axis to the visible range.