Exemplo n.º 1
0
        public void SearchWithQueryParameter()
        {
            var searchRequestDto = new PaginatedSearchRequestDto(100, PaginatedSearchRequestDto.DefaultPaginationOptions);

            searchRequestDto.SetFromSearchString(_assetSchema, "computername".Split(','), "test%");
            var actual = SearchUtils.GetWhere(searchRequestDto, "asset");

            Assert.AreEqual("( UPPER(COALESCE(CASE WHEN LOCATE('//',asset.Description) > 0 THEN LTRIM(RTRIM(SUBSTR(asset.Description,1,LOCATE('//',asset.Description)-1))) ELSE LTRIM(RTRIM(asset.Description)) END,'')) like :computername )", actual);
        }
Exemplo n.º 2
0
        public void DateSearchDtoGtTest()
        {
            var searchRequestDto = new PaginatedSearchRequestDto(100, PaginatedSearchRequestDto.DefaultPaginationOptions);

            searchRequestDto.SetFromSearchString(_schema, "reportdate".Split(','), ">2013-01-03");
            Assert.IsTrue(SearchUtils.GetWhere(searchRequestDto, "SR").Equals("( SR.reportdate > :reportdate_begin )"));
            var parametersMap = SearchUtils.GetParameters(searchRequestDto);

            Assert.IsTrue(parametersMap.Count == 1);
            Assert.IsTrue(parametersMap["reportdate_begin"].Equals(DateUtil.BeginOfDay(DateTime.Parse("2013-01-04"))));
        }
Exemplo n.º 3
0
        public void DateSearchDtoGteTest()
        {
            var searchRequestDto = new PaginatedSearchRequestDto(100, PaginatedSearchRequestDto.DefaultPaginationOptions);

            searchRequestDto.SetFromSearchString(_schema, "ticketid,description,asset_.description,siteid,affectedperson,status,reportdate".Split(','), ">=2013-01-01");
            Assert.IsTrue(SearchUtils.GetWhere(searchRequestDto, "SR").Equals("( SR.reportdate >= :reportdate_begin )"));
            var parametersMap = SearchUtils.GetParameters(searchRequestDto);

            Assert.IsTrue(parametersMap.Count == 1);
            Assert.IsTrue(parametersMap["reportdate_begin"].Equals(DateUtil.BeginOfDay(DateTime.Parse("2013-01-01"))));
        }
Exemplo n.º 4
0
        public void DateTimeSearchDtoLteTest()
        {
            var searchRequestDto = new PaginatedSearchRequestDto(100, PaginatedSearchRequestDto.DefaultPaginationOptions);

            searchRequestDto.SetFromSearchString(_schema, "reportdate".Split(','), "<=2013-01-01 15:45");
            Assert.IsTrue(SearchUtils.GetWhere(searchRequestDto, "SR").Equals("( SR.reportdate <= :reportdate_end )"));
            var parametersMap = SearchUtils.GetParameters(searchRequestDto);

            Assert.IsTrue(parametersMap.Count == 1);
            Assert.AreEqual(DateTime.Parse("2013-01-01 15:45:59.999"), parametersMap["reportdate_end"]);
        }
Exemplo n.º 5
0
        public void NumberSearchDtoGteTest()
        {
            var searchRequestDto = new PaginatedSearchRequestDto(100, PaginatedSearchRequestDto.DefaultPaginationOptions);

            searchRequestDto.SetFromSearchString(_schema, "curbal".Split(','), ">=20");
            Assert.AreEqual("( invbalances.curbal >= :curbal )", SearchUtils.GetWhere(searchRequestDto, "invbalances"));
            var parametersMap = SearchUtils.GetParameters(searchRequestDto);

            Assert.IsTrue(parametersMap.Count == 1);
            Assert.IsTrue(parametersMap["curbal"].Equals(20));
        }
Exemplo n.º 6
0
        public void MultipleFieldsSearchDtoTest()
        {
            var searchRequestDto = new PaginatedSearchRequestDto(100, PaginatedSearchRequestDto.DefaultPaginationOptions);

            searchRequestDto.SetFromSearchString(_schema, "ticketid,description,asset_.description,siteid,affectedperson,status,reportdate".Split(','), "teste");

            Assert.IsNotNull(searchRequestDto);
            Assert.AreEqual("ticketid||,description||,asset_.description||,status", searchRequestDto.SearchParams);
            Assert.AreEqual("teste,,,teste,,,teste,,,teste", searchRequestDto.SearchValues);

            String whereClause = SearchUtils.GetWhere(searchRequestDto, "SR");

            Assert.AreEqual("( SR.ticketid = :ticketid ) OR ( SR.description = :description ) OR ( asset_.description = :asset_.description ) OR ( SR.status = :status )", whereClause);
        }
Exemplo n.º 7
0
        public void BasicSearchDtoTest()
        {
            var searchRequestDto = new PaginatedSearchRequestDto(100, PaginatedSearchRequestDto.DefaultPaginationOptions);

            searchRequestDto.SetFromSearchString(_schema, "ticketid".Split(','), "teste");

            Assert.IsNotNull(searchRequestDto);
            Assert.IsTrue(searchRequestDto.SearchParams.Equals("ticketid"));
            Assert.IsTrue(searchRequestDto.SearchValues.Equals("teste"));

            var whereClause = SearchUtils.GetWhere(searchRequestDto, "SR");

            Assert.AreEqual("( SR.ticketid = :ticketid )", whereClause);
        }
Exemplo n.º 8
0
        public void DateTimeSearchDtoNeqTest()
        {
            var searchRequestDto = new PaginatedSearchRequestDto(100, PaginatedSearchRequestDto.DefaultPaginationOptions);

            searchRequestDto.SetFromSearchString(_schema, "reportdate".Split(','), "!=2013-01-04");
            var @where = SearchUtils.GetWhere(searchRequestDto, "SR");

            Assert.AreEqual("( SR.reportdate NOT BETWEEN :reportdate_begin AND :reportdate_end OR SR.reportdate IS NULL  )", @where);
            var parametersMap = SearchUtils.GetParameters(searchRequestDto);

            Assert.IsTrue(parametersMap.Count == 2);
            Assert.AreEqual(DateUtil.BeginOfDay(DateTime.Parse("2013-01-04")), parametersMap["reportdate_begin"]);
            Assert.AreEqual(DateUtil.EndOfDay(DateTime.Parse("2013-01-04")), parametersMap["reportdate_end"]);
        }
Exemplo n.º 9
0
        public void DateSearchDtoTest()
        {
            var searchRequestDto = new PaginatedSearchRequestDto(100, PaginatedSearchRequestDto.DefaultPaginationOptions);

            searchRequestDto.SetFromSearchString(_schema, "ticketid,description,asset_.description,siteid,affectedperson,status,reportdate".Split(','), "2013-01-01");

            Assert.IsNotNull(searchRequestDto);
            Assert.IsTrue(searchRequestDto.SearchParams.Equals("reportdate"));
            Assert.IsTrue(searchRequestDto.SearchValues.Equals("2013-01-01"));

            String whereClause = SearchUtils.GetWhere(searchRequestDto, "SR");

            Assert.IsTrue(whereClause.Equals("( SR.reportdate BETWEEN :reportdate_begin AND :reportdate_end )"));

            IDictionary <String, Object> parametersMap = SearchUtils.GetParameters(searchRequestDto);

            Assert.IsTrue(parametersMap.Count == 2);
            Assert.IsTrue(parametersMap["reportdate_begin"].Equals(DateUtil.BeginOfDay(DateTime.Parse("2013-01-01"))));
            Assert.IsTrue(parametersMap["reportdate_end"].Equals(DateUtil.EndOfDay(DateTime.Parse("2013-01-01"))));
        }
Exemplo n.º 10
0
        public void AssetSearch()
        {
            var searchRequestDto = new PaginatedSearchRequestDto(100, PaginatedSearchRequestDto.DefaultPaginationOptions);

            searchRequestDto.SetFromSearchString(_assetSchema, "hlagdescription,serialnum".Split(','), "test%");
            Assert.AreEqual("( UPPER(COALESCE(CASE WHEN LOCATE('//',asset.Description) > 0 THEN LTRIM(RTRIM(SUBSTR(asset.Description, LOCATE('//', asset.Description)+3))) ELSE LTRIM(RTRIM(asset.Description)) END,'')) like :hlagdescription ) OR ( UPPER(COALESCE(asset.serialnum,'')) like :serialnum )", SearchUtils.GetWhere(searchRequestDto, "asset"));
        }