public void TestElasticsearchSource_Execute_NullValues_ErrorResult()
        {
            //------------Setup for test--------------------------
            var testElasticsearchSource = new TestElasticsearchSource();
            var serializer = new Dev2JsonSerializer();
            //------------Execute Test---------------------------
            var jsonResult = testElasticsearchSource.Execute(null, null);
            var result     = serializer.Deserialize <ExecuteMessage>(jsonResult);

            //------------Assert Results-------------------------
            Assert.IsTrue(result.HasError);
        }
        public void TestElasticsearchSource_Execute_ResourceIDNotPresent_ErrorResult()
        {
            //------------Setup for test--------------------------
            var values = new Dictionary <string, StringBuilder> {
                { "item", new StringBuilder() }
            };
            var testElasticsearchSource = new TestElasticsearchSource();
            var serializer = new Dev2JsonSerializer();
            //------------Execute Test---------------------------
            var jsonResult = testElasticsearchSource.Execute(values, null);
            var result     = serializer.Deserialize <ExecuteMessage>(jsonResult);

            //------------Assert Results-------------------------
            Assert.IsTrue(result.HasError);
        }
        public void TestElasticsearchSource_Execute_Auth_Password_GivenResourceDefinition_ShouldTestNewSourceReturnResourceDefinitionMsg()
        {
            //---------------Set up test pack-------------------
            var serializer = new Dev2JsonSerializer();
            var dependency = new Depends(Depends.ContainerType.AnonymousElasticsearch);
            var hostName   = "http://" + dependency.Container.IP;
            var source     = new ElasticsearchSourceDefinition()
            {
                Id                 = Guid.Empty,
                Name               = "Name",
                HostName           = hostName,
                Port               = dependency.Container.Port,
                Username           = "******",
                Password           = "******",
                SearchIndex        = "warewolftestlogs",
                AuthenticationType = Dev2.Runtime.ServiceModel.Data.AuthenticationType.Password
            };
            var testElasticsearchSource = new TestElasticsearchSource();
            var values = new Dictionary <string, StringBuilder>
            {
                { "ElasticsearchSource", source.SerializeToJsonStringBuilder() }
            };

            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            try
            {
                var jsonResult = testElasticsearchSource.Execute(values, null);
                var result     = serializer.Deserialize <ExecuteMessage>(jsonResult);
                //---------------Test Result -----------------------
                Assert.IsFalse(result.HasError, result.Message.ToString());
            }
            catch (Exception e)
            {
                if (e.Message.Contains("could not connect to elasticsearch Instance"))
                {
                    Assert.Inconclusive(e.Message);
                }
                else
                {
                    throw;
                }
            }
        }