public async Task Run_Returns_ActivityDTO()
        {
            //Arrange
            var        runUrl  = GetTerminalRunUrl();
            Fr8DataDTO dataDto = HealthMonitor_FixtureData.GetFileListTestFr8DataDTO();

            // Add initial configuretion controls
            using (var crateStorage = Crate.GetUpdatableStorage(dataDto.ActivityDTO))
            {
                crateStorage.Add("Configuration_Controls", new StandardConfigurationControlsCM());
            }
            // Add operational state crate
            AddOperationalStateCrate(dataDto, new OperationalStateCM());

            //Act
            var responseActionDTO =
                await HttpPostAsync <Fr8DataDTO, PayloadDTO>(
                    runUrl,
                    dataDto
                    );

            //Assert
            Assert.IsNotNull(responseActionDTO);
            var crateFromDTO = Crate.FromDto(responseActionDTO.CrateStorage);

            Assert.IsNotNull(crateFromDTO);
            Assert.Greater(crateFromDTO.CratesOfType <StandardFileListCM>().Count(), 0);
        }
        public async Task Post_To_Yammer_Run_Return_Payload()
        {
            //Arrange
            var runUrl      = GetTerminalRunUrl();
            var activityDTO = await ConfigurationRequest();

            var dataDTO = new Fr8DataDTO {
                ActivityDTO = activityDTO
            };

            AddPayloadCrate(
                dataDTO,
                new StandardPayloadDataCM(
                    new KeyValueDTO("message", "Hello")
                    ),
                "Payload crate"
                );

            activityDTO.AuthToken = HealthMonitor_FixtureData.Yammer_AuthToken();

            //Act
            var responsePayloadDTO = await HttpPostAsync <Fr8DataDTO, PayloadDTO>(runUrl, dataDTO);

            //Assert
            var crateStorage          = Crate.FromDto(responsePayloadDTO.CrateStorage);
            var StandardPayloadDataCM = crateStorage.CrateContentsOfType <StandardPayloadDataCM>().SingleOrDefault();

            Assert.IsNotNull(StandardPayloadDataCM);
        }
        public void Run_With_Plan_Payload()
        {
            var configureUrl       = GetTerminalConfigureUrl();
            var requestActivityDTO = FixtureData.MonitorFr8Event_InitialConfiguration_ActivityDTO();
            var dataDTO            = new Fr8DataDTO {
                ActivityDTO = requestActivityDTO
            };
            var responseActivityDTO = HttpPostAsync <Fr8DataDTO, ActivityDTO>(configureUrl, dataDTO).Result;
            var runUrl = GetTerminalRunUrl();

            dataDTO.ActivityDTO = responseActivityDTO;
            AddPayloadCrate(
                dataDTO,
                new EventReportCM()
            {
                EventPayload = new CrateStorage()
                {
                    Fr8.Infrastructure.Data.Crates.Crate.FromContent(
                        "RouteActivatedReport",
                        RouteActivated()
                        )
                },
                EventNames = "RouteActivated"
            }
                );
            AddOperationalStateCrate(dataDTO, new OperationalStateCM());
            var runResponse = HttpPostAsync <Fr8DataDTO, PayloadDTO>(runUrl, dataDTO).Result;

            Assert.NotNull(runResponse);
        }
        public async void Run_With_Plan_Payload_Initial_Run()
        {
            var configureUrl     = GetTerminalConfigureUrl();
            var requestActionDTO = CreateRequestActivityFixture();

            var dataDTO = new Fr8DataDTO {
                ActivityDTO = requestActionDTO
            };

            var responseActionDTO = await HttpPostAsync <Fr8DataDTO, ActivityDTO>(configureUrl, dataDTO);

            var operationalState = new OperationalStateCM();

            operationalState.CallStack.PushFrame(new OperationalStateCM.StackFrame());
            AddOperationalStateCrate(dataDTO, operationalState);
            var runUrl = GetTerminalRunUrl();

            dataDTO.ActivityDTO = responseActionDTO;
            var runResponse = await HttpPostAsync <Fr8DataDTO, PayloadDTO>(runUrl, dataDTO);

            Assert.NotNull(runResponse);
            var crateStorage          = Crate.GetStorage(runResponse);
            var operationalStateCrate = crateStorage.CrateContentsOfType <OperationalStateCM>().Single();

            Assert.AreEqual(ActivityResponse.RequestSuspend.ToString(), operationalStateCrate.CurrentActivityResponse.Type);
        }
        public void Run_With_Plan_Payload_Second_Run()
        {
            var configureUrl     = GetTerminalConfigureUrl();
            var requestActionDTO = CreateRequestActivityFixture();
            var dataDTO          = new Fr8DataDTO {
                ActivityDTO = requestActionDTO
            };

            dataDTO.ActivityDTO = HttpPostAsync <Fr8DataDTO, ActivityDTO>(configureUrl, dataDTO).Result;
            SetDuration(dataDTO.ActivityDTO);
            var runUrl           = GetTerminalRunUrl();
            var operationalState = new OperationalStateCM();

            operationalState.CallStack.PushFrame(new OperationalStateCM.StackFrame {
                CurrentActivityExecutionPhase = OperationalStateCM.ActivityExecutionPhase.ProcessingChildren
            });
            operationalState.CallStack.PushFrame(new OperationalStateCM.StackFrame {
                CurrentActivityExecutionPhase = OperationalStateCM.ActivityExecutionPhase.WasNotExecuted
            });
            operationalState.CallStack.StoreLocalData("Delay", "suspended");
            AddOperationalStateCrate(dataDTO, operationalState);

            var runResponse = HttpPostAsync <Fr8DataDTO, PayloadDTO>(runUrl, dataDTO).Result;

            Assert.NotNull(runResponse);
            var crateStorage          = Crate.GetStorage(runResponse);
            var operationalStateCrate = crateStorage.CrateContentsOfType <OperationalStateCM>().Single();

            Assert.AreEqual(ActivityResponse.Success.ToString(), operationalStateCrate.CurrentActivityResponse.Type);
        }
 public void AddActivityTemplate(Fr8DataDTO dataDTO, ActivityTemplateDTO activityTemplate)
 {
     AddHubCrate(dataDTO, new KeyValueListCM(new KeyValueDTO("ActivityTemplate", JsonConvert.SerializeObject(activityTemplate))),
                 "HealthMonitor_ActivityTemplate",
                 ""
                 );
 }
Esempio n. 7
0
        public void Check_Initial_Configuration_Crate_Structure()
        {
            //Assert.AreEqual(1, 2);
            var configureUrl = GetTerminalConfigureUrl();

            var requestActionDTO = CreateRequestActivityFixture();

            var dataDTO = new Fr8DataDTO {
                ActivityDTO = requestActionDTO
            };
            var responseActionDTO = HttpPostAsync <Fr8DataDTO, ActivityDTO>(configureUrl, dataDTO).Result;

            Assert.NotNull(responseActionDTO);
            Assert.NotNull(responseActionDTO.CrateStorage);

            var crateStorage = Crate.FromDto(responseActionDTO.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 == "Select Fr8 Object"));

            var configCrate = crateStorage
                              .CrateContentsOfType <StandardConfigurationControlsCM>(x => x.Label == "Configuration_Controls")
                              .SingleOrDefault();

            ValidateConfigurationCrateStructure(configCrate);

            var designTimeCrate = crateStorage
                                  .CrateContentsOfType <KeyValueListCM>(x => x.Label == "Select Fr8 Object")
                                  .SingleOrDefault();

            ValidateFr8ObjectCrateStructure(designTimeCrate);
        }
Esempio n. 8
0
        public void Run_With_Container_Payload()
        {
            var configureUrl = GetTerminalConfigureUrl();

            var requestActionDTO = CreateRequestActivityFixture();

            var dataDTO = new Fr8DataDTO {
                ActivityDTO = requestActionDTO
            };

            var responseActionDTO = HttpPostAsync <Fr8DataDTO, ActivityDTO>(configureUrl, dataDTO).Result;

            SetContainersOptionSelected(responseActionDTO);

            var runUrl = GetTerminalRunUrl();

            dataDTO.ActivityDTO = responseActionDTO;

            AddPayloadCrate(dataDTO, new StandardFr8ContainersCM()
            {
                Name        = "Some name",
                Description = "Some description",
                LastUpdated = DateTime.UtcNow,
                CreatedDate = DateTime.UtcNow
            });
            AddOperationalStateCrate(dataDTO, new OperationalStateCM());

            var runResponse = HttpPostAsync <Fr8DataDTO, PayloadDTO>(runUrl, dataDTO).Result;

            Assert.NotNull(runResponse);
        }
Esempio n. 9
0
        public async Task Get_Google_Sheet_Data_v1_FollowupConfiguration_Row_Only_Table()
        {
            var configureUrl = GetTerminalConfigureUrl();

            HealthMonitor_FixtureData fixture = new HealthMonitor_FixtureData();
            var requestActionDTO = fixture.Get_Google_Sheet_Data_v1_Followup_Configuration_Request_ActivityDTO_With_Crates();

            ////Act
            fixture.Get_Google_Sheet_Data_v1_AddPayload(requestActionDTO, "Row_Only");
            var dataDTO = new Fr8DataDTO {
                ActivityDTO = requestActionDTO
            };
            //As the ActionDTO is preconfigured configure url actually calls the follow up configuration
            var responseActionDTO =
                await HttpPostAsync <Fr8DataDTO, ActivityDTO>(
                    configureUrl,
                    dataDTO
                    );

            //Assert
            Assert.NotNull(responseActionDTO);
            Assert.NotNull(responseActionDTO.CrateStorage);

            var crateStorage = Crate.FromDto(responseActionDTO.CrateStorage);

            Assert.AreEqual(1, crateStorage.Count);
            Assert.AreEqual(1, crateStorage.CratesOfType <StandardConfigurationControlsCM>().Count());
        }
Esempio n. 10
0
        public async Task Get_Jira_Issue_v1_Run_CheckPayloadDTO()
        {
            var activityDTO = await ConfigureFollowUp();

            activityDTO.AuthToken = HealthMonitor_FixtureData.Jira_AuthToken();

            var runUrl = GetTerminalRunUrl();
            var data   = new Fr8DataDTO()
            {
                ActivityDTO = activityDTO
            };

            AddPayloadCrate(data, new OperationalStateCM());

            var payload = await HttpPostAsync <Fr8DataDTO, PayloadDTO>(runUrl, data);

            Assert.IsNotNull(payload);
            Assert.IsNotNull(payload.CrateStorage);

            var crateStorage = Crate.FromDto(payload.CrateStorage);

            Assert.AreEqual(2, crateStorage.Count);
            Assert.AreEqual(1, crateStorage.CratesOfType <OperationalStateCM>().Count());
            Assert.AreEqual(1, crateStorage.CratesOfType <StandardPayloadDataCM>().Count());

            var payloadData = crateStorage.CrateContentsOfType <StandardPayloadDataCM>().First();

            Assert.IsNotNull(payloadData.PayloadObjects);
            Assert.AreEqual(1, payloadData.PayloadObjects.Count);
            Assert.AreEqual("FR-1245", payloadData.PayloadObjects[0].GetValue("Key"));
        }
Esempio n. 11
0
        public async Task Get_Google_Sheet_Data_v1_FollowupConfiguration_Row_And_Column_Table()
        {
            var configureUrl = GetTerminalConfigureUrl();

            HealthMonitor_FixtureData fixture = new HealthMonitor_FixtureData();
            var requestActionDTO = fixture.Get_Google_Sheet_Data_v1_Followup_Configuration_Request_ActivityDTO_With_Crates();

            ////Act
            fixture.Get_Google_Sheet_Data_v1_AddPayload(requestActionDTO, "Row_And_Column");
            var dataDTO = new Fr8DataDTO {
                ActivityDTO = requestActionDTO
            };
            //As the ActionDTO is preconfigured configure url actually calls the follow up configuration
            var responseActionDTO =
                await HttpPostAsync <Fr8DataDTO, ActivityDTO>(
                    configureUrl,
                    dataDTO
                    );

            //Assert
            Assert.NotNull(responseActionDTO);
            Assert.NotNull(responseActionDTO.CrateStorage);

            var crateStorage = Crate.FromDto(responseActionDTO.CrateStorage);

            Assert.AreEqual(1, crateStorage.Count);
            Assert.AreEqual(1, crateStorage.CratesOfType <StandardConfigurationControlsCM>().Count());

            // Due to performance issue, remove functionalilty to load table contents
            //  Assert.AreEqual("(2,1)", crateStorage.CratesOfType<StandardTableDataCM>().Single().Content.Table[0].Row[0].Cell.Value);
            //Assert.AreEqual("(2,2)", crateStorage.CratesOfType<StandardTableDataCM>().Single().Content.Table[0].Row[1].Cell.Value);
        }
Esempio n. 12
0
        public async Task Create_Stat_FollowUp_Configuration_Check_Crate_Structure()
        {
            var configureUrl = GetTerminalConfigureUrl();
            var responseDTO  = await CompleteInitialConfiguration();

            responseDTO.AuthToken = await _authorizationTokenHelper.GetStatXAuthToken();

            var dataDTO = new Fr8DataDTO
            {
                ActivityDTO = responseDTO
            };

            responseDTO = await HttpPostAsync <Fr8DataDTO, ActivityDTO>(configureUrl, dataDTO);

            Assert.NotNull(responseDTO, "Response is null on initial configuration");
            Assert.NotNull(responseDTO.CrateStorage, "Crate storage is null on initial configuration");
            var crateStorage = Crate.FromDto(responseDTO.CrateStorage);

            Assert.AreEqual(2, crateStorage.Count, "Crate storage count is not equal to 1");
            Assert.AreEqual(1, crateStorage.CratesOfType <StandardConfigurationControlsCM>().Count(), "StandardConfigurationControlsCM count is not 1");

            Assert.AreEqual(2, crateStorage.CrateContentsOfType <StandardConfigurationControlsCM>().Single().Controls.Count, "Control count is not 2");
            Assert.IsTrue(crateStorage.CrateContentsOfType <StandardConfigurationControlsCM>().Single().Controls[0] is RadioButtonGroup, "First control isn't a RadioButtonGroup");
            Assert.AreEqual("StatXGroupsSelectionGroup", crateStorage.CrateContentsOfType <StandardConfigurationControlsCM>().Single().Controls[0].Name, "Invalid Name on control");
        }
        public async Task Post_To_Chatter_Run_With_ValidParameter_Check_PayloadDto_OperationalState()
        {
            //Arrange
            var authToken = terminalIntegrationTests.Fixtures.HealthMonitor_FixtureData.Salesforce_AuthToken().Result;
            var initialConfigActionDto = await PerformInitialConfiguration();

            initialConfigActionDto.AuthToken = authToken;
            var dataDTO = new Fr8DataDTO {
                ActivityDTO = initialConfigActionDto
            };

            AddOperationalStateCrate(dataDTO, new OperationalStateCM());

            //Act
            var responseOperationalState = await HttpPostAsync <Fr8DataDTO, PayloadDTO>(GetTerminalRunUrl(), dataDTO);

            //Assert
            Assert.IsNotNull(responseOperationalState);
            var newFeedIdCrate = Crate.GetStorage(responseOperationalState)
                                 .CratesOfType <StandardPayloadDataCM>()
                                 .SingleOrDefault();

            Assert.IsNotNull(newFeedIdCrate, "Feed is not created");
            Assert.IsTrue(await _container.GetInstance <SalesforceManager>().Delete(SalesforceObjectType.FeedItem,
                                                                                    newFeedIdCrate.Content.PayloadObjects[0].PayloadObject[0].Value, new AuthorizationToken {
                Token = authToken.Token, AdditionalAttributes = authToken.AdditionalAttributes
            }), "Test feed created is not deleted");
        }
Esempio n. 14
0
        public void Run_With_Plan_Payload()
        {
            var configureUrl = GetTerminalConfigureUrl();

            var requestActionDTO = CreateRequestActivityFixture();

            var dataDTO = new Fr8DataDTO {
                ActivityDTO = requestActionDTO
            };

            var responseActionDTO = HttpPostAsync <Fr8DataDTO, ActivityDTO>(configureUrl, dataDTO).Result;

            SetPlansOptionSelected(responseActionDTO);

            var runUrl = GetTerminalRunUrl();

            dataDTO.ActivityDTO = responseActionDTO;

            AddPayloadCrate(dataDTO, new StandardFr8PlansCM
            {
                CreateDate  = DateTime.UtcNow,
                LastUpdated = DateTime.UtcNow,
                Description = "Some description",
                Name        = "Some name",
                Ordering    = 1,
                PlanState   = "Some state",
                SubPlans    = new List <SubplanDTO>()
            });
            AddOperationalStateCrate(dataDTO, new OperationalStateCM());


            var runResponse = HttpPostAsync <Fr8DataDTO, PayloadDTO>(runUrl, dataDTO).Result;

            Assert.NotNull(runResponse);
        }
Esempio n. 15
0
        public async Task Monitor_DocuSign_FollowUp_Configuration_RecipientValue()
        {
            var configureUrl = GetTerminalConfigureUrl();

            var activityDTO = await GetActivityDTO_WithRecipientValue();

            var dataDTO = new Fr8DataDTO {
                ActivityDTO = activityDTO
            };
            var responseActionDTO =
                await HttpPostAsync <Fr8DataDTO, ActivityDTO>(
                    configureUrl,
                    dataDTO
                    );

            var crateStorage = Crate.GetStorage(responseActionDTO);

            var availableFields = crateStorage
                                  .CrateContentsOfType <CrateDescriptionCM>(x => x.Label == "Runtime Available Crates")
                                  .Single();

            Assert.AreEqual(1, availableFields.CrateDescriptions.Count, "Unexpected number of available crates");

            Assert.AreEqual(7, availableFields.CrateDescriptions[0].Fields.Count, "Unexpected number of available fields");
        }
Esempio n. 16
0
        /// <summary>
        /// Posts ActionDTO to "/activities/&lt;actionType&gt;"
        /// </summary>
        /// <param name="curActionType">Action Type</param>
        /// <param name="activityDTO">DTO</param>
        /// <remarks>Uses <paramref name="curActionType"/> argument for constructing request uri replacing all space characters with "_"</remarks>
        /// <returns></returns>
        public async Task <TResponse> CallActivityAsync <TResponse>(
            string curActionType,
            IEnumerable <KeyValuePair <string, string> > parameters,
            Fr8DataDTO dataDTO,
            string correlationId)
        {
            if (dataDTO == null)
            {
                throw new ArgumentNullException(nameof(dataDTO));
            }

            if (dataDTO.ActivityDTO == null)
            {
                throw new ArgumentNullException(nameof(dataDTO.ActivityDTO));
            }

            if (dataDTO.ActivityDTO.ActivityTemplate == null)
            {
                throw new ArgumentOutOfRangeException(nameof(dataDTO.ActivityDTO), "ActivityTemplate must be specified explicitly");
            }

            var activityTemplate = dataDTO.ActivityDTO.ActivityTemplate;
            var terminal         = ObjectFactory.GetInstance <ITerminal>().GetByNameAndVersion(activityTemplate.TerminalName, activityTemplate.TerminalVersion);

            var    actionName  = Regex.Replace(curActionType, @"[^-_\w\d]", "_").ToLower();
            string queryString = string.Empty;

            if (parameters != null && parameters.Any())
            {
                var queryStringBuilder = new StringBuilder();
                queryStringBuilder.Append("?");
                foreach (var parameter in parameters)
                {
                    if (queryStringBuilder.Length > 1)
                    {
                        queryStringBuilder.Append("&");
                    }

                    queryStringBuilder.Append(WebUtility.UrlEncode(parameter.Key));
                    queryStringBuilder.Append("=");
                    queryStringBuilder.Append(WebUtility.UrlEncode(parameter.Value));
                }

                queryString = queryStringBuilder.ToString();
            }

            var requestUri = new Uri($"activities/{actionName}{queryString}", UriKind.Relative);

            if (string.IsNullOrEmpty(terminal?.Endpoint))
            {
                //_logger.ErrorFormat("Terminal record not found for activityTemplate: {0}. Throwing exception.", dataDTO.ActivityDTO.ActivityTemplate.Name);
                Logger.GetLogger().Error($"Terminal record not found for activityTemplate: {dataDTO.ActivityDTO.ActivityTemplate.Name} Throwing exception.");
                throw new Exception("Unknown terminal or terminal endpoint");
            }

            requestUri = new Uri(new Uri(terminal.Endpoint), requestUri);
            return(await PostAsync <Fr8DataDTO, TResponse>(requestUri, dataDTO, correlationId, _terminalService.GetRequestHeaders(terminal, dataDTO.ActivityDTO.AuthToken.UserId)));
        }
Esempio n. 17
0
        private async Task CallActivityDeactivate(IUnitOfWork uow, Guid activityId)
        {
            var existingNode = uow.PlanRepository.GetById <PlanNodeDO>(activityId);

            if (!(existingNode is ActivityDO))
            {
                return;
            }

            var exisiting = (ActivityDO)existingNode;

            if (exisiting == null || exisiting.ActivationState == ActivationState.Deactivated)
            {
                return;
            }

            var curActivityDO = (ActivityDO)exisiting.Clone();

            var  dto = Mapper.Map <ActivityDO, ActivityDTO>(curActivityDO);
            bool skipDeactivation = false;
            var  template         = _activityTemplate.GetByKey(curActivityDO.ActivityTemplateId);

            if (curActivityDO.AuthorizationTokenId != null || !template.NeedsAuthentication)
            {
                try
                {
                    _authorizationToken.PrepareAuthToken(uow, dto);
                }
                catch (InvalidTokenRuntimeException)
                {
                    throw;
                }
            }
            else
            {
                skipDeactivation = true;
            }

            if (!skipDeactivation)
            {
                var fr8DataDTO = new Fr8DataDTO
                {
                    ActivityDTO = dto
                };

                await ObjectFactory.GetInstance <ITerminalTransmitter>().CallActivityAsync <ActivityDTO>("deactivate", null, fr8DataDTO, Guid.Empty.ToString());
            }

            var root = exisiting.GetTreeRoot() as PlanDO;

            if (root?.PlanState == PlanState.Executing || root?.PlanState == PlanState.Active)
            {
                root.PlanState = PlanState.Inactive;
            }

            exisiting.ActivationState = ActivationState.Deactivated;
        }
        public void AddCrate <T>(Fr8DataDTO dataDTO, T crateManifest, string label)
        {
            var crateStorage = Crate.GetStorage(dataDTO.ExplicitData);

            var crate = Crate <T> .FromContent(label, crateManifest);

            crateStorage.Add(crate);

            dataDTO.ExplicitData = Crate.CrateStorageAsStr(crateStorage);
        }
Esempio n. 19
0
        public async Task HandleFr8Request_NullActivityTemplate_ThrowsException()
        {
            var activityDTO = Fixture_HandleRequest.terminalMockActivityDTO();

            activityDTO.ActivityTemplate = null;
            var fr8Data = new Fr8DataDTO {
                ActivityDTO = activityDTO
            };
            await _activityExecutor.HandleFr8Request("", null, fr8Data);
        }
Esempio n. 20
0
        public async Task HandleFr8Request_TerminalNotExist_ThrowsException()
        {
            ActivityDTO activityDTO = new ActivityDTO();

            activityDTO.ActivityTemplate = new ActivityTemplateSummaryDTO()
            {
                Name = "terminalDummy", Version = "1.1"
            };
            var fr8Data = new Fr8DataDTO {
                ActivityDTO = activityDTO
            };
            await _activityExecutor.HandleFr8Request("", null, fr8Data);
        }
        public void Check_FollowUp_Configuration_Crate_Structure_Selected()
        {
            var configureUrl = GetTerminalConfigureUrl();

            var requestActivityDTO = FixtureData.MonitorFr8Event_InitialConfiguration_ActivityDTO();
            var dataDTO            = new Fr8DataDTO {
                ActivityDTO = requestActivityDTO
            };
            var responseActivityDTO = HttpPostAsync <Fr8DataDTO, ActivityDTO>(configureUrl, dataDTO).Result;

            Assert.NotNull(responseActivityDTO);
            Assert.NotNull(responseActivityDTO.CrateStorage);
            Assert.NotNull(responseActivityDTO.CrateStorage.Crates);
        }
        public async Task Monitor_Form_Responses_Run_WithInvalidPapertrailUrl_ShouldThrowException()
        {
            //Arrange
            var runUrl = GetTerminalRunUrl();

            //prepare the activity DTO with valid target URL
            HealthMonitor_FixtureData fixture = new HealthMonitor_FixtureData();
            var activityDTO = fixture.Monitor_Form_Responses_v1_Run_EmptyPayload();
            var dataDTO     = new Fr8DataDTO {
                ActivityDTO = activityDTO
            };

            //Act
            await HttpPostAsync <Fr8DataDTO, PayloadDTO>(runUrl, dataDTO);
        }
        public async Task Load_Excel_File_v1_Run_WhenFileIsSelected_ResponseContainsTableData()
        {
            var activityDTO = await ConfigureFollowUp(true);

            var runUrl  = GetTerminalRunUrl();
            var dataDTO = new Fr8DataDTO {
                ActivityDTO = activityDTO
            };

            AddOperationalStateCrate(dataDTO, new OperationalStateCM());

            var responsePayloadDTO = await HttpPostAsync <Fr8DataDTO, PayloadDTO>(runUrl, dataDTO);

            Assert.AreEqual(1, _crateManager.GetStorage(responsePayloadDTO).CratesOfType <StandardTableDataCM>().Count(), "Reponse payload doesn't contain table data from file");
        }
Esempio n. 24
0
        private async Task <T> GetDocumentation <T>(ActivityDTO curActivityDTO)
        {
            //Put a method name so that HandleFr8Request could find correct method in the terminal Action
            var actionName = "documentation";

            curActivityDTO.Documentation = curActivityDTO.Documentation;
            var curContainerId = Guid.Empty;
            var fr8Data        = new Fr8DataDTO
            {
                ActivityDTO = curActivityDTO
            };

            //Call the terminal
            return(await ObjectFactory.GetInstance <ITerminalTransmitter>().CallActivityAsync <T>(actionName, null, fr8Data, curContainerId.ToString()));
        }
Esempio n. 25
0
        public async Task Write_To_Log_Run_WithInvalidPapertrailUrl_ShouldReturnError()
        {
            //Arrange
            var runUrl = GetTerminalRunUrl();

            //prepare the action DTO with valid target URL
            var activityDTO = await GetActivityDTO_LogToPapertrailIntegrationTest();

            var dataDTO = new Fr8DataDTO {
                ActivityDTO = activityDTO
            };

            //make the target URL as invalid
            using (var crateStorage = Crate.GetUpdatableStorage(activityDTO))
            {
                var controls = crateStorage.CrateContentsOfType <StandardConfigurationControlsCM>().Single();

                var targetUrlTextBox = (TextBox)controls.Controls[0];
                targetUrlTextBox.Value = "InvalidUrl";
            }

            //add the Log Message in upstream action
            AddPayloadCrate(dataDTO,
                            new StandardLoggingCM
            {
                Item =
                    new List <LogItemDTO>
                {
                    new LogItemDTO {
                        Data = "Integration Test Log Message on " + DateTime.Now, IsLogged = false
                    }
                }
            });

            AddOperationalStateCrate(dataDTO, new OperationalStateCM());

            //Act
            var payload = await HttpPostAsync <Fr8DataDTO, PayloadDTO>(runUrl, dataDTO);

            var      storage            = Crate.GetStorage(payload);
            var      operationalStateCM = storage.CrateContentsOfType <OperationalStateCM>().Single();
            ErrorDTO errorMessage;

            operationalStateCM.CurrentActivityResponse.TryParseErrorDTO(out errorMessage);

            Assert.AreEqual(ActivityResponse.Error.ToString(), operationalStateCM.CurrentActivityResponse.Type);
            Assert.AreEqual("Papertrail URL and PORT are not in the correct format. The given URL is InvalidUrl", errorMessage.Message);
        }
        public async Task GetDataFromFr8Warehouse_Run()
        {
            var activityDTO = await ConfigureFollowUp();

            using (var updater = Crate.UpdateStorage(() => activityDTO.CrateStorage))
            {
                var controls     = updater.CrateContentsOfType <StandardConfigurationControlsCM>().First();
                var queryBuilder = controls.FindByName <QueryBuilder>("QueryBuilder");
                queryBuilder.Value = JsonConvert.SerializeObject(
                    new List <FilterConditionDTO>()
                {
                    new FilterConditionDTO()
                    {
                        Field    = "Status",
                        Operator = "eq",
                        Value    = ""
                    }
                }
                    );
            }

            activityDTO.AuthToken = new AuthorizationTokenDTO()
            {
                UserId = Guid.NewGuid().ToString()
            };

            var runUrl = GetTerminalRunUrl();
            var data   = new Fr8DataDTO()
            {
                ActivityDTO = activityDTO
            };

            AddPayloadCrate(data, new OperationalStateCM());

            var payload = await HttpPostAsync <Fr8DataDTO, PayloadDTO>(runUrl, data);

            Assert.IsNotNull(payload, "PayloadDTO is null");
            Assert.IsNotNull(payload.CrateStorage, "PayloadDTO.CrateStorage is null");

            var crateStorage = Crate.FromDto(payload.CrateStorage);

            Assert.AreEqual(
                1,
                crateStorage.CratesOfType <StandardTableDataCM>()
                .Count(x => x.Label == "Table Generated by Get Data From Fr8 Warehouse"),
                "StandardTableDataCM is expected"
                );
        }
        public async Task GetFileList_InitialConfig_ReturnsActivity()
        {
            //Arrange
            var        configureUrl     = GetTerminalConfigureUrl();
            Fr8DataDTO requestActionDTO = HealthMonitor_FixtureData.GetFileListTestFr8DataDTO();

            //Act
            var responseActionDTO = await HttpPostAsync <Fr8DataDTO, ActivityDTO>(
                configureUrl,
                requestActionDTO
                );

            // Assert
            Assert.NotNull(responseActionDTO);
            Assert.NotNull(responseActionDTO.CrateStorage);
        }
Esempio n. 28
0
        public async Task PostToTimeline_FollowUp_Configuration_Check_Crate_Structure()
        {
            var configureUrl = GetTerminalConfigureUrl();
            var responseDTO  = await CompleteInitialConfiguration();

            responseDTO.AuthToken = FixtureData.Facebook_AuthToken();
            var dataDTO = new Fr8DataDTO
            {
                ActivityDTO = responseDTO
            };

            //nothing should change on followup
            responseDTO = await HttpPostAsync <Fr8DataDTO, ActivityDTO>(configureUrl, dataDTO);

            AssertInitialConfigurationResponse(responseDTO);
        }
Esempio n. 29
0
        private async Task <TResult> CallTerminalActivityAsync <TResult>(
            IUnitOfWork uow,
            string activityName,
            IEnumerable <KeyValuePair <string, string> > parameters,
            ActivityDO curActivityDO,
            Guid containerId,
            string curDocumentationSupport = null)
        {
            if (activityName == null)
            {
                throw new ArgumentNullException("activityName");
            }
            if (curActivityDO == null)
            {
                throw new ArgumentNullException("curActivityDO");
            }

            var dto = Mapper.Map <ActivityDO, ActivityDTO>(curActivityDO);

            var fr8DataDTO = new Fr8DataDTO
            {
                ContainerId = containerId,
                ActivityDTO = dto
            };

            if (curDocumentationSupport != null)
            {
                dto.Documentation = curDocumentationSupport;
            }

            _authorizationToken.PrepareAuthToken(uow, dto);

            EventManager.ActionDispatched(curActivityDO, containerId);

            if (containerId != Guid.Empty)
            {
                var containerDO = uow.ContainerRepository.GetByKey(containerId);
                EventManager.ContainerSent(containerDO, curActivityDO);

                var response = ObjectFactory.GetInstance <ITerminalTransmitter>().CallActivityAsync <TResult>(activityName, parameters, fr8DataDTO, containerId.ToString());

                EventManager.ContainerReceived(containerDO, curActivityDO);
                return(await response);
            }

            return(await ObjectFactory.GetInstance <ITerminalTransmitter>().CallActivityAsync <TResult>(activityName, parameters, fr8DataDTO, containerId.ToString()));
        }
        protected void AddHubCrate <T>(Fr8DataDTO dataDTO, T crateManifest, string label, string innerLabel)
        {
            var crateStorage = Crate.GetStorage(dataDTO.ExplicitData);

            var fullLabel = label;

            if (!string.IsNullOrEmpty(innerLabel))
            {
                fullLabel += "_" + innerLabel;
            }

            var crate = Crate <T> .FromContent(fullLabel, crateManifest);

            crateStorage.Add(crate);

            dataDTO.ExplicitData = Crate.CrateStorageAsStr(crateStorage);
        }