Sha256: 4e1793af759824e76d41b0f113fa8af840794d886475705e3e87ec66659196b9

Contents?: true

Size: 1.49 KB

Versions: 2

Compression:

Stored size: 1.49 KB

Contents

require_relative 'base_model_test'
class SearchQueryBuilderTest < BaseModelTest
  context 'build query' do
    context 'with valid params'do
      context 'with NULL NOTNULL Equality Inequality Date ' do
        setup do
          request = {:id=>"80010714",:amount=>"1..10",:party_id_to => "WSR,Customer",:place=>"NULL",:origin=>"NOTNULL",:age=>"18..", :date=>"2013-01-21T00:01:02..2013-12-13T04:05:06", :array_condition => ["con1", "con2"]}
          searchqueryobject = SearchQueryBuilder.new request
          @query = searchqueryobject.construct
        end

        should "return string as query" do
          assert_instance_of( String, @query)
        end

        should "have query as passed in params" do
          p @query
          assert_equal false, @query.index("id = '80010714'").nil?
          assert_equal false, @query.index("amount >= '1'").nil?
          assert_equal false, @query.index("amount <= '10'").nil?
          assert_equal false, @query.index("place IS NULL").nil?
          assert_equal false, @query.index("origin IS NOT NULL").nil?
          assert_equal false, @query.index("age >= '18'").nil?
          assert_equal false, @query.index("party_id_to IN ( 'WSR' , 'Customer' )").nil?
          assert_equal false, @query.index("date >= '2013-01-21 00:01:02 +0530'").nil?
          assert_equal false, @query.index("date <= '2013-12-13 04:05:06 +0530'").nil?
          assert_equal false, @query.index("array_condition IN ( 'con1' , 'con2' )").nil?
        end

      end

    end


  end

end

Version data entries

2 entries across 1 versions & 1 rubygems

Version Path
apl-library-0.0.90 test/unit/search_query_builder_test.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/test/unit/search_query_builder_test.rb