public string GetXMLForInputs(IBinaryDataList binaryDataList) { var compiler = DataListFactory.CreateDataListCompiler(); ErrorResultTO errors; return(compiler.ConvertFrom(binaryDataList.UID, DataListFormat.CreateFormat(GlobalConstants._XML_Inputs_Only), enTranslationDepth.Data, out errors).ToString()); }
public static DataListFormat ExecuteTests(IDSFDataObject dataObject, IPrincipal userPrinciple, Guid workspaceGuid, Dev2JsonSerializer serializer, ITestCatalog testCatalog, IResourceCatalog resourceCatalog, out string executePayload, ITestCoverageCatalog testCoverageCatalog) { executePayload = null; DataListFormat formatter = null; if (dataObject.TestsResourceIds?.Any() ?? false) { if (dataObject.ReturnType == EmitionTypes.TEST) { formatter = dataObject.RunMultipleTestBatchesAndReturnJSON(userPrinciple, workspaceGuid, serializer, resourceCatalog, testCatalog, out executePayload, testCoverageCatalog); } if (dataObject.ReturnType == EmitionTypes.TRX) { formatter = dataObject.RunMultipleTestBatchesAndReturnTRX(userPrinciple, workspaceGuid, serializer, resourceCatalog, testCatalog, out executePayload, testCoverageCatalog); } dataObject.ResourceID = Guid.Empty; } else { Dev2.Common.Dev2Logger.Warn("No tests found to execute for requested resource", Dev2.Common.GlobalConstants.WarewolfWarn); } Dev2DataListDecisionHandler.Instance.RemoveEnvironment(dataObject.DataListID); dataObject.Environment = null; return(formatter ?? DataListFormat.CreateFormat("XML", EmitionTypes.XML, "text/xml")); }
/// <summary> /// Generates the match fragments from data list. /// </summary> /// <returns></returns> private FuzzyMatchVo GenerateMatchFragmentsFromDataList() { FuzzyMatchVo result = null; if (!string.IsNullOrEmpty(DataList)) { var compiler = DataListFactory.CreateDataListCompiler(); ErrorResultTO invokeErrors; var dlID = compiler.ConvertTo(DataListFormat.CreateFormat(GlobalConstants._XML_Without_SystemTags), string.Empty.ToStringBuilder(), DataList.ToStringBuilder(), out invokeErrors); var dl = compiler.FetchBinaryDataList(dlID, out invokeErrors); IDictionary <Tuple <string, string>, string> tmp = new Dictionary <Tuple <string, string>, string>(); if (dl != null) { foreach (var rs in dl.FetchRecordsetEntries()) { // build map for each column in a recordset ;) foreach (var col in rs.Columns) { if (!tmp.Keys.Any(a => a.Item2 == col.ColumnName && a.Item1 == rs.Namespace)) { tmp[new Tuple <string, string>(rs.Namespace, col.ColumnName)] = rs.Namespace; } } } } result = new FuzzyMatchVo(tmp); } return(result); }
public override IBinaryDataList GetOutputs() { IBinaryDataList result; ErrorResultTO errors; IDataListCompiler compiler = DataListFactory.CreateDataListCompiler(); var outputDlString = compiler.GenerateWizardDataListFromDefs(OutputMapping, enDev2ArgumentType.Output, false, out errors, true); var outputDlShape = compiler.GenerateWizardDataListFromDefs(OutputMapping, enDev2ArgumentType.Output, false, out errors); if (!errors.HasErrors()) { Guid dlId = compiler.ConvertTo(DataListFormat.CreateFormat(GlobalConstants._XML_Without_SystemTags), outputDlString, outputDlShape, out errors); if (!errors.HasErrors()) { result = compiler.FetchBinaryDataList(dlId, out errors); } else { string errorString = string.Join(",", errors.FetchErrors()); throw new Exception(errorString); } } else { string errorString = string.Join(",", errors.FetchErrors()); throw new Exception(errorString); } return(result); }
public void UpsertBuilder_AssignStyleAppend_Expect_10RecordSetEntries_And_Scalar() { IDev2DataListUpsertPayloadBuilder <string> tmp = Dev2DataListBuilderFactory.CreateStringDataListUpsertBuilder(); string error; tmp.Add("[[scalar]]", "myScalar"); tmp.FlushIterationFrame(); tmp.Add("[[recset().f1]]", "field1_value1a"); tmp.Add("[[recset().f2]]", "field2_value1a"); tmp.FlushIterationFrame(); tmp.Add("[[recset(10).f1]]", "field1_value2a"); tmp.Add("[[recset(10).f2]]", "field2_value2a"); ErrorResultTO errors; Guid id = _compiler.ConvertTo(DataListFormat.CreateFormat(GlobalConstants._XML), _adlData.ToStringBuilder(), new StringBuilder(_dlShape), out errors); _compiler.Upsert(id, tmp, out errors); IBinaryDataList bdl = _compiler.FetchBinaryDataList(id, out errors); // Else we good to go, normal asserts ;) IBinaryDataListEntry recset; bdl.TryGetEntry("recset", out recset, out error); IBinaryDataListEntry scalar; bdl.TryGetEntry("scalar", out scalar, out error); var res1 = scalar.FetchScalar().TheValue; var res2 = recset.FetchLastRecordsetIndex(); // we have a single scalar Assert.AreEqual("myScalar", res1); Assert.AreEqual(10, res2); }
private void AddTableToDataList(Table table) { var compiler = DataListFactory.CreateDataListCompiler(); ScenarioContext.Current.Add("compiler", compiler); // build up DataTable var dbData = new DataTable("rs"); foreach (string columnName in table.Header) { dbData.Columns.Add(columnName); } foreach (TableRow row in table.Rows) { dbData.Rows.Add(row[0], row[1], row[2]); } // Execute Translator ErrorResultTO errors; var dataShape = "<root><rs><Col1/><Col2/><Col3/></rs></root>"; var dlId = compiler.ConvertTo(DataListFormat.CreateFormat(GlobalConstants._DATATABLE), dbData, dataShape.ToStringBuilder(), out errors); dataShape = "<root><rs><Col1/><Col2/><Col3/></rs><result/></root>"; ScenarioContext.Current.Add("dlID", dlId); ScenarioContext.Current.Add("dataShape", dataShape); }
// ReSharper disable once InconsistentNaming public void DataListTranslator_ToDataTable_WithDataList_PopulatedDataTable() { //------------Setup for test-------------------------- var compiler = DataListFactory.CreateDataListCompiler(); var dbData = new DataTable("rs"); dbData.Columns.Add("val", typeof(string)); dbData.Columns.Add("otherVal", typeof(int)); dbData.Rows.Add("aaa", 1); dbData.Rows.Add("zzz", 2); ErrorResultTO errors; Guid dlID = compiler.ConvertTo(DataListFormat.CreateFormat(GlobalConstants._DATATABLE), dbData, new StringBuilder("<root><rs><val/><otherVal/></rs></root>"), out errors); var fetchBinaryDataList = compiler.FetchBinaryDataList(dlID, out errors); //------------Execute Test--------------------------- var convertToDataTable = compiler.ConvertToDataTable(fetchBinaryDataList, "rs", out errors); //------------Assert Results------------------------- Assert.IsNotNull(convertToDataTable); Assert.AreEqual(2, convertToDataTable.Columns.Count); Assert.IsTrue(convertToDataTable.Columns.Contains("val")); Assert.IsTrue(convertToDataTable.Columns.Contains("otherVal")); Assert.AreEqual(2, convertToDataTable.Rows.Count); Assert.AreEqual("aaa", convertToDataTable.Rows[0]["val"]); Assert.AreEqual("1", convertToDataTable.Rows[0]["otherVal"]); Assert.AreEqual("zzz", convertToDataTable.Rows[1]["val"]); Assert.AreEqual("2", convertToDataTable.Rows[1]["otherVal"]); }
public static DataListFormat RunCoverageAndReturnJSON(this ICoverageDataObject coverageData, ITestCoverageCatalog testCoverageCatalog, ITestCatalog testCatalog, IResourceCatalog catalog, Guid workspaceGuid, Dev2JsonSerializer serializer, out string executePayload) { var(allCoverageReports, _) = RunListOfCoverage(coverageData, testCoverageCatalog, testCatalog, workspaceGuid, catalog); var formatter = DataListFormat.CreateFormat("JSON", EmitionTypes.JSON, "application/json"); var objArray = allCoverageReports.AllCoverageReportsSummary .Where(o => o.HasTestReports) .Select(o => { var name = o.Resource.ResourceName; if (o.Resource is IFilePathResource filePath) { name = filePath.Path; } return(new JObject { { "ResourceID", o.Resource.ResourceID }, { "Name", name }, { "Reports", new JArray(o.Reports.Select(o1 => o1.BuildTestResultJSONForWebRequest())) } }); }); var obj = new JObject { { "StartTime", allCoverageReports.StartTime }, { "EndTime", allCoverageReports.EndTime }, { "Results", new JArray(objArray) }, }; executePayload = serializer.Serialize(obj); return(formatter); }
public static DataListFormat RunCoverageAndReturnHTML(this ICoverageDataObject coverageData, ITestCoverageCatalog testCoverageCatalog, ITestCatalog testCatalog, IResourceCatalog catalog, Guid workspaceGuid, out string executePayload) { var(allCoverageReports, allTestResults) = RunListOfCoverage(coverageData, testCoverageCatalog, testCatalog, workspaceGuid, catalog); var formatter = DataListFormat.CreateFormat("HTML", EmitionTypes.Cover, "text/html; charset=utf-8"); var stringWriter = new StringWriter(); using (var writer = new HtmlTextWriter(stringWriter)) { writer.SetupNavBarHtml(); allTestResults.Results .SelectMany(o => o.Results) .ToList() .SetupCountSummaryHtml(writer, coverageData); allCoverageReports.AllCoverageReportsSummary .Where(o => o.HasTestReports) .ToList() .ForEach(oo => { var resourcePath = string.Empty; if (oo.Resource is IFilePathResource filePath) { resourcePath = filePath.Path; } writer.SetupWorkflowRowHtml(resourcePath, coverageData, oo); }); } executePayload = stringWriter.ToString(); return(formatter); }
public void Can_Create_BinaryDataList_With_Blank_IsEditable_Blank_Expected_All_IsEditable_Properties_Are_True() { ErrorResultTO errors; var shape = new StringBuilder(@"<DataList><recset Description="""" ColumnIODirection=""Both"" ><f1 Description="""" ColumnIODirection=""Both"" /><f2 Description="""" ColumnIODirection=""Both"" /><f3 Description="""" ColumnIODirection=""Both"" /><f4 Description="""" ColumnIODirection=""Both"" /><f5 Description="""" ColumnIODirection=""Both"" /></recset><myScalar Description="""" ColumnIODirection=""Both"" /></DataList>"); Guid tmp = _compiler.ConvertTo(DataListFormat.CreateFormat(GlobalConstants._Studio_XML), shape, shape, out errors); IBinaryDataList bdl = _compiler.FetchBinaryDataList(tmp, out errors); _compiler.DeleteDataListByID(tmp); foreach (IBinaryDataListEntry entry in bdl.FetchAllEntries()) { if (entry.IsRecordset) { Assert.AreEqual(true, entry.IsEditable); foreach (Dev2Column c in entry.Columns) { Assert.AreEqual(true, c.IsEditable); } } else { Assert.AreEqual(true, entry.IsEditable); } } _compiler.ForceDeleteDataListByID(tmp); }
public void Can_Create_BinaryDataList_With_No_ColumnDirection() { ErrorResultTO errors; var shape = new StringBuilder(@"<DataList><recset Description="""" IsEditable=""True"" ><f1 Description="""" IsEditable=""True"" /><f2 Description="""" IsEditable=""True"" /><f3 Description="""" IsEditable=""True"" /><f4 Description="""" IsEditable=""True"" /><f5 Description="""" IsEditable=""True"" /></recset><myScalar Description="""" IsEditable=""True"" /></DataList>"); Guid tmp = _compiler.ConvertTo(DataListFormat.CreateFormat(GlobalConstants._Studio_XML), string.Empty.ToStringBuilder(), shape, out errors); IBinaryDataList bdl = _compiler.FetchBinaryDataList(tmp, out errors); _compiler.DeleteDataListByID(tmp); foreach (IBinaryDataListEntry entry in bdl.FetchAllEntries()) { if (entry.IsRecordset) { Assert.AreEqual(enDev2ColumnArgumentDirection.None, entry.ColumnIODirection); foreach (Dev2Column c in entry.Columns) { Assert.AreEqual(enDev2ColumnArgumentDirection.None, c.ColumnIODirection); } } else { Assert.AreEqual(enDev2ColumnArgumentDirection.None, entry.ColumnIODirection); } } _compiler.ForceDeleteDataListByID(tmp); }
public void DecisionWithQuotesInDataExpectedNoUnhandledExceptions() { Dev2DecisionStack dds = new Dev2DecisionStack { TheStack = new List <Dev2Decision>(), Mode = Dev2DecisionMode.AND }; IDataListCompiler compiler = DataListFactory.CreateDataListCompiler(); dds.AddModelItem(new Dev2Decision { Col1 = "[[var]]", Col2 = "[[var]]", EvaluationFn = enDecisionType.IsEqual }); string modelData = dds.ToVBPersistableModel(); CurrentDl = "<ADL><var/></ADL>"; TestData = "<root><var>\"something \"data\" \"</var></root>"; ErrorResultTO errors; Guid exeID = compiler.ConvertTo(DataListFormat.CreateFormat(GlobalConstants._XML), new StringBuilder(TestData), new StringBuilder(CurrentDl), out errors); IList <string> getDatalistID = new List <string> { exeID.ToString() }; var res = new Dev2DataListDecisionHandler().ExecuteDecisionStack(modelData, getDatalistID); // remove test datalist ;) DataListRemoval(exeID); Assert.IsTrue(res); }
bool SqlExecution(ErrorResultTO errors, out object executeService) { try { if (SqlServer != null) { var parameters = GetSqlParameters(Service.Method.Parameters); if (parameters != null) { // ReSharper disable CoVariantArrayConversion using (var dataSet = SqlServer.FetchDataTable(parameters.ToArray())) // ReSharper restore CoVariantArrayConversion { ApplyColumnMappings(dataSet); IDataListCompiler compiler = DataListFactory.CreateDataListCompiler(); executeService = compiler.PopulateDataList(DataListFormat.CreateFormat(GlobalConstants._DATATABLE), dataSet, InstanceOutputDefintions, DataObj.DataListID, out errors); return(true); } } } } catch (Exception ex) { errors.AddError(string.Format("{0}{1}{2}", ex.Message, Environment.NewLine, ex.StackTrace)); } executeService = null; return(false); }
internal IResponseWriter ExecuteAsTest(string serviceName, string executePayload, Guid workspaceGuid, IDSFDataObject dataObject, Dev2JsonSerializer serializer, IPrincipal userPrinciple) { var xmlFormatter = DataListFormat.CreateFormat("XML", EmitionTypes.XML, "text/xml"); var formatter = ServiceTestExecutor.ExecuteTests(serviceName, dataObject, xmlFormatter, userPrinciple, workspaceGuid, serializer, _testCatalog, _resourceCatalog, ref executePayload); return(new StringResponseWriter(executePayload, formatter.ContentType)); }
/// <summary> /// Used to transform the WorkflowInputs into XML /// </summary> public void SetXmlData() { var compiler = DataListFactory.CreateDataListCompiler(); ErrorResultTO errors; var dl = compiler.ConvertTo(DataListFormat.CreateFormat(GlobalConstants._Studio_Debug_XML), string.Empty.ToStringBuilder(), DebugTo.DataList.ToStringBuilder() ?? "<Datalist></Datalist>".ToStringBuilder(), out errors); DataList = compiler.FetchBinaryDataList(dl, out errors); // For some damn reason this does not always bind like it should! ;) Thread.Sleep(150); foreach (var item in WorkflowInputs) { string error; if (item.IsRecordset && !string.IsNullOrEmpty(item.Value)) { DataList.TryCreateRecordsetValue(item.Value, item.Field, item.Recordset, Convert.ToInt32(item.RecordsetIndex), out error); } else if (!item.IsRecordset) { DataList.TryCreateScalarValue(item.Value, item.Field, out error); } } var dlId = compiler.PushBinaryDataList(DataList.UID, DataList, out errors); var dataListString = compiler.ConvertFrom(dlId, DataListFormat.CreateFormat(GlobalConstants._Studio_Debug_XML), enTranslationDepth.Data, out errors); try { XmlData = XElement.Parse(dataListString.ToString()).ToString(); } catch (Exception) { XmlData = "Invalid characters entered"; } }
private static IResponseWriter DebugFromWebExecutionResponse(IDSFDataObject dataObject, Dev2JsonSerializer serializer) { var formatter = DataListFormat.CreateFormat("JSON", EmitionTypes.JSON, "application/json"); var serialize = SetupForWebExecution(dataObject, serializer); return(new StringResponseWriter(serialize, formatter.ContentType)); }
public static DataListFormat GetTestCoverageReports(ICoverageDataObject coverageObject, Guid workspaceGuid, Dev2JsonSerializer serializer, ITestCoverageCatalog testCoverageCatalog, ITestCatalog testCatalog, IResourceCatalog resourceCatalog, out string executePayload) { DataListFormat formatter = null; if (coverageObject.CoverageReportResourceIds?.Any() ?? false) { if (coverageObject.ReturnType == EmitionTypes.CoverJson) { formatter = coverageObject.RunCoverageAndReturnJSON(testCoverageCatalog, testCatalog, resourceCatalog, workspaceGuid, serializer, out executePayload); } else if (coverageObject.ReturnType == EmitionTypes.Cover) { formatter = coverageObject.RunCoverageAndReturnHTML(testCoverageCatalog, testCatalog, resourceCatalog, workspaceGuid, out executePayload); } else { executePayload = null; } } else { executePayload = null; Common.Dev2Logger.Warn("No test coverage reports found to execute for requested resource", Common.GlobalConstants.WarewolfWarn); } return(formatter ?? DataListFormat.CreateFormat("HTML", EmitionTypes.Cover, "text/html; charset=utf-8")); }
public IBinaryDataList DeSerialize(string data, string targetShape, enTranslationTypes typeOf, out string error) { error = string.Empty; IBinaryDataList result = Dev2BinaryDataListFactory.CreateDataList(); IDataListCompiler compiler = DataListFactory.CreateDataListCompiler(); if (typeOf == enTranslationTypes.XML) { ErrorResultTO errors; Guid resultId = compiler.ConvertTo(DataListFormat.CreateFormat(GlobalConstants._Studio_Debug_XML), data.ToStringBuilder(), new StringBuilder(targetShape), out errors); if (errors.HasErrors()) { error = errors.FetchErrors()[0]; // take the first error ;) } else { if (result != null) { compiler.ForceDeleteDataListByID(result.UID); } result = compiler.FetchBinaryDataList(resultId, out errors); if (errors.HasErrors()) { error = errors.FetchErrors()[0]; // take the first error ;) } } } return(result); }
public void SetupScenerio() { var sqlBulkInsert = new DsfSqlBulkInsertActivity(); var dbSource = SqlServerTests.CreateDev2TestingDbSource(); ResourceCatalog.Instance.SaveResource(Guid.Empty, dbSource); ScenarioContext.Current.Add("dbSource", dbSource); sqlBulkInsert.Database = dbSource; sqlBulkInsert.TableName = "SqlBulkInsertSpecFlowTestTable_for_" + ScenarioContext.Current.ScenarioInfo.Title.Replace(' ', '_'); var dataColumnMappings = new List <DataColumnMapping> { new DataColumnMapping { InputColumn = "[[rs(*).Col1]]", OutputColumn = new DbColumn { ColumnName = "Col1", DataType = typeof(Int32), MaxLength = 100 }, }, new DataColumnMapping { InputColumn = "[[rs(*).Col2]]", OutputColumn = new DbColumn { ColumnName = "Col2", DataType = typeof(String), MaxLength = 100 } }, new DataColumnMapping { InputColumn = "[[rs(*).Col3]]", OutputColumn = new DbColumn { ColumnName = "Col3", DataType = typeof(Guid), MaxLength = 100 } } }; sqlBulkInsert.InputMappings = dataColumnMappings; TestStartNode = new FlowStep { Action = sqlBulkInsert }; ErrorResultTO errors; var compiler = ScenarioContext.Current.Get <IDataListCompiler>("compiler"); var dlId = ScenarioContext.Current.Get <Guid>("dlID"); var dataShape = ScenarioContext.Current.Get <string>("dataShape"); var data = compiler.ConvertFrom(dlId, DataListFormat.CreateFormat(GlobalConstants._XML), enTranslationDepth.Data, out errors); CurrentDl = dataShape; TestData = data.ToString(); ScenarioContext.Current.Add("activity", sqlBulkInsert); }
public void ExecutionDtoExtentions_CreateResponseWriter_NotWasInternalService_And_IsDebug_Success() { //-------------------------------Arrange---------------------------------- var mockDSFDataObject = new Mock <IDSFDataObject>(); mockDSFDataObject.Setup(o => o.Environment.HasErrors()).Returns(false); mockDSFDataObject.Setup(o => o.IsDebug).Returns(true); var dataListDataFormat = DataListFormat.CreateFormat("JSON", EmitionTypes.JSON, "application/json"); var executionDto = new ExecutionDto { Resource = null, DataObject = mockDSFDataObject.Object, ErrorResultTO = new ErrorResultTO(), DataListFormat = dataListDataFormat, }; var executionDtoExtentions = new ExecutionDtoExtentions(executionDto); //-------------------------------Act-------------------------------------- executionDtoExtentions.CreateResponseWriter(new StringResponseWriterFactory()); //-------------------------------Assert----------------------------------- Assert.AreEqual(expected: string.Empty, actual: executionDto.PayLoad); }
public void XML_Without_SystemTags_ConvertTo_WhenSingleRecordset_ExpectNoErrors() { //------------Setup for test-------------------------- IDataListCompiler compiler = DataListFactory.CreateDataListCompiler(); ErrorResultTO errors; var data = new StringBuilder("<DataList><hero index=\"1\"><name>Chuck Norris</name><pushups>All of them</pushups></hero></DataList>"); var shape = new StringBuilder(@"<DataList> <hero Description="""" IsEditable=""True"" ColumnIODirection=""Output""> <name Description="""" IsEditable=""True"" ColumnIODirection=""Output"" /> <pushups Description="""" IsEditable=""True"" ColumnIODirection=""Output"" /> </hero> <rect Description="""" IsEditable=""True"" ColumnIODirection=""None""> <set Description="""" IsEditable=""True"" ColumnIODirection=""None"" /> </rect> </DataList>"); //------------Execute Test--------------------------- var dlID = compiler.ConvertTo(DataListFormat.CreateFormat(GlobalConstants._XML_Without_SystemTags), data, shape, out errors); var result = compiler.ConvertFrom(dlID, DataListFormat.CreateFormat(GlobalConstants._XML_Without_SystemTags), enTranslationDepth.Data, out errors); //------------Assert Results------------------------- const string expected = "<DataList><hero><name>Chuck Norris</name><pushups>All of them</pushups></hero></DataList>"; StringAssert.Contains(result.ToString(), expected); }
public void ExecutionDtoExtentions_CreateResponseWriter_WasInternalService_And_ExecuteMessageXML_PayLoadIsNullOrEmpty_Success() { //-------------------------------Arrange---------------------------------- var mockDSFDataObject = new Mock <IDSFDataObject>(); mockDSFDataObject.Setup(o => o.Environment.HasErrors()).Returns(false); var esbExecuteRequestMessage = "<xml>test message</xml>"; var jsonSerializer = new Dev2JsonSerializer(); var serExecuteMessage = jsonSerializer.Serialize(esbExecuteRequestMessage); var executionDto = new ExecutionDto { DataObject = mockDSFDataObject.Object, DataListFormat = DataListFormat.CreateFormat("XML", EmitionTypes.XML, "application/xml"), ErrorResultTO = new ErrorResultTO(), Request = new EsbExecuteRequest { WasInternalService = true, ExecuteResult = new StringBuilder(serExecuteMessage) }, Serializer = jsonSerializer, }; var executionDtoExtentions = new ExecutionDtoExtentions(executionDto); //-------------------------------Act-------------------------------------- executionDtoExtentions.CreateResponseWriter(new StringResponseWriterFactory()); //-------------------------------Assert----------------------------------- Assert.AreEqual(expected: "\"<xml>test message</xml>\"", actual: executionDto.PayLoad); }
public void DataListXMLTranslatorWithOutSystemTags_ConvertFrom_WhereIndexOneDeleted_AllItemsButIndexOne() { //------------Setup for test-------------------------- var compiler = DataListFactory.CreateDataListCompiler(); ErrorResultTO errors; var format = DataListFormat.CreateFormat(GlobalConstants._XML_Without_SystemTags); StringBuilder data = new StringBuilder("<root><person><fname>bob</fname><lname>smith</lname></person><person><fname>sara</fname><lname>jones</lname></person></root>"); StringBuilder shape = new StringBuilder("<root><person><fname/><lname/></person></root>"); var dlID = compiler.ConvertTo(format, data, shape, out errors); var bdl = compiler.FetchBinaryDataList(dlID, out errors); string error; IBinaryDataListEntry entry; bdl.TryGetEntry("person", out entry, out error); entry.TryDeleteRows("1", out error); //------------Execute Test--------------------------- var result = compiler.ConvertFrom(dlID, format, enTranslationDepth.Data, out errors); //------------Assert Results------------------------- const string expected = "<DataList><person><fname>sara</fname><lname>jones</lname></person></DataList>"; StringAssert.Contains(result.ToString(), expected); }
public void ExecutionDtoExtentions_CreateResponseWriter_NotWasInternalService_And_EmitionTypesSWAGGER_Success() { //-------------------------------Arrange---------------------------------- var mockDSFDataObject = new Mock <IDSFDataObject>(); var mockResource = new Mock <IResource>(); mockResource.Setup(o => o.DataList).Returns(new StringBuilder("<DataList>the test string to be built</DataList>")); mockDSFDataObject.Setup(o => o.Environment.HasErrors()).Returns(false); mockDSFDataObject.Setup(o => o.ReturnType).Returns(EmitionTypes.SWAGGER); var dataListDataFormat = DataListFormat.CreateFormat("SWAGGER", EmitionTypes.SWAGGER, "application/json"); var webRequestTO = new WebRequestTO { WebServerUrl = "http://serverName:3142/public/resourceName.api" }; var executionDto = new ExecutionDto { Resource = mockResource.Object, DataObject = mockDSFDataObject.Object, ErrorResultTO = new ErrorResultTO(), DataListFormat = dataListDataFormat, WebRequestTO = webRequestTO, }; var executionDtoExtentions = new ExecutionDtoExtentions(executionDto); //-------------------------------Act-------------------------------------- executionDtoExtentions.CreateResponseWriter(new StringResponseWriterFactory()); //-------------------------------Assert----------------------------------- Assert.AreEqual(expected: "{\r\n \"swagger\": 2,\r\n \"info\": {\r\n \"title\": null,\r\n \"description\": \"\",\r\n \"version\": \"1.0.0\"\r\n },\r\n \"host\": \":0/\",\r\n \"basePath\": \"/\",\r\n \"schemes\": [\r\n \"http\"\r\n ],\r\n \"produces\": [\r\n \"application/json\",\r\n \"application/xml\"\r\n ],\r\n \"paths\": {\r\n \"serviceName\": \"/public/resourceName.api\",\r\n \"get\": {\r\n \"summary\": \"\",\r\n \"description\": \"\",\r\n \"parameters\": []\r\n }\r\n },\r\n \"responses\": {\r\n \"200\": {\r\n \"schema\": {\r\n \"$ref\": \"#/definition/Output\"\r\n }\r\n }\r\n },\r\n \"definitions\": {\r\n \"Output\": {\r\n \"type\": \"object\",\r\n \"properties\": {}\r\n }\r\n }\r\n}", actual: executionDto.PayLoad); }
public void UpsertBuilder_AssignStyleAppend_Expect_Scalar_WithLastRecord() { IDev2DataListUpsertPayloadBuilder <string> tmp = Dev2DataListBuilderFactory.CreateStringDataListUpsertBuilder(); tmp.Add("[[recset().f1]]", "field1_value1a"); tmp.Add("[[recset().f2]]", "field2_value1a"); tmp.FlushIterationFrame(); tmp.Add("[[scalar]]", "[[recset(*).f1]]"); tmp.FlushIterationFrame(); ErrorResultTO errors; Guid id = _compiler.ConvertTo(DataListFormat.CreateFormat(GlobalConstants._XML), _adlData.ToStringBuilder(), new StringBuilder(_dlShape), out errors); _compiler.Upsert(id, tmp, out errors); IBinaryDataList bdl = _compiler.FetchBinaryDataList(id, out errors); IBinaryDataListEntry scalar; string error; bdl.TryGetEntry("scalar", out scalar, out error); var res = scalar.FetchScalar().TheValue; // we have a single scalar Assert.AreEqual("field1_value1a", res); }
public void ExecutionDtoExtentions_CreateResponseWriter_NotWasInternalService_And_EmitionTypesXML_Success() { //-------------------------------Arrange---------------------------------- var mockDSFDataObject = new Mock <IDSFDataObject>(); var mockResource = new Mock <IResource>(); mockResource.Setup(o => o.DataList).Returns(new StringBuilder("<DataList>the test string to be built</DataList>")); mockDSFDataObject.Setup(o => o.Environment.HasErrors()).Returns(false); mockDSFDataObject.Setup(o => o.ReturnType).Returns(EmitionTypes.XML); var dataListDataFormat = DataListFormat.CreateFormat("XML", EmitionTypes.XML, "application/xml"); var executionDto = new ExecutionDto { Resource = mockResource.Object, DataObject = mockDSFDataObject.Object, ErrorResultTO = new ErrorResultTO(), DataListFormat = dataListDataFormat, }; var executionDtoExtentions = new ExecutionDtoExtentions(executionDto); //-------------------------------Act-------------------------------------- executionDtoExtentions.CreateResponseWriter(new StringResponseWriterFactory()); //-------------------------------Assert----------------------------------- Assert.AreEqual(expected: "<DataList />", actual: executionDto.PayLoad); }
static string GetExecutePayload(IDSFDataObject dataObject, IResource resource, WebRequestTO webRequest, ref DataListFormat formatter) { var notDebug = !dataObject.IsDebug || dataObject.RemoteInvoke || dataObject.RemoteNonDebugInvoke; if (notDebug && resource?.DataList != null) { switch (dataObject.ReturnType) { case EmitionTypes.XML: { return(ExecutionEnvironmentUtils.GetXmlOutputFromEnvironment(dataObject, resource.DataList.ToString(), 0)); } case EmitionTypes.SWAGGER: { formatter = DataListFormat.CreateFormat("SWAGGER", EmitionTypes.SWAGGER, "application/json"); return(ExecutionEnvironmentUtils.GetSwaggerOutputForService(resource, resource.DataList.ToString(), webRequest.WebServerUrl)); } default: case EmitionTypes.JSON: { formatter = DataListFormat.CreateFormat("JSON", EmitionTypes.JSON, "application/json"); return(ExecutionEnvironmentUtils.GetJsonOutputFromEnvironment(dataObject, resource.DataList.ToString(), 0)); } } } return(string.Empty); }
protected override Guid ExecutionImpl(IEsbChannel esbChannel, IDSFDataObject dataObject, string inputs, string outputs, out ErrorResultTO tmpErrors) { tmpErrors = new ErrorResultTO(); ErrorResultTO invokeErrors; var compiler = DataListFactory.CreateDataListCompiler(); var oldID = dataObject.DataListID; var webserviceExecution = GetNewWebserviceExecution(dataObject); #pragma warning disable 168 var remainingMappings = esbChannel.ShapeForSubRequest(dataObject, inputs, outputs, out invokeErrors); #pragma warning restore 168 tmpErrors.MergeErrors(invokeErrors); if (webserviceExecution != null && !tmpErrors.HasErrors()) { webserviceExecution.InstanceOutputDefintions = outputs; // set the output mapping for the instance ;) var result = webserviceExecution.Execute(out invokeErrors); tmpErrors.MergeErrors(invokeErrors); // Adjust the remaining output mappings ;) compiler.SetParentID(dataObject.DataListID, oldID); compiler.ConvertFrom(dataObject.DataListID, DataListFormat.CreateFormat(GlobalConstants._XML_Without_SystemTags), enTranslationDepth.Data, out invokeErrors); tmpErrors.MergeErrors(invokeErrors); compiler.ConvertFrom(oldID, DataListFormat.CreateFormat(GlobalConstants._XML_Without_SystemTags), enTranslationDepth.Data, out invokeErrors); tmpErrors.MergeErrors(invokeErrors); return(result); } return(oldID); }
public void ThenIHaveTheFollowingData(Table table) { var compiler = DataListFactory.CreateDataListCompiler(); var dataListID = ScenarioContext.Current.Get <Guid>("DataListID"); ErrorResultTO errors; var result = compiler.ConvertFrom(dataListID, DataListFormat.CreateFormat(GlobalConstants._XML), enTranslationDepth.Data, out errors); Assert.IsNotNull(result); var resultXml = XElement.Parse(result.ToString()); var dataElements = resultXml.Elements().Where(element => !element.Name.LocalName.StartsWith("Dev2System") && element.Name.LocalName == "results"); using (var dataSet = new DataSet()) { using (var reader = dataElements.ToList()[0].CreateReader()) { dataSet.ReadXml(reader, XmlReadMode.Auto); var dataListTable = dataSet.Tables[0]; var rowID = 0; foreach (var tableRow in table.Rows) { var dataRow = dataListTable.Rows[rowID]; foreach (var header in table.Header) { Assert.AreEqual(dataRow[header], tableRow[header]); } rowID++; } } } }
public static DataListFormat GetTestCoverageReports(ICoverageDataObject coverageObject, Guid workspaceGuid, Dev2JsonSerializer serializer, ITestCoverageCatalog testCoverageCatalog, IResourceCatalog resourceCatalog, out string executePayload) { DataListFormat formatter = null; if (coverageObject.CoverageReportResourceIds.Any()) { if (coverageObject.ReturnType == EmitionTypes.CoverJson) { formatter = coverageObject.RunCoverageAndReturnJSON(testCoverageCatalog, resourceCatalog, workspaceGuid, serializer, out executePayload); } else if (coverageObject.ReturnType == EmitionTypes.Cover) { formatter = coverageObject.RunCoverageAndReturnHTML(testCoverageCatalog, resourceCatalog, workspaceGuid, out executePayload); } else { executePayload = null; } } else { executePayload = null; throw new Exception("do not expect this to be executed any longer"); } return(formatter); }