//@include sol.dev.TestUtils.js
//@include lib_sol.common.ix.DynKwlBLPIterator.js

/**
 * Please consider to move the following variables to your eslint config
 */
/* jasmine variables */
/* global jasmine, describe, beforeAll, beforeEach, afterEach, afterAll, it, expect */
/* test variables */
/* global ConnectionHandler, TestUtils */
/* business solution variables */
/* global sol */

describe("lib_sol.common.ix.DynKwlBLPIterator.js", function () {
  var originalTimeout,
      mask,
      entries;

  beforeAll(function () {
    originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
    jasmine.DEFAULT_TIMEOUT_INTERVAL = 100000;
    ixConnect = ConnectionHandler.connectIx();
  });

  // beforeEach(function () {
  // });

  describe("Testing the DynKWL BLP iterator", function () {

    beforeEach(function () {
    });

    it("should get all entries", function () {
      var result;

      expect(function () {
        var provider = sol.create("sol.common.ix.DynKwlBLPIterator", {
          queryName: "psql.alle",
          queryModule: "OleDb",
          queryConditions: [],
          serverUrl: "http://10.49.110.26:30009",
          appToken: "HThYifwwOEmuYf400XSaiINismku3LTDOPqan8EoyfM=",
          projectId: "ELODEMO",
          moduleId: "a7f28149-7202-43f2-b3ec-d225743b06ee",
          addInId: "da414d55-45b5-451a-a03a-9517727ae9c7"
        });

        result = provider.getQueryResults([]);
        expect(result.length).toBeGreaterThan(0);
      }).not.toThrow();
    });

    it("should get filtered entries", function () {
      var result, map = { 
        IX_GRP_PARTNER_NO: "",
        IX_MAP_CONTRACT_CONTACT_REFERENCE: "",
        IX_GRP_CONTACT_FIRSTNAME: "",
        IX_GRP_CONTACT_LASTNAME: ""
      };

      expect(function () {
        var provider = sol.create("sol.common.ix.DynKwlBLPIterator", {
          queryName: "psql.einenSatz",
          queryModule: "OleDb",
          serverUrl: "http://10.49.110.26:30009",
          appToken: "HThYifwwOEmuYf400XSaiINismku3LTDOPqan8EoyfM=",
          projectId: "ELODEMO",
          moduleId: "a7f28149-7202-43f2-b3ec-d225743b06ee",
          addInId: "da414d55-45b5-451a-a03a-9517727ae9c7",
          tableKeyNames: [
            "CONTACT_FIRSTNAME",
            "CONTACT_LASTNAME",
            "IX_MAP_PARTNER_PHONE"
          ],
          queryConditions: [
            {
                "name": "IDX1",
                "value": "nachname2"
            }
          ],
        });

        provider.openMap(ixConnect, map, "IX_GRP_CONTACT_FIRSTNAME");
        expect(provider.resultSet.length).toBeGreaterThan(0);
      }).not.toThrow();
    });

    afterEach(function () {
    });
  });

  afterAll(function () {
    jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
  });
});