public void TestDuplicateParameters(Parameters parameter, Values value)
        {
            var handler  = new BulkUpdateManager();
            var response = handler.BulkUpdate <BulkUpdateResponse>(value == Values.Same ? DuplicateParametersSameValue[parameter](RecordsCreator) : DuplicateParametersNotSameValue[parameter](RecordsCreator), System.Net.Http.HttpMethod.Post);

            PrAssert.That(response, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.NoContent));
        }
        public void TestWrongContentTypeBulkUpdate()
        {
            var handler  = new BulkUpdateManager();
            var response = handler.BulkUpdate <BulkUpdateResponse>(GetBulkUpdateContent(RecordTypes.Single, Filters.Replace, HRBCClientPrivate.Common.ResourceId.Client, "P_Name", "Test Name", RecordsCreator, Filters.Replace), System.Net.Http.HttpMethod.Post, "html/text");

            PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(System.Net.HttpStatusCode.BadRequest));
        }
Example #3
0
        public static void BulkUpdateDateForRecordsCreator(HrbcRecordCreator RecordsCreator, string date, ValidTestCases testCase, int numRecords = 0)
        {
            var      bulkManager = new BulkUpdateManager();
            DateTime dateTime    = DateTime.Parse(date);

            int plusMinutes = 0;

            foreach (ResourceId resource in Utils.Resources())
            {
                for (var i = 0; i < numRecords; i++)
                {
                    if (testCase == ValidTestCases.Less)
                    {
                        plusMinutes = -(numRecords - i);
                    }
                    else if (testCase == ValidTestCases.Greater)
                    {
                        plusMinutes = i;
                    }

                    var recordId = RecordsCreator.Data[$"{resource}{i}"].Id;
                    var response = bulkManager.BulkUpdate <BulkUpdateResponse>(GetBulkUpdateContent(resource, new List <ulong> {
                        recordId
                    }, dateTime.AddMinutes(plusMinutes).ToString(SearchConstants.SearchApiFullDateTemplate)), System.Net.Http.HttpMethod.Post);
                    PrAssume.That(response, PrIs.SuccessfulResponse());

                    if (GetBulkUpdateQueueStatus(response.Result.Id.ToString()))
                    {
                        continue;
                    }
                }
            }
        }
        public void TestBulkUpdateByOtherHttpMethod(HttpMethod inputType)
        {
            var handler  = new BulkUpdateManager();
            var response = handler.BulkUpdate <BulkUpdateResponse>(GetBulkUpdateContent(RecordTypes.Single, Filters.Replace, HRBCClientPrivate.Common.ResourceId.Client, "P_Name", "Test Name", RecordsCreator, Filters.Replace), inputType.ToNetHttpMethod());

            PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(System.Net.HttpStatusCode.NotFound));
        }
Example #5
0
        public static PrivateData <int> GetBulkUpdate(int numbRecords, int numRecordsEachCase, HrbcRecordCreator recordsCreator, string fieldValue, TestCoreFramework.Enums.FieldType type, HrbcFieldCreator fieldCreator)
        {
            return(new PrivateData <int>(
                       (session, test) =>
            {
                return Task.Run(() =>
                {
                    foreach (var resource in Enum.GetValues(typeof(ResourceId)).Cast <ResourceId>().Except(new[] { ResourceId.None }))
                    {
                        var bulkManager = new BulkUpdateManager();

                        for (var i = 0; i < numbRecords - numRecordsEachCase; i++)
                        {
                            var recordId = recordsCreator.Data[$"{resource}{i}"].Id;
                            var response = bulkManager.BulkUpdate <BulkUpdateResponse>(GetBulkUpdateContent(resource, new List <ulong> {
                                recordId
                            }, i, fieldValue, type, fieldCreator), System.Net.Http.HttpMethod.Post);
                            PrAssume.That(response, PrIs.SuccessfulResponse());

                            if (GetBulkUpdateQueueStatus(response.Result.Id.ToString()))
                            {
                                continue;
                            }
                        }
                    }
                    return 0;
                });
            },
                       (session, test, res) => Task.Run(() =>
            {
            })));
        }
Example #6
0
        private static void BulkUpdateByReplaceFilter()
        {
            var handler  = new BulkUpdateManager();
            var response = handler.BulkUpdate <BulkUpdateResponse>(GetBulkUpdateContent(Filters.Replace), HttpMethod.Post);

            PrAssume.That(response, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.OK));
            PrAssume.That(SearchHelpers.GetBulkUpdateQueueStatus(response.Result.Id.ToString(), 30, false));
        }
        public void TestBulkUpdateInjection(Parameters parameter, InjectionInput inputType)
        {
            var handler    = new BulkUpdateManager();
            var request    = DefaultBulkUpdateParameters(RecordTypes.Single, Filters.Replace, HRBCClientPrivate.Common.ResourceId.Client, "P_Name", "Test Name", RecordsCreator);
            var valueInput = InjectionInputData.InjectionInputMapper[inputType];

            request = GetRequestForBulkUpdate(request, parameter, valueInput);
            var response = handler.BulkUpdate <BulkUpdateResponse>(request, System.Net.Http.HttpMethod.Post);

            PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(System.Net.HttpStatusCode.BadRequest));
        }
Example #8
0
        public void TestBulkUpdateSpecials(Specials inputType)
        {
            var handler  = new BulkUpdateManager();
            var request  = DefaultBulkUpdateParameters(RecordTypes.Single, Filters.Replace, ResourceId.Client, "P_Name", "Test Name", RecordsCreator);
            var response = handler.BulkUpdate <BulkUpdateResponse>(GetRequestForBulkUpdate(request, inputType), System.Net.Http.HttpMethod.Post);

            if (inputType == Specials.WrongSystemField || inputType == Specials.WrongUserField)
            {
                PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(System.Net.HttpStatusCode.BadRequest));
            }
            else
            {
                PrAssert.That(SearchHelpers.GetBulkUpdateQueueStatus(response.Result.Id.ToString()), PrIs.EqualTo(inputType == Specials.MissingPhaseDate ? true : false), "Bulk update could not update");
            }
        }
        public void TestBulkUpdateGenarateInvalid(Parameters parameter, InvalidTestCases inputType, System.Net.HttpStatusCode resultCode)
        {
            var handler = new BulkUpdateManager();
            var request = DefaultBulkUpdateParameters(RecordTypes.Single, Filters.Replace, HRBCClientPrivate.Common.ResourceId.Client, "P_Name", "Test Name", RecordsCreator);

            request = GetRequestForBulkUpdate(request, parameter, InvalidMaps[inputType].ToString(), inputType);
            var response = handler.BulkUpdate <BulkUpdateResponse>(request, System.Net.Http.HttpMethod.Post);

            if (resultCode == System.Net.HttpStatusCode.OK)
            {
                PrAssert.That(response, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.OK));
            }
            else
            {
                PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(System.Net.HttpStatusCode.BadRequest));
            }
        }
Example #10
0
        public void PerformCombineTwoFieldsTests()
        {
            var handler         = new BulkUpdateManager();
            var firstFieldName  = FieldNames.First();
            var secondFieldName = FieldNames.Last();

            //Clean up data
            if (Filter != Filters.Replace)
            {
                var ignoredFieldsCleanUp = new string[] { "P_Phase", "Date", "P_Resource", "Owner" };
                if (!(firstFieldName.ContainsStrings(ignoredFieldsCleanUp) || secondFieldName.ContainsStrings(ignoredFieldsCleanUp)))
                {
                    BulkUpdateByReplaceFilter();
                }
            }

            var fieldType = GetFieldTypes();

            Fields[firstFieldName]  = DefaultValueFieldTypes[fieldType[firstFieldName]](RecordCreator, Resource, firstFieldName, UserIds);
            Fields[secondFieldName] = DefaultValueFieldTypes[fieldType[secondFieldName]](RecordCreator, Resource, secondFieldName, UserIds);

            if (Filter == Filters.Append)
            {
                var ignoredFieldsNotAppend = new string[] { InputType.OptionOnlyItem.ToString(), InputType.Id.ToString(), InputType.OptionPhase.ToString(), "Date", "System",
                    InputType.Currency.ToString(), InputType.Number.ToString() };
                if (fieldType[firstFieldName].ToString().ContainsStrings(ignoredFieldsNotAppend) || fieldType[secondFieldName].ToString().ContainsStrings(ignoredFieldsNotAppend))
                {
                    var response = handler.BulkUpdate <BulkUpdateResponse>(GetBulkUpdateContent(Filter), HttpMethod.Post);
                    PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(System.Net.HttpStatusCode.BadRequest));
                }
                else
                {
                    //Replace data
                    BulkUpdateByReplaceFilter();

                    //Append data
                    ExecuteAndVerifyBulk();
                }
            }
            else //Merge filter does not currently work, will seprate replace and merge here
            {
                ExecuteAndVerifyBulk(Filter);
            }
        }
        public void TestInvalidBodyJson(OriginalSearchHelpers.InvalidSpecialCondition inputType)
        {
            var handler = new BulkUpdateManager();
            var bulkUpdateContentObject = GetBulkUpdateContent(RecordTypes.Single, Filters.Replace, HRBCClientPrivate.Common.ResourceId.Client, "P_Name", "Test Name", RecordsCreator, Filters.Replace);

            string jsonContent = string.Empty;

            if (inputType == OriginalSearchHelpers.InvalidSpecialCondition.BrokenJsonFormat)
            {
                jsonContent = JsonConvert.SerializeObject(bulkUpdateContentObject).ToString().Substring(1);
            }
            else
            {
                jsonContent = DashboardHelpers.InvalidBodyJsonTestCasesMapper[inputType].ToString();
            }

            var response = handler.BulkUpdate <BulkUpdateResponse>(jsonContent, System.Net.Http.HttpMethod.Post);

            PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(System.Net.HttpStatusCode.BadRequest));
        }
Example #12
0
        private static void ExecuteAndVerifyBulk(Filters selectionRecordIdsFilter = Filters.Append)
        {
            var handler  = new BulkUpdateManager();
            var response = handler.BulkUpdate <BulkUpdateResponse>(GetBulkUpdateContent(selectionRecordIdsFilter), HttpMethod.Post);

            PrAssert.That(response, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.OK));

            var firstFieldName  = FieldNames.First();
            var secondFieldName = FieldNames.Last();
            var fieldType       = GetFieldTypes();

            var ignoredFieldsNotAppend = new string[] { InputType.Url.ToString(), InputType.Mail.ToString(), InputType.Telephone.ToString() };

            if (Filter == Filters.Append && (fieldType[firstFieldName].ToString().ContainsStrings(ignoredFieldsNotAppend) || fieldType[secondFieldName].ToString().ContainsStrings(ignoredFieldsNotAppend)))
            {
                PrAssert.That(SearchHelpers.GetBulkUpdateQueueStatus(response.Result.Id.ToString(), 30, false), PrIs.False, "Bulk update is unsuccessfull");
            }
            else
            {
                PrAssume.That(SearchHelpers.GetBulkUpdateQueueStatus(response.Result.Id.ToString(), 30, false), "Bulk update is unsuccessfull");
                ReadAndVerifyData();
            }
        }