private void EnsureAvailableDataCrate() { if (_availableData == null) { _availableData = _crateStorage.CrateContentsOfType <CrateDescriptionCM>(x => x.Label == RuntimeCrateDescriptionsCrateLabel).FirstOrDefault(); if (_availableData == null) { _availableData = new CrateDescriptionCM(); _crateStorage.Add(Crate.FromContent(RuntimeCrateDescriptionsCrateLabel, _availableData)); } } }
private void AssertConfigureCrate(ICrateStorage crateStorage) { Assert.AreEqual(2, crateStorage.Count, "Crate storage count is not equal to 2"); Assert.AreEqual(1, crateStorage.CratesOfType <StandardConfigurationControlsCM>().Count(), "StandardConfigurationControlsCM count is not 1"); Assert.AreEqual(1, crateStorage.CratesOfType <CrateDescriptionCM>().Count(), "FieldDescriptionsCM count is not 1"); AssertConfigureControls(crateStorage.CrateContentsOfType <StandardConfigurationControlsCM>().Single()); var fieldDescriptions = crateStorage.CratesOfType <CrateDescriptionCM>().Single(); Assert.AreEqual("Runtime Available Crates", fieldDescriptions.Label, "Monitor Atlassian Runtime Fields labeled FieldDescriptionsCM was not found"); Assert.AreEqual(2, fieldDescriptions.Content.CrateDescriptions.Count(), "CrateDescriptions count is not 2"); var crateDescription = fieldDescriptions.Content.CrateDescriptions.Where(t => t.ManifestType.Equals("Standard Payload Data")); var fields = crateDescription.Single().Fields; Assert.AreEqual("Monitor Atlassian Runtime Fields", crateDescription.Single().Label, "Monitor Atlassian Runtime Fields labeled CrateDescription was not found"); Assert.AreEqual(9, crateDescription.Single().Fields.Count, "Published runtime field count is not 9"); Assert.IsTrue(fields.Exists(x => x.Name == IssueKey), "IssueKey is not signalled"); Assert.IsTrue(fields.Exists(x => x.Name == ProjectName), "ProjectName is not signalled"); Assert.IsTrue(fields.Exists(x => x.Name == IssueResolution), "IssueResolution is not signalled"); Assert.IsTrue(fields.Exists(x => x.Name == IssuePriority), "IssuePriority is not signalled"); Assert.IsTrue(fields.Exists(x => x.Name == IssueAssignee), "IssueAssignee is not signalled"); Assert.IsTrue(fields.Exists(x => x.Name == IssueSummary), "IssueSummary is not signalled"); Assert.IsTrue(fields.Exists(x => x.Name == IssueStatus), "IssueStatus is not signalled"); Assert.IsTrue(fields.Exists(x => x.Name == IssueDescription), "IssueDescription is not signalled"); Assert.IsTrue(fields.Exists(x => x.Name == EventType), "EventType is not signalled"); }
private Crate <StandardQueryCM> ExtractQueryCrate(ICrateStorage storage) { var configurationControls = storage .CrateContentsOfType <StandardConfigurationControlsCM>() .SingleOrDefault(); if (configurationControls == null) { throw new ApplicationException("Action was not configured correctly"); } var actionUi = new ActivityUi(); actionUi.ClonePropertiesFrom(configurationControls); var criteria = JsonConvert.DeserializeObject <List <FilterConditionDTO> >( actionUi.QueryBuilder.Value ); // This is weird to use query's name as the way to address MT type. // MT type has unique ID that should be used for this reason. Query name is something that is displayed to user. It should not contain any internal data. var queryCM = new StandardQueryCM( new QueryDTO() { Name = MT.DocuSignEnvelope.GetEnumDisplayName(), Criteria = criteria } ); return(Crate <StandardQueryCM> .FromContent(QueryCrateLabel, queryCM)); }
public static void AssertPayloadHasError(ICrateStorage storage) { var operationalStateCM = storage.CrateContentsOfType <OperationalStateCM>().Single(); ErrorDTO errorMessage; Assert.IsTrue(operationalStateCM.CurrentActivityResponse.TryParseErrorDTO(out errorMessage)); }
private void AssertConfigureCrate(ICrateStorage crateStorage) { Assert.AreEqual(1, crateStorage.Count); Assert.AreEqual(1, crateStorage.CratesOfType <StandardConfigurationControlsCM>().Count()); AssertConfigureControls(crateStorage.CrateContentsOfType <StandardConfigurationControlsCM>().Single()); }
private void ValidateConfigurationControls(ICrateStorage crateStorage) { var controls = crateStorage.CrateContentsOfType <StandardConfigurationControlsCM>().Single(); Assert.AreEqual(ControlTypes.TextArea, controls.Controls[0].Type); Assert.AreEqual(ControlTypes.QueryBuilder, controls.Controls[1].Type); Assert.AreEqual("QueryBuilder", controls.Controls[1].Name); Assert.AreEqual(ControlTypes.Button, controls.Controls[2].Type); Assert.AreEqual("Continue", controls.Controls[2].Name); }
public static void AssertPayloadHasAuthenticationError(ICrateStorage storage) { var operationalStateCM = storage.CrateContentsOfType <OperationalStateCM>().Single(); ErrorDTO errorMessage; operationalStateCM.CurrentActivityResponse.TryParseErrorDTO(out errorMessage); Assert.AreEqual(ActivityResponse.Error.ToString(), operationalStateCM.CurrentActivityResponse.Type); Assert.AreEqual(ActivityErrorCode.AUTH_TOKEN_NOT_PROVIDED_OR_INVALID.ToString(), errorMessage.ErrorCode); Assert.AreEqual("No AuthToken provided.", errorMessage.Message); }
/**********************************************************************************/ private OperationalStateCM GetOperationalState(ICrateStorage crateStorage) { var operationalState = crateStorage.CrateContentsOfType <OperationalStateCM>().FirstOrDefault(); if (operationalState == null) { throw new Exception("OperationalState was not found within the container payload."); } return(operationalState); }
public void RestoreCustomFields(ICrateStorage crateStorage) { var controls = crateStorage.CrateContentsOfType <StandardConfigurationControlsCM>().First(); foreach (var control in controls.Controls) { if (control.Name.StartsWith("CustomField_")) { Controls.Add(control); } } }
private List <KeyValueDTO> ExtractPayloadFields(ICrateStorage currentPayload) { var eventReportMS = currentPayload.CrateContentsOfType <EventReportCM>().SingleOrDefault(); var eventFieldsCrate = eventReportMS?.EventPayload.SingleOrDefault(); if (eventFieldsCrate == null) { return(null); } return(eventReportMS.EventPayload.CrateContentsOfType <StandardPayloadDataCM>().SelectMany(x => x.AllValues()).ToList()); }
protected StandardConfigurationControlsCM GetOrCreateStandardConfigurationControlsCM() { var controlsCM = _crateStorage .CrateContentsOfType <StandardConfigurationControlsCM>() .FirstOrDefault(); if (controlsCM == null) { controlsCM = new StandardConfigurationControlsCM(); _crateStorage.Add(Crate.FromContent(ConfigurationControlsLabel, controlsCM)); } return(controlsCM); }
/**********************************************************************************/ /// <summary> /// Remove all crates with the content of given type /// </summary> /// <typeparam name="T"></typeparam> /// <returns></returns> public static T GetOrAdd <T>(this ICrateStorage storage, Func <Crate <T> > createNewCrate) { var exising = storage.CrateContentsOfType <T>().FirstOrDefault(); if (exising == null) { var newCrate = createNewCrate(); storage.Add(newCrate); return(newCrate.Content); } return(exising); }
private void ValidateSolutionOperationalState(ICrateStorage crateStorage) { Assert.AreEqual(1, crateStorage.CratesOfType <OperationalStateCM>().Count()); var state = crateStorage.CrateContentsOfType <OperationalStateCM>().Single(); Assert.AreEqual( ActivityResponse.ExecuteClientActivity.ToString(), state.CurrentActivityResponse.Type ); Assert.AreEqual( "RunImmediately", state.CurrentActivityResponse.Body ); }
private void AssertConfigControls(ICrateStorage storage) { Assert.IsNotNull(storage, "Save to Salesforce.com activty crate storage is null."); var configControls = storage.CrateContentsOfType <StandardConfigurationControlsCM>().Single(); Assert.IsNotNull(configControls, "There is no config controls for Save to Salesforce.com activity"); Assert.AreEqual(1, configControls.Controls.Count, "There is more than one config control at initial config of Save to Salesforce.com"); var dropDownList = configControls.Controls.OfType <DropDownList>().Single(); Assert.IsNotNull(dropDownList, "SF Object Type drop down list is NULL in Save to SF.com"); Assert.IsNotNull(dropDownList.ListItems, "List items are not populated with supported SF object types."); Assert.IsTrue(dropDownList.ListItems.Count > 0, "List items are not populated with supported SF object types."); }
private void ValidatePlanName(PlanDTO plan, ICrateStorage crateStorage) { var configurationControls = crateStorage .CrateContentsOfType <StandardConfigurationControlsCM>() .SingleOrDefault(); var actionUi = new ActivityUi(); actionUi.ClonePropertiesFrom(configurationControls); var criteria = JsonConvert.DeserializeObject <List <FilterConditionDTO> >( actionUi.QueryBuilder.Value ); Assert.AreEqual(plan.Name.Trim().ToLower(), FilterConditionHelper.ParseConditionToText(criteria).Trim().ToLower()); }
protected StandardConfigurationControlsCM GetOrCreateStandardConfigurationControlsCM() { var controlsCM = _crateStorage .CrateContentsOfType <StandardConfigurationControlsCM>() .FirstOrDefault(); if (controlsCM == null) { var crate = _crateManager.CreateStandardConfigurationControlsCrate(ConfigurationControlsLabel); _crateStorage.Add(crate); controlsCM = crate.Content; } return(controlsCM); }
public static string FindField(this ICrateStorage payloadStorage, string fieldKey, bool ignoreCase = false, MT?manifestType = null, string label = null) { //search through every crate except operational state crate Expression <Func <Crate, bool> > defaultSearchArguments = (c) => c.ManifestType.Id != (int)MT.OperationalStatus; //apply label criteria if not null if (label != null) { Expression <Func <Crate, bool> > andLabel = (c) => c.Label == label; defaultSearchArguments = Expression.Lambda <Func <Crate, bool> >(Expression.AndAlso(defaultSearchArguments, andLabel), defaultSearchArguments.Parameters); } //apply manifest criteria if not null if (manifestType != null) { Expression <Func <Crate, bool> > andManifestType = (c) => c.ManifestType.Id == (int)manifestType; defaultSearchArguments = Expression.Lambda <Func <Crate, bool> >(Expression.AndAlso(defaultSearchArguments, andManifestType), defaultSearchArguments.Parameters); } //find user requested crate var foundCrates = payloadStorage.Where(defaultSearchArguments.Compile()).ToList(); if (!foundCrates.Any()) { return(null); } //get operational state crate to check for loops var operationalState = payloadStorage.CrateContentsOfType <OperationalStateCM>().Single(); //iterate through found crates to find the payload foreach (var foundCrate in foundCrates) { var foundField = FindField(operationalState, foundCrate, fieldKey); if (foundField != null) { return(foundField.Value); } } return(null); }
private void AssertConfigureCrate(ICrateStorage crateStorage) { Assert.AreEqual(3, crateStorage.Count, "Crate storage count is not equal to 3"); Assert.AreEqual(1, crateStorage.CratesOfType <StandardConfigurationControlsCM>().Count(), "StandardConfigurationControlsCM count is not 1"); Assert.AreEqual(1, crateStorage.CratesOfType <EventSubscriptionCM>().Count(), "EventSubscriptionCM count is not 1"); Assert.AreEqual(1, crateStorage.CratesOfType <CrateDescriptionCM>().Count(), "FieldDescriptionsCM count is not 1"); AssertConfigureControls(crateStorage.CrateContentsOfType <StandardConfigurationControlsCM>().Single()); var fieldDescriptions = crateStorage.CratesOfType <CrateDescriptionCM>().Single(); Assert.AreEqual("Runtime Available Crates", fieldDescriptions.Label, "Monitor Facebook Runtime Fields labeled FieldDescriptionsCM was not found"); Assert.AreEqual(1, fieldDescriptions.Content.CrateDescriptions.Count(), "CrateDescriptions count is not 1"); var fields = fieldDescriptions.Content.CrateDescriptions.Single().Fields; Assert.AreEqual("Monitor Facebook Runtime Fields", fieldDescriptions.Content.CrateDescriptions.Single().Label, "Monitor Facebook Runtime Fields labeled CrateDescription was not found"); Assert.AreEqual(4, fieldDescriptions.Content.CrateDescriptions.Single().Fields.Count, "Published runtime field count is not 4"); Assert.IsTrue(fields.Exists(x => x.Name == FacebookFeedIdField), "FacebookFeedIdField is not signalled"); Assert.IsTrue(fields.Exists(x => x.Name == FacebookFeedMessageField), "FacebookFeedMessageField is not signalled"); Assert.IsTrue(fields.Exists(x => x.Name == FacebookFeedStoryField), "FacebookFeedStoryField is not signalled"); Assert.IsTrue(fields.Exists(x => x.Name == FacebookFeedCreatedTimeField), "FacebookFeedCreatedTimeField is not signalled"); }
public static string FindField(this ICrateStorage payloadStorage, FieldDTO fieldToMatch) { if (payloadStorage == null) { throw new ArgumentNullException(nameof(payloadStorage)); } if (fieldToMatch == null) { throw new ArgumentNullException(nameof(fieldToMatch)); } if (string.IsNullOrWhiteSpace(fieldToMatch.Key)) { return(null); } var filteredCrates = payloadStorage.AsQueryable(); if (!string.IsNullOrWhiteSpace(fieldToMatch.SourceActivityId)) { filteredCrates = filteredCrates.Where(x => x.SourceActivityId == fieldToMatch.SourceActivityId); } if (!string.IsNullOrEmpty(fieldToMatch.SourceCrateLabel)) { filteredCrates = filteredCrates.Where(x => x.Label == fieldToMatch.SourceCrateLabel); } if (fieldToMatch.SourceCrateManifest != CrateManifestType.Any && fieldToMatch.SourceCrateManifest != CrateManifestType.Unknown) { filteredCrates = filteredCrates.Where(x => x.ManifestType.Equals(fieldToMatch.SourceCrateManifest)); } var operationalState = payloadStorage.CrateContentsOfType <OperationalStateCM>().Single(); //iterate through found crates to find the payload foreach (var foundCrate in filteredCrates) { var foundField = FindField(operationalState, foundCrate, fieldToMatch.Key); if (foundField != null) { return(foundField.Value); } } return(null); }
private void AssertConfigureCrate(ICrateStorage crateStorage) { Assert.AreEqual(3, crateStorage.Count, "Crate storage count is not equal to 3"); Assert.AreEqual(1, crateStorage.CratesOfType <StandardConfigurationControlsCM>().Count(), "StandardConfigurationControlsCM count is not 1"); Assert.AreEqual(1, crateStorage.CratesOfType <EventSubscriptionCM>().Count(), "EventSubscriptionCM count is not 1"); Assert.AreEqual(1, crateStorage.CratesOfType <CrateDescriptionCM>().Count(), "FieldDescriptionsCM count is not 1"); AssertConfigureControls(crateStorage.CrateContentsOfType <StandardConfigurationControlsCM>().Single()); var fieldDescriptions = crateStorage.CratesOfType <CrateDescriptionCM>().Single(); Assert.AreEqual("Runtime Available Crates", fieldDescriptions.Label, "Monitor Instagram Runtime Fields labeled FieldDescriptionsCM was not found"); Assert.AreEqual(1, fieldDescriptions.Content.CrateDescriptions.Count(), "CrateDescriptions count is not 1"); var fields = fieldDescriptions.Content.CrateDescriptions.Single().Fields; Assert.AreEqual("Monitor Instagram Runtime Fields", fieldDescriptions.Content.CrateDescriptions.Single().Label, "Monitor Instagram Runtime Fields labeled CrateDescription was not found"); Assert.AreEqual(6, fieldDescriptions.Content.CrateDescriptions.Single().Fields.Count, "Published runtime field count is not 6"); Assert.IsTrue(fields.Exists(x => x.Name == InstagramMediaId), "InstagramMediaId is not signalled"); Assert.IsTrue(fields.Exists(x => x.Name == InstagramCaptionId), "InstagramCaptionId is not signalled"); Assert.IsTrue(fields.Exists(x => x.Name == InstagramCaptionText), "InstagramCaptionText is not signalled"); Assert.IsTrue(fields.Exists(x => x.Name == InstagramCaptionCreatedTimeField), "InstagramCaptionCreatedTimeField is not signalled"); Assert.IsTrue(fields.Exists(x => x.Name == InstagramImageUrl), "InstagramImageUrl is not signalled"); Assert.IsTrue(fields.Exists(x => x.Name == InstagramImageUrlStandardResolution), "InstagramImageUrlStandardResolution is not signalled"); }
public OperationalStateCM GetOperationalState(ICrateStorage crateStorage) { OperationalStateCM curOperationalState = crateStorage.CrateContentsOfType <OperationalStateCM>().Single(); return(curOperationalState); }
public StandardConfigurationControlsCM GetConfigurationControls(ICrateStorage storage) { return(storage.CrateContentsOfType <StandardConfigurationControlsCM>(c => c.Label == BaseTerminalActivity.ConfigurationControlsLabel).FirstOrDefault()); }