示例#1
0
        public async Task WhenGettingTheServerElasticubes_ShouldReturnThemWithTheCorrectInformation()
        {
            // Arrange
            IHttpClient    httpClient    = new FakeHttpClient(responseMessageToReturn: CreateResponse());
            IAuthenticator authenticator = new FakeAuthenticator();
            var            service       = new ElastiCubesService("", httpClient, authenticator);

            // Act
            var result = await service.GetElastiCubesByServerAsync("myserver");

            // Assert
            Assert.Equal(2, result.Count());
            Assert.Equal("9ef5aa670a32e20ae046c83f", result.First().Id);
            Assert.Equal(DateTimeOffset.FromUnixTimeMilliseconds(1491905885118), result.First().CreatedUtc);
            Assert.Equal("clients", result.First().DatabaseName);
            Assert.Equal(DateTimeOffset.FromUnixTimeMilliseconds(1525312805480), result.First().LastBuiltUtc);
            Assert.Equal(1, result.First().PermissionsSummary);
            Assert.Equal(2.3436, result.First().SizeInMb);
            Assert.Equal(ElastiCubeStatus.Stopped, result.First().Status);
            Assert.Equal("clients", result.First().Title);
            Assert.Null(result.First().Error);

            Assert.False(result.First().Shares.First().BelongsToEveryoneGroup);
            Assert.Equal("5422c7343cd8fa3410000001", result.First().Shares.First().PartyId);
            Assert.Equal("w", result.First().Shares.First().Permission);
            Assert.Equal("user", result.First().Shares.First().Type);
        }
示例#2
0
 public SisenseClient(string serverUrl, IAuthenticator authenticator, IHttpClient httpClient)
 {
     authenticator.ServerUrl = serverUrl;
     Authentication          = new AuthenticationService(serverUrl, httpClient, authenticator);
     ElastiCubes             = new ElastiCubesService(serverUrl, httpClient, authenticator);
     JaqlRunnerService       = new JaqlRunnerService(serverUrl, httpClient, authenticator);
     SqlRunnerService        = new SqlRunnerService(serverUrl, httpClient, authenticator);
     ApplicationService      = new ApplicationService(serverUrl, httpClient, authenticator);
 }
        public async Task WhenGettingABuildRevision_ShouldReturnTheCorrectInformation()
        {
            // Arrange
            IHttpClient    httpClient    = new FakeHttpClient(responseMessageToReturn: CreateResponse());
            IAuthenticator authenticator = new FakeAuthenticator();
            var            service       = new ElastiCubesService("", httpClient, authenticator);

            // Act
            var result = await service.GetBuildRevisionAsync("localhost", "mycube");

            // Assert
            Assert.Equal("fece84e9-dd78-4ac8-d8b7-fac83fad9a6d", result);
        }
        public async Task WhenThereIsNoConnectivity_ShouldReturnFalse()
        {
            // Arrange
            IHttpClient    httpClient    = new FakeHttpClient(responseMessageToReturn: CreateResponse("false"));
            IAuthenticator authenticator = new FakeAuthenticator();
            var            service       = new ElastiCubesService("", httpClient, authenticator);

            // Act
            var result = await service.VerifyConnectivityWithRServerAsync("localhost", "rserver");

            // Assert
            Assert.False(result.Test);
        }
示例#5
0
        public async Task WhenGettingACustomTable_ShouldReturnItWithTheCorrectInformation()
        {
            // Arrange
            IHttpClient    httpClient    = new FakeHttpClient(responseMessageToReturn: CreateResponse());
            IAuthenticator authenticator = new FakeAuthenticator();
            var            service       = new ElastiCubesService("", httpClient, authenticator);

            // Act
            var result = await service.GetCustomTableAsync("localhost", "mycube", "mytable");

            // Assert
            Assert.Equal("SELECT id, name \nFROM [users]", result.QueryString);
            Assert.Equal("users", result.TableName);
        }
示例#6
0
        public async Task WhenThereIsAnErrorInAServer_ShouldReturnTheErrorMessage()
        {
            // Arrange
            IHttpClient    httpClient    = new FakeHttpClient(responseMessageToReturn: CreateResponseWithError());
            IAuthenticator authenticator = new FakeAuthenticator();
            var            service       = new ElastiCubesService("", httpClient, authenticator);

            // Act
            var result = await service.GetServersElastiCubesAsync();

            // Assert
            Assert.Equal(2, result.Count());
            Assert.Equal("LocalHost", result.First().Address);
            Assert.Equal("Unknown error occurred while attempting to communicate with the server", result.First().ErrorMessage);
        }
        public async Task WhenGettingTheServersStatus_ShouldReturnThemWithTheCorrectInformation()
        {
            // Arrange
            IHttpClient    httpClient    = new FakeHttpClient(responseMessageToReturn: CreateResponse());
            IAuthenticator authenticator = new FakeAuthenticator();
            var            service       = new ElastiCubesService("", httpClient, authenticator);

            // Act
            var result = await service.GetServerStatusAsync("myserver");

            // Assert
            Assert.Equal(2, result.Count());
            Assert.Equal(ElastiCubeStatus.Stopped, result.First().Status);
            Assert.Equal("clients", result.First().Title);
        }
        public async Task WhenGettingTheServersMetadata_ShouldReturnThemWithTheCorrectInformation()
        {
            // Arrange
            IHttpClient    httpClient    = new FakeHttpClient(responseMessageToReturn: CreateResponse());
            IAuthenticator authenticator = new FakeAuthenticator();
            var            service       = new ElastiCubesService("", httpClient, authenticator);

            // Act
            var result = await service.GetServersMetadataAsync();

            // Assert
            Assert.Equal(2, result.Count());
            Assert.Equal("192.168.4", result.First().Address);
            Assert.Equal(1, result.First().PermissionsSummary);
        }
示例#9
0
        public async Task WhenGettingCustomTablesRelations_ShouldReturnThemWithTheCorrectInformation()
        {
            // Arrange
            IHttpClient    httpClient    = new FakeHttpClient(responseMessageToReturn: CreateResponse());
            IAuthenticator authenticator = new FakeAuthenticator();
            var            service       = new ElastiCubesService("", httpClient, authenticator);

            // Act
            var result = await service.GetCustomTableRelationsAsync("localhost", "mycube", "mytable");

            // Assert
            Assert.Equal(3, result.Count());
            Assert.Equal("key", result.First().SourceField);
            Assert.Equal("articlekey", result.First().TargetField);
            Assert.Equal("articles", result.First().TargetTable);
        }
        public async Task WhenGettingTheMetadata_ShouldReturnItWithCorrectInformation()
        {
            // Arrange
            IHttpClient    httpClient    = new FakeHttpClient(responseMessageToReturn: CreateResponse());
            IAuthenticator authenticator = new FakeAuthenticator();
            var            service       = new ElastiCubesService("", httpClient, authenticator);

            // Act
            var result = await service.GetElastiCubeMetadataAsync("mycube");

            // Assert
            Assert.Equal("mycube1", result.Title);
            Assert.Equal("127.0.0.1/mycube1", result.FullName);
            Assert.Equal("a10LgAa0LgAa20LgAa9_amycube1", result.Id);
            Assert.Equal("amycube1", result.Database);
            Assert.Equal("My Cube Set", result.ElastiCubeSet);
        }
示例#11
0
        public async Task WhenGettingThePermissions_ShouldReturnThemWithTheCorrectInformation()
        {
            // Arrange
            IHttpClient    httpClient    = new FakeHttpClient(responseMessageToReturn: CreateResponse());
            IAuthenticator authenticator = new FakeAuthenticator();
            var            service       = new ElastiCubesService("", httpClient, authenticator);

            // Act
            var result = await service.GetElastiCubePermissionsAsync("myserver", "mycube");

            // Assert
            Assert.Equal("7cf5ab680a32e20ae046c899", result.Id);
            Assert.Equal("myserver", result.Server);
            Assert.Equal("mycube", result.Title);
            Assert.Equal("56a2c7343eb8fa3410000001", result.Creator);
            Assert.Equal(2, result.Shares.Count());
            Assert.Equal("5422c7343cd8fa3410000009", result.Shares.First().PartyId);
            Assert.Equal("user", result.Shares.First().Type);
            Assert.Equal("w", result.Shares.First().Permission);
        }
        public async Task WhenGettingTheServerSettings_ShouldReturnTheCorrectInformation()
        {
            // Arrange
            IHttpClient    httpClient    = new FakeHttpClient(responseMessageToReturn: CreateResponse());
            IAuthenticator authenticator = new FakeAuthenticator();
            var            service       = new ElastiCubesService("", httpClient, authenticator);

            // Act
            var result = await service.GetServerSettingsAsync("localhost");

            // Assert
            Assert.Equal(100000, result.DataImportChunkSize);
            Assert.Equal("F:\\Sisense\\PrismServer\\ElastiCubeData", result.DefaultServerDataFolder);
            Assert.Equal(100, result.ElasticubeMemoryAllocation);
            Assert.Equal(16, result.ProcessorCount);
            Assert.Equal(300, result.QueryTimeout);
            Assert.True(result.RecycleQueries);
            Assert.Equal("127.0.0.1:6311", result.RServer);
            Assert.False(result.RServerEnabled);
            Assert.Equal(8, result.SimultaneousQueryExecutions);
        }
        public async Task WhenGettingASet_ShouldReturnTheCorrectInformation()
        {
            // Arrange
            IHttpClient    httpClient    = new FakeHttpClient(responseMessageToReturn: CreateResponse());
            IAuthenticator authenticator = new FakeAuthenticator();
            var            service       = new ElastiCubesService("", httpClient, authenticator);

            // Act
            var result = await service.GetSetAsync("");

            // Assert
            Assert.Equal("693da0c2fa54e82c0d000789", result.Id);
            Assert.Equal("127.0.0.1/cube", result.FullNames.First());
            Assert.Equal("Majority", result.RoutingMode);
            Assert.Equal("My Set", result.Title);
            Assert.Equal("1232c7345cd8fa3410000001", result.Creator);
            Assert.Equal("1232c7345cd8fa3410000001", result.Shares.First().PartyId);
            Assert.Equal("user", result.Shares.First().Type);
            Assert.Equal("w", result.Shares.First().Permission);
            Assert.Equal("None", result.Failover);
        }
示例#14
0
        public async Task WhenGettingTheServersCubes_ShouldReturnTheCorrectInformation()
        {
            // Arrange
            IHttpClient    httpClient    = new FakeHttpClient(responseMessageToReturn: CreateResponse());
            IAuthenticator authenticator = new FakeAuthenticator();
            var            service       = new ElastiCubesService("", httpClient, authenticator);

            // Act
            var result = await service.GetServersElastiCubesAsync();

            // Assert
            Assert.Equal(2, result.Count());
            Assert.Equal("127.0.0.1", result.First().Address);
            Assert.Equal(DateTimeOffset.FromUnixTimeMilliseconds(1434368184275), result.First().Cubes.First().CreatedUtc);
            Assert.Equal("clients", result.First().Cubes.First().DatabaseName);
            Assert.Equal(DateTimeOffset.FromUnixTimeMilliseconds(1528482614360), result.First().Cubes.First().LastBuiltUtc);
            Assert.Equal(1, result.First().Cubes.First().PermissionsSummary);
            Assert.Equal(87509.8537, result.First().Cubes.First().SizeInMb);
            Assert.Equal(ElastiCubeStatus.Running, result.First().Cubes.First().Status);
            Assert.Equal("mycube", result.First().Cubes.First().Title);
            Assert.Equal(3, result.First().PermissionsSummary);
        }
示例#15
0
        public async Task WhenGettingTheMetadataFields_ShouldReturnThemWithCorrectInformation()
        {
            // Arrange
            IHttpClient    httpClient    = new FakeHttpClient(responseMessageToReturn: CreateResponse());
            IAuthenticator authenticator = new FakeAuthenticator();
            var            service       = new ElastiCubesService("", httpClient, authenticator);

            // Act
            var result = await service.GetElastiCubeMetadataFieldsAsync("mycube");

            // Assert
            Assert.Equal(3, result.Count());
            Assert.Equal("[def_daysofweek.day]", result.First().Id);
            Assert.Equal("dimension", result.First().Type);
            Assert.Equal("text", result.First().DimType);
            Assert.Equal("day", result.First().Title);
            Assert.Equal("def_daysofweek", result.First().Table);
            Assert.Equal("day2", result.First().Column);
            Assert.False(result.First().Merged);
            Assert.True(result.First().Indexed);
            Assert.Null(result.First().DimensionTable);
        }