Exemple #1
0
        private void AssertCrateTypes(ICrateStorage crateStorage)
        {
            Assert.AreEqual(2, crateStorage.Count);

            Assert.AreEqual(1, crateStorage.CratesOfType <StandardConfigurationControlsCM>().Count());
            Assert.AreEqual(1, crateStorage.CratesOfType <EventSubscriptionCM>().Count());
        }
        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 void AssertCrateTypes(ICrateStorage crateStorage)
        {
            Assert.AreEqual(2, crateStorage.Count);

            Assert.AreEqual(1, crateStorage.CratesOfType <StandardConfigurationControlsCM>().Count(x => x.Label == "Configuration_Controls"));
            Assert.AreEqual(1, crateStorage.CratesOfType <KeyValueListCM>().Count(x => x.Label == "Available Groups"));
        }
 private void AssertCrateTypes(ICrateStorage crateStorage)
 {
     Assert.AreEqual(5, crateStorage.Count);
     Assert.AreEqual(1, crateStorage.CratesOfType <StandardConfigurationControlsCM>().Count());
     Assert.AreEqual(1, crateStorage.CratesOfType <KeyValueListCM>().Count(x => x.Label == "AvailableTemplates"));
     Assert.AreEqual(1, crateStorage.CratesOfType <KeyValueListCM>().Count(x => x.Label == "AvailableHandlers"));
     Assert.AreEqual(1, crateStorage.CratesOfType <KeyValueListCM>().Count(x => x.Label == "AvailableRecipientEvents"));
     Assert.AreEqual(1, crateStorage.CratesOfType <KeyValueListCM>().Count(x => x.Label == "AvailableRunTimeDataFields"));
 }
        private void AssertFollowUpCrateTypes(ICrateStorage crateStorage)
        {
            Assert.AreEqual(4, crateStorage.Count);
            Assert.AreEqual(3, crateStorage.CratesOfType <KeyValueListCM>().Count());
            Assert.AreEqual(1, crateStorage.CratesOfType <StandardConfigurationControlsCM>().Count());

            Assert.AreEqual(1, crateStorage.CratesOfType <KeyValueListCM>().Count(x => x.Label == "Sql Table Definitions"));
            Assert.AreEqual(1, crateStorage.CratesOfType <KeyValueListCM>().Count(x => x.Label == "Sql Column Types"));
            Assert.AreEqual(1, crateStorage.CratesOfType <KeyValueListCM>().Count(x => x.Label == "Sql Connection String"));
        }
Exemple #6
0
        private void AssertCrateTypes(ICrateStorage crateStorage, bool expectValidationErrors = false)
        {
            Assert.AreEqual(1, crateStorage.CratesOfType <StandardConfigurationControlsCM>().Count(), "Missing configuration controls");
            Assert.AreEqual(1, crateStorage.CratesOfType <EventSubscriptionCM>().Count(x => x.Label == "Standard Event Subscriptions"), "Missing Standard Event Subscriptions");

            if (expectValidationErrors)
            {
                Assert.AreEqual(1, crateStorage.CratesOfType <ValidationResultsCM>().Count(x => x.Content.HasErrors), "Missing validation errors");
            }

            Assert.AreEqual(expectValidationErrors ? 3 : 2, crateStorage.Count, "Unexpected crates present");
        }
        private void AssertConfigureCrate(ICrateStorage crateStorage)
        {
            Assert.AreEqual(1, crateStorage.Count);
            Assert.AreEqual(1, crateStorage.CratesOfType <StandardConfigurationControlsCM>().Count());

            AssertConfigureControls(crateStorage.CrateContentsOfType <StandardConfigurationControlsCM>().Single());
        }
Exemple #8
0
        //This method returns one crate of the specified Manifest Type from the payload
        public T GetByManifest <T>(PayloadDTO payloadDTO) where T : Manifest
        {
            ICrateStorage curCrateStorage = FromDto(payloadDTO.CrateStorage);
            var           curCrate        = curCrateStorage.CratesOfType <T>().Single().Content;

            return(curCrate);
        }
Exemple #9
0
        private void AssertCrateTypes(ICrateStorage crateStorage)
        {
            Assert.AreEqual(1, crateStorage.Count,
                            "There should be only one crate storage in initial and follow up configuration of Write To Log action.");

            Assert.AreEqual(1, crateStorage.CratesOfType <StandardConfigurationControlsCM>().Count(),
                            "The target URL text box is missing in the configuration of Write To Log action.");
        }
        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");
        }
        private void ShouldHaveCorrectCrateStructure(ICrateStorage crateStorage)
        {
            Assert.True(crateStorage.CratesOfType <StandardConfigurationControlsCM>().Any(), "Crate StandardConfigurationControlsCM is missing in API response.");

            var controls = crateStorage.CratesOfType <StandardConfigurationControlsCM>().FirstOrDefault().Get <StandardConfigurationControlsCM>();

            var templatesDDLB = controls.FindByNameNested("TemplateSelector") as DropDownList;

            Assert.NotNull(templatesDDLB);
            Assert.True(templatesDDLB.ListItems.Any());

            var recipientEventDDLB = controls.FindByNameNested("RecipientEventSelector") as DropDownList;

            Assert.NotNull(recipientEventDDLB);
            Assert.True(recipientEventDDLB.ListItems.Any());

            var notifiersDDLB = controls.FindByNameNested("NotifierSelector") as DropDownList;

            Assert.NotNull(notifiersDDLB);
            Assert.True(notifiersDDLB.ListItems.Any());
        }
Exemple #12
0
        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");
        }
        private void SendDocuSignEnvelope_SelectFirstTemplate(ICrateStorage curCrateStorage)
        {
            // Fetch Available Template crate and parse StandardDesignTimeFieldsMS.
            // Fetch Configuration Controls crate and parse StandardConfigurationControlsMS

            var configurationControlsCrateDTO = curCrateStorage.CratesOfType <StandardConfigurationControlsCM>().Single(x => x.Label == "Configuration_Controls");

            var controlsMS = configurationControlsCrateDTO.Content;

            // Modify value of Selected_DocuSign_Template field and push it back to crate,
            // exact same way we do on front-end.
            var docuSignTemplateControlDTO = (DropDownList)controlsMS.Controls.Single(x => x.Name == "target_docusign_template");

            docuSignTemplateControlDTO.Value = docuSignTemplateControlDTO.ListItems.First().Value;
        }
Exemple #14
0
        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
                );
        }
        /// <summary>
        /// Add Advisory messages in case some user stat doesn't have inserted stat titles. Tell the users to update their mobile app
        /// </summary>
        /// <param name="storage"></param>
        public static void AddAdvisoryMessage(ICrateStorage storage)
        {
            var advisoryCrate          = storage.CratesOfType <AdvisoryMessagesCM>().FirstOrDefault();
            var currentAdvisoryResults = advisoryCrate == null ? new AdvisoryMessagesCM() : advisoryCrate.Content;

            var advisory = currentAdvisoryResults.Advisories.FirstOrDefault(x => x.Name == AdvisoryName);

            if (advisory == null)
            {
                currentAdvisoryResults.Advisories.Add(new AdvisoryMessageDTO {
                    Name = AdvisoryName, Content = AdvisoryContent
                });
            }
            else
            {
                advisory.Content = AdvisoryContent;
            }

            storage.Add(Crate.FromContent("Advisories", currentAdvisoryResults));
        }
 private void AssertCrateTypes(ICrateStorage crateStorage)
 {
     Assert.AreEqual(1, crateStorage.Count);
     Assert.AreEqual(1, crateStorage.CratesOfType <StandardConfigurationControlsCM>().Count(x => x.Label == "Configuration_Controls"));
 }
        public async Task Extract_Data_From_Envelopes_EndToEnd()
        {
            await RevokeTokens();

            string baseUrl = GetHubApiBaseUrl();

            var solutionCreateUrl = baseUrl + "plans?solutionName=Extract_Data_From_Envelopes";

            //
            // Create solution
            //
            var plan = await HttpPostAsync <string, PlanDTO>(solutionCreateUrl, null);

            var solution = plan.SubPlans.FirstOrDefault().Activities.FirstOrDefault();

            //
            // Send configuration request without authentication token
            //
            _solution = await HttpPostAsync <ActivityDTO, ActivityDTO>(_baseUrl + "activities/configure?id=" + solution.Id, solution);

            _crateStorage = Crate.FromDto(_solution.CrateStorage);
            var authTokenId = await ResolveAuth(_solution, _crateStorage);

            //
            // Send configuration request with authentication token
            //
            _solution = await HttpPostAsync <ActivityDTO, ActivityDTO>(_baseUrl + "activities/configure?id=" + _solution.Id, _solution);

            _crateStorage = Crate.FromDto(_solution.CrateStorage);
            Assert.True(_crateStorage.CratesOfType <StandardConfigurationControlsCM>().Any(), "Crate StandardConfigurationControlsCM is missing in API response.");

            var controlsCrate = _crateStorage.CratesOfType <StandardConfigurationControlsCM>().First();
            var controls      = controlsCrate.Content.Controls;

            //let's make some selections and go for re-configure
            var dataSource = controls.OfType <DropDownList>().FirstOrDefault(c => c.Name == "FinalActionsList");

            dataSource.Value       = "Send_DocuSign_Envelope";
            dataSource.selectedKey = "Send DocuSign Envelope";

            using (var updater = Crate.GetUpdatableStorage(_solution))
            {
                updater.Remove <StandardConfigurationControlsCM>();
                updater.Add(controlsCrate);
            }

            _solution = await HttpPostAsync <ActivityDTO, ActivityDTO>(baseUrl + "activities/configure?id=" + _solution.Id, _solution);

            _crateStorage = Crate.FromDto(_solution.CrateStorage);
            Assert.AreEqual(2, _solution.ChildrenActivities.Count(), "Solution child activities failed to create.");
            Assert.True(_solution.ChildrenActivities.Any(a => a.ActivityTemplate.Name == "Monitor_DocuSign_Envelope_Activity" && a.Ordering == 1),
                        "Failed to detect Monitor DocuSign Envelope Activity as the first child activity");
            Assert.True(_solution.ChildrenActivities.Any(a => a.ActivityTemplate.Name == "Send_DocuSign_Envelope" && a.Ordering == 2),
                        "Failed to detect Send DocuSign Envelope as the second child activity");


            var monitorDocuSignEnvelopeActivity = _solution.ChildrenActivities
                                                  .Single(x => x.ActivityTemplate.Name == "Monitor_DocuSign_Envelope_Activity");

            //
            // Apply auth-token to child MonitorDocuSignEvnelope activity.
            //

            var applyToken = new AuthenticationTokenGrantDTO()
            {
                ActivityId  = monitorDocuSignEnvelopeActivity.Id,
                AuthTokenId = authTokenId,
                IsMain      = false
            };

            await HttpPostAsync <AuthenticationTokenGrantDTO[], string>(
                _baseUrl + "authentication/tokens/grant",
                new AuthenticationTokenGrantDTO[] { applyToken }
                );


            monitorDocuSignEnvelopeActivity = await HttpPostAsync <ActivityDTO, ActivityDTO>(
                _baseUrl + "activities/configure?id=" + monitorDocuSignEnvelopeActivity.Id,
                monitorDocuSignEnvelopeActivity
                );

            //
            // Rename route
            //
            var newName = plan.Name + " | " + DateTime.UtcNow.ToShortDateString() + " " +
                          DateTime.UtcNow.ToShortTimeString();

            await HttpPostAsync <object, PlanDTO>(_baseUrl + "plans?id=" + plan.Id,
                                                  new { id = plan.Id, name = newName });

            //
            // Configure Monitor DocuSign Envelope action
            //
            _crateStorage = Crate.FromDto(monitorDocuSignEnvelopeActivity.CrateStorage);

            controlsCrate = _crateStorage.CratesOfType <StandardConfigurationControlsCM>().First();

            var checkbox = (CheckBox)controlsCrate.Content.Controls.Single(c => c.Type == ControlTypes.CheckBox && c.Name == "EnvelopeSent");

            checkbox.Selected = true;

            var radioButtonGroup = (RadioButtonGroup)controlsCrate.Content.Controls.Single(c => c.Type == ControlTypes.RadioButtonGroup && c.Name == "TemplateRecipientPicker");

            radioButtonGroup.Radios[1].Selected = true;

            using (var updatableStorage = Crate.GetUpdatableStorage(monitorDocuSignEnvelopeActivity))
            {
                updatableStorage.Remove <StandardConfigurationControlsCM>();
                updatableStorage.Add(controlsCrate);
            }

            monitorDocuSignEnvelopeActivity = await HttpPostAsync <ActivityDTO, ActivityDTO>(_baseUrl + "activities/save", monitorDocuSignEnvelopeActivity);

            monitorDocuSignEnvelopeActivity = await HttpPostAsync <ActivityDTO, ActivityDTO>(_baseUrl + "activities/configure", monitorDocuSignEnvelopeActivity);

            radioButtonGroup = (RadioButtonGroup)controlsCrate.Content.Controls.Single(c => c.Type == ControlTypes.RadioButtonGroup && c.Name == "TemplateRecipientPicker");
            var docuSignTemplate = radioButtonGroup.Radios[1].Controls.OfType <DropDownList>().First();

            docuSignTemplate.Value       = "9a4d2154-5b18-4316-9824-09432e62f458";
            docuSignTemplate.selectedKey = "Medical_Form_v1";
            docuSignTemplate.ListItems.Add(new ListItem()
            {
                Value = "9a4d2154-5b18-4316-9824-09432e62f458", Key = "Medical_Form_v1"
            });

            using (var updatableStorage = Crate.GetUpdatableStorage(monitorDocuSignEnvelopeActivity))
            {
                updatableStorage.Remove <StandardConfigurationControlsCM>();
                updatableStorage.Add(controlsCrate);
            }

            monitorDocuSignEnvelopeActivity = await HttpPostAsync <ActivityDTO, ActivityDTO>(_baseUrl + "activities/save", monitorDocuSignEnvelopeActivity);

            monitorDocuSignEnvelopeActivity = await HttpPostAsync <ActivityDTO, ActivityDTO>(_baseUrl + "activities/configure", monitorDocuSignEnvelopeActivity);

            _crateStorage    = Crate.FromDto(monitorDocuSignEnvelopeActivity.CrateStorage);
            controlsCrate    = _crateStorage.CratesOfType <StandardConfigurationControlsCM>().First();
            radioButtonGroup = (RadioButtonGroup)controlsCrate.Content.Controls.Single(c => c.Type == ControlTypes.RadioButtonGroup && c.Name == "TemplateRecipientPicker");
            docuSignTemplate = radioButtonGroup.Radios[1].Controls.OfType <DropDownList>().First();

            Assert.AreEqual("9a4d2154-5b18-4316-9824-09432e62f458", docuSignTemplate.Value, "Selected DocuSign Template did not save on Send DocuSign Envelope activity.");
            Assert.AreEqual("Medical_Form_v1", docuSignTemplate.selectedKey, "Selected DocuSign Template did not save on Send DocuSign Envelope activity.");

            //
            // Configure Send DocuSign Envelope action
            //
            var sendEnvelopeAction = _solution.ChildrenActivities.Single(a => a.ActivityTemplate.Name == "Send_DocuSign_Envelope");

            var sendEnvelopeApplyToken = new AuthenticationTokenGrantDTO()
            {
                ActivityId  = sendEnvelopeAction.Id,
                AuthTokenId = authTokenId,
                IsMain      = false
            };

            await HttpPostAsync <AuthenticationTokenGrantDTO[], string>(
                _baseUrl + "authentication/tokens/grant",
                new AuthenticationTokenGrantDTO[] { sendEnvelopeApplyToken }
                );

            sendEnvelopeAction = await HttpPostAsync <ActivityDTO, ActivityDTO>(
                _baseUrl + "activities/configure?id=" + sendEnvelopeAction.Id,
                sendEnvelopeAction
                );


            using (var updatableStorage = Crate.GetUpdatableStorage(sendEnvelopeAction))
            {
                controlsCrate = updatableStorage.CratesOfType <StandardConfigurationControlsCM>().First();

                docuSignTemplate             = controlsCrate.Content.Controls.OfType <DropDownList>().First();
                docuSignTemplate.Value       = "9a4d2154-5b18-4316-9824-09432e62f458";
                docuSignTemplate.selectedKey = "Medical_Form_v1";
                docuSignTemplate.ListItems.Add(new ListItem()
                {
                    Value = "9a4d2154-5b18-4316-9824-09432e62f458", Key = "Medical_Form_v1"
                });
            }

            sendEnvelopeAction = await HttpPostAsync <ActivityDTO, ActivityDTO>(_baseUrl + "activities/save", sendEnvelopeAction);

            sendEnvelopeAction = await HttpPostAsync <ActivityDTO, ActivityDTO>(_baseUrl + "activities/configure", sendEnvelopeAction);

            // Follow-up Configuration

            TextSource emailField;
            TextSource emailNameField;

            using (var updatableStorage = Crate.GetUpdatableStorage(sendEnvelopeAction))
            {
                controlsCrate          = updatableStorage.CratesOfType <StandardConfigurationControlsCM>().First();
                emailField             = controlsCrate.Content.Controls.OfType <TextSource>().First(f => f.InitialLabel == "freight testing role email");
                emailField.ValueSource = "specific";
                emailField.Value       = TestEmail;
                emailField.TextValue   = TestEmail;

                emailNameField             = controlsCrate.Content.Controls.OfType <TextSource>().First(f => f.InitialLabel == "freight testing role name");
                emailNameField.ValueSource = "specific";
                emailNameField.Value       = TestEmailName;
                emailNameField.TextValue   = TestEmailName;
            }

            sendEnvelopeAction = await HttpPostAsync <ActivityDTO, ActivityDTO>(_baseUrl + "activities/save", sendEnvelopeAction);

            _crateStorage = Crate.FromDto(sendEnvelopeAction.CrateStorage);
            controlsCrate = _crateStorage.CratesOfType <StandardConfigurationControlsCM>().First();

            docuSignTemplate = controlsCrate.Content.Controls.OfType <DropDownList>().First();
            Assert.AreEqual("9a4d2154-5b18-4316-9824-09432e62f458", docuSignTemplate.Value, "Selected DocuSign Template did not save on Send DocuSign Envelope action.");
            Assert.AreEqual("Medical_Form_v1", docuSignTemplate.selectedKey, "Selected DocuSign Template did not save on Send DocuSign Envelope action.");

            emailField = controlsCrate.Content.Controls.OfType <TextSource>().First(f => f.InitialLabel == "freight testing role email");
            Assert.AreEqual(TestEmail, emailField.Value, "Email did not save on Send DocuSign Envelope action.");
            Assert.AreEqual(TestEmail, emailField.TextValue, "Email did not save on Send DocuSign Envelope action.");

            emailNameField = controlsCrate.Content.Controls.OfType <TextSource>().First(f => f.InitialLabel == "freight testing role name");
            Assert.AreEqual(TestEmailName, emailNameField.Value, "Email Name did not save on Send DocuSign Envelope action.");
            Assert.AreEqual(TestEmailName, emailNameField.TextValue, "Email Name did not save on Send DocuSign Envelope action.");

            // Delete Monitor action
            await HttpDeleteAsync(_baseUrl + "activities?id=" + _solution.ChildrenActivities[0].Id);

            // Add Add Payload Manually action
            var activityCategoryParam = ActivityCategories.ProcessId.ToString();
            var activityTemplates     = await HttpGetAsync <List <WebServiceActivitySetDTO> >(_baseUrl + "webservices?id=" + activityCategoryParam);

            var apmActivityTemplate = activityTemplates
                                      .SelectMany(a => a.Activities)
                                      .Single(a => a.Name == "Add_Payload_Manually");
            var activityTemplateSummary = new ActivityTemplateSummaryDTO
            {
                Name            = apmActivityTemplate.Name,
                Version         = apmActivityTemplate.Version,
                TerminalName    = apmActivityTemplate.Terminal.Name,
                TerminalVersion = apmActivityTemplate.Terminal.Version
            };
            var apmAction = new ActivityDTO()
            {
                ActivityTemplate = activityTemplateSummary,
                ParentPlanNodeId = _solution.Id,
                RootPlanNodeId   = plan.Id
            };

            apmAction = await HttpPostAsync <ActivityDTO, ActivityDTO>(_baseUrl + "activities/save", apmAction);

            Assert.NotNull(apmAction, "Add Payload Manually action failed to create");
            Assert.IsTrue(apmAction.Id != default(Guid), "Add Payload Manually activity failed to create");

            //Add rows to Add Payload Manually action
            apmAction = await HttpPostAsync <ActivityDTO, ActivityDTO>(_baseUrl + "activities/configure", apmAction);

            _crateStorage = Crate.FromDto(apmAction.CrateStorage);
            controlsCrate = _crateStorage.CratesOfType <StandardConfigurationControlsCM>().First();
            var fieldList = controlsCrate.Content.Controls.OfType <FieldList>().First();

            fieldList.Value = @"[{""Key"":""Doctor"",""Value"":""Doctor1""},{""Key"":""Condition"",""Value"":""Condition1""}]";

            using (var updatableStorage = Crate.GetUpdatableStorage(apmAction))
            {
                updatableStorage.Remove <StandardConfigurationControlsCM>();
                updatableStorage.Add(controlsCrate);
            }

            // Move Add Payload Manually action to the beginning of the plan
            apmAction.Ordering = 1;
            apmAction          = await HttpPostAsync <ActivityDTO, ActivityDTO>(_baseUrl + "activities/save", apmAction);

            apmAction = await HttpPostAsync <ActivityDTO, ActivityDTO>(_baseUrl + "activities/configure", apmAction);

            Assert.AreEqual(1, apmAction.Ordering, "Failed to reoder the activity Add Payload Manually");

            //
            // Activate and run plan
            //
            await HttpPostAsync <string, ContainerDTO>(_baseUrl + "plans/run?planId=" + plan.Id, null);

            //
            // Deactivate plan
            //
            await HttpPostAsync <string, string>(_baseUrl + "plans/deactivate?planId=" + plan.Id, null);

            //
            // Delete plan
            //
            //await HttpDeleteAsync(_baseUrl + "plans?id=" + plan.Id);
        }
        public async Task Track_DocuSign_Recipients_EndToEnd()
        {
            await RevokeTokens();

            string baseUrl = GetHubApiBaseUrl();

            var solutionCreateUrl = baseUrl + "plans?solutionName=Track_DocuSign_Recipients_v2";


            //
            // Create solution
            //
            var plan = await HttpPostAsync <string, PlanDTO>(solutionCreateUrl, null);

            var solution = plan.SubPlans.FirstOrDefault().Activities.FirstOrDefault();

            var planReloadUrl = string.Format(baseUrl + "plans?id={0}&include_children=true", plan.Id);

            //
            // Send configuration request without authentication token
            //
            this._solution = await HttpPostAsync <ActivityDTO, ActivityDTO>(baseUrl + "activities/configure?id=" + solution.Id, solution);

            _crateStorage = Crate.FromDto(this._solution.CrateStorage);
            var  stAuthCrate = _crateStorage.CratesOfType <StandardAuthenticationCM>().FirstOrDefault();
            bool defaultDocuSignAuthTokenExists = stAuthCrate == null;

            if (!defaultDocuSignAuthTokenExists)
            {
                //
                // Authenticate with DocuSign
                //
                var creds = GetDocuSignCredentials();
                creds.Terminal = new TerminalSummaryDTO
                {
                    Name    = solution.ActivityTemplate.TerminalName,
                    Version = solution.ActivityTemplate.TerminalVersion
                };

                var token = await HttpPostAsync <CredentialsDTO, JObject>(baseUrl + "authentication/token", creds);

                Assert.AreEqual(false, String.IsNullOrEmpty(token["authTokenId"].Value <string>()), "AuthTokenId is missing in API response.");
                Guid tokenGuid = Guid.Parse(token["authTokenId"].Value <string>());

                //
                // Asociate token with action
                //
                var applyToken = new AuthenticationTokenGrantDTO()
                {
                    ActivityId  = solution.Id,
                    AuthTokenId = tokenGuid,
                    IsMain      = true
                };
                await HttpPostAsync <AuthenticationTokenGrantDTO[], string>(baseUrl + "authentication/tokens/grant", new AuthenticationTokenGrantDTO[] { applyToken });

                //let's give it some time to create MonitorDocusignEvents plan
                await Task.Delay(TimeSpan.FromSeconds(15));

                //let's post a fake event to populate MT database
                await PostFakeEvent();
            }



            //
            // Send configuration request with authentication token
            //
            this._solution = await HttpPostAsync <ActivityDTO, ActivityDTO>(baseUrl + "activities/configure?id=" + solution.Id, solution);

            _crateStorage = Crate.FromDto(this._solution.CrateStorage);

            ShouldHaveCorrectCrateStructure(_crateStorage);
            Assert.True(this._solution.ChildrenActivities.Length == 0);

            var controlsCrate = _crateStorage.CratesOfType <StandardConfigurationControlsCM>().First();
            var controls      = controlsCrate.Content.Controls;

            #region CHECK_CONFIGURATION_CONTROLS

            Assert.AreEqual(5, controls.Count);
            Assert.True(controls.Any(c => c.Type == ControlTypes.DropDownList && c.Name == "NotifierSelector"));
            Assert.True(controls.Any(c => c.Type == ControlTypes.DropDownList && c.Name == "RecipientEventSelector"));
            Assert.True(controls.Any(c => c.Type == ControlTypes.Duration && c.Name == "TimePeriod"));
            Assert.True(controls.Any(c => c.Type == ControlTypes.RadioButtonGroup && c.Name == "EnvelopeTypeSelectionGroup"));

            var radioButtonGroup = (RadioButtonGroup)controls.Single(c => c.Type == ControlTypes.RadioButtonGroup && c.Name == "EnvelopeTypeSelectionGroup");
            Assert.AreEqual(2, radioButtonGroup.Radios.Count);
            Assert.True(radioButtonGroup.Radios.Any(c => c.Name == "SentToSpecificRecipientOption"));
            Assert.True(radioButtonGroup.Radios.Any(c => c.Name == "BasedOnTemplateOption"));

            var specificRecipientOption = (RadioButtonOption)radioButtonGroup.Radios.Single(c => c.Name == "SentToSpecificRecipientOption");
            Assert.AreEqual(1, specificRecipientOption.Controls.Count);
            Assert.True(specificRecipientOption.Controls.Any(c => c.Name == "SpecificRecipientEmailText" && c.Type == ControlTypes.TextBox));

            var specificTemplateOption = (RadioButtonOption)radioButtonGroup.Radios.Single(c => c.Name == "BasedOnTemplateOption");
            Assert.AreEqual(1, specificTemplateOption.Controls.Count);
            Assert.True(specificTemplateOption.Controls.Any(c => c.Name == "TemplateSelector" && c.Type == ControlTypes.DropDownList));

            #endregion

            //let's make some selections and go for re-configure
            //RDN shouldn't update it's child activity structure until we select a notification method
            radioButtonGroup.Radios[0].Selected       = true;
            radioButtonGroup.Radios[1].Selected       = false;
            specificRecipientOption.Controls[0].Value = "*****@*****.**";

            using (var updater = Crate.GetUpdatableStorage(_solution))
            {
                updater.Remove <StandardConfigurationControlsCM>();
                updater.Add(controlsCrate);
            }

            this._solution = await HttpPostAsync <ActivityDTO, ActivityDTO>(baseUrl + "activities/configure?id=" + this._solution.Id, this._solution);

            _crateStorage = Crate.FromDto(this._solution.CrateStorage);
            ShouldHaveCorrectCrateStructure(_crateStorage);
            Assert.True(this._solution.ChildrenActivities.Length == 0);

            //everything seems perfect for now
            //let's force RDN for a followup configuration

            var timePeriod          = (Duration)controls.Single(c => c.Type == ControlTypes.Duration && c.Name == "TimePeriod");
            var notificationHandler = (DropDownList)controls.Single(c => c.Type == ControlTypes.DropDownList && c.Name == "NotifierSelector");
            var recipientEvent      = (DropDownList)controls.Single(c => c.Type == ControlTypes.DropDownList && c.Name == "RecipientEventSelector");

            timePeriod.Days    = 0;
            timePeriod.Hours   = 0;
            timePeriod.Minutes = 0;

            notificationHandler.SelectByKey("Send Email Using SendGrid Account");
            Assert.IsNotNullOrEmpty(notificationHandler.Value);
            recipientEvent.SelectByKey("Signed Envelope");
            Assert.IsNotNullOrEmpty(recipientEvent.Value);

            var button = (Button)controls.Single(c => c.Type == ControlTypes.Button && c.Name == "BuildSolutionButton");
            button.Clicked = true;

            using (var updatableStorage = Crate.GetUpdatableStorage(_solution))
            {
                updatableStorage.Remove <StandardConfigurationControlsCM>();
                updatableStorage.Add(controlsCrate);
            }

            this._solution = await HttpPostAsync <ActivityDTO, ActivityDTO>(baseUrl + "activities/configure?id=" + this._solution.Id, this._solution);

            _crateStorage = Crate.FromDto(this._solution.CrateStorage);

            //from now on our solution should have followup crate structure
            Assert.True(this._solution.ChildrenActivities.Length == 4, "Solution child actions failed to create.");

            Assert.True(this._solution.ChildrenActivities.Any(a => a.ActivityTemplate.Name == "Monitor_DocuSign_Envelope_Activity" && a.Ordering == 1));
            Assert.True(this._solution.ChildrenActivities.Any(a => a.ActivityTemplate.Name == "Set_Delay" && a.Ordering == 2));
            Assert.True(this._solution.ChildrenActivities.Any(a => a.ActivityTemplate.Name == "Get_Data_From_Fr8_Warehouse" && a.Ordering == 3));
            Assert.True(this._solution.ChildrenActivities.Any(a => a.ActivityTemplate.Name == "Test_Incoming_Data" && a.Ordering == 4));

            plan = await HttpGetAsync <PlanDTO>(planReloadUrl);

            Assert.AreEqual(3, plan.SubPlans.First().Activities.Count);
            Assert.True(plan.SubPlans.First().Activities.Any(a => a.ActivityTemplate.Name == "Build_Message" && a.Ordering == 2));
            var emailActivity = plan.SubPlans.First().Activities.Last();

            var activityTemplates = await HttpGetAsync <IEnumerable <ActivityTemplateCategoryDTO> >($"{baseUrl}/activity_templates");

            var templates            = activityTemplates.SelectMany(x => x.Activities);
            var selectedActivityName = templates.First(x => x.Id == Guid.Parse(notificationHandler.Value));
            Assert.True(emailActivity.ActivityTemplate.Name == selectedActivityName.Name);

            //let's configure email settings

            //let's configure this
            emailActivity = await HttpPostAsync <ActivityDTO, ActivityDTO>(baseUrl + "activities/configure?id=" + emailActivity.Id, emailActivity);

            var emailCrateStorage = Crate.GetStorage(emailActivity);

            var emailControlsCrate = emailCrateStorage.CratesOfType <StandardConfigurationControlsCM>().First();
            var emailAddress       = (TextSource)emailControlsCrate.Content.Controls.Single(c => c.Name == "EmailAddress");
            var emailSubject       = (TextSource)emailControlsCrate.Content.Controls.Single(c => c.Name == "EmailSubject");
            var emailBody          = (TextSource)emailControlsCrate.Content.Controls.Single(c => c.Name == "EmailBody");

            var upstreamFieldDescription = await HttpGetAsync <IncomingCratesDTO>(baseUrl + "plan_nodes/signals?id=" + emailActivity.Id);

            Assert.True(upstreamFieldDescription.AvailableCrates.SelectMany(x => x.Fields).Any(y => y.Name == "NotificationMessage"));
            Assert.AreEqual("NotificationMessage", emailBody.Value);

            emailAddress.ValueSource = "specific";
            emailAddress.Value       = TestEmail;
            emailAddress.TextValue   = TestEmail;

            emailSubject.ValueSource = "specific";
            emailSubject.Value       = "Fr8-TrackDocuSignRecipientsTest";
            emailSubject.TextValue   = "Fr8-TrackDocuSignRecipientsTest";

            emailBody.ValueSource = "specific";
            emailBody.Value       = "Fr8-TrackDocuSignRecipientsTest";
            emailBody.TextValue   = "Fr8-TrackDocuSignRecipientsTest";

            using (var updatableStorage = Crate.GetUpdatableStorage(emailActivity))
            {
                updatableStorage.Remove <StandardConfigurationControlsCM>();
                updatableStorage.Add(emailControlsCrate);
            }

            //save changes
            await HttpPostAsync <ActivityDTO, ActivityDTO>(baseUrl + "activities/save", emailActivity);

            //
            //Rename plan
            //
            var newName = plan.Name + " | " + DateTime.UtcNow.ToShortDateString() + " " + DateTime.UtcNow.ToShortTimeString();
            await HttpPostAsync <object, PlanDTO>(baseUrl + "plans?id=" + plan.Id, new { id = plan.Id, name = newName });

            //let's activate our plan
            await HttpPostAsync <string, string>(baseUrl + "plans/run?planId=" + plan.Id, null);


            //everything seems perfect -> let's fake a docusign event
            await PostFakeEvent();

            //let's wait 45 seconds before continuing
            await Task.Delay(TimeSpan.FromSeconds(45));

            //we should have received an email about this operation


            //
            // Deactivate plan
            //
            await HttpPostAsync <string, string>(baseUrl + "plans/deactivate?planid=" + plan.Id, plan.Id.ToString());

            //
            // Delete plan
            //
            await HttpDeleteAsync(baseUrl + "plans?id=" + plan.Id);

            // Verify that test email has been received
            //EmailAssert.EmailReceived(ConfigurationManager.AppSettings["OpsEmail"], "Fr8-TrackDocuSignRecipientsTest");
        }
Exemple #19
0
        public async Task Mail_Merge_Into_DocuSign_EndToEnd_Upstream_Values_From_Google_Check_Tabs()
        {
            //
            //Setup Test
            //
            await RevokeTokens();

            var terminalGoogleTestTools = new Fr8.Testing.Integration.Tools.Terminals.IntegrationTestTools_terminalGoogle(this);
            var googleActivityTestTools = new Fr8.Testing.Integration.Tools.Activities.IntegrationTestTools_terminalGoogle(this);
            var googleAuthTokenId       = await terminalGoogleTestTools.ExtractGoogleDefaultToken();

            string spreadsheetName    = Guid.NewGuid().ToString();
            string spreadsheetKeyWord = Guid.NewGuid().ToString();
            string worksheetName      = "TestSheet";

            //create new excel spreadsheet inside google and insert one row of data inside the spreadsheet
            //spreadsheetKeyWord is an identifier that will help up later in the test to easily identify specific envelope
            var    tableFixtureData = FixtureData.TestStandardTableData(TestEmail, spreadsheetKeyWord);
            string spreadsheetId    = await terminalGoogleTestTools.CreateNewSpreadsheet(googleAuthTokenId, spreadsheetName, worksheetName, tableFixtureData);

            //
            // Create solution
            //
            var parameters = await _docuSignActivitiesTestTools.CreateAndConfigure_MailMergeIntoDocuSign_Solution("Get_Google_Sheet_Data",
                                                                                                                  "Get Google Sheet Data", "a439cedc-92a8-49ad-ab31-e2ee7964b468", "Fr8 Fromentum Registration Form", false);

            this.solution = parameters.Item1;
            var plan      = parameters.Item2;
            var tokenGuid = parameters.Item3;

            //
            // configure Get_Google_Sheet_Data activity
            //
            var googleSheetActivity = this.solution.ChildrenActivities.Single(a => a.ActivityTemplate.Name.Equals("Get_Google_Sheet_Data", StringComparison.InvariantCultureIgnoreCase));
            await googleActivityTestTools.ConfigureGetFromGoogleSheetActivity(googleSheetActivity, spreadsheetName, false, worksheetName);

            //
            // configure Loop activity
            //
            var loopActivity         = this.solution.ChildrenActivities.Single(a => a.ActivityTemplate.Name.Equals("Loop", StringComparison.InvariantCultureIgnoreCase));
            var terminalFr8CoreTools = new IntegrationTestTools_terminalFr8(this);

            loopActivity = await terminalFr8CoreTools.ConfigureLoopActivity(loopActivity, "Standard Table Data", "Table Generated From Google Sheet Data");

            //
            // Configure Send DocuSign Envelope action
            //

            //
            // Initial Configuration
            //
            var sendEnvelopeAction = loopActivity.ChildrenActivities.Single(a => a.ActivityTemplate.Name == "Send_DocuSign_Envelope");

            crateStorage = Crate.FromDto(sendEnvelopeAction.CrateStorage);
            var controlsCrate = crateStorage.CratesOfType <StandardConfigurationControlsCM>().First();

            var docuSignTemplate = controlsCrate.Content.Controls.OfType <DropDownList>().First();

            docuSignTemplate.Value       = "a439cedc-92a8-49ad-ab31-e2ee7964b468";
            docuSignTemplate.selectedKey = "Fr8 Fromentum Registration Form";

            using (var updatableStorage = Crate.GetUpdatableStorage(sendEnvelopeAction))
            {
                updatableStorage.Remove <StandardConfigurationControlsCM>();
                updatableStorage.Add(controlsCrate);
            }

            sendEnvelopeAction = await HttpPostAsync <ActivityDTO, ActivityDTO>(_baseUrl + "activities/save", sendEnvelopeAction);

            sendEnvelopeAction = await HttpPostAsync <ActivityDTO, ActivityDTO>(_baseUrl + "activities/configure", sendEnvelopeAction);

            //
            // Follow-up Configuration
            //
            //chosen "Fr8 Fromentum Registration Form" contains 7 specific DocuSign tabs that will be configured with upstream values
            crateStorage  = Crate.FromDto(sendEnvelopeAction.CrateStorage);
            controlsCrate = crateStorage.CratesOfType <StandardConfigurationControlsCM>().First();
            var emailField = controlsCrate.Content.Controls.OfType <TextSource>().First(f => f.InitialLabel == "Lead role email");

            emailField.ValueSource = "upstream";
            emailField.Value       = "emailaddress";
            emailField.selectedKey = "emailaddress";

            var emailNameField = controlsCrate.Content.Controls.OfType <TextSource>().First(f => f.InitialLabel == "Lead role name");

            emailNameField.ValueSource = "upstream";
            emailNameField.Value       = "name";
            emailNameField.selectedKey = "name";

            var phoneField = controlsCrate.Content.Controls.OfType <TextSource>().First(f => f.InitialLabel == "Phone (Lead)");

            phoneField.ValueSource = "upstream";
            phoneField.Value       = "phone";
            phoneField.selectedKey = "phone";

            var titleField = controlsCrate.Content.Controls.OfType <TextSource>().First(f => f.InitialLabel == "Title (Lead)");

            titleField.ValueSource = "upstream";
            titleField.Value       = "title";
            titleField.selectedKey = "title";

            var companyField = controlsCrate.Content.Controls.OfType <TextSource>().First(f => f.InitialLabel == "Company (Lead)");

            companyField.ValueSource = "upstream";
            companyField.Value       = "companyname";
            companyField.selectedKey = "companyname";

            var radioGroup = controlsCrate.Content.Controls.OfType <RadioButtonGroup>().First(f => f.GroupName == "Registration Type (Lead)");

            foreach (var radios in radioGroup.Radios)
            {
                //reset all preselected radioButtons
                radios.Selected = false;
            }
            var radioButton = radioGroup.Radios.FirstOrDefault(x => x.Name == "Buy 2, Get 3rd Free");

            radioButton.Selected = true;

            var checkboxField = controlsCrate.Content.Controls.OfType <CheckBox>().First(f => f.Name == "CheckBoxFields_GovernmentEntity? (Lead)");

            checkboxField.Selected = true;

            var dropdownField = controlsCrate.Content.Controls.OfType <DropDownList>().First(f => f.Name == "DropDownListFields_Size of Company (Lead)");

            dropdownField.Value       = "Medium (51-250)";
            dropdownField.selectedKey = "Medium (51-250)";

            using (var updatableStorage = Crate.GetUpdatableStorage(sendEnvelopeAction))
            {
                updatableStorage.Remove <StandardConfigurationControlsCM>();
                updatableStorage.Add(controlsCrate);
            }

            sendEnvelopeAction = await HttpPostAsync <ActivityDTO, ActivityDTO>(_baseUrl + "activities/save", sendEnvelopeAction);

            crateStorage  = Crate.FromDto(sendEnvelopeAction.CrateStorage);
            controlsCrate = crateStorage.CratesOfType <StandardConfigurationControlsCM>().First();

            docuSignTemplate = controlsCrate.Content.Controls.OfType <DropDownList>().First();
            Assert.AreEqual("a439cedc-92a8-49ad-ab31-e2ee7964b468", docuSignTemplate.Value, "Selected DocuSign Template did not save on Send DocuSign Envelope action.");
            Assert.AreEqual("Fr8 Fromentum Registration Form", docuSignTemplate.selectedKey, "Selected DocuSign Template did not save on Send DocuSign Envelope action.");

            //
            // Activate and run plan
            //
            var container = await HttpPostAsync <string, ContainerDTO>(_baseUrl + "plans/run?planId=" + plan.Id, null);

            Assert.AreEqual(container.State, State.Completed, "Container state is not equal to completed on Mail_Merge e2e test");

            //
            // Assert
            //
            var authorizationTokenDO = _terminalDocuSignTestTools.GetDocuSignAuthToken(tokenGuid);
            var authorizationToken   = new AuthorizationToken()
            {
                Token = authorizationTokenDO.Token,
            };
            var configuration = new DocuSignManager().SetUp(authorizationToken);
            //find the envelope on the Docusign Account
            var folderItems = DocuSignFolders.GetFolderItems(configuration, new DocuSignQuery()
            {
                Status     = "sent",
                SearchText = spreadsheetKeyWord
            });

            var envelope = folderItems.FirstOrDefault();

            Assert.IsNotNull(envelope, "Cannot find created Envelope in sent folder of DocuSign Account");
            var envelopeApi = new EnvelopesApi(configuration.Configuration);
            //get the recipient that receive this sent envelope
            var envelopeSigner = envelopeApi.ListRecipients(configuration.AccountId, envelope.EnvelopeId).Signers.FirstOrDefault();

            Assert.IsNotNull(envelopeSigner, "Envelope does not contain signer as recipient. Send_DocuSign_Envelope activity failed to provide any signers");
            //get the tabs for the envelope that this recipient received
            var tabs = envelopeApi.ListTabs(configuration.AccountId, envelope.EnvelopeId, envelopeSigner.RecipientId);

            Assert.IsNotNull(tabs, "Envelope does not contain any tabs. Check for problems in DocuSignManager and HandleTemplateData");

            //check all tabs and their values for received envelope, and compare them to those from the google sheet configured into Mail_Merge_Into_Docusign solution
            var titleRecipientTab = tabs.TextTabs.FirstOrDefault(x => x.TabLabel == "Title");

            Assert.IsNotNull(titleRecipientTab, "Envelope does not contain Title tab. Check for problems in DocuSignManager and HandleTemplateData");
            Assert.AreEqual(tableFixtureData.Table[1].Row.FirstOrDefault(x => x.Cell.Key == "title").Cell.Value, titleRecipientTab.Value, "Provided value for Title in document for recipient after finishing mail merge plan is incorrect");

            var companyRecipientTab = tabs.TextTabs.FirstOrDefault(x => x.TabLabel == "Company");

            Assert.IsNotNull(companyRecipientTab, "Envelope does not contain Company tab. Check for problems in DocuSignManager and HandleTemplateData");
            Assert.AreEqual(tableFixtureData.Table[1].Row.FirstOrDefault(x => x.Cell.Key == "companyname").Cell.Value, companyRecipientTab.Value, "Provided value for CompanyName in document for recipient after finishing mail merge plan is incorrect");

            var phoneRecipientTab = tabs.TextTabs.FirstOrDefault(x => x.TabLabel == "Phone");

            Assert.IsNotNull(phoneRecipientTab, "Envelope does not contain phone tab. Check for problems in DocuSignManager and HandleTemplateData");
            Assert.AreEqual(tableFixtureData.Table[1].Row.FirstOrDefault(x => x.Cell.Key == "phone").Cell.Value, phoneRecipientTab.Value, "Provided value for phone in document for recipient after finishing mail merge plan is incorrect");

            var listRecipientTab = tabs.ListTabs.FirstOrDefault(x => x.TabLabel == "Size of Company");

            Assert.IsNotNull(listRecipientTab, "Envelope does not contain List Tab for Size of Company tab. Check for problems in DocuSignManager and HandleTemplateData");
            Assert.AreEqual("Medium (51-250)", listRecipientTab.Value, "Provided value for Size of Company(Lead) in document for recipient after finishing mail merge plan is incorrect");

            var checkboxRecipientTab = tabs.CheckboxTabs.FirstOrDefault(x => x.TabLabel == "GovernmentEntity?");

            Assert.IsNotNull(checkboxRecipientTab, "Envelope does not contain Checkbox for Goverment Entity tab. Check for problems in DocuSignManager and HandleTemplateData");
            Assert.AreEqual("true", checkboxRecipientTab.Selected, "Provided value for GovernmentEntity? in document for recipient after finishing mail merge plan is incorrect");

            var radioButtonGroupTab = tabs.RadioGroupTabs.FirstOrDefault(x => x.GroupName == "Registration Type");

            Assert.IsNotNull(radioButtonGroupTab, "Envelope does not contain RadioGroup tab for registration. Check for problems in DocuSignManager and HandleTemplateData");
            Assert.AreEqual("Buy 2, Get 3rd Free", radioButtonGroupTab.Radios.FirstOrDefault(x => x.Selected == "true").Value, "Provided value for Registration Type in document for recipient after finishing mail merge plan is incorrect");

            // Verify that test email has been received
            EmailAssert.EmailReceived("*****@*****.**", "Test Message from Fr8");

            //
            // Cleanup
            //

            //delete spreadsheet
            await terminalGoogleTestTools.DeleteSpreadSheet(googleAuthTokenId, spreadsheetId);

            //
            // Deactivate plan
            //
            await HttpPostAsync <string, string>(_baseUrl + "plans/deactivate?planId=" + plan.Id, null);

            //
            // Delete plan
            //
            //await HttpDeleteAsync(_baseUrl + "plans?id=" + plan.Id);
        }
        private async Task <Guid> ResolveAuth(ActivityDTO solution, ICrateStorage crateStorage)
        {
            Guid?tokenGuid = null;

            var stAuthCrate = crateStorage
                              .CratesOfType <StandardAuthenticationCM>()
                              .FirstOrDefault();

            if (stAuthCrate != null)
            {
                var terminalsAndTokens =
                    await HttpGetAsync <AuthenticationTokenTerminalDTO[]>(
                        _baseUrl + "authentication/tokens"
                        );

                var terminalDocuSign = terminalsAndTokens
                                       .SingleOrDefault(x => x.Name == "terminalDocuSign");

                if (terminalDocuSign != null)
                {
                    var token = terminalDocuSign.AuthTokens.FirstOrDefault(x => x.IsMain);
                    if (token == null)
                    {
                        token = terminalDocuSign.AuthTokens.FirstOrDefault();
                    }

                    Assert.NotNull(token, "Failed to get the auth token for Docusign terminal. ");
                    tokenGuid = token.Id;
                }

                if (!tokenGuid.HasValue)
                {
                    var creds = GetDocuSignCredentials();
                    creds.Terminal = new TerminalSummaryDTO
                    {
                        Name    = solution.ActivityTemplate.TerminalName,
                        Version = solution.ActivityTemplate.TerminalVersion
                    };

                    var token = await HttpPostAsync <CredentialsDTO, JObject>(
                        _baseUrl + "authentication/token",
                        creds
                        );

                    Assert.AreEqual(
                        false,
                        string.IsNullOrEmpty(token["authTokenId"].Value <string>()),
                        "AuthTokenId is missing in API response."
                        );

                    tokenGuid = Guid.Parse(token["authTokenId"].Value <string>());
                }
            }

            var applyToken = new AuthenticationTokenGrantDTO()
            {
                ActivityId  = solution.Id,
                AuthTokenId = tokenGuid.Value,
                IsMain      = false
            };

            await HttpPostAsync <AuthenticationTokenGrantDTO[], string>(
                _baseUrl + "authentication/tokens/grant",
                new AuthenticationTokenGrantDTO[] { applyToken }
                );

            return(tokenGuid.Value);
        }
Exemple #21
0
 /// <summary>
 /// Returns first crate with content of the given type.
 /// This method will return NULL if no such crates exists
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="predicate"></param>
 /// <returns></returns>
 public static Crate <T> FirstCrateOrDefault <T>(this ICrateStorage storage)
 {
     return(storage.CratesOfType <T>().FirstOrDefault());
 }
Exemple #22
0
 /**********************************************************************************/
 /// <summary>
 /// Returns first crate's content that complies with the predicate and with content of the given type.
 /// This method will return NULL if no such crates exists
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="predicate"></param>
 /// <returns></returns>
 public static T FirstCrateContentOrDefault <T>(this ICrateStorage storage, Predicate <Crate> predicate)
     where T : class
 {
     return(storage.CratesOfType <T>(predicate).FirstOrDefault()?.Content);
 }
Exemple #23
0
 /**********************************************************************************/
 /// <summary>
 /// Returns first crate that complies with the predicate and with content of the given type.
 /// This method will return NULL if no such crates exists
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="predicate"></param>
 /// <returns></returns>
 public static Crate <T> FirstCrateOrDefault <T>(this ICrateStorage storage, Predicate <Crate> predicate)
 {
     return(storage.CratesOfType <T>(predicate).FirstOrDefault());
 }
Exemple #24
0
 /**********************************************************************************/
 /// <summary>
 /// Returns all crates content that complies with the predicate and with content of the give type.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="predicate"></param>
 /// <returns></returns>
 public static IEnumerable <T> CrateContentsOfType <T>(this ICrateStorage storage, Predicate <Crate> predicate)
 {
     return(storage.CratesOfType <T>().Where(x => predicate(x)).Select(x => x.Get <T>()));
 }
Exemple #25
0
 /**********************************************************************************/
 /// <summary>
 /// Returns all crates content of the given type.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <returns></returns>
 public static IEnumerable <T> CrateContentsOfType <T>(this ICrateStorage storage)
 {
     return(storage.CratesOfType <T>().Select(x => x.Get <T>()));
 }
Exemple #26
0
 /**********************************************************************************/
 /// <summary>
 /// Returns all crates with content of the given type
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <returns></returns>
 public static IEnumerable <Crate <T> > CratesOfType <T>(this ICrateStorage storage)
 {
     return(storage.CratesOfType <T>(null));
 }
Exemple #27
0
 private void ValidateCrateStructure(ICrateStorage crateStorage)
 {
     Assert.AreEqual(1, crateStorage.CratesOfType <StandardConfigurationControlsCM>().Count());
     Assert.AreEqual(1, crateStorage.CratesOfType <FieldDescriptionsCM>().Count());
     Assert.AreEqual("Queryable Criteria", crateStorage.CratesOfType <FieldDescriptionsCM>().Single().Label);
 }