public void EnumParamterValidationTest(ResourceId resource, VerificationCaseType testCase, PrivateApiResponseCode expectedCode, Action <SearchRequest, Func <string, string> > requestUpdater, string caseDescription)
        {
            var request = SearchRequestComposer.GetBuilderWithRestrictions(resource).
                          BooleanFilter(OperatorType.And, new List <SearchFilter>
            {
                new SearchFilter
                {
                    Area       = "TEXT",
                    SplitMode  = "AND",
                    SearchType = "COND_FREEWORD",
                    Operator   = "IN",
                    Value      = SearchValue.CreateConst("TEST")
                },
                new SearchFilter
                {
                    Operator   = "=",
                    SearchType = "COND_DATE2",
                    Timezone   = "UTC",
                    Field      = new SearchField
                    {
                        Type  = "FIELD",
                        Route = $"{resource}.A_TestDate1"
                    },
                    Value = SearchValue.CreatePeriod("+P2Y", "DAY")
                }
            });

            request.Conditions.OrderBy.First().Direction = "DESC";
            PerformValidationTest(request, resource, testCase, expectedCode, requestUpdater);
        }
Exemple #2
0
        public void TimezoneDstTest(ResourceId resource, TestCoreFramework.Enums.FieldType fieldType, string fieldCategory, string timezone, int timeOffset, Func <string> fieldNameProvider)
        {
            var request    = SearchRequestComposer.GetBuilderWithRestrictions(resource).DateFilter(fieldNameProvider(), OperatorType.Eq, timezone, AltTestDateTime.AddHours(timeOffset).ToString(SearchConstants.SearchApiFullDateTemplate));
            var expectedId = RecordsCreator.Data[$"{resource} Alt"].Id;

            PerformHappyPathTest(resource, request, (int)expectedId);
        }
        public void RouteParamterValidationTest(ResourceId resource, VerificationCaseType testCase, PrivateApiResponseCode expectedCode, Action <SearchRequest, Func <string, string> > requestUpdater, string caseDescription)
        {
            var request = SearchRequestComposer.GetBuilderWithRestrictions(resource).
                          NumFilter($"{resource}.A_TestNumberScale0", OperatorType.Eq, 1234);

            PerformValidationTest(request, resource, testCase, expectedCode, requestUpdater);
        }
 private static SearchRequest GetDefaultSearchFilters(ResourceId resource)
 {
     return(SearchRequestComposer.GetBuilderWithRestrictions(resource).BooleanFilter(
                OperatorType.Or, new List <SearchFilter> {
         SearchHelpers.SearchFilters[SearchFilterType.NumIn](resource, "P_Id", CurrentDateTime, Timezone, RecordsCreator)
     }));
 }
Exemple #5
0
        private static Dictionary <string, Func <SearchRequest> > PrepareDateCases(ResourceId resource, Func <string> fullFieldName, DateTime testValue, DateTime altTestValue)
        {
            Func <OperatorType, DateTime, SearchRequest> dateOpRequestCreator =
                (op, value) => SearchRequestComposer.GetBuilderWithRestrictions(resource).DateFilter(fullFieldName(), op, DefaultTimezone, value.ToString(SearchConstants.SearchApiFullDateTemplate));
            Func <OperatorType, DateTime, SearchRequest> periodOpRequestCreator =
                (op, value) => SearchRequestComposer.GetBuilderWithRestrictions(resource).DateFilter(fullFieldName(), op, DefaultTimezone, System.Xml.XmlConvert.ToString(Truncate(value - DateTime.Now)), crop: "HOUR");

            return(new Dictionary <string, Func <SearchRequest> >
            {
                ["Date - LessOrEqual <= -- value is equal"] = () => dateOpRequestCreator(OperatorType.Le, testValue),
                ["Date - LessOrEqual <= -- value is less"] = () => dateOpRequestCreator(OperatorType.Le, (testValue).AddDays(2)),
                ["Date - Less <"] = () => dateOpRequestCreator(OperatorType.Lt, (testValue).AddDays(2)),
                ["Date - Equal ="] = () => dateOpRequestCreator(OperatorType.Eq, testValue),
                ["Date - NotEqual !="] = () => dateOpRequestCreator(OperatorType.Neq, altTestValue),
                [$"Date - Greater > {ImportantCaseMarker}"] = () => dateOpRequestCreator(OperatorType.Gt, (testValue).AddDays(-2)),
                ["Date - GreaterOrEqual >= -- value is equal"] = () => dateOpRequestCreator(OperatorType.Ge, testValue),
                ["Date - GreaterOrEqual >= -- value is greater"] = () => dateOpRequestCreator(OperatorType.Ge, (testValue).AddDays(-2)),
                ["Period - LessOrEqual <= -- value is equal"] = () => periodOpRequestCreator(OperatorType.Le, testValue),
                ["Period - LessOrEqual <= -- value is less"] = () => periodOpRequestCreator(OperatorType.Le, testValue.AddDays(2)),
                ["Period - Less <"] = () => periodOpRequestCreator(OperatorType.Lt, (testValue).AddDays(2)),
                ["Period - Equal ="] = () => periodOpRequestCreator(OperatorType.Eq, testValue),
                ["Period - NotEqual !="] = () => periodOpRequestCreator(OperatorType.Neq, altTestValue),
                ["Period - Greater >"] = () => periodOpRequestCreator(OperatorType.Gt, (testValue).AddDays(-2)),
                ["Period - GreaterOrEqual >= -- value is equal"] = () => periodOpRequestCreator(OperatorType.Ge, testValue),
                ["Period - GreaterOrEqual >= -- value is greater"] = () => periodOpRequestCreator(OperatorType.Ge, (testValue).AddDays(-2))
            });
        }
        public void MultipleValidSearchCondition(ResourceId resource, OperatorType boolFilterType, SearchFilterType firstFilterType, SearchFilterType secondFilterType, string firstFieldName, string secondFieldName)
        {
            var firstExpectedId  = RecordsCreatorForNumCond.Data[$"{resource}0"].Id;
            var secondExpectedId = RecordsCreatorForNumCond.Data[$"{resource}1"].Id;
            var searchFilters    = new List <SearchFilter>();

            searchFilters.Add(SearchHelpers.SearchFilters[firstFilterType](resource, firstFieldName, CurrentDateTime, Timezone, RecordsCreatorForNumCond));
            searchFilters.Add(SearchHelpers.SearchFilters[secondFilterType](resource, secondFieldName, CurrentDateTime, Timezone, RecordsCreatorForNumCond));
            var request  = SearchRequestComposer.GetBuilderWithRestrictions(resource).BooleanFilter(boolFilterType, searchFilters);
            var handler  = new DefaultManager();
            var response = handler.Send <SearchResponse>(request);

            PrAssert.That(response, PrIs.SuccessfulResponse());
            PrAssert.That(response?.Result?.Status, PrIs.Not.Null.And.EqualTo("OK"));
            PrAssert.That(response?.Result?.Total, PrIs.Not.Null.And.GreaterThanOrEqualTo(1));

            if (boolFilterType == OperatorType.And)
            {
                if (TwoRecordsBeReturned(firstFilterType) && TwoRecordsBeReturned(secondFilterType))
                {
                    PrAssert.That(response?.Result?.Items, PrIs.Not.Null.And.Contains(firstExpectedId).And.Contains(secondExpectedId));
                }
                else
                {
                    PrAssert.That(response?.Result?.Items, PrIs.Not.Null.And.Contains(firstExpectedId).Or.Contains(secondExpectedId));
                }
            }
            else
            {
                PrAssert.That(response?.Result?.Items, PrIs.Not.Null.And.Contains(firstExpectedId).And.Contains(secondExpectedId));
            }
        }
        public void PeriodParamterValidationTest(ResourceId resource, VerificationCaseType testCase, PrivateApiResponseCode expectedCode, Action <SearchRequest, Func <string, string> > requestUpdater, string caseDescription)
        {
            var request = SearchRequestComposer.GetBuilderWithRestrictions(resource).
                          DateFilter($"{resource}.A_TestDate1", OperatorType.Gt, "Asia/Tokyo", "P1M", null);

            PerformValidationTest(request, resource, testCase, expectedCode, requestUpdater);
        }
        public void TextParamterValidationTest(ResourceId resource, VerificationCaseType testCase, PrivateApiResponseCode expectedCode, Action <SearchRequest, Func <string, string> > requestUpdater, string caseDescription)
        {
            var request = SearchRequestComposer.GetBuilderWithRestrictions(resource).
                          TextFilter("A_TestSingleLineText", OperatorType.Eq, null, "test");

            PerformValidationTest(request, resource, testCase, expectedCode, requestUpdater);
        }
Exemple #9
0
        public static void VerifySearchByDateField(ResourceId resource, ValidTestCases testCase, string fieldName, Directions direction, string currentDateTime, string timezone, int numRecords, HrbcRecordCreator hrbcRecordCreator)
        {
            SearchValue searchValue1    = null;
            SearchValue searchValue2    = null;
            DateTime    dateTimeGreater = DateTime.Parse(currentDateTime);
            DateTime    dateTimeLess    = DateTime.Parse(currentDateTime);

            if (testCase == ValidTestCases.EqualsTo)
            {
                searchValue1 = searchValue2 = SearchValue.CreateDate(currentDateTime);
            }
            else
            if (testCase == ValidTestCases.Greater)
            {
                searchValue1 = SearchValue.CreateDate(currentDateTime);
                searchValue2 = SearchValue.CreateDate(dateTimeGreater.AddMinutes(numRecords - 1).ToString(SearchConstants.SearchApiFullDateTemplate));
            }
            else
            {
                searchValue2 = SearchValue.CreateDate(currentDateTime);
                searchValue1 = SearchValue.CreateDate(dateTimeLess.AddMinutes(-numRecords).ToString(SearchConstants.SearchApiFullDateTemplate));
            }

            var request = SearchRequestComposer.GetBuilderWithRestrictions(resource).DateFilter($"{resource.ToString()}.{fieldName}", OperatorType.Between, timezone, searchValue1, searchValue2);

            request.Conditions.OrderBy = GetOrderByType(resource, fieldName, direction);
            var handler  = new DefaultManager();
            var response = handler.Send <SearchResponse>(request);

            PrAssert.That(response, PrIs.SuccessfulResponse());

            Assertions[direction](response.Result.Items, resource, hrbcRecordCreator, numRecords);
        }
        public void InvalidSearchByCustomDateField(ResourceId resource, FieldType fieldType, string fieldName, Func <string> fieldNameProvider, SearchHelpers.InvalidTestCases testCase)
        {
            var request  = SearchRequestComposer.GetBuilderWithRestrictions(resource).DateFilter(fieldNameProvider(), OperatorType.Eq, Timezone, SearchHelpers.DateTimeMap[testCase].ToString());
            var handler  = new DefaultManager();
            var response = handler.Send <SearchResponse>(request);

            PrAssert.That(response, PrIs.ErrorResponse());
        }
Exemple #11
0
        public void InvalidSearchBySystemUpdateDateField(ResourceId resource, SearchHelpers.InvalidTestCases testCase, string fieldName)
        {
            var request  = SearchRequestComposer.GetBuilderWithRestrictions(resource).DateFilter($"{resource.ToString()}.{fieldName}", OperatorType.Eq, Timezone, SearchHelpers.DateTimeMap[testCase].ToString());
            var handler  = new DefaultManager();
            var response = handler.Send <SearchResponse>(request);

            PrAssert.That(response, PrIs.ErrorResponse());
        }
        public void SuccessfulSearch_AreaAllOnly_SplitModeNOT(ResourceId resource, TestCoreFramework.Enums.FieldType fieldType, OperatorType op, string fieldCategory)
        {
            var value = GetFieldValueByFieldType(fieldType, resource, fieldCategory).ToString();

            value = SearchValueTransformationsByOperator[op](value);
            var request = SearchRequestComposer.GetBuilderWithRestrictions(resource).FreewordFilter(op, null, "NOT", "ALL", value);

            PerformSuccessfulInvertedSearchTest(resource, request);
        }
        public void SuccessfulSearch_FileOnly_SplitModeAnd_PrcKeyword(ResourceId resource, FileType fileType, OperatorType op)
        {
            var value = $"Sample {fileType.ToString().ToUpper()}File {fileType} PRC";

            value = SearchValueTransformationsByOperator[op](value);
            var request = SearchRequestComposer.GetBuilderWithRestrictions(resource).FreewordFilter(op, null, "NOT", "FILES", value);

            PerformSuccessfulInvertedSearchTest(resource, request);
        }
        public void SuccessfulSearch_TextOnly_SplitModeOR(ResourceId resource, TestCoreFramework.Enums.FieldType fieldType, OperatorType op, string fieldCategory)
        {
            var value = GetFieldValueByFieldType(fieldType, resource, fieldCategory).ToString();

            value = SearchValueTransformationsByOperator[op](value) + " SomeRandomString";
            var request = SearchRequestComposer.GetBuilderWithRestrictions(resource).FreewordFilter(op, null, "OR", "TEXT", value);

            PerformSuccessfulSearchTest(resource, request);
        }
        public void ResourceRouteParamterValidationTest(ResourceId resource, VerificationCaseType testCase, PrivateApiResponseCode expectedCode, Action <SearchRequest, Func <string, string> > requestUpdater, string caseDescription)
        {
            var request = SearchRequestComposer.GetBuilder(resource, $"{(int)resource}")
                          .Filter(searchType: SearchRequestComposer.SearchTypeMap[SearchFilterType.NumOperator],
                                  field: $"{resource.ToString()}.P_Id",
                                  op: SearchRequestComposer.OperatorTypeMap[OperatorType.Eq],
                                  value: SearchValue.CreateConst("1234"));

            PerformValidationTest(request, resource, testCase, expectedCode, requestUpdater);
        }
Exemple #16
0
 private static Dictionary <string, Func <SearchRequest> > PrepareTextCases(ResourceId resource, Func <string> fullFieldName, string testValue)
 {
     return(new Dictionary <string, Func <SearchRequest> >
     {
         ["StartsWith operator"] = () => SearchRequestComposer.GetBuilderWithRestrictions(resource).TextFilter(fullFieldName(), OperatorType.StartsWith, null, testValue.Substring(0, 5)),
         ["IN operator"] = () => SearchRequestComposer.GetBuilderWithRestrictions(resource).TextFilter(fullFieldName(), OperatorType.In, null, testValue.Substring(3, 5)),
         ["IN operator one character"] = () => SearchRequestComposer.GetBuilderWithRestrictions(resource).TextFilter(fullFieldName(), OperatorType.In, null, testValue.Substring(3, 1)),
         [$"Equals operator {ImportantCaseMarker}"] = () => SearchRequestComposer.GetBuilderWithRestrictions(resource).TextFilter(fullFieldName(), OperatorType.Eq, null, testValue)
     });
 }
Exemple #17
0
        private static Dictionary <string, Func <SearchRequest> > PrepareNumAllCases(ResourceId resource, Func <string> fullFieldName, object testValue)
        {
            var range = (testValue as string[]);

            return(new Dictionary <string, Func <SearchRequest> >
            {
                [$"1:1 match {ImportantCaseMarker}"] = () => SearchRequestComposer.GetBuilderWithRestrictions(resource).NumAllFilter(fullFieldName(), range),
                ["Search is narrower"] = () => SearchRequestComposer.GetBuilderWithRestrictions(resource).NumAllFilter(fullFieldName(), range.Skip(1))
            });
        }
        public void SearchEqualOpAccessEndpointTests(AccessState accessState, HttpStatusCode httpStatusCode, ResultCode resultCode)
        {
            AccessEndpointManager accessEndpointHandler = new AccessEndpointManager();
            string value         = "memo";
            var    requestSearch = SearchRequestComposer.GetBuilderWithRestrictions(ResourceId.Client).TextFilter($"{ResourceId.Client}.P_Memo", OperatorType.Eq, null, value);

            var response = accessEndpointHandler.AccessEndpoint <SearchResponse>(accessState, SearchManager.EndPoint, requestSearch, HttpMethod.Post);

            PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(httpStatusCode).And.ErrorCode((int)resultCode));
        }
Exemple #19
0
        public void PerformSearchWithExcessiveParametersTest_ForSimpleNumSearch(string parameterPath, bool allSame)
        {
            var request = SearchRequestComposer.GetBuilderWithRestrictions(ResourceId.Client, limit: 10, offset: 0)
                          .NumFilter("Client.P_Id", SearchHandlingComponent.Enums.OperatorType.Gt, 0);
            var requestString = GetRequestStringWithExcessiveParameters(request, parameterPath, allSame ? null : "TEST_PROPERTY_VALUE");
            var connection    = PrivateApiConnection.GetConnectionForCurrentTest();

            using (var response = connection.SendAsync(SearchManager.EndPoint, requestString, System.Net.Http.HttpMethod.Post).Result)
            {
                PrAssert.That(!response.IsSuccessStatusCode, "A request with wrong HTTP method was successful, while expected fail");
            }
        }
Exemple #20
0
        private void PerformHappyPathBoolNotTest(ResourceId resource, SearchRequest request)
        {
            var expectedId     = RecordsCreator.Data[$"{resource}"].Id;
            var boolNotRequest = SearchRequestComposer.GetBuilderWithRestrictions(resource).BooleanNotFilter(request.Conditions.Filter);

            var handler  = new DefaultManager();
            var response = handler.Send <SearchResponse>(boolNotRequest);

            PrAssert.That(response, PrIs.SuccessfulResponse());
            PrAssert.That(response?.Result?.Status, PrIs.Not.Null.And.EqualTo("OK"));
            PrAssert.That(response?.Result?.Items, PrIs.Not.Null.And.Not.Contains(expectedId));
        }
Exemple #21
0
        public void PerformSearchWithExcessiveParametersTest_ForSublistSearch(string parameterPath, bool allSame)
        {
            var request = SearchRequestComposer.GetBuilderWithRestrictions(ResourceId.Client, limit: 10, offset: 0)
                          .SubqueryFilter("Client.P_Id", ResourceId.Job, "Job.P_Id", SearchFilter.CreateNum("Job.P_Id", ">", 0));
            var requestString = GetRequestStringWithExcessiveParameters(request, parameterPath, allSame ? null : "10010");
            var connection    = PrivateApiConnection.GetConnectionForCurrentTest();

            using (var response = connection.SendAsync(SearchManager.EndPoint, requestString, System.Net.Http.HttpMethod.Post).Result)
            {
                PrAssert.That(!response.IsSuccessStatusCode, "A request with an extra parameter was successful while expected fail");
            }
        }
        public void SearchSystemApplicationFieldCore(ResourceId resourceId, string field, SearchDateFieldCases.TestCases cases, bool isAsc)
        {
            var expectedOperator = cases == SearchDateFieldCases.TestCases.EqualsTo ? OperatorType.Eq : cases == SearchDateFieldCases.TestCases.Less ? OperatorType.Lt : OperatorType.Gt;
            var requestBuilder   = SearchRequestComposer.GetBuilderWithRestrictions(resourceId)
                                   .WithSort(isAsc, $"{resourceId.ToString()}.{field}");
            var request = requestBuilder.DateFilter($"{resourceId.ToString()}.{field}", expectedOperator,
                                                    "Asia/Tokyo", CreateDateTime.ToString(SearchConstants.SearchApiShortDateTemplate));
            var handler  = new DefaultManager();
            var response = handler.Send <SearchResponse>(request);

            SearchDateFieldCases.VerifySearchResult(response, resourceId, cases, $"{resourceId.ToString()}.{field}", isAsc, RecordsCreator, NumRecordsEachCase, DateResponseFormat);
        }
        public void SearchUserFieldCore(ResourceId resourceId, SearchDateFieldCases.TestCases cases, bool isAsc)
        {
            var expectedOperator = cases == SearchDateFieldCases.TestCases.EqualsTo ? OperatorType.Eq : cases == SearchDateFieldCases.TestCases.Less ? OperatorType.Lt : OperatorType.Gt;
            var request          = SearchRequestComposer.GetBuilderWithRestrictions(resourceId)
                                   .WithSort(isAsc, $"{resourceId}.{FieldCreator.Data[$"{resourceId}_{TestCoreFramework.Enums.FieldType.DateTime}"].Name}")
                                   .DateFilter($"{resourceId}.{FieldCreator.Data[$"{resourceId}_{TestCoreFramework.Enums.FieldType.DateTime}"].Name}", expectedOperator,
                                               "Asia/Tokyo", CreateDateTime.ToString(SearchConstants.SearchApiFullDateTemplate));
            var handler  = new DefaultManager();
            var response = handler.Send <SearchResponse>(request);

            SearchDateFieldCases.VerifySearchResult(response, resourceId, cases, $"{resourceId.ToString()}.{FieldCreator.Data[$"{resourceId}_{TestCoreFramework.Enums.FieldType.DateTime}"].Name}", isAsc, RecordsCreator, NumRecordsEachCase, DateTimeResponseFormat);
        }
Exemple #24
0
 private static Dictionary <string, Func <SearchRequest> > PrepareNumCases(ResourceId resource, Func <string> fullFieldName, object testValue, object altTestValue)
 {
     return(new Dictionary <string, Func <SearchRequest> >
     {
         ["LessOrEqual <= -- value is equal"] = () => SearchRequestComposer.GetBuilderWithRestrictions(resource).NumFilter(fullFieldName(), OperatorType.Le, testValue),
         ["LessOrEqual <= -- value is less"] = () => SearchRequestComposer.GetBuilderWithRestrictions(resource).NumFilter(fullFieldName(), OperatorType.Le, (double)testValue + 1),
         ["Less <"] = () => SearchRequestComposer.GetBuilderWithRestrictions(resource).NumFilter(fullFieldName(), OperatorType.Lt, (double)testValue + 1),
         ["Equal ="] = () => SearchRequestComposer.GetBuilderWithRestrictions(resource).NumFilter(fullFieldName(), OperatorType.Eq, testValue),
         ["NotEqual !="] = () => SearchRequestComposer.GetBuilderWithRestrictions(resource).NumFilter(fullFieldName(), OperatorType.Neq, altTestValue),
         [$"Greater > {ImportantCaseMarker}"] = () => SearchRequestComposer.GetBuilderWithRestrictions(resource).NumFilter(fullFieldName(), OperatorType.Gt, (double)testValue - 1),
         ["GreaterOrEqual >= -- value is equal"] = () => SearchRequestComposer.GetBuilderWithRestrictions(resource).NumFilter(fullFieldName(), OperatorType.Ge, testValue),
         ["GreaterOrEqual >= -- value is greater"] = () => SearchRequestComposer.GetBuilderWithRestrictions(resource).NumFilter(fullFieldName(), OperatorType.Ge, (double)testValue - 1)
     });
 }
Exemple #25
0
        private void PerformHappyPathSubqueryTest(ResourceId resource, SearchRequest request)
        {
            var expectedId      = RecordsCreator.Data[$"{resource}"].Id;
            var subqueryRequest = SearchRequestComposer.GetBuilderWithRestrictions(resource).SubqueryFilter($"{resource}.P_Id", resource, $"{resource}.P_Id", request.Conditions.Filter);
            //request.Conditions.Filter.Field.Route, resource, request.Conditions.Filter.Field.Route, request.Conditions.Filter);//(request.Conditions.Filter);
            //TODO: uncomment the line above and set bug 39348

            var handler  = new DefaultManager();
            var response = handler.Send <SearchResponse>(subqueryRequest);

            PrAssert.That(response, PrIs.SuccessfulResponse());
            PrAssert.That(response?.Result?.Status, PrIs.Not.Null.And.EqualTo("OK"));
            PrAssert.That(response?.Result?.Items, PrIs.Not.Null.And.Contains(expectedId));
        }
        public void MultipleInvalidSearchCondition(ResourceId resource, OperatorType boolFilterType, SearchFilterType firstFilterType, SearchFilterType secondFilterType, string firstFieldName, string secondFieldName)
        {
            var searchFilters = new List <SearchFilter>();

            searchFilters.Add(SearchHelpers.SearchFilters[firstFilterType](resource, firstFieldName, CurrentDateTime, Timezone, RecordsCreatorForNumCond));
            var secondSearchFilter = SearchHelpers.SearchFilters[secondFilterType](resource, secondFieldName, CurrentDateTime, Timezone, RecordsCreatorForNumCond);

            secondSearchFilter.Operator = "Invalid Operator";
            searchFilters.Add(secondSearchFilter);
            var request  = SearchRequestComposer.GetBuilderWithRestrictions(resource).BooleanFilter(boolFilterType, searchFilters);
            var handler  = new DefaultManager();
            var response = handler.Send <SearchResponse>(request);

            PrAssert.That(response, PrIs.ErrorResponse());
        }
        public void SuccessfulSearch_FileOnly_SplitModeNot(ResourceId resource, FileType fileType, OperatorType op)
        {
            var value = $"Sample {fileType.ToString().ToUpper()}File {fileType} SomeRandomString";

            value = SearchValueTransformationsByOperator[op](value);
            var request = SearchRequestComposer.GetBuilderWithRestrictions(resource).FreewordFilter(op, null, "NOT", "FILES", value);

            if (!NotReadableFiles.Contains(fileType))
            {
                PerformSuccessfulSearchTest(resource, request);
            }
            else
            {
                PerformSuccessfulInvertedSearchTest(resource, request);
            }
        }
        public void MultipleSearchWithDifferentCondition(ResourceId resource, OperatorType boolFilterType, SearchFilterType filterType, string fieldName)
        {
            var firstExpectedIdOfFirstCondition   = RecordsCreatorForFirstCondition.Data[$"{resource}0"].Id;
            var secondExpectedIdOfFirstCondition  = RecordsCreatorForFirstCondition.Data[$"{resource}1"].Id;
            var firstExpectedIdOfSecondCondition  = RecordsCreatorForSecondCondition.Data[$"{resource}0"].Id;
            var secondExpectedIdOfSecondCondition = RecordsCreatorForSecondCondition.Data[$"{resource}1"].Id;

            var searchFilters = ListSearchFilters[filterType](resource, fieldName, CurrentDateTime, Timezone);
            var request       = SearchRequestComposer.GetBuilderWithRestrictions(resource).BooleanFilter(boolFilterType, searchFilters);
            var handler       = new DefaultManager();
            var response      = handler.Send <SearchResponse>(request);

            PrAssert.That(response, PrIs.SuccessfulResponse());
            PrAssert.That(response?.Result?.Status, PrIs.Not.Null.And.EqualTo("OK"));

            if (boolFilterType == OperatorType.And)
            {
                if (filterType.ToString().Contains("Date") || filterType == SearchFilterType.FreeWord)
                {
                    PrAssert.That(response?.Result?.Total, PrIs.Not.Null.And.GreaterThanOrEqualTo(1));
                    PrAssert.That(response?.Result?.Items, PrIs.Not.Null.And.Contains(firstExpectedIdOfFirstCondition).And.Contains(secondExpectedIdOfFirstCondition)
                                  .And.Contains(firstExpectedIdOfSecondCondition).And.Contains(secondExpectedIdOfSecondCondition));
                }
                else
                {
                    PrAssert.That(response?.Result?.Items, PrIs.Null.Or.Empty);
                }
            }
            else
            {
                PrAssert.That(response?.Result?.Total, PrIs.Not.Null.And.GreaterThanOrEqualTo(1));

                if (filterType == SearchFilterType.NumIn || filterType == SearchFilterType.NumOperator)
                {
                    PrAssert.That(response?.Result?.Items, PrIs.Not.Null.And.Contains(firstExpectedIdOfFirstCondition).And.Contains(firstExpectedIdOfSecondCondition));
                }
                else
                {
                    PrAssert.That(response?.Result?.Items, PrIs.Not.Null.And.Contains(firstExpectedIdOfFirstCondition).And.Contains(secondExpectedIdOfFirstCondition)
                                  .Or.Contains(firstExpectedIdOfSecondCondition).And.Contains(secondExpectedIdOfSecondCondition));
                }
            }
        }
Exemple #29
0
        public void SearchWrongOperatorInBoolCondition(ResourceId resource, SearchFilterType filterType, OperatorType boolFilterType, SearchFilterType subFilterType, string fieldName)
        {
            var searchFilter = SearchHelpers.SearchFilters[subFilterType](resource, fieldName, CurrentDateTime, Timezone, RecordsCreatorForNumCond);

            SearchRequest request = null;

            if (filterType == SearchFilterType.BoolAndOr)
            {
                request = SearchRequestComposer.GetBuilderWithRestrictions(resource).BooleanFilter(boolFilterType, new[] { searchFilter });
            }
            else
            {
                request = SearchRequestComposer.GetBuilderWithRestrictions(resource).BooleanNotFilter(searchFilter);
            }

            var handler  = new DefaultManager();
            var response = handler.Send <SearchResponse>(request);

            PrAssert.That(response, PrIs.ErrorResponse());
        }
Exemple #30
0
 private static Dictionary <string, Func <SearchRequest> > PrepareNumInCases(ResourceId resource, Func <string> fullFieldName, object testValue, object altTestValue, TestCoreFramework.Enums.FieldType fieldType)
 {
     if (fieldType == TestCoreFramework.Enums.FieldType.OptionCheckbox)
     {
         var range = (testValue as string[]);
         return(new Dictionary <string, Func <SearchRequest> >
         {
             [$"1:1 match {ImportantCaseMarker}"] = () => SearchRequestComposer.GetBuilderWithRestrictions(resource).NumInFilter(fullFieldName(), range),
             ["Search is wider"] = () => SearchRequestComposer.GetBuilderWithRestrictions(resource).NumInFilter(fullFieldName(), range.Append("42")),
             ["Search is narrower"] = () => SearchRequestComposer.GetBuilderWithRestrictions(resource).NumInFilter(fullFieldName(), range.Skip(1)),
             ["Search is partially matching"] = () => SearchRequestComposer.GetBuilderWithRestrictions(resource).NumInFilter(fullFieldName(), range.Skip(1).Append("42"))
         });
     }
     else
     {
         return(new Dictionary <string, Func <SearchRequest> >
         {
             [$"Value inside range {ImportantCaseMarker}"] = () => SearchRequestComposer.GetBuilderWithRestrictions(resource).NumInFilter(fullFieldName(), new[] { 0, testValue, altTestValue, 100010 })
         });
     }
 }