public void DebugItem_ResultList_AddMoreThanTenItems_ShouldKeepValues() { var item = new DebugItem(); const int max = 12; for (int i = 1; i <= max; i++) { var item1 = new DebugItemResult { GroupIndex = i, GroupName = "[[CoinMarketCap(*)]]", HasError = false, Label = "", MockSelected = false, MoreLink = null, Operator = "=", TestStepHasError = false, Type = DebugItemResultType.Variable, Value = "2019/04/11 06:00:03 AM", Variable = "[[CoinMarketCap(" + i + ").date_updated]]" }; item.Add(item1); } Assert.AreEqual(11, item.ResultsList.Count); foreach (var res in item.ResultsList) { Assert.IsNotNull(res.Variable, "GroupIndex " + res.GroupIndex.ToString() + " failed."); Assert.IsNotNull(res.Value, "GroupIndex " + res.GroupIndex.ToString() + " failed."); } }
private void AddDebugInputItem(string expression, string labelText, IBinaryDataListEntry valueEntry, Guid executionId) { DebugItem itemToAdd = new DebugItem(); if (labelText == "Where") { AddDebugItem(new DebugItemStaticDataParams(SearchType, "Where"), itemToAdd); AddDebugItem(new DebugItemVariableParams(expression, labelText, valueEntry, executionId), itemToAdd); _debugInputs.Add(itemToAdd); return; } if (!string.IsNullOrWhiteSpace(labelText)) { itemToAdd.Add(new DebugItemResult { Type = DebugItemResultType.Label, Value = labelText }); } if (valueEntry != null) { AddDebugItem(new DebugItemVariableParams(expression, labelText, valueEntry, executionId), itemToAdd); } _debugInputs.Add(itemToAdd); }
public void DebugItem_GroupIndex_Greater_Than_MaxItemDispatchCount() { var item = new DebugItem(); item.Add(new DebugItemResult { GroupIndex = 15, GroupName = "Hello", Value = "world", Type = DebugItemResultType.Value }); Assert.AreEqual(0, item.ResultsList.Count); }
// ReSharper disable InconsistentNaming - Unit Test public void Serialized_Expected_CanBeDeserialized() // ReSharper restore InconsistentNaming { var rw = new MockByteReaderWriter(); var debugStateIn = DebugStateIn(); DebugItem itemToAdd = new DebugItem(); itemToAdd.Add(new DebugItemResult { GroupIndex = 0, GroupName = "Group1", Type = DebugItemResultType.Label, Value = "MyLabel" }); itemToAdd.Add(new DebugItemResult { GroupIndex = 0, GroupName = "Group1", Type = DebugItemResultType.Variable, Value = "[[MyVar]]" }); itemToAdd.Add(new DebugItemResult { GroupIndex = 0, GroupName = "Group1", Type = DebugItemResultType.Value, Value = "MyValue" }); debugStateIn.Inputs.Add(itemToAdd); debugStateIn.Write(rw); var debugStateOut = new DebugState(rw); Assert.AreEqual(debugStateIn.WorkspaceID, debugStateOut.WorkspaceID); Assert.AreEqual(debugStateIn.ID, debugStateOut.ID); Assert.AreEqual(debugStateIn.ParentID, debugStateOut.ParentID); Assert.AreEqual(debugStateIn.StateType, debugStateOut.StateType); Assert.AreEqual(debugStateIn.DisplayName, debugStateOut.DisplayName); Assert.AreEqual(debugStateIn.Name, debugStateOut.Name); Assert.AreEqual(debugStateIn.ActivityType, debugStateOut.ActivityType); Assert.AreEqual(debugStateIn.Version, debugStateOut.Version); Assert.AreEqual(debugStateIn.IsSimulation, debugStateOut.IsSimulation); Assert.AreEqual(debugStateIn.HasError, debugStateOut.HasError); Assert.AreEqual(debugStateIn.ErrorMessage, debugStateOut.ErrorMessage); Assert.AreEqual(debugStateIn.Server, debugStateOut.Server); Assert.AreEqual(debugStateIn.Server, debugStateOut.Server); Assert.AreEqual(debugStateIn.ServerID, debugStateOut.ServerID); Assert.AreEqual(debugStateIn.StartTime, debugStateOut.StartTime); Assert.AreEqual(debugStateIn.EndTime, debugStateOut.EndTime); Assert.AreEqual(debugStateIn.SessionID, debugStateOut.SessionID); Assert.IsTrue(debugStateOut.Inputs[0].FetchResultsList().SequenceEqual(debugStateIn.Inputs[0].FetchResultsList(), new DebugItemResultEqualityComparer())); }
public void Constructor_With_Array_Expected_InitializesWithArray() { var result = new DebugItemResult { GroupName = "Hello", Value = "world" }; var item = new DebugItem(); item.Add(result); Assert.AreEqual(1, item.FetchResultsList().Count); Assert.AreSame(result, item.FetchResultsList()[0]); }
public void Contains_With_EmptyFilter_Expected_ReturnsInstance() { var item = new DebugItem(); item.Add(new DebugItemResult { GroupName = "Hello", Value = "world" }); var result = item.Contains(string.Empty); Assert.IsTrue(result); }
public void Contains_With_InvalidFilter_Expected_ReturnsInstance() { var item = new DebugItem(); item.Add(new DebugItemResult { GroupName = "Hello", Value = "world" }); var result = item.Contains("the"); Assert.IsFalse(result); }
public override List <DebugItem> GetDebugOutputs(IExecutionEnvironment env, int update) { var result = new List <DebugItem>(); var itemToAdd = new DebugItem(); itemToAdd.Add(new DebugItemResult { Type = DebugItemResultType.Value, Value = Text }); result.Add(itemToAdd); return(result); }
public override List <DebugItem> GetDebugOutputs(IExecutionEnvironment dataList) { List <DebugItem> result = new List <DebugItem>(); DebugItem itemToAdd = new DebugItem(); itemToAdd.Add(new DebugItemResult { Type = DebugItemResultType.Value, Value = Text }); result.Add(itemToAdd); return(result); }
public void Contains_With_Filter_Expected_IsCaseInsensitive() { var item = new DebugItem(); item.Add(new DebugItemResult { GroupName = "Hello", Value = "world" }); var result = item.Contains("hel"); Assert.IsTrue(result); }
public void DebugItem_GroupIndex_Greater_Than_MaxItemDispatchCount_Type_Label() { var item = new DebugItem(); const string val = LongText + LongText + LongText + LongText + LongText + LongText + LongText + LongText + LongText + LongText + LongText + LongText + LongText + LongText + LongText + LongText + LongText + LongText + LongText + LongText + LongText + LongText + LongText + LongText; item.Add(new DebugItemResult { GroupIndex = 15, GroupName = "Hello", Value = val, Type = DebugItemResultType.Label }); Assert.AreEqual(0, item.ResultsList.Count); }
public void DebugItem_GroupIndex_Less_Than_MaxItemDispatchCount() { var item = new DebugItem(); item.Add(new DebugItemResult { GroupIndex = 5, GroupName = "Hello", Value = LongText, Type = DebugItemResultType.Value }); Assert.AreEqual(1, item.ResultsList.Count); Assert.AreEqual(5, item.ResultsList[0].GroupIndex); Assert.AreEqual("Hello", item.ResultsList[0].GroupName); Assert.IsFalse(item.ResultsList[0].HasError); Assert.AreEqual("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore", item.ResultsList[0].Value); Assert.IsTrue(item.ResultsList[0].MoreLink.StartsWith("http://localhost:3142/Services/FetchDebugItemFileService?DebugItemFilePath=C:\\ProgramData\\Warewolf\\Temp\\Warewolf\\Debug\\", StringComparison.Ordinal), "Expected " + item.ResultsList[0].MoreLink); }
public void Filter_Where_ContentIsDebugState_And_FilterTextMatchesOuputOnValue_Expected_True() { var debugState = new DebugState(); var itemToAdd = new DebugItem(); itemToAdd.Add(new DebugItemResult { Type = DebugItemResultType.Variable, Value = "cake" }); debugState.Outputs.Add(itemToAdd); const bool Expected = true; var actual = _debugOutputFilterStrategy.Filter(debugState, "ak"); Assert.AreEqual(Expected, actual); }
private static void CreateDebugState(string result, string workflowName, string taskName) { string user = Thread.CurrentPrincipal.Identity.Name.Replace("\\", "-"); var state = new DebugState { HasError = true, ID = Guid.NewGuid(), Message = string.Format("{0}", result), StartTime = DateTime.Now, EndTime = DateTime.Now, ErrorMessage = string.Format("{0}", result), DisplayName = workflowName }; var debug = new DebugItem(); debug.Add(new DebugItemResult { Type = DebugItemResultType.Label, Value = "Warewolf Execution Error:", Label = "Scheduler Execution Error", Variable = result }); var js = new Dev2JsonSerializer(); Thread.Sleep(5000); string correlation = GetCorrelationId(WarewolfTaskSchedulerPath + taskName); if (!Directory.Exists(OutputPath)) { Directory.CreateDirectory(OutputPath); } File.WriteAllText( string.Format("{0}DebugItems_{1}_{2}_{3}_{4}.txt", OutputPath, workflowName.Replace("\\", "_"), DateTime.Now.ToString("yyyy-MM-dd"), correlation, user), js.SerializeToBuilder(new List <DebugState> { state }).ToString()); }
public void DebugItem_GroupIndex_Greater_And_Equal_To_MaxItemDispatchCount() { var oldWebServerUri = EnvironmentVariables.WebServerUri; try { EnvironmentVariables.WebServerUri = "http://localhost:3142"; var item = new DebugItem(); item.Add(new DebugItemResult { GroupIndex = 11, GroupName = "Hello", Value = "world" }); Assert.AreEqual(1, item.ResultsList.Count); Assert.AreEqual(11, item.ResultsList[0].GroupIndex); Assert.AreEqual("Hello", item.ResultsList[0].GroupName); Assert.IsFalse(item.ResultsList[0].HasError); Assert.AreEqual("world", item.ResultsList[0].Value); Assert.IsTrue(item.ResultsList[0].MoreLink.StartsWith("http://localhost:3142/Services/FetchDebugItemFileService?DebugItemFilePath=C:\\ProgramData\\Warewolf\\Temp\\Warewolf\\Debug\\", StringComparison.Ordinal), "Expected " + item.ResultsList[0].MoreLink); } finally { EnvironmentVariables.WebServerUri = oldWebServerUri; } }
private static void Deserialize(IByteReaderBase reader, ICollection <IDebugItem> items) { var count = reader.ReadInt32(); for (var i = 0; i < count; i++) { var item = new DebugItem(); var resultCount = reader.ReadInt32(); for (var j = 0; j < resultCount; j++) { item.Add(new DebugItemResult { Type = (DebugItemResultType)reader.ReadInt32(), Label = reader.ReadString(), Variable = reader.ReadString(), Value = reader.ReadString(), GroupName = reader.ReadString(), GroupIndex = reader.ReadInt32(), MoreLink = reader.ReadString() }, true); } items.Add(item); } }
// ReSharper restore RedundantOverridenMember /// <summary> /// Executes the logic of the activity and calls the backend code to do the work /// Also responsible for adding the results to the data list /// </summary> /// <param name="context"></param> protected override void OnExecute(NativeActivityContext context) { _debugInputs = new List <DebugItem>(); _debugOutputs = new List <DebugItem>(); IDataListCompiler compiler = DataListFactory.CreateDataListCompiler(); IDSFDataObject dataObject = context.GetExtension <IDSFDataObject>(); ErrorResultTO errors; ErrorResultTO allErrors = new ErrorResultTO(); Guid executionId = dataObject.DataListID; InitializeDebug(dataObject); try { IsSingleValueRule.ApplyIsSingleValueRule(Result, allErrors); // Fetch all fields to search.... IList <string> toSearch = FieldsToSearch.Split(','); // now process each field for entire evaluated Where expression.... IBinaryDataListEntry bdle = compiler.Evaluate(executionId, enActionType.User, SearchCriteria, false, out errors); if (dataObject.IsDebugMode()) { var itemToAdd = new DebugItem(); itemToAdd.Add(new DebugItemResult { Type = DebugItemResultType.Label, Value = "Fields To Search" }); _debugInputs.Add(itemToAdd); } allErrors.MergeErrors(errors); if (bdle != null) { IDev2DataListEvaluateIterator itr = Dev2ValueObjectFactory.CreateEvaluateIterator(bdle); IDev2DataListUpsertPayloadBuilder <string> toUpsert = Dev2DataListBuilderFactory.CreateStringDataListUpsertBuilder(true); int idx; if (!Int32.TryParse(StartIndex, out idx)) { idx = 1; } IBinaryDataList toSearchList = compiler.FetchBinaryDataList(executionId, out errors); allErrors.MergeErrors(errors); int iterationIndex = 0; foreach (string s in toSearch) { if (dataObject.IsDebugMode()) { IBinaryDataListEntry tmpEntry = compiler.Evaluate(executionId, enActionType.User, s, false, out errors); AddDebugInputItem(s, string.Empty, tmpEntry, executionId); } // each entry in the recordset while (itr.HasMoreRecords()) { IList <IBinaryDataListItem> cols = itr.FetchNextRowData(); foreach (IBinaryDataListItem c in cols) { IRecsetSearch searchTo = ConvertToSearchTo(c.TheValue, idx.ToString(CultureInfo.InvariantCulture)); IList <string> results = RecordsetInterrogator.FindRecords(toSearchList, searchTo, out errors); allErrors.MergeErrors(errors); string concatRes = string.Empty; // ReSharper disable LoopCanBeConvertedToQuery foreach (string r in results) // ReSharper restore LoopCanBeConvertedToQuery { concatRes = string.Concat(concatRes, r, ","); } if (concatRes.EndsWith(",")) { concatRes = concatRes.Remove(concatRes.Length - 1); } //2013.06.03: Ashley Lewis for bug 9498 - handle multiple regions in result DataListCleaningUtils.SplitIntoRegions(Result); //2013.06.07: Massimo Guerrera for BUG 9497 - To handle putting out to a scalar as a CSV if (!DataListUtil.IsValueRecordset(Result)) { toUpsert.Add(Result, concatRes); toUpsert.FlushIterationFrame(); if (dataObject.IsDebugMode()) { AddDebugOutputItem(new DebugOutputParams(Result, concatRes, executionId, iterationIndex)); } } else { iterationIndex = 0; foreach (string r in results) { toUpsert.Add(Result, r); toUpsert.FlushIterationFrame(); if (dataObject.IsDebugMode()) { AddDebugOutputItem(new DebugOutputParams(Result, r, executionId, iterationIndex)); } iterationIndex++; } } } } } if (dataObject.IsDebugMode()) { AddDebugInputItem(SearchCriteria, "Where", bdle, executionId); } // now push the result to the server compiler.Upsert(executionId, toUpsert, out errors); allErrors.MergeErrors(errors); } } finally { var hasErrors = allErrors.HasErrors(); if (hasErrors) { DisplayAndWriteError("DsfFindRecordsActivity", allErrors); compiler.UpsertSystemTag(dataObject.DataListID, enSystemTag.Dev2Error, allErrors.MakeDataListReady(), out errors); compiler.Upsert(executionId, Result, (string)null, out errors); } if (dataObject.IsDebugMode()) { if (hasErrors) { AddDebugOutputItem(new DebugItemStaticDataParams("", Result, "")); } DispatchDebugState(context, StateType.Before); DispatchDebugState(context, StateType.After); } } }
public void DispatchDebugState(IDSFDataObject dataObject, StateType stateType) { Guid remoteID; Guid.TryParse(dataObject.RemoteInvokerID, out remoteID); if (stateType == StateType.Before) { if (_debugState == null) { InitializeDebugState(stateType, dataObject, remoteID, false, ""); } if (_debugState != null) { // Bug 8595 - Juries var type = GetType(); var instance = Activator.CreateInstance(type); var activity = instance as Activity; if (activity != null) { _debugState.Name = activity.DisplayName; } var act = instance as DsfActivity; //End Bug 8595 try { Copy(GetDebugInputs(dataObject.Environment), _debugState.Inputs); } catch (Exception err) { Dev2Logger.Log.Error("DispatchDebugState", err); AddErrorToDataList(err, dataObject); var errorMessage = dataObject.Environment.FetchErrors(); _debugState.ErrorMessage = errorMessage; _debugState.HasError = true; var debugError = err as DebugCopyException; if (debugError != null) { _debugState.Inputs.Add(debugError.Item); } } if (dataObject.RemoteServiceType == "Workflow" && act != null && !_debugState.HasError) { var debugItem = new DebugItem(); var debugItemResult = new DebugItemResult { Type = DebugItemResultType.Value, Label = "Execute workflow asynchronously: ", Value = dataObject.RunWorkflowAsync ? "True" : "False" }; debugItem.Add(debugItemResult); _debugState.Inputs.Add(debugItem); } } } else { bool hasError = dataObject.Environment.HasErrors(); var errorMessage = String.Empty; if (hasError) { errorMessage = string.Join(Environment.NewLine, dataObject.Environment.Errors); } if (_debugState == null) { InitializeDebugState(stateType, dataObject, remoteID, hasError, errorMessage); } if (_debugState != null) { _debugState.NumberOfSteps = IsWorkflow ? dataObject.NumberOfSteps : 0; _debugState.StateType = stateType; _debugState.EndTime = DateTime.Now; _debugState.HasError = hasError; _debugState.ErrorMessage = errorMessage; try { if (dataObject.RunWorkflowAsync && !_debugState.HasError) { var debugItem = new DebugItem(); var debugItemResult = new DebugItemResult { Type = DebugItemResultType.Value, Value = "Asynchronous execution started" }; debugItem.Add(debugItemResult); _debugState.Outputs.Add(debugItem); _debugState.NumberOfSteps = 0; } else { Copy(GetDebugOutputs(dataObject.Environment), _debugState.Outputs); } } catch (Exception e) { Dev2Logger.Log.Error("Debug Dispatch Error", e); AddErrorToDataList(e, dataObject); errorMessage = dataObject.Environment.FetchErrors(); _debugState.ErrorMessage = errorMessage; _debugState.HasError = true; } } } if (_debugState != null && (!(_debugState.ActivityType == ActivityType.Workflow || _debugState.Name == "DsfForEachActivity") && remoteID == Guid.Empty)) { _debugState.StateType = StateType.All; // Only dispatch 'before state' if it is a workflow or for each activity or a remote activity ;) if (stateType == StateType.Before) { return; } } // We know that if a if it is not a workflow it must be a service ;) if (dataObject.RemoteServiceType != "Workflow" && !String.IsNullOrWhiteSpace(dataObject.RemoteServiceType)) { if (_debugState != null) { _debugState.ActivityType = ActivityType.Service; } } if (_debugState != null) { if (remoteID == Guid.Empty) { switch (_debugState.StateType) { case StateType.Before: _debugState.Outputs.Clear(); break; case StateType.After: _debugState.Inputs.Clear(); break; } } // BUG 9706 - 2013.06.22 - TWR : refactored from here to DebugDispatcher _debugState.ClientID = dataObject.ClientID; _debugState.OriginatingResourceID = dataObject.ResourceID; _debugDispatcher.Write(_debugState, dataObject.RemoteInvoke, dataObject.RemoteInvokerID, dataObject.ParentInstanceID, dataObject.RemoteDebugItems); if (stateType == StateType.After) { // Free up debug state _debugState = null; } } }
private static void Deserialize(IByteReaderBase reader, ICollection<IDebugItem> items) { var count = reader.ReadInt32(); for(var i = 0; i < count; i++) { var item = new DebugItem(); var resultCount = reader.ReadInt32(); for(var j = 0; j < resultCount; j++) { item.Add(new DebugItemResult { Type = (DebugItemResultType)reader.ReadInt32(), Label = reader.ReadString(), Variable = reader.ReadString(), Value = reader.ReadString(), GroupName = reader.ReadString(), GroupIndex = reader.ReadInt32(), MoreLink = reader.ReadString() }, true); } items.Add(item); } }
public void DebugItem_Add_GroupIndexIsGreaterThan10_MoreLinkHasData() { DebugItem itemToAdd = new DebugItem(); itemToAdd.Add(new DebugItemResult { GroupIndex = 1, GroupName = "[[record(*).row]]", Label = "", Operator = "=", Value = "1", Type = DebugItemResultType.Variable, Variable = "[[record(1).row]]" }); itemToAdd.Add(new DebugItemResult { GroupIndex = 2, GroupName = "[[record(*).row]]", Label = "", Operator = "=", Value = "2", Type = DebugItemResultType.Variable, Variable = "[[record(2).row]]" }); itemToAdd.Add(new DebugItemResult { GroupIndex = 3, GroupName = "[[record(*).row]]", Label = "", Operator = "=", Value = "3", Type = DebugItemResultType.Variable, Variable = "[[record(3).row]]" }); itemToAdd.Add(new DebugItemResult { GroupIndex = 4, GroupName = "[[record(*).row]]", Label = "", Operator = "=", Value = "4", Type = DebugItemResultType.Variable, Variable = "[[record(4).row]]" }); itemToAdd.Add(new DebugItemResult { GroupIndex = 5, GroupName = "[[record(*).row]]", Label = "", Operator = "=", Value = "5", Type = DebugItemResultType.Variable, Variable = "[[record(5).row]]" }); itemToAdd.Add(new DebugItemResult { GroupIndex = 6, GroupName = "[[record(*).row]]", Label = "", Operator = "=", Value = "6", Type = DebugItemResultType.Variable, Variable = "[[record(6).row]]" }); itemToAdd.Add(new DebugItemResult { GroupIndex = 7, GroupName = "[[record(*).row]]", Label = "", Operator = "=", Value = "7", Type = DebugItemResultType.Variable, Variable = "[[record(7).row]]" }); itemToAdd.Add(new DebugItemResult { GroupIndex = 8, GroupName = "[[record(*).row]]", Label = "", Operator = "=", Value = "8", Type = DebugItemResultType.Variable, Variable = "[[record(8).row]]" }); itemToAdd.Add(new DebugItemResult { GroupIndex = 9, GroupName = "[[record(*).row]]", Label = "", Operator = "=", Value = "9", Type = DebugItemResultType.Variable, Variable = "[[record(9).row]]" }); itemToAdd.Add(new DebugItemResult { GroupIndex = 10, GroupName = "[[record(*).row]]", Label = "", Operator = "=", Value = "10", Type = DebugItemResultType.Variable, Variable = "[[record(10).row]]" }); itemToAdd.Add(new DebugItemResult { GroupIndex = 11, GroupName = "[[record(*).row]]", Label = "", Operator = "=", Value = "11", Type = DebugItemResultType.Variable, Variable = "[[record(11).row]]" }); itemToAdd.Add(new DebugItemResult { GroupIndex = 12, GroupName = "[[record(*).row]]", Label = "", Operator = "=", Value = "12", Type = DebugItemResultType.Variable, Variable = "[[record(12).row]]" }); itemToAdd.Add(new DebugItemResult { GroupIndex = 12, GroupName = "[[record(*).row]]", Label = "", Operator = "=", Value = "13", Type = DebugItemResultType.Variable, Variable = "[[record(13).row]]" }); Assert.AreEqual(11, itemToAdd.ResultsList.Count); Assert.IsTrue(string.IsNullOrEmpty(itemToAdd.ResultsList[0].MoreLink)); Assert.IsTrue(string.IsNullOrEmpty(itemToAdd.ResultsList[1].MoreLink)); Assert.IsTrue(string.IsNullOrEmpty(itemToAdd.ResultsList[2].MoreLink)); Assert.IsTrue(string.IsNullOrEmpty(itemToAdd.ResultsList[3].MoreLink)); Assert.IsTrue(string.IsNullOrEmpty(itemToAdd.ResultsList[4].MoreLink)); Assert.IsTrue(string.IsNullOrEmpty(itemToAdd.ResultsList[5].MoreLink)); Assert.IsTrue(string.IsNullOrEmpty(itemToAdd.ResultsList[6].MoreLink)); Assert.IsTrue(string.IsNullOrEmpty(itemToAdd.ResultsList[7].MoreLink)); Assert.IsTrue(string.IsNullOrEmpty(itemToAdd.ResultsList[8].MoreLink)); Assert.IsTrue(string.IsNullOrEmpty(itemToAdd.ResultsList[9].MoreLink)); Assert.IsFalse(string.IsNullOrEmpty(itemToAdd.ResultsList[10].MoreLink)); }