<commit_before>import { module, test } from 'qunit';

import QueryBuilder from 'ember-flexberry-data/query/builder';
import FilterOperator from 'ember-flexberry-data/query/filter-operator';
import Condition from 'ember-flexberry-data/query/condition';
import { SimplePredicate, ComplexPredicate, StringPredicate, DetailPredicate } from 'ember-flexberry-data/query/predicate';
import ODataAdapter from 'ember-flexberry-data/query/odata-adapter';
import startApp from '../../helpers/start-app';

const baseUrl = 'http://services.odata.org/Northwind/Northwind.svc';
const app = startApp();
const store = app.__container__.lookup('service:store');
const adapter = new ODataAdapter(baseUrl, store);

module('query');

test('adapter | odata | id', function (assert) {
  // Arrange.
  let builder = new QueryBuilder(store, 'customer').byId(42);

  // Act && Assert.
  runTest(assert, builder, '/Customers?$filter=CustomerID eq 42');
});

test('adapter | odata | simple predicate | eq', function (assert) {
  // Arrange.
  let builder = new QueryBuilder(store, 'customer').where('firstName', FilterOperator.Eq, 'Vasya');

  // Act && Assert.
  runTest(assert, builder, `/Customers?$filter=FirstName eq 'Vasya'`);
});

test('adapter | odata | simple predicate | eq | null', function (assert) {
  // Arrange.
  let builder = new QueryBuilder(store, 'customer').where('firstName', FilterOperator.Eq, null);

  // Act && Assert.
  runTest(assert, builder, `/Customers?$filter=FirstName eq null`);
});

test('adapter | odata | simple predicate | eq | master pk', function (assert) {
  // Arrange.
  let builder = new QueryBuilder(store, 'customer').where('manager', FilterOperator.Eq, '3bcc4730-9cc1-4237-a843-c4b1de881d7c');

  // Act && Assert.
  runTest(assert, builder, `/Customers?$filter=Manager/EmployeeID eq 3bcc4730-9cc1-4237-a843-c4b1de881d7c`);
});

test('adapter | odata | simple predicate | eq | master master pk', function (assert) {
  // Arrange.
  let builder = new QueryBuilder(store, 'customer').where('manager.manager', FilterOperator.Eq, '3bcc4730-9cc1-4237-a843-c4b1de881d7c');

  // Act && Assert.
  runTest(assert, builder, `/Customers?$filter=Manager/Manager/EmployeeID eq 3bcc4730-9cc1-4237-a843-c4b1de881d7c`);
});

test('adapter | odata | simple predicate | eq | master field | with cast', function (assert) {
  // Arrange.
  let builder = new QueryBuilder(store, 'customer').where('manager', FilterOperator.Eq, 'cast(3bcc4730-9cc1-4237-a843-c4b1de881d7c,Edm.Guid)');

  // Act && Assert.
  runTest(assert, builder, `/Customers?$filter=Manager/EmployeeID eq cast(3bcc4730-9cc1-4237-a843-c4b1de881d7c,Edm.Guid)`);
});

test('adapter | odata | simple predicate | eq | master id', function (assert) {
  // Arrange.
  let builder = new QueryBuilder(store, 'customer').where('manager.id', FilterOperator.Eq, '3bcc4730-9cc1-4237-a843-c4b1de881d7c');

  // Act && Assert.
  runTest(assert, builder, `/Customers?$filter=Manager/EmployeeID eq 3bcc4730-9cc1-4237-a843-c4b1de881d7c`);
});

test('adapter | odata | simple predicate | eq | master field', function (assert) {
  // Arrange.
  let builder = new QueryBuilder(store, 'customer').where('manager.First Name', FilterOperator.Eq, 'Vasya');

  // Act && Assert.
  runTest(assert, builder, `/Customers?$filter=Manager/First Name eq 'Vasya'`);
});

test('adapter | odata | simple predicate | neq', function (assert) {
  // Arrange.
  let builder = new QueryBuilder(store, 'customer').where('firstName', FilterOperator.Neq, 'Vasya');

  // Act && Assert.
  runTest(assert, builder, `/Customers?$filter=FirstName ne 'Vasya'`);
});

test('adapter | odata | simple predicate | neq | null', function (assert) {<commit_msg>Add test OData URL with filter by boolean attribute<commit_after>import { module, test } from 'qunit';

import QueryBuilder from 'ember-flexberry-data/query/builder';
import FilterOperator from 'ember-flexberry-data/query/filter-operator';
import Condition from 'ember-flexberry-data/query/condition';
import { SimplePredicate, ComplexPredicate, StringPredicate, DetailPredicate } from 'ember-flexberry-data/query/predicate';
import ODataAdapter from 'ember-flexberry-data/query/odata-adapter';
import startApp from '../../helpers/start-app';

const baseUrl = 'http://services.odata.org/Northwind/Northwind.svc';
const app = startApp();
const store = app.__container__.lookup('service:store');
const adapter = new ODataAdapter(baseUrl, store);

module('query');

test('adapter | odata | id', function (assert) {
  // Arrange.
  let builder = new QueryBuilder(store, 'customer').byId(42);

  // Act && Assert.
  runTest(assert, builder, '/Customers?$filter=CustomerID eq 42');
});

test('adapter | odata | simple predicate | eq', function (assert) {
  // Arrange.
  let builder = new QueryBuilder(store, 'customer').where('firstName', FilterOperator.Eq, 'Vasya');

  // Act && Assert.
  runTest(assert, builder, `/Customers?$filter=FirstName eq 'Vasya'`);
});

test('adapter | odata | simple predicate | eq | null', function (assert) {
  // Arrange.
  let builder = new QueryBuilder(store, 'customer').where('firstName', FilterOperator.Eq, null);

  // Act && Assert.
  runTest(assert, builder, `/Customers?$filter=FirstName eq null`);
});

test('adapter | odata | simple predicate | eq | master pk', function (assert) {
  // Arrange.
  let builder = new QueryBuilder(store, 'customer').where('manager', FilterOperator.Eq, '3bcc4730-9cc1-4237-a843-c4b1de881d7c');

  // Act && Assert.
  runTest(assert, builder, `/Customers?$filter=Manager/EmployeeID eq 3bcc4730-9cc1-4237-a843-c4b1de881d7c`);
});

test('adapter | odata | simple predicate | eq | master master pk', function (assert) {
  // Arrange.
  let builder = new QueryBuilder(store, 'customer').where('manager.manager', FilterOperator.Eq, '3bcc4730-9cc1-4237-a843-c4b1de881d7c');

  // Act && Assert.
  runTest(assert, builder, `/Customers?$filter=Manager/Manager/EmployeeID eq 3bcc4730-9cc1-4237-a843-c4b1de881d7c`);
});

test('adapter | odata | simple predicate | eq | master field | with cast', function (assert) {
  // Arrange.
  let builder = new QueryBuilder(store, 'customer').where('manager', FilterOperator.Eq, 'cast(3bcc4730-9cc1-4237-a843-c4b1de881d7c,Edm.Guid)');

  // Act && Assert.
  runTest(assert, builder, `/Customers?$filter=Manager/EmployeeID eq cast(3bcc4730-9cc1-4237-a843-c4b1de881d7c,Edm.Guid)`);
});

test('adapter | odata | simple predicate | eq | master id', function (assert) {
  // Arrange.
  let builder = new QueryBuilder(store, 'customer').where('manager.id', FilterOperator.Eq, '3bcc4730-9cc1-4237-a843-c4b1de881d7c');

  // Act && Assert.
  runTest(assert, builder, `/Customers?$filter=Manager/EmployeeID eq 3bcc4730-9cc1-4237-a843-c4b1de881d7c`);
});

test('adapter | odata | simple predicate | eq | master field', function (assert) {
  // Arrange.
  let builder = new QueryBuilder(store, 'customer').where('manager.First Name', FilterOperator.Eq, 'Vasya');

  // Act && Assert.
  runTest(assert, builder, `/Customers?$filter=Manager/First Name eq 'Vasya'`);
});

test('adapter | odata | simple predicate | eq | boolean', function (assert) {
  // Arrange.
  let builder = new QueryBuilder(store, 'ember-flexberry-dummy-application-user').where('activated', FilterOperator.Eq, true);

  // Act && Assert.
  runTest(assert, builder, `/EmberFlexberryDummyApplicationUsers?$filter=Activated eq true`);
});

test('adapter | odata | simple predicate | neq', function (assert) {
  // Arrange.
  let builder = new QueryBuilder(store, 'customer').where('firstName', FilterOperator.Neq, 'Vasya');

  // Act && Assert.
  runTest(assert, builder, `/Customers?$filter=FirstName ne 'Vasya'`);
});

test('adapter | odata | simple predicate | neq | null', function (assert) {
{'fraction_non_alphanumeric': 0.1623721351806293, 'fraction_numerical': 0.04247054253528421, 'mean_word_length': 4.918773946360154, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '961013', 'n_tokens_mistral': 2752, 'n_tokens_neox': 2580, 'n_words': 561}