"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
const internal_1 = require("../../../../internal");
const Persistence_1 = require("../../../../Persistence");
const testHelper_1 = require("../../../testHelper");
describe('Persistence.CdmFolder.DataPartitionPattern', () => {
    /// <summary>
    /// The path between TestDataPath and TestName.
    /// </summary>
    const testsSubpath = 'Persistence/CdmFolder/DataPartitionPattern';
    /**
     * Testing for folder with local entity declaration with data partition patterns.
     */
    it('TestLoadLocalEntityWithDataPartitionPattern', () => {
        const readFile = testHelper_1.testHelper.getInputFileContent(testsSubpath, 'TestLoadLocalEntityWithDataPartitionPattern', 'entities.manifest.cdm.json');
        const cdmManifest = Persistence_1.CdmFolder.ManifestPersistence.fromObject(new internal_1.resolveContext(new internal_1.CdmCorpusDefinition(), undefined), '', '', '', JSON.parse(readFile));
        expect(cdmManifest.entities.length)
            .toBe(2);
        const entity1 = cdmManifest.entities.allItems[0];
        expect(entity1.getObjectType())
            .toBe(internal_1.cdmObjectType.localEntityDeclarationDef);
        expect(entity1.dataPartitionPatterns.length)
            .toBe(1);
        const pattern1 = entity1.dataPartitionPatterns.allItems[0];
        expect(pattern1.name)
            .toBe('testPattern');
        expect(pattern1.explanation)
            .toBe('test explanation');
        expect(pattern1.rootLocation)
            .toBe('test location');
        expect(pattern1.regularExpression)
            .toBe('\\s*');
        expect(pattern1.parameters.length)
            .toBe(2);
        expect(pattern1.parameters[0])
            .toBe('testParam1');
        expect(pattern1.parameters[1])
            .toBe('testParam2');
        expect(pattern1.specializedSchema)
            .toBe('test special schema');
        expect(pattern1.exhibitsTraits.length)
            .toBe(1);
        const entity2 = cdmManifest.entities.allItems[1];
        expect(entity2.getObjectType())
            .toBe(internal_1.cdmObjectType.localEntityDeclarationDef);
        expect(entity2.dataPartitionPatterns.length)
            .toBe(1);
        const pattern2 = entity2.dataPartitionPatterns.allItems[0];
        expect(pattern2.name)
            .toBe('testPattern2');
        expect(pattern2.rootLocation)
            .toBe('test location2');
        expect(pattern2.globPattern)
            .toBe('/*.csv');
        const manifestData = Persistence_1.CdmFolder.ManifestPersistence.toData(cdmManifest, new internal_1.resolveOptions(), new internal_1.copyOptions());
        expect(manifestData.entities.length)
            .toBe(2);
        const entityData1 = manifestData.entities[0];
        expect(entityData1.dataPartitionPatterns.length)
            .toBe(1);
        const patternData1 = entityData1.dataPartitionPatterns[0];
        expect(patternData1.name)
            .toBe('testPattern');
        expect(patternData1.explanation)
            .toBe('test explanation');
        expect(patternData1.rootLocation)
            .toBe('test location');
        expect(patternData1.regularExpression)
            .toBe('\\s*');
        expect(patternData1.parameters.length)
            .toBe(2);
        expect(patternData1.parameters[0])
            .toBe('testParam1');
        expect(patternData1.parameters[1])
            .toBe('testParam2');
        expect(patternData1.specializedSchema)
            .toBe('test special schema');
        expect(patternData1.exhibitsTraits.length)
            .toBe(1);
        const entityData2 = manifestData.entities[1];
        expect(entityData2.dataPartitionPatterns.length)
            .toBe(1);
        const patternData2 = entityData2.dataPartitionPatterns[0];
        expect(patternData2.name)
            .toBe('testPattern2');
        expect(patternData2.rootLocation)
            .toBe('test location2');
        expect(patternData2.globPattern)
            .toBe('/*.csv');
    });
});
//# sourceMappingURL=DataPartitionPattern.test.js.map